what's difference between Order ID and Transaction ID?

iwqs2000
Contributor
Contributor

I am using Paypal sandbox to test my application.  The JSON file returned by Paypal onApprove contains Order ID, but when logging in Paypal account, it has Transaction ID only, and these two don't match.  How are those two IDs related?  Can I capture Transaction ID to make the search better?

Login to Me Too
6 REPLIES 6

MTS_Justin
Moderator
Moderator
Hello,

An order id is returned when you create an order via our REST API. It's a unique identifier for the specific order you have created.

A transaction id is returned when you complete a transaction, for example, if you create an order with an intent of "authorize" and then capture it, a unique transaction id for the captured transaction will be returned within the API response and this transaction id can be viewed within an account.

https://developer.paypal.com/docs/api/orders/v2/#orders_capture

The same would apply if you created an order with an intent of "authorize" and then authorized a payment for the order. An authorization transaction id would be returned within the API response.

https://developer.paypal.com/docs/api/orders/v2/#orders_authorize

Thanks !

Was my post helpful? If so, please give me a kudos!
Login to Me Too

iwqs2000
Contributor
Contributor

Thank you for your reply, but I still don't understand...

I am going to give you the details, you tell me where things went wrong please.

I call Paypal:

https://www.paypal.com/sdk/js?client-id=<my_client_id>&currency=USD&intent=capture&enable-funding=ve...

The website displays Paypal GUI, after the User makes the payment, the website recieved a JSON response:

{
"id": "8N330975DN102892E",
"intent": "CAPTURE",
"status": "COMPLETED",
"purchase_units": [
{
"reference_id": "default",
"amount": {
"currency_code": "USD",
"value": "69.00"
},
"payee": {
"email_address": "merchant_email",
"merchant_id": "YMTQYPWYKZ92S"
},
"shipping": {
"name": {
"full_name": "Loop Customer"
},
"address": {
"address_line_1": "1 Main St",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
},
"payments": {
"captures": [
{
"id": "1EX23284TH533935C",
"status": "COMPLETED",
"amount": {
"currency_code": "USD",
"value": "69.00"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"create_time": "2022-10-10T14:28:47Z",
"update_time": "2022-10-10T14:28:47Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "Loop",
"surname": "Customer"
},
"email_address": "user_email",
"payer_id": "6PVUDTX7YB8D8",
"address": {
"country_code": "US"
}
},
"create_time": "2022-10-10T14:28:29Z",
"update_time": "2022-10-10T14:28:47Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8N330975DN102892E",
"rel": "self",
"method": "GET"
}
]
}

 

In this JSON response, we see:

the first line says: "id": "8N330975DN102892E" <ID1>

in the Payment section, it says: "id": "1EX23284TH533935C" <ID2>

If you go to User's account, it says:[Removed. Phone #s not permitted]>

If you go to merchant's account, it says: Transaction ID: "1EX23284TH533935C" <ID4>
So there are 3 unique IDs in 4 places.
As a merchat, I should capture the <ID2> from the JSON content in the User's database, because it matches with merchat's Paypal's <ID4>, correct?
If so, what is <ID1>? What's the purpose of <ID1>? how is it related to <ID2>?  Should I capture it for any reason?
And what is "href": "https://api.sandbox.paypal.com/v2/checkout/orders/8N330975DN102892E"?  Any action on merchat's side?
If I paste this in a browser, I got: 
{"name":"AUTHENTICATION_FAILURE","message":"Authentication failed due to invalid authentication credentials or a missing Authorization header.","links":[{"href":"https://developer.paypal.com/docs/api/overview/#error","rel":"information_link"}]}
So what is it?
What's the purpose of <ID3>? how is it related to <ID4>?  Since I (as a merchant) can't see <ID3>, I should NOT care, correct?
Please answer all questions, I appreciate your help.
 

 

Login to Me Too

iwqs2000
Contributor
Contributor
It is so difficult working with Paypal, it took something out in my post:
If you go to User's account, it says:[Removed. Phone #s not permitted]
 
There is no phone number there!  The line reads:
If you go to User's account, it says: Transaction ID[Removed. Phone #s not permitted]>
Login to Me Too

iwqs2000
Contributor
Contributor

<removed>  -- No profanity in your posts please

 

The <ID3> is another 17-digit so called "Transaction ID" found in the User's Paypal account, and different than <ID1> <ID2> and <ID4>.

Login to Me Too

MTS_Justin
Moderator
Moderator
Hello,

"id": "8N330975DN102892E"

This is the order id.

"captures": [
{
"id": "1EX23284TH533935C",

This is the capture transaction id.

I've checked this transaction id and it's associated with this sandbox business account "YMTQYPWYKZ92S" and it shows in the transaction activity for this account.

Thanks !


Was my post helpful? If so, please give me a kudos!
Login to Me Too

alexkuzmov
Contributor
Contributor

@amts I`m dealing with the same issue, and that is incorrect.
The captures object is not always returned.
For example, if you get the details of on order for a subscription payment, you get something like this:

 

 

 

{
   "id":"2M9235603X788581X",
   "intent":"CAPTURE",
   "status":"APPROVED",
   "payment_source":{
      "paypal":{
         "email_address":"email_address",
         "account_id":"8XHXZUT5Y3CVS",
         "name":{
            "given_name":"John",
            "surname":"Doe"
         },
         "address":{
            "country_code":"US"
         }
      }
   },
   "purchase_units":[
      
   ],
   "payer":{
      "name":{
         "given_name":"John",
         "surname":"Doe"
      },
      "email_address":"email_address",
      "payer_id":"8XHXZUT5Y3CVS",
      "address":{
         "country_code":"US"
      }
   },
   "create_time":"2023-02-13T17:24:46Z",
   "links":[
      {
         "href":"https:\/\/api.sandbox.paypal.com\/v2\/checkout\/orders\/2M9235603X788581X",
         "rel":"self",
         "method":"GET"
      },
      {
         "href":"https:\/\/api.sandbox.paypal.com\/v2\/checkout\/orders\/2M9235603X788581X",
         "rel":"update",
         "method":"PATCH"
      },
      {
         "href":"https:\/\/api.sandbox.paypal.com\/v2\/checkout\/orders\/2M9235603X788581X\/capture",
         "rel":"capture",
         "method":"POST"
      }
   ]
}

 

 

 

Which is fine for the initial confirmation, but what do you do when you want to get the Fees for example?
Or you want to confirm the payment if the subscription is for later payment, not immidiate capture?
Well you search endlessly on google, and pull out some hair.
Because this is what the webhook gets as confirmation on the 'PAYMENT.SALE.COMPLETED' event:

 

 

 

{
   "id":"WH-6SE66006R98946535-7F814879YL577135N",
   "event_version":"1.0",
   "create_time":"2023-02-13T17:25:09.906Z",
   "resource_type":"sale",
   "event_type":"PAYMENT.SALE.COMPLETED",
   "summary":"Payment completed for EUR 39.37 EUR",
   "resource":{
      "billing_agreement_id":"I-0HN4N0KTWLMP",
      "amount":{
         "total":"39.37",
         "currency":"EUR",
         "details":{
            "subtotal":"39.37"
         }
      },
      "payment_mode":"INSTANT_TRANSFER",
      "update_time":"2023-02-13T17:25:03Z",
      "create_time":"2023-02-13T17:25:03Z",
      "protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
      "transaction_fee":{
         "currency":"EUR",
         "value":"1.76"
      },
      "protection_eligibility":"ELIGIBLE",
      "links":[
         {
            "method":"GET",
            "rel":"self",
            "href":"https://api.sandbox.paypal.com/v1/payments/sale/036421861N8145017"
         },
         {
            "method":"POST",
            "rel":"refund",
            "href":"https://api.sandbox.paypal.com/v1/payments/sale/036421861N8145017/refund"
         }
      ],
      "id":"036421861N8145017",
      "state":"completed",
      "invoice_number":""
   },
   "links":[
      {
         "href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-6SE66006R98946535-7F814879YL577135N",
         "rel":"self",
         "method":"GET"
      },
      {
         "href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-6SE66006R98946535-7F814879YL577135N/resend",
         "rel":"resend",
         "method":"POST"
      }
   ]
}

 

 

 

 

Ok, so this is partial information, I have fees but not much else in terms of values, and I dont have a direct link to list all transaction/orders for a subscription.
Lets see what the API gives when you try and look for all the transaction for a given subscription:

 

 

 

{
   "transactions":[
      {
         "status":"COMPLETED",
         "id":"036421861N8145017",
         "amount_with_breakdown":{
            "gross_amount":{
               "currency_code":"EUR",
               "value":"39.37"
            },
            "fee_amount":{
               "currency_code":"EUR",
               "value":"1.76"
            },
            "net_amount":{
               "currency_code":"EUR",
               "value":"37.61"
            }
         },
         "payer_name":{
            "given_name":"John",
            "surname":"Doe"
         },
         "payer_email":"email_address",
         "time":"2023-02-13T17:25:03.000Z"
      }
   ],
   "links":[
      {
         "href":"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-0HN4N0KTWLMP/transactions?start_time=2023-02-01T07%3A50%3A20.940Z&end_time=2023-02-28T07%3A50%3A20.940Z",
         "rel":"SELF",
         "method":"GET"
      }
   ]
}

 

 

 

 

Thats odd, I had to specify a date to get transactions for a subscription, which makes no sense, but at least I got the fees and the proper amounts.
Ok good, soooo whats left now is for me to somehow connect the transaction ID with the order ID.....?!?!??!?!

And its basically a dead end, at least I dont see how to proceed.
I was left with the same question, whats the difference between order ID and transaction ID (in practicality, not the decided convention of the data structure)?
Also how do you connect them together?
If the order doesnt contain the fees or the captures where I can usually find the transaction IDs for one time paymnents, then how do I get them?
I dont have a way to connect a transaction ID with an order ID of a subscription payment, please help.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.