2

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!

Ray
  • 21
  • 1

1 Answers1

1

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.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44
  • 1
    Thanks I am using the Smart Button for when its the first time subscribing for a service on my site. But this is just for when a subscriber wants to change the quantity of the subscription. The Smart Button doesnt seem to fit the purpose as it automatically launches a window for new subscriptions. Any idea where to define the return URL for the Subscription API Revise call? – Ray Aug 30 '20 at 06:49
  • In application_context -> return_url – Preston PHX Aug 30 '20 at 13:27
  • @PrestonPHX looking for reference code for smart button, I found this. Could you confirm this is correct? https://github.com/paypal/paypal-checkout-components/issues/1239 PS: Thanks for all your paypal answers on SO, really appreciate them!! – Kevin Danikowski Feb 27 '21 at 19:15
  • To revise a subscription with a smart button, yes that's how to do it – Preston PHX Feb 27 '21 at 20:13