Paypal Subscription Revise - how to capture onApprove or onCancel using the Subcription API?

Viewed 288

I am using Laravel 7 and have a subscriptions page that list out all the services that a user is subscribed to. On the same page, I have a button where the user can update the quantity of each subscription.

Following the below instructions, I was able to redirect the user to the HATEOS link where the user can confirm and agree to the new quantity and new monthly recurring fee.

https://developer.paypal.com/docs/subscriptions/full-integration/subscription-management/#revise-subscription

As indicated in the above documentation, the subscription on Paypal's side (both the buyer and the sellers paypal accounts) will only be updated if the buyer confirm and agree/approved the new quantity and new recurring free in the HATEOS approval link.

The challenge I have is: how do I capture the users confirmation in the provided HATEOS link or if the user did not approve the new quantity and recurring fee by simply closing the browser with the HATEOS link -- as this will obviously determine whether to update the subscription table database (i.e. update database if user approved the change in the HATEOS link or no change in the database if user did not approve the HATEOS link)?

Note: in my subscription page, I am not using Paypal's Smart Button. I am using a normal button that calls a controller and a function that executes the Subscription API code (i.e. curl bash) which returns the HATEOS links including the link for the user to approve the change.

Hope someone can help! Thanks!

1 Answers

The recommended solution is to use the Smart Button, which has the benefit of giving a modern "in context" experience, to approve without redirecting the user away from your site (it stays loaded in the background). This is a better user experience.

But if you insist on an old-style redirect integration, the way it works is they should return to the return_url you specified in your revise call, with query string parameters pertaining to the operation so you can then do an API call to get an update on the current status before updating your database.

Related