[Vuejs]-Braintree update Subscription from yearly to monthly PHP

0👍

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

Calculate a pro-rated amount to use as a one-time discount on the new monthly subscription.

  • In the Control Panel, create a discount for the monthly plan. Set the default amount to $0 and the number of billing cycles to 1.
  • Calculate the amount you want to deduct from the original subscription price as your proration amount. Braintree documents their proration formula here if you want to use that as an example.
  • Create the subscription, using the calculated proration amount as the amount of the discount:

    $result = $gateway->subscription()->create([
    ‘paymentMethodToken’ => ‘the_token’,
    ‘planId’ => ‘silver_plan’,
    ‘discounts’ => [
    ‘update’ => [
    ‘existingId’ => ‘discountId’,
    ‘amount’ => ‘proratedAmountToDiscount’,
    ]
    ]
    ]);

Notes-

  1. When creating a subscription, it will automatically inherit any add-ons and/or discounts associated with the plan. You can override those details at the time you create or update the subscription. If you don’t need to pro-rate, don’t override the discount because the default discount will be $0.

  2. If the amount of the discount is larger than the amount of the monthly charge, the subscription will be created with a negative balance to be applied to the next billing cycle. Example: A $1 monthly subscription created with a discount of $1.50 will be created with $0 charged the first month and a balance of -$0.50 to be applied the next month. The next month’s charge will be $0.50 ($1 – $0.50).

Leave a comment