Which webhook event will call if subscription payment failed for paypal - paypal

I'm integrating PayPal payment gateway into my application. I'm using the PayPal REST API's. I'm able to authorize the request and webhook. Also, API and webhooks are working fine for me. The only thing about I'm little confused that which event and sequences of events will be if subscription payment failed?

For subscriptions, the only event you need to act on is PAYMENT.SALE.COMPLETED. When you receive this event, update the profile's valid date through the next cycle (e.g. 1 month in the future). If you don't receive a new PAYMENT.SALE.COMPLETED in time, the subscription has lapsed.
When creating the subscription you can set a custom_id which is useful for reconcilliation.

Related

What event is triggered from PayPal on successful recuring payment (for subscription)?

I have a subscription based web site where I would like to get statistics about all the current active subscribers and how many cycles they have made. This would have been easy task if the PayPal API had an endpoint for fetching all subscriptions but this is missing from their API. So I'm tracking this in our DB. I'm successfully recording the new subscriptions and the cancellations. But I'm not sure what event I should expect from PayPal to be triggered when a subscription renews.
In PayPal's documentation I have found only few events related to the subscriptions, and none of those seems to serve my needs. There are also an event called BILLING.SUBSCRIPTION.RE-ACTIVATED but it comes from "Billing plans and agreements" which is deprecated.
In SO I have found this post which advises to check for the PAYMENT.SALE.COMPLETED, but this is not perfect as I will get all sort of payments that hit this PayPal account (it is used not only for subscriptions but also for one-time payments).
It's PAYMENT.SALE.COMPLETED
For one time payments, a /v2/checkout/orders integration shouldn't trigger that same event, only the deprecated /v1/payments does AFAIK.
You can tell whether it's a subscription payment by the payload, subscription IDs begin with I-

Paypal Webhook is created sufficient to imply activated

Paypal with active webhooks. We use a subscription plan.
When a customer
subscribes to the subscription plan PayPal's webhook sends us a BILLING.SUBSCRIPTION.CREATED. 

We do not get a BILLING.SUBSCRIPTION.ACTIVATED. Can I expect it being activated when it is
created or do I need to double check that?
(Side note, when trying to send an api request to activate it, an error message informs me that the subscription plan is not “suspended”. So that looks like it is already activated. Logging into PayPal also confirms it is activated.)

The documentation on it is a little vague.
Created means the user clicked the button to subscribe. It does not mean they entered any payment details, or finished subscribing.
If you are not receiving a BILLING.SUBSCRIPTION.ACTIVATED event but the subscription is active, perhaps you did not subscribe to that event?
In any case, the most useful event to listen for is PAYMENT.SALE.COMPLETED. This will occur for the first payment as well as every future payment on the schedule. You can build all your business logic with only PAYMENT.SALE.COMPLETED , using every receipt of this event to mark how long the subscription is valid for in your system (e.g. 1 month from receipt)

PayPal Webhooks. How can I link a webhook to a previous subscription

Maybe this is a dumb question, but here goes none the less.
I created a webhook and added its clientID to my PayPal-button-container code.
When I have gotten a new subscription purchase with this button, I see that it accesses my webhook when a new BILLING.SUBSCRIPTION.ACTIVATED fires. This is a live account and a live button. My hope is that the webhook will fire for PAYMENT.SALE.COMPLETED but this hasn't happened yet.
Here is my real question: what do I have to do to connect this webhook to the subscriptions that did NOT have this clientID in the button when they purchased/set up the subscription. I want this webhook to fire when those accounts process the PAYMENT.SALE.COMPLETED call.
I can put the webhook clientID in the original PayPal-button-container retroactively... but will that work for existing subscriptions?
Or does a webhook work for all payments, and I just haven't seen anything else post yet?
Thanks
Webhooks only work for payments and subscriptions that were created with that same webhook's client ID.
If payments were created with a different client ID, register a webhook event listener for that other client ID.

Paypal Webhooks

I have setup webhook and IPNs (Instanst Payment Notifications) with in paypal. It is my understanding that if I select ' * All Events ' within the webhook setup, that I would receive a webhook for any transaction that occurred in paypal - including ebay sales that were paid through paypal.
Since setting up the webhook, I have had a few sales go through paypal, but 0 webhook notifications were receivied.
Am I missing something about paypal webhooks?
The most effective way before you start receiving payments is usually by testing your webhook events and if they're going through, follow the below step
Set up your development environment.
Configure a webhook listener.
Validate your listener configuration with mock webhook events.
Subscribe to events.
Verify event notifications.
Go to this link for step 3
https://developer.paypal.com/docs/api-basics/notifications/webhooks/rest/#validate-your-listener-configuration-with-mock-webhook-events

Paypal doesn't fire webhook on BILLING.SUBSCRIPTION.CANCELLED in sandbox

I haven't tested in live, but currently I have a webhook subscribed to the following events
Billing subscription cancelled
Billing subscription created
Billing subscription re-activated
Billing subscription suspended
Billing subscription updated
I'm receiving Webhook events for CREATED but nothing is being sent when a user cancels the subscription from their PayPal dashboard.
Is this expected behavior? is there another event I should be subscribe to to capture that user action?
Is there a debug id that you can share so we can trouble shoot?
Thanks,
Usha
From Paypal support (I still don't understand why the BILLING.SUBSCRIPTION.CANCELLED doesn't fire when a user cancels from their dashboard, similar issue here: BILLING.SUBSCRIPTION.CANCELLED does not fire upon user action?)
"But surely users subscribing via the button is the most common method of subscribing (how else would they subscribe?). The IPN route seems like a completely non-developer-friendly one (seeing as there isn't even simulator events for it)"
If you integrate a solution which is not based on our REST API's and want to receive HTTP notifications, you need to use instant payment notification (IPN). The IPN simulator may not provide a method of simulating the events, but you can create subscriptions in our sandbox environment and setup a sandbox business account with IPN and test cancelling the subscriptions, which will generate an IPN for the cancellation. We have a sandbox testing guide available here if you're not familiar with that environment and want to get started.
"So why would webhooks ONLY fire for API-based subscriptions (and why would a business website subscribe users using the API rather than the simple button)? What is the logic behind this?"
It depends on the integration and needs of the individual business. Some businesses only use our REST-based API solutions for their complete integration, from checkout payments to subscriptions and logically, this makes sense to them to only have to use one set of API's for their complete integration. Other business only want / need a more simple solution such as using buttons and as these are legacy solutions which are not REST-based, they use our legacy HTTP notification service which is instant payment notification (IPN).