DevT
DevT

Reputation: 1511

Paypal Form Payment correct workflow

I need to integrate payments with PayPal and I'm using the form integration

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_cart">
  <input type="hidden" name="upload" value="1">
  ...
  <input type="hidden" name="return" value="http://example.com/Thankyou.html">
  <input type="hidden" name="notify_url" value="http://example.com/IPN">
  <input type="image" name="submit" border="0" src="/img/logos_icons/paypal-btn.png" alt="PayPal - The safer, easier way to pay online">
</form>

After this point I'm a little bit confused: when the user click on the buy button is redirected on the PayPal website and when the transaction is completed is redirected on the "retun" link (a thank you page). At the same time PayPal send a notification (IPN) to the "notify_url".

is this the correct workflow? if yes, in the notify method I should book the purchased products but how can I understand which is the original transaction linked to the current notification ?

Upvotes: 1

Views: 75

Answers (1)

geewiz
geewiz

Reputation: 2206

You have the flow correct, although depending upon the nature of the transaction or user experience you are trying to provide you may have the fulfillment activity "book the purchased products") possible in two places: handled by the page the user the returns to (if they do return promptly and you want to fulfill the order immediately, e.g. so that they can navigate to a subscribed page) and via IPN to catch the cases where the user pays but does not return immediately to your site.

Generally you send a unique identifier of your choice to PayPal in the invoice field of the button; that identifier is linked to whatever context you need (purchase details/shopping cart, user account, whatever) on your side.

Upvotes: 2

Related Questions