#birendra_api
1 messages · Page 1 of 1 (latest)
đź‘‹ Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đź”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1332258765793398844
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
hello! Can you share the subscription id? it will have the prefix sub_
To confirm, you want to upgrade an existing subscription with Checkout? Or create a second subscription?
Because you can't use Checkout to upgrade an existing subscription
@worthy dragon Generally it creating the second subscription, But I am not sure what it should be. But technically I want to buy a new plan with checkout, but existing subscription will not be active afer that. And the payment should be according to the new price like $199 - $99 around
Why not just upgrade the existing subscriptions in that case? You're creating more overhead for your integration by creating a new sub and cancelling the old
https://docs.stripe.com/billing/subscriptions/upgrade-downgrade
I want to make the rest of the payment through checkout, like If I have paid for existing subscription is $99 and If I want to buy the $199, then the rest of the payment should be $100 around and that should be paid from stripe popup like we are doing it while purchasing subscription at first time
Yeah that's not really how it works though unfortunately. The new subscription created via Checkout will not account for any previous payments made on other subscriptions. If you do the upgrade explained above and prorate correctly then it will account for the $99 payment and automatically charge the saved card the remaining amount to upgrade
Okay
- When the payment will be charged ? I mean at the same time when we will upgrade the subscription?
- How much it will charge when we will upgrade the subscription?
- If i want to make the payment from different card, then how can I handle that?
- Immediately, assuming we have saved payment details for the sub/customer
- It depends on the parameters you pass
- Depends on whether you already have the new card saved/setup or not, or whether you want to collect payment details form the customer
- okay
- If I want to charge user the payment like $100 not complete $199,
- Card would not be saved there already, card would be entered at runtime, but I do not want to add the card from our platform, just like checkout
Did you try just making an API call to update the subscription? I'd recommend trying that, see how it behaves and then I can help you configure the parameters to get the behaviour you want
Configuration is okay, I was just trying it through the checkout to make the payment if possible for new subscription
As I said, Checkout is not the way to do this. You're making it way too complicated to simply upgrade a subscription
If you want as hosted UI, look at the portal: https://docs.stripe.com/customer-management
Yes, But the card entered by user I am recommending the stripe checkout. Anyways If it is not possible through checkout
when I am using the proration
$session = $stripe->checkout->sessions->create([
'customer' => $customer,
'success_url' => $successUrl,
'cancel_url' => $returnUrl,
'line_items' => [
[
'price' => $priceToken,
'quantity' => 1
]
],
'subscription_data' => [
'proration_behavior' => 'create_prorations',
'billing_cycle_anchor' => strtotime('+1 hour')
],
'mode' => $mode,
'metadata' => $metaData
]);
I already explained why
But why it showing $0.27
Because of the billing_cycle_anchor timestamp you're passing
I have created it just after 2 minutes of the existing subscription purchase
You can explicitly set a subscription’s billing cycle anchor to a fixed date (for example, the 1st of the next month) when creating a Checkout Session. The billing cycle anchor determines the first full invoice date, when customers are billed the full subscription amount. The billing cycle anchor and the recurring interval of its price also determine a subscription’s future billing dates. For example, a monthly subscription created on 15 May with an anchor at 1 June is billed on 15 May, then always on the 1st of the month.
https://docs.stripe.com/payments/checkout/billing-cycle?payment-ui=stripe-hosted
The existing subscription is irrelevant
đź‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
So on this, it will not bill the amount at same time, and charge the rest of the amount on the date it showing
would you mind elaborating more?
sorry I didn't understand what you're saying
I mean how this amount is being calculated on checkout session popup
proration is calculated based on the time fraction of the used time
so basically if you're upgrading after 2 minutes
you get the number of seconds in 2minutes (ie 2* 60) and divide that over the period of the billing cycle (ie month = 30 * 24 * 3600) and you then multiply that by the old price