3

I'm implementing the v2 Express Checkout Paypal Integration; It works fine, however it does not fully complete the transaction (business account does not receive the payment).

  1. I'm running tests on sandbox.

  2. The token is generated as well as the Order ID.

  3. I copy and paste the given link into the URL bar and press enter to proceed to complete the transaction. https://www.sandbox.paypal.com/checkoutnow?token=2463323E24235WQ.

  4. The transaction is completed and redirects to a new URL https://example.com/return?token=2463323E24235WQ&PayerID=UEJ2NE9233DS5W.

Everything seems to work well, however when I come to check the notifications of the sandbox business account (in which the payments were supposed to go to), it does not show any payment.

Everything seems to be set accordingly but the payments just don't go to my account.

1 Answers1

3

transaction is completed

Nope, wrong; the buyer approved the payment. There is no transaction.

To create a transaction, when the buyer returns to e.g. https://example.com/return?token=2463323E24235WQ&PayerID=UEJ2NE9233DS5W , you must display an order review page and capture the order with the appropriate API call.

If you want to capture the order immediately (skipping the display of an order review page), you can specify this in the initial order setup so that the "Continue" button the buyer clicks to return to your site instead says "Pay Now".

Preston PHX
  • 27,642
  • 4
  • 24
  • 44
  • Thank you, but let me see if I understood. Let's say I've already displayed an order review page and the user clicked on a "Proceed to Payment" button, then, the payment order would be generated and his info would be saved in the database; the user would be redireted to this example URL `https://example.com/return?token=2463323E24235WQ&PayerID=UEJ2NE9233DS5W` afterwards (where the transaction is completed), right? – Thiago Guimarães Apr 23 '20 at 15:04
  • 1
    You need to tell PayPal to make the final button read "Pay Now" instead of continue. And when the user lands on that URL, you need to immediately execute the API call to capture the order. If it fails, you need to tell the user this. But actually, there is a better question --- why are you using redirects? – Preston PHX Apr 23 '20 at 15:07
  • 1
    Don't use redirects. Don't use any redirects at all. Redirects are a terrible experience for modern websites. Instead, keep your site loaded in the background and display an in-context window. Here is the front-end code you need: https://developer.paypal.com/demo/checkout/#/pattern/server – Preston PHX Apr 23 '20 at 15:08
  • Well, to be honest, I have never done an integration before (bare with me) so I'm starting off with the basics. I'm using the file `OrdersCreateTest.php` to directly create a payment order (for testing purposes). This order gives me the order ID, the checkout URL, e.g.: `https://www.sandbox.paypal.com/checkoutnow?token=02H52232KS42123`, etc. When i access the checkout URL, it shows me with payment methods, total and the item description, then I choose a payment method and click on "Pay" it redirects me to `https://example.com/return?token=02H52232KS42123&PayerID=R2F3233233DS5W`. – Thiago Guimarães Apr 23 '20 at 15:20
  • So I thought the transaction was already completed when I clicked on "Pay". It was just returning the transaction information. – Thiago Guimarães Apr 23 '20 at 15:21
  • 1
    Alright well it might say Pay vs. Continue by default, but either way you need to capture it via the API after being redirected back to your site. This is how all the PayPal checkout APIs work. More importantly, use a JS SDK to fetch the order ID and display a window so you don't have to redirect. – Preston PHX Apr 23 '20 at 15:34
  • Oh my bad, I'm sorry. Indeed the Checkout page says "Continue" and not "Pay", and then redirects me to that url with the token and payid. So If I don't want to display a checkout page (I already have done it in my system), I just pass the orderID and payid to the client and the javascript will fetch it from the server for the user to pay and complete the transaction, right? – Thiago Guimarães Apr 23 '20 at 15:42
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/212371/discussion-between-thiago-guimaraes-and-preston-phx). – Thiago Guimarães Apr 23 '20 at 16:18