#jamesedwards-change-price
1 messages ยท Page 1 of 1 (latest)
the customer should not have a credit balance after cancelling their subscription
I can provide a test customer to view if that is something that you can also see
after refunding the credit balance does not change to reflect
If you just want to avoid the credit, you should be able to cancel with prorate=false: https://stripe.com/docs/api/subscriptions/cancel#cancel_subscription-prorate
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but if you want to refund, that is a bit different
yes but then the customer is billed for time they did not use
i want the money to return to their card, rather than being applied as a customer credit balance
the issue isn't the cancellation... the invoice generated as a result of the downgrade from plan 2 to plan 1 generates a customer credit balance
this credit balance is then unaffected by the cancellation and if I select to refund the charges the credit balance remains.
customers can cancel their plan, and I would rather not have to manually refund the charges less the accrued credit balance within the dashboard
regardless of whether a refund should alter the credit balance (which is should and doesn't) - is there a way to prevent the credit balance from being applied to the customer account and always return it to their card?
so you can either use prorate=false to avoid that balance, and issue the refund for any amount you like
or you can allow the credit as a convenient calculation, then refund the charge on the lat paid invoice
can this be done through the api
in either case you'll need to create a refund for the charge of the last paid invoice (or more than 1 invoice)
yes, but multiple requests
its a single request you can make
is the credited amount the amount you want to refund?
or do you want to refund the full charge of that invoice?
upon cancellation yes the credit balance should no longer exist
the customer money is stuck in stripe otherwise
so if set prorate=false and then i have to listen for subscription cancellation events, but if they do not cancel I also have to listen for subscription update events
sure, you need to refund the charge of the latest invoice:
https://stripe.com/docs/api/invoices/object#invoice_object-charge
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
multiple invoice would need to be refunded in the sample scenario i describe earlier
this would be part of teh cancellation, they would be cancelled in both cases
changing the plan without cancellation also results in credit balance applied to the account
i understand that if i do not prorate this will not occur, but then i am asking on how to give the customer money back as a prorated amount for the unused time
basically i never want a credit balance to exists
can i give you a customer id to show this scenario?
sure - lets take a look at an example
thanks
here is a customer where no refund has been applied yet cus_KEVumNCgE96coT
they have a credit balance and as the remaining invoices finalize they will be added to the credit balance
here is a different customer where the same steps have been applied and a refund of one charge has been carried out cus_KELHA6lHoQmcJy
the credit balance for customer cus_KELHA6lHoQmcJy did not change as a result of the refund
yes, thats expected, the credit is entirely separate
so there are multiple things in these scenarios, but if no credit balance is ever applied they would be resolved
if you want to clear out the customer balance because you expect to use that customer again and refunded them instead, just clear out their balance by send the amount times -1:
https://stripe.com/docs/billing/customer/balance#api
i want the customer to get their money back
by never having a credit balance applied
yes, thats what the refund is for. i'm trying to explain these are separate.
they paid you for some period on an invoice, then downgraded, with default behaviour this is prorated and they get a credit balance for future invoices
does it seem like them being separate can lead to confusion? say i refund the charges but never adjust the customer credit balance
presumaly the downgrade invoice was for $0 after the credit was applied
the customer would get free money
well if you refund to cover the amount "you owe them" from the balance, then yes you should adjust the balance accordingly
however the main issue is that the customer money is stuck in credit balance and i have to go into dashboard to refund - is there a way to prevent credit balance from occurring during subscription cancel while also giving the refund of the prorated amount through the api?
this works fine without the cancelation, because that balance just reduces future invoice amounts
this is a two step process and should be one, no?
its only messy because of the cancellation, which is a scenario you need to handle carefully according to your policies
right so through the api, how can i handle this scenario i am outlining
"is there a way to prevent credit balance from occurring during subscription cancel while also giving the refund of the prorated amount through the api?"
maybe! but some other business might prefer it the other way, never refunding
the issue is that the credit is coming form the downgrade, not the cancellation
so you cant, really
right? in your flow the credit i expect to appear after the downgrade, before the cancellation
yes
regardless of cancellation the amount of unused time at point of downgrade is applied as a credit balance
i was hoping there was a parameter i missed to issue that automatically as refund back to the customer card
(also i have been talking to support and you are the first person to understand the scenario to this extent. I really appreciate your help so far!)
also just to clarify, when the "downgrade" occurs i have tried both the update api and also using the delete and create api - neither of which prevent the credit balance from being applied
heh, quite welcome, and appreciate your patience here while i mentally juggle multiple complex questions ๐
yes i understand there are thousands asking for help, i do hope that in time an approach to handle this can be determined
you can disable prorations during the downgrade to avoid the credit being applied, but normally you wouldnt want this (for a continuing customer who did in fact pay you)
so this why you need to manage those refunds explicitly - its a very sensitive thing for a business to release funds back to a customer
so what do you suggest?
you'll need to create refunds for any invoice charges as appropriate for your agreement and policy with the customer
and then clear the balance if you've refunded money, that makes sense
i see
do most people not use proration?
im just imaging this scenario but spread out over more time
in which case it might be difficult to determine the amount to refund
and unfortunately requires logging into the dashboard, which i think would mean watching the subscription cancelled event and having that notify me in some way to do this manual process
Unless this can be handled trhough the api?
what part requires logging in? all of this can be done via API
ok that is good
how would it be checked with the api that all customer invoices are paid after they cancel their subscription?
at the point which all invoices are paid (and the subscription is cancelled) does it make sense to check with api for a customer credit balance, and if one exists to use the refund api to refund exactly that amount? (i see the refund api must relate to a charge so i am confused by this)
or would it need to be on each invoice finalized event that occurs with the subscription cancelled
ah yea this is a bit of a pointy edge case -- you need to check the invoice status explicitly if you suspect they might be unpaid
im not sure what you mean by that but it is quite pointy yes
its helpful to separate the invoice payments form the subscription status -- the subscription continues even if invoices are unpaid, unless you configure settings to behave otherwise
so if you arents cancelling after payment failures say, you might have unpaid invoices, including those downgraded credit ones
yeah how do i link the downgrade credit invoice to the charge id for the refund
its actually better to check this at the time of downgrade: look at the latest invoice on the subscription and if its not paid, disable proration for the downgrade
so the customer.subscription.updated event?
i do want to prorate the amount
im not really following the exmple you are providing
So, before you do the upgrade/downgrade, its best to check the latest invoice: https://stripe.com/docs/api/subscriptions/object#subscription_object-latest_invoice
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
if thats not paid, you most likely want to disable prorations for the downgrade
the latest invoice would be paid if they are downgrading with an active subscription
ok so assuming all paid up and the scenario we started with, then you just want to go get those charges and refund them
right but if they waited some time i need to find out the prorated amount
you can list the invoices for a particular subscription: https://stripe.com/docs/api/invoices/list#list_invoices-subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and that wont be applied to the customer balance until the negative invoice is finalized
(not negative but the invoice generating the credit balance)
they'll be mot recent first, so if you want to refund charges going back 2 invoices, you could make that request with limit=2 then refund the charge/payment intent for each
how would i determine the amount to refund
not sure what you mean by that the invoices finalized, theyd all be finalized already
the invoices that result in a credit balance being applied take atleast one hour to be paid
you would decide the amount based on the timstamps etc - thats really up to you
im sorry if im using the wrong term
so you are saying i have to calculate the proration?
ok sure, if this all happens in close succession there may be weird states, so you may want to said until those pay before handling any of this
its a tricky edge cases, and you'll need ot test extensively if this is a common flow for you
yeah the customer.subsription.updated event will occur before the credit balance is applied as a result of the invoice moving to paid which holds the credit balance
proration for credits no, but choosing the refund amount yes
is there an invoice.paid event?
i guess payment succeeded would work
would it make sense to listen for that event and if the invoice amount is zero and there is a customer credit balance to then generate a refund of the latest charge for the credit balance?
invoice.paid yes, that one is usually better
ok
i think that might work for me
does the customer balance update at the same time as invoice.paid
i think so - the amount due would be reduce by any available balance, then payment taken for whats left
during the downgrade im not certain, so i'd suggest testing
in a scenario where the invoice generates teh credit baalnce
im not observing the customer credit balanece update immediately
on subscription change, only after invoice is paid
editted above, i am not sure on that part
ok np
i feel like this might be common scenario for anyone with multiple subscription plans - can you point me to any other resources where i might find out how others resolved this?
There are a number of related implementation in stack overflow, such as: https://stackoverflow.com/a/59201871
np!
can the refund amount be greater than the invoice amount?
no, you can only refund up to the amount of a given charge
ah ok
many points
i will look more into this example you provided since it is very close to what i am hoping to do
thanks again and have a great day!
you too! you're welcome ๐