Stumped On Subscriptions

MusicCityCoder
New Community Member

I understand how to create a subscription through the Rest API, but I don't see any documentation on how to get the user to approve the subscription after I create it. 

 

So I followed the documentation's suggestion about using the Rest API to create a plan, and then use a smart button to get the user to accept the subscription (bypassing the Rest API to create the subscription). 

 

The problem is that when using their "smart" buttons, there is no way I can tell to pass in a plan id variable:

 

paypal.Buttons({
style: {color: 'blue', shape: 'rect', label: 'pay', height: 40},
createSubscription: function(data, actions) {
return actions.subscription.create({ 'plan_id': 'XXXXXXXXXX', application_context: { shipping_preference: 'NO_SHIPPING' } });
},
onApprove: function(data) {

window.location.href = "<URL>?SubscriptionID=" + data.subscriptionID;
//alert('You have successfully created subscription ' + data.subscriptionID);
//document.getElementById("btnSubscriptionComplete").click();
}
}).render('#paypal-button-container');

 

Can someone either show me how to replace the XXXXXXXXXX with an assigned variable value or show me how to get a user to approve a subscription created via the REST API Create Subscription method?

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

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