- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I'm using the V2 REST API (with the PayPalCheckoutSdk) to capture an authorization for an order created with the PayPal Smart Payment Buttons.
The problem I'm facing, is that after I capture the authorized Order, I need a way to get the TransactionID so that I can include it in our customer's receipt and record it in our DB. Currently /v2/checkout/orders/{order_id} does NOT return the same TransactionID that can be seen from a client's purchase history in the PayPal sandbox. I have looked through the entire data structure returned from an OrdersGetRequest and cannot find this TransactionId.
I found some relevant documentation that says I should be able to find this transactionId on the purchase_unit data structure for this order:
The documentation suggests I need to call /v2/checkout/orders/{order_id}/save to generate this id, but when I attempt this, I get an error stating that the order cannot be saved, and that I need to set the intent to authorize and set processing_instruction to ORDER_SAVED_EXPLICITLY.
Does anyone have any insights on how I can properly use the V2 REST API to create Orders and retrieve transaction ids that match the transaction ids that customers will see?
Solved! Go to Solution.
- Labels:
-
Payments REST APIs
-
Payouts Rest APIs
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, precisely, I perform a PATCH on the order after it is created but before the user authorizes the capture.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please provide a link to the "id" description that you have pasted below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, thanks for getting back to me. The id is listed under the purchase_unit data structure you can find here. https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit
I have not been able to find the correct way to call save on the order to generate the id. Your assistance is appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I can help you with /save but it won't solve your problem.
At the moment we don't really return the transaction ID sent to the buyer to the merchant.
At the moment your best bet and what I see a lot of our merchants do is to generate their own invoice_id which also shows up in the receipt sent by PayPal and it's a common link between your transaction and the buyers transaction.
Please let me know if you have more questions - happy to help in anyway I can.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, my current workaround for this inconsistency between the two APIs is to take the orderId returned from PayPal and attach it to the order's invoiceId field after order creation. This is necessary in our integration since we don't actually create a purchaseId in our database until the payment is completed, and once a payment is completed, we cannot attach an invoiceId to the order. Please let me know if this is an inadvisable solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do you do "PayPal and attach it to the order's invoiceId field after order creation." do you do a PATCH on invoice_id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, precisely, I perform a PATCH on the order after it is created but before the user authorizes the capture.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What you are doing is correct.
I am presuming that you want to use the "id" that you get back from order rather than generating a random string as presumably you are already storing the Order Id somewhere so it avoid saving twice. I really can't see a way to avoid the PATCH.
I am investigating if we can expose the buyer transaction_id but that might not be that quick so what you have is a good way to do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had this issue also, here is the answer to get the transaction id
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
console.log(JSON.stringify(details.purchase_units[0].payments.captures[0].id));
var transid = JSON.stringify(details.purchase_units[0].payments.captures[0].id)
});
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- « Previous page
- Next page »
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- PHP SDK error: broken content-length header in SDKs
- Some negative testing value only reply 403 Forbidden in Sandbox Environment
- If I don't capture within the 3 hour limit, how can I be sure that the payment went through? in REST APIs
- PayPal integration with Next, Lambda and API Gateway - 400 Invalid Request in Sandbox Environment
- paypal angular sandbox, receiving not approved order ,when Capture even OnApprove is triggered in Sandbox Environment