PayPal Subscription Cancellation from Merchant Website - paypal

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.

Related

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

Paypal canceling recurring profile buyer email notification

I am useing paypal exprees checkout API. I want to cancel recurring profile. I add a note for reason of canceling. The recurring profile cancel successfully and note setup to buyer profile history page. But The note does show buyer email notification.
Can you tell anyone how can I show user reason of cancellation in email notification?
Thanks advance
That note is considered an internal use sort of thing, and isn't meant to be shown to the buyer.
What you can do, though, is setup an Instant Payment Notification (IPN) solution which would get hit when the profile is canceled. Within this you can generate a custom, branded email notification, update your database, hit 3rd party web services, etc. It's a very useful tool that allows you to automate all sorts of things based on different transaction types.

PayPal: How do you get notifications of payment through the permissions API?

Using the PayPal permissions API can you receive notifications from payments made after a customer clicks on a payment button, proceeds to PayPal, and then pays?
I notice they have IPN, but will this work with the permissions API?
Thanks!
You can include NotifyURL in your API requests to set a URL for IPN to POST data to. It's not something that technically "works with the permissions API" but any transaction that is made would indeed trigger the IPN.
If you're building an app for 3rd parties to use, though, and you're passing NotifyURL in your API requests, that will override any IPN configuration each individual merchant using your tool might have setup on their own. This can cause frustration for such users because then their own IPN solution doesn't get hit when they take payments through your app.
If you're going to do that I recommend setting up a way for your users to enter their own IPN URL in your app settings, and then if they have a value, forward the POSTed data to their URL when PayPal sends it to yours. That way both IPN scripts will get hit and process the data accordingly.

How can I cancel a paypal recurring payment from my website?

I'm currently integrating the paypal recurring payment process in my website (thanks to https://www.paypal.com/uk/cgi-bin/webscr?cmd=_pdn_subscr_techview_outside) and, for the moment, it works.
But I have a simple question, and I don't find the answer on Internet. Let's say a user deletes his account on my website after 2 months. How can I cancel automatically his subscription ?
Thank you!
It takes a bit of effort to find, but Paypal does publish a guide on subscriptions.
To cancel someone's subscription, you need to create a link to Paypal -- see page 171 of that reference. There doesn't appear to be an API which allows you to cancel their subscription for them: they need to click a link to Paypal and cancel the subscription themselves.
The guide actually says
Paste the code onto you webpage [sic] near text that explains how subscription cancellations work.
Apparently it's possible to cancel recurring payments with the API. See:
Can you cancel a PayPal automatic payment via API? (Subscription created via Hosted button)
This is certainly more complex than the "unsubscribe" button that paypal gives you, but... it could actually work. The "unsubscribe" button requires that people's payments are coming from their PayPal account, which is not the case if they set up recurring payments on a credit card (without logging into PayPal.)

Checking if paypal payment was successful

I have downloaded sample code from paypal to allow me to use parallel payments via their sandbox accounts. When I run parallel.php, I get redirected to paypal's sandbox login page.
How am I supposed to know "server side" that the payment has been made successfully, so I can update my database records?
I believe you have to work with PayPals IPN system. This will basically send a confirmation to your server that tells you it has gone through.
https://www.paypal.com/ipn
Paypal lets you register a notification url which is part of the IPN (instant payment notification IIRC) system. So if someone pays by a delayed payment (such as a bank transfer) the transaction will update days later. You need to have an application (web page) on your server that can be called by Paypal with transaction details to update a payment.
You'll need to create an initial transaction record in your system when paypal redirects back to you so refer to their documentation for that. I'd also recommend looking at either OSCommerce or Zen cart for an idea of how they do it as they support the same kind of thing.