Redirect onApprove of Subscription

DEPDESIGN
New Community Member

I would like to add a redirect to a specific page after a user has successfully subscribed. Below is the code I would like to modify with the example I made.  Any help would be greatly appreciated.

 

PayPal pre-created code :

onApprove: function(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}

 

My example of what I'm trying to do:

 onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
//After payment is taken, we redirect the user to the success page.
window.location.replace("/success.php?id=<?php echo intval($id); ?>");
});
},

 

Login to Me Too
1 REPLY 1

Kavyar
Moderator
Moderator

Good day @DEPDESIGN 

 

Thank you for posting to the PayPal community.

 

I would recommend including an option to input the return URL during the subscription creation process.

 

I kindly request that you refer to the detailed guide linked below for further assistance:

 

https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create

 

https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create!path=application_contex...

 

If your still facing issues, please create an MTS ticket via - https://www.paypal-support.com/s/?language=en_US  with the detailed information and error details.

 

Sincerely,

Kavya

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.