我一直在尝试从 paypal 获取沙箱环境应用程序来在我的 Angular 应用程序上运行。 我一直收到错误 422,不知道为什么。 一切都很顺利,我登录了测试帐户,但我不断收到 422 错误。 是的,我的用户 ID 是正确的
我在底部添加了 paypal reposne。
我来自波斯尼亚。
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
declare var paypal: any;
@Component({
selector: 'app-paypal',
templateUrl: './paypal.component.html',
styleUrls: ['./paypal.component.css']
})
export class PaypalComponent implements OnInit {
@ViewChild('paypal', { static: true }) paypalElement!: ElementRef;
product = {
price: 1,
description: 'Used Couch, decent condition',
};
paidfor = false;
ngOnInit() {
paypal
.Buttons({
createOrder: (data: any, actions: any) => {
return actions.order.create({
purchase_units: [
{
description: this.product.description,
amount: {
currency_code: 'USD', // Changed currency code to EUR
value: this.product.price.toString(), // Ensure price is a string
},
},
],
});
},
onApprove: async (data: any, actions: any) => {
try {
const order = await actions.order.capture();
this.paidfor = true;
console.log(order);
} catch (error) {
console.error('Error capturing order:', error);
}
},
onError: (err: any) => {
console.error('PayPal error:', err);
}
})
.render(this.paypalElement.nativeElement);
}
}
<script src="https://www.sandbox.paypal.com/sdk/js?client-id=USER_ID¤cy=USD&debug=true"></script>
// Here is the json paypal response:
{
"additional_properties": {},
"body": {
"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": "f1358601be5d7",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-COMPLIANCE_VIOLATION",
"rel": "information_link",
"method": "GET"
}
]
},
"duration_time": "xxxxxx",
"header": {
"APPLICATION_ID": "APP-80W284485P519543T",
"Access-Control-Expose-Headers": "xxxxxx",
"BORDER-IP": "xxxxxx",
"CALLER_ACCT_NUM": "SYFYX283TNPKN",
"Date": "Wed, 11 Sep 2024 15:01:51 GMT",
"Keep-Alive": "xxxxxx",
"PROCESSING-IP": "xxxxxx",
"SERVER_INFO": "xxxxxx",
"Server-Timing": "xxxxxx",
"paypal-debug-id": "f1358601be5d7"
},
"status": 422
}
这是一个国家问题。
PayPal 结帐 UNPROCESSABLE_ENTITY:COMPLIANCE_VIOLATION
对于未来的标签:
阿尔巴尼亚、阿尔及利亚、安提瓜和巴布达、巴巴多斯、伯利兹、波斯尼亚和黑塞哥维那、多米尼克、埃及、斐济、法属波利尼西亚、格林纳达、莱索托、马拉维、新喀里多尼亚、帕劳、圣基茨和尼维斯、圣卢西亚、塞舌尔、特立尼达和多巴哥, 特克斯和凯科斯群岛
这些国家可能面临着与我相同的问题。检查文档以修复。