Proration example: Customer on 30/weekplan,3of7daysused,upgradesto100/month:
100 − 30 × (3 ÷ 7) = $87.14For downgrades, negative amounts floor at $0 (no credit issued).
2
Mount the SDK
Display checkout with the customer’s saved payment method:
const checkout = new PayNextCheckout()checkout.mount('checkout-container', { clientToken: session.id, environment: 'sandbox', onCheckoutComplete: (result) => { // Subscription updated, billing cycle reset console.log('Plan changed:', result.payment_id) }, onCheckoutFail: (error) => { // Customer can retry with different card // Subscription stays on old plan until payment succeeds }})
Outcomes:
Success: Plan updates immediately, billing cycle resets to today
Failure: Subscription stays on old plan; customer can retry with a different card
The prorated amount must reach the minimum charge amount of $0.50 (USD equivalent). If the calculation produces a smaller amount—common for downgrades or small upgrades—the client session returns a 400 error. Change the plan without a charge instead.
When the prorated amount is below the minimum or you don’t want to charge now, change the plan with the subscription endpoint. Set change_mode to immediate to reset the billing cycle to today.
The plan changes immediately in the system. The next charge, on the existing billing date, uses the new plan’s price.
change_mode controls only when the billing cycle starts. With next_billing_date (the default), the existing billing date stays the same. With immediate, the next billing date resets to today plus the new plan’s period.