【发布时间】:2020-09-07 20:19:16
【问题描述】:
我正在尝试将 PayPal 结帐集成到我的 Angular 网站中。集成似乎很好,但我在创建订单时总是出错。您将在下面找到我使用的所有代码。
index.html
<head>
...
<script src="https://www.paypal.com/sdk/js?client-id=MY-APP-SANDBOX-ID"></script>
</head>
donation.component.ts
declare var paypal;
...
export class DonationComponent implements OnInit{
...
ngOnInit(): void {
...
paypal.Buttons({
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [{
description: "Donation For Al-Darb Platform.",
amount: {
currency_code: 'USD',
value: this.value
}
}]
});
},
onApprove: async (data, actions) => {
const order = await actions.order.capture();
console.log(order);
},
onError: err => {
console.log(err);
}
}).render(this.paypalElement.nativeElement);
}
}
donation.component.html
...
<div #paypal></div>
执行后一切正常,仅在结帐时(登录到 Paypal 并验证付款后)。我总是收到以下错误HTTP 400:
{
ack: "contingency",
contingency: "UNPROCESSABLE_ENTITY"
data: {name: "UNPROCESSABLE_ENTITY", details: [{ issue: "COMPLIANCE_VIOLATION" ...}],
...
}
【问题讨论】:
-
"COMPLIANCE_VIOLATION" ...}],..." 这不是技术问题。您在这些...后面隐藏了哪些其他细节?接收 PayPal 的国家/地区是什么帐号?
-
... = "API 无法完成请求的操作,或者请求的操作在语义上不正确或业务验证失败。"
-
国家是阿尔及利亚。
标签: paypal