捕获付款:请求的操作无法执行、语义不正确或业务验证失败
Capturing payments: The requested action could not be performed, semantically incorrect, or failed business validation
我对新版 PayPal API (v2) 和沙盒有疑问
1- 创建订单https://api.sandbox.paypal.com/v2/checkout/orders
{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": 10
},
"payee": {
"email": "xxxx@gmail.com",
"merchant_id": "xxxx"
}
}
],
"application_context": {
"shipping_preference": "NO_SHIPPING"
}
}
2- 转到响应中的 approve
link
If the sandbox account has a credit card, PayPal shows: "Sorry, we are not able to process your request. Please try again later"
3- 登录并批准订单
The sandbox account doesn't have a credit card
When the continue button is clicked, the page show the loading indicator and it disappears again and nothing happens
4- 查看订单状态 APPROVED
{
...
"status": "APPROVED"
...
}
5- 尝试捕获付款 https://api.sandbox.paypal.com/v2/checkout/orders/xxx/capture
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "TRANSACTION_REFUSED",
"description": "The request was refused"
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "939b641049ad2",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-TRANSACTION_REFUSED",
"rel": "information_link",
"method": "GET"
}
]
}
我明白了。这很简单。正文负载在 application_context
中缺少 return_url
。
PayPal 确实需要更好地记录错误。
我花了 5 个小时来调试。与 Ziad 的情况一样,我的问题是 application_context
,但与 Ziad 不同的是,我同时定义了 cancel_url
和 return_url
。不过,我之前已经更改了 payment_method
,据我所知,这是一个更好的配置。
这些改变对我有帮助。
payment_method": {
"payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
}
到
payment_method": {
"payee_preferred": "UNRESTRICTED"
}
Paypal 应该受到指责,因为它没有帮助我们缩小这些无情的区域范围。
迟到总比不到好:)
我发现这个错误一般是因为用户没有回复PayPal的邮件来验证身份导致的!贝宝偶尔会发送电子邮件来验证您的身份,我们中的一些人可能已经将它们标记为垃圾邮件了!当您不回复和验证您的身份时,他们会限制您的帐户,然后您会收到此错误消息:
description: "The merchant account is restricted."
field: "/purchase_units/@reference_id=='default'/payee"
issue: "PAYEE_ACCOUNT_RESTRICTED"
The requested action could not be performed, semantically incorrect, or failed business validation.
您必须登录您的 PayPal 帐户并转到 https://www.paypal.com/restore/dashboard
UNPROCESSABLE_ENTITY
错误涵盖了大量问题,如此处的文档所述:
https://developer.paypal.com/docs/api/reference/orders-v2-errors/#capture-order
在我的例子中,我使用的是旧的测试 Visa 4111 1111 1111 1111。现在你必须使用你在开发者帐户中生成的测试卡号:
https://developer.paypal.com/developer/creditCardGenerator
我对新版 PayPal API (v2) 和沙盒有疑问
1- 创建订单https://api.sandbox.paypal.com/v2/checkout/orders
{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": 10
},
"payee": {
"email": "xxxx@gmail.com",
"merchant_id": "xxxx"
}
}
],
"application_context": {
"shipping_preference": "NO_SHIPPING"
}
}
2- 转到响应中的 approve
link
If the sandbox account has a credit card, PayPal shows: "Sorry, we are not able to process your request. Please try again later"
3- 登录并批准订单
The sandbox account doesn't have a credit card
When the continue button is clicked, the page show the loading indicator and it disappears again and nothing happens
4- 查看订单状态 APPROVED
{
...
"status": "APPROVED"
...
}
5- 尝试捕获付款 https://api.sandbox.paypal.com/v2/checkout/orders/xxx/capture
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "TRANSACTION_REFUSED",
"description": "The request was refused"
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "939b641049ad2",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-TRANSACTION_REFUSED",
"rel": "information_link",
"method": "GET"
}
]
}
我明白了。这很简单。正文负载在 application_context
中缺少 return_url
。
PayPal 确实需要更好地记录错误。
我花了 5 个小时来调试。与 Ziad 的情况一样,我的问题是 application_context
,但与 Ziad 不同的是,我同时定义了 cancel_url
和 return_url
。不过,我之前已经更改了 payment_method
,据我所知,这是一个更好的配置。
这些改变对我有帮助。
payment_method": {
"payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
}
到
payment_method": {
"payee_preferred": "UNRESTRICTED"
}
Paypal 应该受到指责,因为它没有帮助我们缩小这些无情的区域范围。
迟到总比不到好:)
我发现这个错误一般是因为用户没有回复PayPal的邮件来验证身份导致的!贝宝偶尔会发送电子邮件来验证您的身份,我们中的一些人可能已经将它们标记为垃圾邮件了!当您不回复和验证您的身份时,他们会限制您的帐户,然后您会收到此错误消息:
description: "The merchant account is restricted."
field: "/purchase_units/@reference_id=='default'/payee"
issue: "PAYEE_ACCOUNT_RESTRICTED"
The requested action could not be performed, semantically incorrect, or failed business validation.
您必须登录您的 PayPal 帐户并转到 https://www.paypal.com/restore/dashboard
UNPROCESSABLE_ENTITY
错误涵盖了大量问题,如此处的文档所述:
https://developer.paypal.com/docs/api/reference/orders-v2-errors/#capture-order
在我的例子中,我使用的是旧的测试 Visa 4111 1111 1111 1111。现在你必须使用你在开发者帐户中生成的测试卡号: https://developer.paypal.com/developer/creditCardGenerator