贝宝结帐中的验证错误 [英] Validation Error in paypal checkout

查看:189
本文介绍了贝宝结帐中的验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Angular5上使用PayPal结帐脚本.

I am using PayPal checkout script on Angular5.

我试图拆分包含价格的字符串并将结果转换为float,但是出现以下错误:

I am trying to split a string which contain the price and convert the result to float, but I get the following error:

{
"name": "VALIDATION_ERROR",
"details": [
    {
        "field": "transactions.amount",
        "issue": "Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by '.', optional thousands separator ',', limited to 7 digits before the decimal point and currency which is a valid ISO Currency Code"
    }
],
"message": "Invalid request - see details",
"information_link": "https://developer.paypal.com/docs/api/payments/#errors",
"debug_id": "ea4b3e3713de"
}

request/</<@https://www.paypalobjects.com/api/checkout.js:14680:39

这是我的贝宝配置:

let price = parseFloat(this.objRate.split("$")[1]);
let amount = 1;

let total = price * amount;
this.payPalConfig = {
  env: 'sandbox',
  client: {
    sandbox: '<key>',
    production: '<key>'
  },
  commit: true,
  payment: (data: any, actions: any) => {
    return actions.payment.create({
      payment: {
        transactions: [{
          amount: {
            currency: "USD",
            total: Number(total).toFixed(2)
          }
        }]
      }
    });
  },
  onAuthorize: (data: any, actions: any) => {
    return actions.payment.execute().then((payment: any) => {
      this.payPalSuccess = true;
    });
  }

预先感谢

推荐答案

我已经通过将配置Paypal检出中的变量total替换为total1之类的其他名称来解决了该问题.显然,配置json的键和同名变量之间存在冲突.

I already solve it by replacing the variable total in the configuration paypal checkout to another name like total1. Apparently there was a conflict between the key of configuration json and the variable of same name.

这篇关于贝宝结帐中的验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆