skip to Main Content

I am implementing a PayPal Donate button into a project for a charity. That is working great, and I am grabbing the JS response object which includes the Transaction ID. I store that for future API calls. With consent, we need to store donor name and email. So I am trying to use the PayPal API with the transaction ID to get these. It seems straightforward.

Per the PayPal REST API V2 docs, the relevant endpoint seemed to be /checkout/orders with the Order ID which admittedly I assumed was the Transaction ID, but having delved deeper appears not.

I am using Postman to test (auth is working fine), and the /checkout/orders endpoint returns Resource Not Found with a valid Transaction ID. It is the same account, correct API credentials etc.

I think that is now the wrong endpoint and I would need an Order ID. BUT the Donate buttons do not return Order ID, they return Transaction ID, as it is a ‘sale’ not an ‘order’. I now understand the difference, though frankly I would like to have a talk with PayPal developers on meanings and documentation.

So I just cannot find the correct REST V2 endpoint to use for these ‘sales’ with Transaction IDs – can anyone help please?

I saw an older SO question with an answer here which said the v1/payments/sale endpoint worked – but this endpoint does not exist in V2!

I have looked at transaction search, but that grabs a list by date, not with an existing transaction ID. I know the transaction I want.

I really have tried to go over the documentation, find guidance, and have tested with Postman, but I’m getting nowhere for what seems a basic API usage! Thank you all for any guidance.

2

Answers


  1. Chosen as BEST ANSWER

    Thank you to Preston PHX for pointing me in the right direction.

    Whilst /v2/payments/captures works with the Transaction ID returned from a hosted Donate button, it only shows transaction info like dates, values, fees etc. No payer info which was what was requested.

    For that, you have to use the /v1/reporting/transactions endpoint and supply transaction_id along with start_date and end_date - these are required, but can be grabbed from the previous captures call if not objectively known.

    Note that v1/payments/sale as mentioned in Preston's answer is fully deprecated so cannot be used as a one-stop call.

    In short, for the original question, two API calls are needed as above. However I have decided to simply grab consent and name/email on the website directly, rather than use the PayPal API. I will use the /v2/payments/captures endpoint however to verify a transaction was sent to and processed by this PayPal account rather than the button ID being modified somehow.


  2. v2 order IDs are like v1 PAYIDs or classic EC tokens. All three are only used during the payment approval process, and have no use once a transaction is completed.

    The equivalent of a v1 sale is a v2 capture. Both are completed PayPal transaction IDs.

    The endpoint to query a v2 capture’s status is documented here: https://developer.paypal.com/docs/api/payments/v2/#captures_get

    v1 APIs are still used for some payment types, like Subscriptions. I am not sure about Donations but either the v2 capture or v1 sale endpoint should work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search