[英]Validation Error in paypal checkout
我在Angular5上使用PayPal结帐脚本。
我正在尝试拆分一个包含价格的字符串并将结果转换为float,但出现以下错误:
{
"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
来解决了这个total1
。 显然,配置json的键和同名变量之间存在冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.