PayPal: Straightforward ask to pay - get confirmation example and docs (PHP)

46 views Asked by At

I have a list of products on my site. The way it is implemented on my site is of no importance, lLet's say it is a table with checkmarks. The user selects products to order:

product_1 $4.99

product_2 $4.99 checked

product_3 $3.99 checked

product_4 $4.99

...

Then the user clicks "order". My PHP script calls something on PP side, and the user is presented with the "please pay" page (again, on PP side):

product_2 $4.99

product_3 $4.99

...

Total: ...

As you can see, I have sent to PP list of product names, product prices AND some hidden field called "transaction id", that I will use later to identify the payment, it is a value generated by me.

The user pays, and it triggers the WebHook (IPN?) from PP side, calling another PHP script on my side. It passes payment status (success) and transaction id. Upon receiving it, I will know that the user purchased these items.

That's it. I need to know if this is possible and a sample code, because PP dev docs are not very beginner friendly.

Please help.

1

There are 1 answers

2
Preston PHX On

Use a standard PayPal integration. Its sample backend routes are in node.js for example purposes. Implement the backend routes in PHP instead. Your own "transaction_id" (you should call it something else), if unique and never used before for a completed transaction on your PayPal account, should be set as the v2/checkout/order's invoice_id value.