贝宝 REST API 交易已获批准

Posted

技术标签:

【中文标题】贝宝 REST API 交易已获批准【英文标题】:paypal REST API transaction approved 【发布时间】:2014-05-12 12:54:38 【问题描述】:

我正在与贝宝进行集成。我正在为 java 使用 REST API。目前,我有待付款的问题。当我在沙盒环境中查找付款 (https://api.paypal.com/v1/payments/payment/paymentId) 以检查付款状态时,响应不同。 当我作为卖家批准付款时,付款处于状态

批准

销售处于状态

完成

示例响应: "id": "PAY-5YK922393D847794YKER7MUI", "create_time": "2013-02-19T22:01:53Z", "update_time": "2013-02-19T22:01:55Z", "state": "approved", "intent": "sale", "payer": "payment_method": "credit_card", "funding_instruments": [ "credit_card": "type": "mastercard", "number": "xxxxxxxxxxxx5559", "expire_month": "2", "expire_year": "2018", "first_name": "Betsy", "last_name": "Buyer" ] , "transactions": [ "amount": "total": "7.47", "currency": "USD", "details": "subtotal": "7.47" , "description": "This is the payment transaction description.", "related_resources": [ "sale": "id": "36C38912MN9658832", "create_time": "2013-02-19T22:01:53Z", "update_time": "2013-02-19T22:01:55Z", "state": "completed", "amount": "total": "7.47", "currency": "USD" , "parent_payment": "PAY-5YK922393D847794YKER7MUI", "links": [ "href": "https://api.sandbox.paypal.com/v1/payments/sale/36C38912MN9658832", "rel": "self", "method": "GET" , "href": "https://api.sandbox.paypal.com/v1/payments/sale/36C38912MN9658832/refund", "rel": "refund", "method": "POST" , "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "rel": "parent_payment", "method": "GET" ] ] ], "links": [ "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "rel": "self", "method": "GET" ] 有时付款是

待定

以及在

中的销售状态

已完成 示例响应: "id": "PAY-5YK922393D847794YKER7MUI", "create_time": "2013-02-19T22:01:53Z", "update_time": "2013-02-19T22:01:55Z", "state": "pending", "intent": "sale", "payer": "payment_method": "credit_card", "funding_instruments": [ "credit_card": "type": "mastercard", "number": "xxxxxxxxxxxx5559", "expire_month": "2", "expire_year": "2018", "first_name": "Betsy", "last_name": "Buyer" ] , "transactions": [ "amount": "total": "7.47", "currency": "USD", "details": "subtotal": "7.47" , "description": "This is the payment transaction description.", "related_resources": [ "sale": "id": "36C38912MN9658832", "create_time": "2013-02-19T22:01:53Z", "update_time": "2013-02-19T22:01:55Z", "state": "completed", "amount": "total": "7.47", "currency": "USD" , "parent_payment": "PAY-5YK922393D847794YKER7MUI", "links": [ "href": "https://api.sandbox.paypal.com/v1/payments/sale/36C38912MN9658832", "rel": "self", "method": "GET" , "href": "https://api.sandbox.paypal.com/v1/payments/sale/36C38912MN9658832/refund", "rel": "refund", "method": "POST" , "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "rel": "parent_payment", "method": "GET" ] ] ], "links": [ "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI", "rel": "self", "method": "GET" ]

同样,当我拒绝交易时,Sanbox 也能正常工作。一旦付款状态失败,销售状态被反转,另一个时间等待和保留。

我的问题是什么时候可以 100% 确定交易是完成还是失败? 我应该检查付款状态还是销售状态? 也许这个问题只与沙盒有关,与生产无关。

PS。此代码仅为示例,请勿分析。

【问题讨论】:

【参考方案1】:

您应确保即使销售状态显示已完成,付款也已获得批准。即使在销售状态显示完成后,也可能存在与特定买家帐户相关的内容,从而使付款处于待处理状态。在发货之前,您应确保付款已获批准。

【讨论】:

以上是关于贝宝 REST API 交易已获批准的主要内容,如果未能解决你的问题,请参考以下文章

执行付款后调用的 PayPal REST API 取消 URL

带有付款的 PayPal REST API 交叉参考交易

必填字段缺失。 PHP 贝宝 REST API

有没有办法设置参考交易贝宝的休息 API

如何获得贝宝销售交易

Paypal Rest API - 来自批准 URL 的令牌生命周期