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

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).

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 Subscription Cancellation - Webhook

From a developer perspective, what is the best way to capture (webhook wise) a user cancelling their PayPal subscription via their dashboard (and/or subscription payment failing)?
I've had some discussions with PayPal support and have learnt the following:
Subscription button:
-simple, elegant, works well to let user subscribe
-however, when user cancels subscription via their dashboard does NOT fire a BILLING.SUBSCRIPTION.CANCELLED webhook. Only an IPN HTTP "webhook" gets fired. From the paypal docs, IPN seems harder to integrate (not REST, and for example the IPN simulator doesn't even have "subscription cancellation" events)
Using API (PayPal PHP SDK):
-DOES fire BILLING.SUBSCRIPTION.CANCELLED webhook events when user cancels their subscription via their PayPal dashboard (why this doesn't work for button-created subscriptions I do not understand)
-However, seems much more complex to set up than the button (what does the web flow look like?)
Just some thoughts on the best approach would be appreciated.
It depends on the type of 'Subscribe' button.
Legacy 'Subscribe' buttons created via e.g. https://www.paypal.com/buttons , will not fire a BILLING.SUBSCRIPTION.CANCELLED webhook. Those buttons predate webhooks by 10 years, and only use the very old IPN service. Stay away...
Current smart subscribe buttons, created via e.g. https://www.paypal.com/billing/plans or following the documentation do trigger the BILLING.SUBSCRIPTION.CANCELLED webhook.
In general, you can make use of the CANCELLED webhook and track this status if you want to but it's not necessary. The most important best practice is to make use of PAYMENT.SALE.COMPLETED and record when a subscription was last actually successfully paid for. If it doesn't get paid for again on time, then it's lapsed and you treat it accordingly.
When creating a subscription, along with the plan_id you can pass a custom_id which will be returned in all the webhooks. This can be useful for reconciliation purposes so you know which user it's for.
Using API (PayPal PHP SDK):
That SDK is deprecated, don't use it. Any API calls should be done directly via HTTPS.

Is IPN required to detect cancellation of REST created Subscriptions?

I have REST API created Payment Plans and agreements and would like to be able to detect when a user cancel an agreement. My original take on this was that the cancel_url on the merchant_preferences object for billing_plan would be used if a users canceled the agreement through the PayPal API, but I am not seeing any callbacks coming in so perhaps this is incorrect?
I have seen plenty on information on IPN processing cancellations and I would love to know if that is the only way to receive a cancellation notification or should I be using another field in the REST API to set this up?
I'm not against using IPN (hey whatever gets the job done!), but it seems to me that the REST API should have its own capabilities for achieving this as well.
Hey this is Avi from PayPal. Refer to this github issue for information about getting IPN notifications for subscription events.
The REST API does have webhooks, and work is in progress to support subscription events for webhooks as well.

PayPal Subscription Cancellation from Merchant Website

we have a paypal payment system integrated into our website so people can register and choose a subscription. The subscription part works fine as the payment goes through and the IPN hits our website and updates our systems. Now we want users to be able to cancel their subscription from within our website so we have a custom cancellation button which when clients click, should send a request to paypal and cancel their subscription. We managed to get this going on sandbox test system however since we have brought the system into live testing we can not get the cancellation feature to work. So currently when the user clicks on cancel button, i think paypal is not being notified and hence no IPN received from PayPal.
Do you know what all info we need in order to cancel the subscription from our website. I know there is a way where users can log into paypal and cancel their subscription or we can log into our paypal and cancel their subscription but we want it to work from our website.
Please help!
Thanks.
When you say you have it working on the sandbox but not live, what exactly is going wrong when you try it live?
I'm actually a little confused by that, because my initial answer was going to be that you can't kill subscriptions via the API unless you're using Recurring Payments. Standard subscriptions aren't accessible via the API.
If you're saying you're doing that in the sandbox, though, then there must be something I'm unaware of..??
On that note, I know the PayPal system pretty well, so I'm thinking maybe you did Recurring Payments on the sandbox, but live you're using Standard Subscriptions..?? If that's accurate then you'll need to move to recurring payments instead of standard subscriptions on the live site.

Automated subscription service using PayPal or other payment processor?

I am developing an app which will be free to download from the Apple App store. However, users will be able to subscribe for advanced features which include the use of a web service. I would like the ability to detect those users who have subscribed and then cancelled their subscriptions so I can halt the use of the web service. I would like to do this automatically.
I know PayPal is one way to set up subscriptions, but is it able to detect when people cancel their subscriptions and notify me in a way that my web service can be automatically updated?
Any other advice or pointers welcomed - I cant be the first person/company looking to do this. But I dont really know where to start!
It sounds like you need two specific features: recurring billing and webhooks. The recurring billing will take care of the subscription, while the webhooks will automatically alert you to a cancellation so that your web service can be updated. Webhooks are real time notifications that alert you whenever an automated event occurs in our system. Payment gateways like Braintree offer both of these features.