问题描述
我正在尝试集成PayPal,但出现以下错误
您可以在此处使用任何PayPal沙箱买家帐户测试代码: Codepen
这是我正在使用的代码
paypal.Buttons({
createOrder: function (data,actions) {
// This function sets up the details of the transaction,including the amount and line item details.
return actions.order.create({
purchase_units: [{
amount: {
value: '5.00'
}
}]
});
},onApprove: function (data,actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(details => {
// This function shows a transaction success message to your buyer.
alert('Transaction completed by ' + details.payer.name.given_name);
});
}
}).render('#paypal-button-container');
有关错误的更多信息
解决方法
从“网络”标签测试您的Codepen,您将获得COMPLIANCE_VIOLATION,这可能是由于您要测试的帐户所在的国家/地区未在沙盒中正确设置。
尝试在沙盒中使用其他国家/地区进行测试。在https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts%2F上创建一个新的业务帐户,然后使用新的ClientID / Secret创建一个新的REST应用。