#birendra_api

1 messages · Page 1 of 1 (latest)

outer doveBOT
#

đź‘‹ 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.

shrewd lotus
#

hello! Can you share the subscription id? it will have the prefix sub_

hazy root
#

@shrewd lotus

#

sub_1QkfvoCpEcSEX1OLg6cZZbSs

#

this is the subscription id

outer doveBOT
worthy dragon
#

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

hazy root
#

@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

worthy dragon
hazy root
#

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

worthy dragon
#

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

hazy root
#

Okay

  1. When the payment will be charged ? I mean at the same time when we will upgrade the subscription?
  2. How much it will charge when we will upgrade the subscription?
  3. If i want to make the payment from different card, then how can I handle that?
worthy dragon
#
  1. Immediately, assuming we have saved payment details for the sub/customer
  2. It depends on the parameters you pass
  3. Depends on whether you already have the new card saved/setup or not, or whether you want to collect payment details form the customer
hazy root
#
  1. okay
  2. If I want to charge user the payment like $100 not complete $199,
  3. 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
worthy dragon
#

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

hazy root
#

Configuration is okay, I was just trying it through the checkout to make the payment if possible for new subscription

worthy dragon
#

As I said, Checkout is not the way to do this. You're making it way too complicated to simply upgrade a subscription

hazy root
#

Yes, But the card entered by user I am recommending the stripe checkout. Anyways If it is not possible through checkout

outer doveBOT
hazy root
#

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
]);

hazy root
#

But why it showing $0.27

worthy dragon
#

Because of the billing_cycle_anchor timestamp you're passing

hazy root
#

I have created it just after 2 minutes of the existing subscription purchase

worthy dragon
#

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

Set a subscription's billing cycle anchor to a fixed date.

worthy dragon
balmy hill
#

đź‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

hazy root
balmy hill
#

would you mind elaborating more?

hazy root
#

yes a bit how it is working would be appreciated

#

Thanks in advance

balmy hill
#

sorry I didn't understand what you're saying

hazy root
#

I mean how this amount is being calculated on checkout session popup

balmy hill
#

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