PayPal HTML Buy Now Button and Webhook Events

mmrmichael
New Community Member

hi,

 

I created a simple Buy Now Button on my homepage. The user can click at the button and will be forward to PayPal and the User can start the payment.

 

I read that I can use IPN to receive notifications when someone used the button to pay. Does the Buy Now Button fires Webhook Events too? And which events are fired during the payment process?

 

Thanks in advance

 

Michael

Login to Me Too
2 REPLIES 2

BilltheCat
Contributor
Contributor

I'm basically in the same boat, and trying to figure out how this process works.  Honestly there's so much documentation and procedure, it's hard to keep it all straight. 

So, here's my interpretation of the process, hopefully someone will verify or correct me:

  1. The buy now button (aka Checkout, aka Smart Payment) is sitting on your website, and uses Javascript to communicate the payment to PayPal.
  2. Depending on your implementation of the button, it can either POST to your application back-end or redirect the user to a confirmation page. Either way, you want to grab the order ID received from PayPal and save it in your database or some other storage.
  3. Now here's where it gets unclear for me.  You need to make sure your customer doesn't cancel the payment, so just accepting the initial payment isn't enough.
    1. Subscribe to Webhooks for event notification. In the Developer site, go to 'My Apps & Credentials' > Click the name of your app (or create one) > in the Sandbox/Live webhooks, click 'Add webhook'.
    2. Enter the URL to your listening page, and subscribe to the events you want.  I subscribed to all, just to be sure. Your listening page needs to accept POST input from PayPal, and there's some good info on that here: Notification Messages
    3. The POST message could be faked, so PayPal includes a signature that needs to be validated and you use the notification event headers to do that.  You're looking for three things: 
      1. PAYPAL-TRANSMISSION-SIG (Generated Signature)
      2. PAYPAL-AUTH-ALGO (Algorithm used to generate it)
      3. PAYPAL-CERT-URL (Public key certificate to verify the signature)
    4. Assuming the signature validates, then the message is real.
  4. Now you need to write code that handles each of the notifications that you'll use.  I'm currently working on:
    1. "event_type": "CHECKOUT.ORDER.COMPLETED"
    2. "event_type":"CHECKOUT.ORDER.VOIDED"
Login to Me Too

angelleye
Advisor
Advisor

If you are using PayPal Standard (HTML) buttons, you'll need to use IPN.

 

If you're using the Checkout APIs (REST services) then you can configure webhooks and use that.  

 

 

Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.