捕获沙盒 Paypal 智能按钮时出错 COMPLIANCE_VIOLATION
Error on capture sandbox Paypal smart buttons COMPLIANCE_VIOLATION
我正在尝试在客户端集成一个非常基本的 Paypal 智能按钮,与 docs 页面上的完全一样,这是我的代码片段:
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=[my_sandbox_app_id]¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{ "description": "first product", "amount": { "currency_code": "USD", "value": 5 } }]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
},
onError: function (err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
但我收到这些错误 422
500
而不是批准:
通过检查“网络”选项卡,我找到了有关错误 422
:
的这些详细信息
如何克服这个错误?
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "COMPLIANCE_VIOLATION",
"description": "Transaction cannot be processed due to a possible compliance violation. To get more information about the transaction, call Customer Support."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "19961f1d1be55",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-COMPLIANCE_VIOLATION",
"rel": "information_link",
"method": "GET"
}
]
}
对于沙盒测试,为不同的国家(例如美国)创建一个沙盒帐户和关联的 REST 应用程序。
我正在尝试在客户端集成一个非常基本的 Paypal 智能按钮,与 docs 页面上的完全一样,这是我的代码片段:
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=[my_sandbox_app_id]¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{ "description": "first product", "amount": { "currency_code": "USD", "value": 5 } }]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
},
onError: function (err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
但我收到这些错误 422
500
而不是批准:
通过检查“网络”选项卡,我找到了有关错误 422
:
如何克服这个错误?
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "COMPLIANCE_VIOLATION",
"description": "Transaction cannot be processed due to a possible compliance violation. To get more information about the transaction, call Customer Support."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "19961f1d1be55",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-COMPLIANCE_VIOLATION",
"rel": "information_link",
"method": "GET"
}
]
}
对于沙盒测试,为不同的国家(例如美国)创建一个沙盒帐户和关联的 REST 应用程序。