V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xcstream
V2EX  ›  Node.js

支付宝回调函数金额的判断,不知道有没有问题。

  •  
  •   xcstream · 2018-07-10 12:59:13 +08:00 · 3719 次点击
    这是一个创建于 2110 天前的主题,其中的信息可能已经有所发展或是发生改变。
    等于号左边是支付宝传来的'0.01'这样的字符串,右边是一个数字表示分
    if(parseInt(parseFloat(req.body.total_fee) * 100) == amount ){

    }
    3 条回复    2018-07-17 10:17:01 +08:00
    ChristopherWu
        1
    ChristopherWu  
       2018-07-10 17:01:36 +08:00
    支付宝不用分来存这么 6 的吗
    xcstream
        2
    xcstream  
    OP
       2018-07-11 11:54:52 +08:00
    parseInt 改成 Math.round 了
    cqu1980
        3
    cqu1980  
       2018-07-17 10:17:01 +08:00
    @xcstream parseInt 会出问题,改 Math.round 比较好,主要是经常会出现 9999 的情况。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2800 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 13:07 · PVG 21:07 · LAX 06:07 · JFK 09:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.