捕获付款:无法执行请求的操作,语义上不正确或业务验证失败

Zia*_*rka 6 paypal paypal-sandbox

我对新的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"
    }
}
Run Code Online (Sandbox Code Playgroud)

2-转到approve响应中的链接

如果沙盒帐户有信用卡,PayPal会显示:“抱歉,我们无法处理您的请求。请稍后重试”

3-登录并批准订单

沙盒帐户没有信用卡

批准订单图片

单击继续按钮后,页面上将显示加载指示器,并且该指示器再次消失并且什么也没有发生

4-检查订单的状态 APPROVED

{
    ...
    "status": "APPROVED"
    ...
}
Run Code Online (Sandbox Code Playgroud)

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"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

Zia*_*rka 7

我想到了。这很简单。正文有效负载缺少return_urlin application_context。PayPal 确实需要更好地记录错误。