paypal REST API交易已获批准

时间:2014-04-01 16:07:12

标签: paypal paypal-rest-sdk

我与paypal进行了整合。我正在使用REST API for java。目前,我的待付款有问题。当我向沙箱环境查找付款(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 个答案:

答案 0 :(得分:1)

您应该确保即使销售状态显示已完成,付款也已获得批准。即使在销售状态显示完成后,也可能存在与特定买方帐户相关的某些内容,这使得付款处于待处理状态。在运送产品之前,您应确保付款已获得批准。