Testing linking to the receipt using PayPal sandbox - paypal

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.

Related

How to find paypal buyer order id in paypal official page

I have tried to find overtime for get paypal order id in paypal page but nothing found yet. Can anybody tell find buyer order id from paypal page
Order IDs from the v2/checkout/orders API are only used to keep track of a checkout attempt for approval. They are not persisted in the PayPal system afterward, and you cannot find them in any account views or reports. They are not useful for any accounting once a transaction has been captured, that is not their purpose.
When a v2/checkout/order is captured, the PayPal transaction ID will be in the capture response at purchase_units[0].payments.captures[0].id. This ID is the one that should be persisted, and will be useful to reference in account views and reports.
You can also store your system's own unique ID as part of any transaction. The invoice_id at order creation time exists for this. Make sure it is unique (never before used for a previously successfully captured transaction). For a non-unique field that can store arbitrary data, use custom_id.

What should I do for a reliable checkout flow with Paypal?

A listener on my website 'listens' for successful purchases made via Paypal. Data retrieved by the listener includes a post variable that I can set before initiating the purchase. This is possible with Paypal's IPN(Instant Payment Notification). I am trying to get the IPN to recognize the users account on my website upon purchase. Every account on my website has a unique user ID number.
I have tried passing the accounts unique ID through Paypal's "Custom" variable so the IPN can listen for that. Though I think this is a bad idea because then people can purchase things for another account if they passed their unique ID. Though this is a guaranteed purchase handler, hackers can take advantage of this with social engineering.
I see that some people instead pass the session_id with php, but this isn't safe because the listener would have no way of recognizing the user's website account if the session_id were to disappear. I also see that people will pass a cookie tied to the user's unique account. I don't think this is a good idea because the cookie could be cleared.
It is to my impression that I can not send a refund or cancel a purchase if the user's account could not be identified(Without doing it manually). What checkout flow should I do?
I would create a local invoice record in your system, and this invoice would get a customer ID associated with it.
Then you can use the INVOICE parameter to pass the invoice ID to PayPal, and that would come back in IPN where you can then lookup the customer ID based on that invoice ID.

Retrieve transaction ID via rest API

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.

What is a PayPal payer id?

Instant Payment Notification script receives among other parameters the following one:
payer_id = LPLWNMTBWMFAY
What is the meaning of that string?
It's an external unique identifier of a particular PayPal account. Since email addresses change over time. A PayerID is static.
As others have said, payer_id can be used to identify a Paypal account. HOWEVER! -- a single Paypal account can have several payer_ids associated with it, one for each credit card or funding source used by that account. Because of this, a given Paypal account does NOT map one-to-one to a single payer_id.
For example, if Bob buys from my website (through Paypal) using his Visa card, the transaction will include one payer_id. If Bob later buys using his Mastercard, the transaction will include a different payer_id.
I confirmed this in a phone call with Paypal Merchant Technical Solutions, in May of 2013, after running into problems with my order processing (due to an incorrect assumption I had made about payer_id being a reliable way to see if a customer already existed within my customer database).
NB: One ramification of this fact is that, when writing a Paypal IPN-processing script, payer_id should properly be stored only in the "orders" database table, and not stored in the "customers" table.
See also this answer: Is the paypal payer_id unique per credit card?
EDIT:
Apparently, each PayPal account does get just one payer_id. (That is not what I gleaned from my aforementioned phone call with Paypal Merchant Technical Solutions, but I can't find my notes on that call, so perhaps there was some confusion there.) Regardless, the payer_id does NOT uniquely identify a customer – as in a single, unique individual somewhere out there in the world. A customer could use multiple Paypal accounts, or could make some purchases as a "guest" using a different funding source than their primary Paypal account, and merchants would get different payer_ids for each one – even if the person's name, address, and all other identifying information were exact matches.
For these reasons, it is misleading for Paypal to call the payer_id variable a "Unique customer ID". Unfortunately, that description still persists in their documentation (scroll to the bottom of the "Buyer information variables" section):
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/#id091EB01I0Y4
It's just the id of the user who paid. You have to log it, to be able to give it to Paypal in case of conflict.
Payer_id is just paypal id of who pay the payment.
Email id is dynamic and always change, but payer_id is static.

How do you connect a Paypal IPN confirmation to a user?

I wanted to use Paypal's IPN service to verify payments for a recurring subscription charge for my website. How do you tie the IPN confirmations to a user in your site?
The IPN confirmation message has a name, email, paypal ID, recurring payment ID, but it seems to not give a unique identifier since I don't know where the paypal ID or recurring payment id comes from and it may not be trivial to uniquely match up the name/email that a user has on their paypal account (or entered there) with the name/email I have for them on my site (there may be many John Smith's and the person may choose to use a different email.)
1) When I send the initial payment request to Paypal, I can attach a unique UUID in the URL I ask them to send back to me, so if I save that unique ID for that user I can match that payment confirmation to the user who initiated it. Am I making that harder than it is? Is there an easier way?
2) Also, for a recurring/subscription charge, does paypal always use the URL I specified with the initial payment initiation? Does anyone have practical experience using the recurring Paypal payments with IPN's, does it reuse that unique URL? Or do I have to associate the Paypal ID's with the user after the first recurring payment is received?
Attaching unique data to the payment request is pretty much the accepted way to do it.
I don't have any experience with recurring charges.
I recently also set up some reoccurring payments with Paypal.
I actually wanted people to register as members after paying for the subscription, if they wanted to. As having to sign up as a member could add some friction to the sale process. So I don't send any user info along with the Subscribe button.
What my IPN script does is generate a unique activation code tied to the Paypal subscriptionID in the Activations table, then it sends this code to whoever paid for the subscription, with instructions on how to activate.
At the point of activation, you need to register or login. At this point the userID is added to the relevant row in the Activations table.
When the EndOfTerm IPN notification comes in the IPN script looks up the userID from the Activations table based on the SubscriberID given in the IPN. Then I can do whatever I need to do to that user to disable their subscription.
At all time the URL of the IPN script remains the same.
1) You can send an 'item_number' parameter with the initial subscription setup, which will get passed back to you. I'd suggest embedding an identification token in it.
2) If you mean the 'return' parameter, no, that's for sending the user to at the conclusion of the subscription setup. The renewal is automatic and doesn't 'ping' that page.
1) You want to be using the item_number parameter. Set this in your HTML form shown to the customer, and it will be returned to you by the paypal IPN, so you can put a database row ID in here, and use it to match up to the right person later.