Search code examples
phppaypalpaypal-subscriptions

Have one Plan that can create customer subscription with free trial or without free trial


Let's say that I do have a Bronze Plan that offers a [Free Trial] for users for 1 month.

When the user cancels their Bronze plan, the second time that they purchased the Bronze Plan again, it should not have the [Free Trial] any more.

Another scenario would be when user upgrades to let's say Gold Plan, they're not applicable for [Free Trial] anymore since they already used their trial once.

Any solution for this?

I'm trying to avoid creating duplicate plans as much as possible.

Like creating One Plan for Bronze Plan that has a free trial, and another Bronze Plan that does not have a free trial.

In total I have 6 Plans, if I do create a duplicate Plan without a free trial embedded to it, it would have 12 plans which would make things complicated.

Not sure if this would help but I'm using Paypal buttons JS SDK to create subscriptions.

paypal.Buttons({
    createSubscription: function(paypal_data, actions) {
        return actions.subscription.create({
            "plan_id": data.plan_id
        });
    } //And so on...
}).render('#paypal-button-container');

What I'm aiming to do is just like how we handle Stripe subscription functionality. That I'm freely to choose if I should give a free trial of 30 days or not.

return Subscription::create([
    'customer' => $customer_id,
    'items' => [
        [
            'plan' => $plan_id
        ]
    ],
    'trial_period_days' => 30,
    'expand' => ['latest_invoice.payment_intent']
]);

API Reference Link:

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

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


Solution

  • I sent a ticket on Technical Paypal Support and received a response regarding this issue.

    Quoted from part of the email that I received

    According to your description, you want to dynamically set the free trial in a plan which has be created, right?

    But unfortunately, our current subscription payment product doesn't support dynamically change the trial info after the plan has been created.

    So as my suggestion, currently the best solution is to prepare 2 version (trial on/off) for each plan, totally 12 plans, which you have mentioned as well. That's the only method to fulfill your business requirement.

    In short, there's no way at this current time to have a plan that dynamically change the trial info after the plan has been created.