#bhaumik1665_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/1239902186293559317
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi, see https://stripe.com/docs/billing/subscriptions/upgrade-downgrade for all the details.
I have tried the upcoming invoice API to get the prorated amount. But how can I charge that invoice?
you make the call to Update Subscription API with the same parameters.
I have tried updating the subscription items but even through the payment is incomplete dashboard is showing me the updated quantity.
yes, that is what happens. If you want the change to only apply after the payment happens, look at using https://stripe.com/docs/billing/subscriptions/pending-updates
Can't find anything on the downgrade at the end of the cycle.
SubscriptionSchedules https://docs.stripe.com/billing/subscriptions/subscription-schedules
I don't want to charge the customer immediately for the prorated amount. Instead, I want to generate the invoice & payment intent of that invoice with an incomplete status and use that incomplete payment intent client secret inside frontend to complete the payment using Stripe.confirmCardPayment().
And that's why I kept the payment_behavior of the subscription update to default incomplete.
now, how can I merge pending_if_incomplete with that?
so the default behaviour is that when you do the update, the subscription immediately changes, and proration 'items' are created and those end up being included in the next recurring invoice.
An immediate invoice is created if you pass proration_behavior:always_invoice or if the update requires an immediate payment(see the first docs link in my previous message).
that payment is always immediate though, which is your problem. It can't be an incomplete invoice, that only applies for the first invoice of a subscription.
can I use combination of proration_behavior:always_invoice & payment_behavior:default_incomplete parameters while updating?
meaning the invoice will be incomplete and I want to generate an invoice for the prorated amount and not move that prorated to the next billing cycle.
Will that work?
But problem with that approach is that even though the payment is incomplete the subscription is updated...
I want to only update subscription after the payment is success.
I don't think it works but you can try it in test mode!
then use the pending update guide linked above
I already tried its not working, its updating the subscription even though the payment of the prorated invoice is not complete.
yep, because you have to use payment_behavior=pending_if_incomplete if you want the update to only happen after the payment completes.
and as I said , the payment attempt is immediate in these cases , it's impossible to have "default incomplete" for this update flow, sorry
the pending flow here is for if that immediate payment attempt fails(which then creates an incomplete Invoice/PaymentIntent).
If I use that pending_if_incomplete then I won't be getting the prorated amount invoice, it will be charged on the next billing cycle, correct?
incorrect
it creates and immediately tries to charge an invoice with the prorated amounts
hi! I'm taking over this thread. please let me know if you have follow up questions.
okay, so if I want to use Stripe.confirmCardPayment() for the prorated amount invoice it won't be possible because if I use default_incomplete then subscription will be updated even throgh the payment is incomplete.
And if I use pending_if_incomplete then the invoice will automatically charged without client's confirming via frontend using Stripe.confirmCardPayment
correct?
correct
thanks for your input.
Can we do something like this?
calculate the prorated amount using upcoming invoice API and then manually generate an incomplete invoice of that amount (not attached with the subscription), once the invoice payment is completed we can use webhook to update the subscription.
but can I change the subscription without charging customers the prorated amounts? not immediately nor in the next cycle?
๐ taking over for my colleague. Let me catch up.
but can I change the subscription without charging customers the prorated amounts? not immediately nor in the next cycle?
I'm not sure I understand the question
would you mind elaborating please?
okay, so here is what I want.
- Charge customer prorated amount invoice while upgrading the subscription.
- But that invoice payment should happen in the frontend using Stripe.confirmCardPayment()
now If I use payment_behavior:default_incomelete even through the payment of prorated amount is not confirmed by client using Stripe.confirmCardPayment() the subscription plan quantities are updated.
and if I use payment_behavior:pending_if_incomete I don't have control over the payment of the prorated amount invoice (it's automatically charged/completed), I want to only complete the prorated amount invoice after client confirms it using Stripe.confirmCardPayment().
As karllekko mentioned that my above case is not possible.
so I'm thinking of a work-around.
Work-around.
I can calculate prorated amount using upcoming invoice API (upcoming invoice API won't be charged its just for calculation purposes.)
And whatever (n $ amount) is given by upcoming invoice API I generate manual invoice using Invoice::create() for that (n $ amount) and once that invoice is paid (confirmed using Stripe.confirmCardPayment I can update the subscription using update API.
But that invoice payment should happen in the frontend using Stripe.confirmCardPayment()
why do you need that?
But my concern is that client should not be charged twice in that work-around.
1 when I generate manual Invoice
1 when I update subscription -> This should happen without charging prorated amount.
I don't really see the benefit of doing it this way to be honest
I might be wrong, just trying to understand your use-case
I want a 2FA kind of thing, once a client changes the quantity/plans, I want his/her confirmation to update the subscription and not make changes straight away & that's why I want to use Stripe.confirmCardPayment().
what do you mean by 2FA in this context? are you talking about a process on your end? or is this about 3DS?
yes 3DS confirmation.
Also, what if client want to use another payment method for prorated invoice then the one attached with subscription.
that can't be possible if I don't use Stripe.confirmCardPayment.
ok in that case the best thing to do is to use Customer Balance
what is customer balance?
basically you create a PI with the prorated amount and you collect the payment
and once you do you create a Customer Credit Balance with the same amount of the PI
and then update the subscription
what that will do is basically use the available Customer Credit Balance to pay off the invoice generated from the Subscription update
so you mean to say is that I generate PI of prorated amount and that amount will be credited into client's wallet (Customer Balance)
and once I update the subscription that wallet balance will decreased by the subscription update prorated amount.
Is it so?
exactly
by default if a customer has credit balance it will be automatically deducted from the upcoming invoice
which in your case is the one generated from the subscription update
does that make sense?
To be honest, my case is already a little complicated, I don't want to add another Stripe API to make it more complicated.
Also, how can I automatically update the subscription? Is there any webhook that I can use to make sure that the PI I generated was credited to the customer's balance (wallet).
And then I update the subscription.
Is there any webhook that I can use to make sure that the PI I generated was credited to the customer's balance (wallet).
the PI won't credit the customer's balance automatically you will have to modify the credit balance https://docs.stripe.com/billing/customer/balance#modifying.
basically what you will do is you listen to the payment_intent.succeeded event and you then credit the customer the balance and then update the subscription
let me see what I can do.
Do you have any other way?
Hi all ๐ catching up as @strong bay needs to step away soon and I'll be taking over.
I think I would suggest pursuing the workaround you discussed here.
A couple finer points on it. For the one-off Invoice I'd suggest using the subscription parameter to associate it and it's items with the Subscription.
And when updating the Subscription, after Invoice payment, set proration_behavior to none
I'm sorry,
But I didn't get you.
Which part?
A couple finer points on it. For the one-off Invoice I'd suggest using the subscription parameter to associate it and it's items with the Subscription.
And when updating the Subscription, after Invoice payment, set proration_behavior to none
Above part
When creating the Invoice Items and Invoice for your manual proration calculations, use their subscription parameter:
https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-subscription
https://docs.stripe.com/api/invoices/create#create_invoice-subscription
When making the request to update the Subscription after that Invoice payment, use the proration_behavior and set it to none so se don't calculate prorations:
https://docs.stripe.com/api/subscriptions/update#update_subscription-proration_behavior
When creating the Invoice Items and Invoice for your manual proration calculations, use their subscription parameter
so you're trying to say that I should use subscription & subscription item parameters while generating prorated amount invoice?
And while updating subscription if I use proration_behavior to none the prorated amount won't be charged to customer twice (1 when invoice and 1 when update subscription).
correct?
so you're trying to say that I should use subscription & subscription item parameters while generating prorated amount invoice?
Justsubscription, I didn't point to asubscription_itemparameter.
And while updating subscription if I use proration_behavior to none the prorated amount won't be charged to customer twice (1 when invoice and 1 when update subscription).
Yes, setting it tononedisables the proration calculation for the update altogether.
okay. I'll see.
Thanks for your input!