I'm trying to figure out how to pass in a "trial" period, or custom "start date" for a subscription. I have:
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': window.my_config.paypal_sub_ids[window.my_config["period"]],
'custom_id': $('#Email').val() + "----" + window.my_config["period"]
});
},
onApprove: function(data, actions) {
$('#AJAXloadingWrapper').show();
console.log({ data: data, actions: actions });
// all the rest is done on the server
},
onError: function (err) {
// Show an error page here, when an error occurs
console.log("ERROR")
console.dir(err);
}
}).render('#paypalWrapper');
This works fine. The problem I'm having, is that what I want to do is offer a unique number of free days to a user. A use case is that a user is already a paid member (one off payments), and they want to setup a subscription with us. So obviously you don't want the subscription to start until their current date has expired.
Is there a way to pass this in with the JS SDK? Or is it going to be a PITA where I have to create a custom price plan for that user, with the correct number of days set?
UPDATE: Alternatively, is there a way to "clone" an existing subscription plan, and then tweak the trial_days server side, ready to return to the front end for the JS side of things?
You can get a plan's details and create a new modified plan based on it.
The API call is https://developer.paypal.com/docs/api/subscriptions/v1/#plans_get