xcstream
V2EX  ›  Node.js

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

  •  
  •   xcstream · Jul 10, 2018 · 4363 views
    This topic created in 2864 days ago, the information mentioned may be changed or developed.
    等于号左边是支付宝传来的'0.01'这样的字符串,右边是一个数字表示分
    if(parseInt(parseFloat(req.body.total_fee) * 100) == amount ){

    }
    3 replies    2018-07-17 10:17:01 +08:00
    huoru
        1
    huoru  
       Jul 10, 2018
    支付宝不用分来存这么 6 的吗
    xcstream
        2
    xcstream  
    OP
       Jul 11, 2018
    parseInt 改成 Math.round 了
    cqu1980
        3
    cqu1980  
       Jul 17, 2018
    @xcstream parseInt 会出问题,改 Math.round 比较好,主要是经常会出现 9999 的情况。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4545 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 10:06 · PVG 18:06 · LAX 03:06 · JFK 06:06
    ♥ Do have faith in what you're doing.