Paypal REST - get payment details only works for p

2019-08-22 02:33发布

问题:

I was planning to use this endpoint to check and see if a sale has completed, using the sale's payment id: /v1/payments/payment/{payment_id} (https://developer.paypal.com/docs/api/payments/#payment_get)

But I just noticed this sentence in the description of this endpoint:

Shows details for a payment, by ID, that has yet to complete.

I've spent days reading the docs and I don't know what the bolded part means. I would like to be able to use the payment id and this endpoint to check the status of a sale days, months, even years after the user has completed their purchase, but the bolded part of this sentence seems to tell me I won't be able to do that.

Does this mean that after the sale has status = completed I can no longer use this endpoint to get the payment/sale details? Does the payment get deleted from paypal's system, and only the sale remains?

Thanks!

回答1:

I am not trying to justify why the wording is the way it is which needs to be updated but below is really what's happening.

When you do POST /v1/payments/ it creates a payment resource typically identified by an id PAY-xxxx

this typically goes in 3 statuses created. The transaction was successfully created. approved. The payer approved the transaction. failed. The transaction request failed.

when you do a POST /v1/payments/PAY-XXXX/execute (presuming you did an intent=sale) this results in the creation of a new resource called "sale" which can be seen in the related_resources when you examine the response.

Does this mean that after the sale has status = completed I can no longer use this endpoint to get the payment/sale details? you can if you notice even though the sale status=completed the payment status is still "approved" (sale is a related_resource within payment). so you can always lookup a PAY-xxxx and then see what are the related resources and their corresponding status at this point the status of PAY-xxxx is less consequential.

Does the payment get deleted from paypal's system, and only the sale remains? you can still query by the PAY-xxxx so it would suggest that it doesn't get deleted in anyways.



标签: paypal