代码之家  ›  专栏  ›  技术社区  ›  aircraft

货币金额必须为非负数,可以选择正好包含由“.”分隔的2个小数位

  •  0
  • aircraft  · 技术社区  · 6 年前

    当我使用 vue-paypal-check :

     <PayPal amount="amount"
             currency="USD"
             :client="credentials"
             env="sandbox"
            >
     </Paypal>  
    ...
    computed: {
      amount() {
    
        var total_price = Number(this.product_physical_session_storage_from_before.total_price_local)
    
        var abs_total_price = Math.abs(total_price.toFixed(2))
    
        return abs_total_price  // there is Number `120.00`
      }
    },
    

    我收到以下错误:

    {“name”:“VALIDATION\u ERROR”,“details”:[{“field”:“transactions[0]。amount.total”,“issue”:“Currency amount必须是非负数,可以选择正好包含由“.”分隔的2个小数位,可选的千位分隔符“,”,小数点前限制为7位“}],“message”:“无效请求-请参阅详细信息”,“information\u link”:” https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR “,”debug\u id“:”efa7b058ad30e“}

    1 回复  |  直到 6 年前
        1
  •  0
  •   aircraft    6 年前

    后来我发现了问题,我被跟踪 GitHub steps :

    <PayPal
      amount="10.00"
      currency="USD"
      :client="credentials">
    </PayPal>
    

    这个 10.00 是给定的数字,我在传递一个变量,我应该使用

    <PayPal
      :amount="amount"
      currency="USD"
      :client="credentials">
    </PayPal>
    

    然后我解决了我的问题。