PayPal REST API捕获订单未返回exchange_rate的原因咨询
PayPal沙箱环境下捕获订单未返回
exchange_rate字段问题 我已搭建PayPal Advanced Checkout沙箱环境,使用以下API调用捕获订单:
/v2/checkout/orders/{{order_id}}/capture
创建订单时的交易详情
{ "intent": "CAPTURE", "payer": { "address": { "admin_area_2": "Downton", "postal_code": "SP5", "country_code": "GB" } }, "purchase_units": [ { "description": "Test Item", "custom_id": "12345", "soft_descriptor": "Purchase Descriptior", "amount": { "currency_code": "USD", "value": "58.80", "breakdown": { "item_total": { "currency_code": "USD", "value": "49.00" }, "tax_total": { "currency_code": "USD", "value": "9.80" } } }, "items": [ { "name": "Test Item", "unit_amount": { "currency_code": "USD", "value": "49.00" }, "tax": { "currency_code": "USD", "value": "9.80" }, "quantity": 1, "category": "PHYSICAL_GOODS" } ], "shipping": {} } ] }
订单捕获响应
{ "id": "4FS9138999682320N", "status": "COMPLETED", "payment_source": { "paypal": { "email_address": "sb-bdd43g21513704@personal.example.com", "account_id": "V7ZN4NEJRLGZA", "name": { "given_name": "John", "surname": "Doe" }, "address": { "country_code": "GB" } } }, "purchase_units": [ { "reference_id": "default", "shipping": { "name": { "full_name": "John Doe" }, "address": { "address_line_1": "Whittaker House", "address_line_2": "2 Whittaker Avenue", "admin_area_2": "Richmond", "admin_area_1": "Surrey", "postal_code": "TW9 1EH", "country_code": "GB" } }, "payments": { "captures": [ { "id": "40V95236PS9814847", "status": "COMPLETED", "amount": { "currency_code": "USD", "value": "58.80" }, "final_capture": true, "seller_protection": { "status": "ELIGIBLE", "dispute_categories": [ "ITEM_NOT_RECEIVED", "UNAUTHORIZED_TRANSACTION" ] }, "seller_receivable_breakdown": { "gross_amount": { "currency_code": "USD", "value": "58.80" }, "paypal_fee": { "currency_code": "USD", "value": "2.30" }, "net_amount": { "currency_code": "USD", "value": "56.50" } }, "custom_id": "12345", "links": [ { "href": "https://api.sandbox.paypal.com/v2/payments/captures/40V95236PS9814847", "rel": "self", "method": "GET" }, { "href": "https://api.sandbox.paypal.com/v2/payments/captures/40V95236PS9814847/refund", "rel": "refund", "method": "POST" }, { "href": "https://api.sandbox.paypal.com/v2/checkout/orders/4FS9138999682320N", "rel": "up", "method": "GET" } ], "create_time": "2022-10-31T16:42:07Z", "update_time": "2022-10-31T16:42:07Z" } ] } } ], "payer": { "name": { "given_name": "John", "surname": "Doe" }, "email_address": "sb-bdd43g21513704@personal.example.com", "payer_id": "V7ZN4NEJRLGZA", "address": { "country_code": "GB" } }, "links": [ { "href": "https://api.sandbox.paypal.com/v2/checkout/orders/4FS9138999682320N", "rel": "self", "method": "GET" } ] }
我收到了状态为COMPLETED的响应,但尽管付款方币种与收款方币种不同,响应中却未返回exchange_rate字段。请问原因是什么?
回答
出现这种情况主要有以下几个可能的原因:
付款方未发生实际货币兑换
虽然付款方地址归属英国,但如果其PayPal账户默认币种为USD,或者付款时选择了用USD余额、绑定的USD支付方式完成交易,全程没有涉及币种转换,自然不会返回exchange_rate字段。沙箱环境的特殊逻辑限制
PayPal沙箱环境的货币兑换规则和生产环境存在差异,部分跨币种交易场景下可能不会返回汇率信息。可以尝试给沙箱付款方账户设置仅持有GBP余额,再发起支付测试,观察是否会返回该字段。API字段的触发条件
根据PayPal的API规范,exchange_rate字段仅在实际发生货币兑换操作的场景下才会返回。如果交易的付款、收款环节全程使用同一币种,该字段不会出现在响应结果中。
内容的提问来源于stack exchange,提问作者Henry-95
相关产品推荐
相关产品推荐

