I'm trying to determine a way to issue a refund for the user's order using the PayPal REST API. After taking a look at this section, I see that in the documentation on the left PayPal uses the terms "id" and "sale_id", while in the example on the right I see {transactionId}. The docs seem to be using the term "sale id" and "transaction id" interchangeably. Should I believe the example, and go ahead and use the transaction id I received via IPN earlier to issue a refund for the order?
Yes. sale_id is the same as transaction id in your PayPal account and IPN messages.
Related
I have been able to create an order, get it approved and capture payment using PayPal sandbox. I would now like to test linking to the receipt for that order.
So, given that the order id assigned by PayPal is 1VC7586169694032B, based on the docs I tried to point my browser to the following locations:
https://www.paypal.com/receipt/?id=1VC7586169694032B
https://api.sandbox.paypal.com/receipt/?id=1VC7586169694032B
https://api.sandbox.paypal.com/v2/receipt/?id=1VC7586169694032B
https://www.api.sandbox.paypal.com/receipt/?id=1VC7586169694032B
https://www.api.sandbox.paypal.com/v2/receipt/?id=1VC7586169694032B
https://sandbox.paypal.com/v2/receipt/?id=1VC7586169694032B
None of these worked.
So, are receipts for sandbox transactions stored? If so, what is the correct link? If not, how can I test the feature of linking to the order receipt without creating a real live transaction?
An order id is not a PayPal transaction id. And neither one is a receipt id, much less a PayPal Here invoice id which are the docs and links in your question.
When you capture an order id, the merchant account's transaction id will be in the response at purchase_units[0].payments.captures[0].id.
That id can be looked up in PayPal.com . Perhaps you could dynamically link to the resulting details page, I haven't tested it.
Note that the merchant account and the payer account each have their own different transaction id, but it's possible to search for the "other account's" transaction id in paypal.com and still reach the details page.
My application uses PayPal java library to make payments. Everything works fine but I can't understand one thing. What exactly is transaction code? Let's say I make a payment and then approve it. As a result I receive the JSON object which has an ID (PAY-*) and transactions->related resources->sale->ID. Both of them I store in the DB in order to show later to user (in case he wants to refund the money). But if I see these payments from PayPal customer portal, in the descriptions of payment I see non of these ID's.. Transaction code is totally different! So which one of them should I store?
Thank you in advance
PayPal generally uses a transaction ID. It's a 16 character alphanumeric string. This will appear in both your API response and the PayPal site. Assuming REST is like Classic, the Transaction ID is how you will reference the payment for any future operations (capture, refund, etc).
Please note that if you're using Express Checkout (where the customer pays via PayPal account) they will have their own transaction ID for the exact same transaction.
Let's assume the PayPal REST API is used to fulfill a standard PayPal payment process. When executing the payment it is returned as 'pending', so the payment is not through, yet. The REST APi provides a payment id:
https://developer.paypal.com/docs/api/#execute-an-approved-paypal-payment
When payment is completed the URL of my IPN listener is called, however as said on this site included only a txn_id which seems to be not the same as the payment id of the REST API:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#id08CKFJ00JYK
So how to match these two ids?
IPN was designed for supporting the classic APIs on PayPal and the txn_id would have matched the txn_id of a payment made with the classic API.
For payments made via the REST API, you may still be notified via IPN but unfortunately cannot match payments using ids currently. Your best option right now would be to check the attributes of the payment (amount, currency etc) and check that it matches attributes of a payment you were expecting.
Currently this is the existing option for push based notifications. The other option may be to poll at regular intervals and check the status of the payment.
There are certainly limitations to both approaches, and there is webhook support upcoming which would have push based notification support for REST payments to alleviate these issues.
The txn_id of IPN messages are also included with the REST API message but called 'sale id' there.
I'm using PayPal Express checkout and I'm trying to display to the customer their transaction id at the end of the checkout process on the thank you page.
I'm currently pulling back:
PAYMENTREQUEST_0_TRANSACTIONID
Which is the transaction id that is logged in my business account. However the transaction id on the email sent to the customer is different to this id that is being returned.
I'm using this API: https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/
The documentation states
"(Optional) Transaction identification number of the transaction that was created. You can specify up to 10 payments, where n is a digit between 0 and 9, inclusive.
Note This field is only returned after a successful transaction for DoExpressCheckout has occurred.
TRANSACTIONID is deprecated since version 63.0. Use PAYMENTREQUEST_0_TRANSACTIONID instead. "
I'm also using
PAYMENTREQUEST_0_INVNUM
Which is very helpful and lets me put my order reference number into the main body of the email that the customer receives, but I'd also like their transaction id, so that if they send a query through this can be logged in a field in the database and cross referenced against the order with just the transaction id.
Any help would be appreciated!
Thanks
PayPal assigns different transactions to the buyer and the seller. I'm not exactly sure why, but I know they do.
If a customer gives you their transaction ID, though, you CAN find it in your PayPal account by doing a search through paypal.com or via the TransactionSearch API.
I'm looking for the correct endpoint to use in the Paypal API for looking up a transaction by invoice id. We submit the invoice id to paypal when redirecting customers to PayPal for payment on their site. In order for us to resolve abandoned carts correctly, I need to look these invoice ids back up in paypal to see if there are completed transactions or not. Thanks.
You can use the TransactionSearch API, and use the INVNUM as the criteria to search by. The API Endpoint will depend on if you are trying this on live or sandbox, what type of format you are using, and what type of authentication you are using. You can find a list of the endpoints here.