#truuutipz-subscription-cancel
1 messages · Page 1 of 1 (latest)
truuutipz-subscription-cancel
@frank canopy that's not really possible sadly. What you can do is look at the credit after the cancellation and then refund a recent charge (or multiple ones)
Okay so if I cancel a subscription using Cancel Subscripton Stripe API.
A customer will get credits back. If I'm interested in using the refund stripe API, how could I make sure that the credits will not be applied on their next invoice since they will be refunded for the amount?
generally, the way i would go about it is to refund the customer immediately and then adjust the customer's balance once the refund succeeds.
@tame drift are there any stripe apis that could help me achieve what you just mentioned?
This is not something which Stripe does automatically at the moment, you would do the following steps :
-Look at the credit in the account balance and/or sum pending invoice items
-Use the List Invoices API and pass the subscription id in the subscription parameter to only view Invoices for that subscription. Also expand the associated charge if any. For each invoice:
Check if there’s an associated charge
If so, create a refund for up to the amount of the account balance
If the charge amount is smaller than the credit, refund fully and subtract the charge amount from the credit
Move to the next invoice in the list until the full credit has been refunded
-Update the customer’s account balance back to 0 via the API and/or delete the pending invoice items.
Related API links :
https://stripe.com/docs/api/customer_balance_transactions
https://stripe.com/docs/api/invoices/list
https://stripe.com/docs/api/expanding_objects
thank you for the information! Ill take a look and if I have any questions, I will follow up
When you say associated charge, which parameter should I be looking at? Is it amount_due?
Got it, thank yyou!
@tame drift Thanks for all your help, I took a lot of the docs and I think I understand how to implement this. Just want to go with the flow with you to confirm
-
Customer invokes Stripe Cancel Subscription with parameters
invoice_nowandprorateset to true -
Receive the
subscriptionIdfrom the canceled subscription -
Given the
subscriptionIdfrom the canceled subscription, I invoke the Stripe List Invoices API and expand thechargeobject -
List Invoices API w/
subscriptionIdas a parameter returns a list of invoices of my canceled subscription. For each iteration, I look at thechargeobject and look atcharge.amount
- I invoke Stripe API to either retrieve or list customer balance transactions of the associated canceled subscription, we'll name it
customer.balance.amount - If
charge.amount<customer.balance.amount, I refund fully and calculate(charge.amount - customer.balance.amount) - Repeat the same steps for each iteration in the list of invoices
- Invoke Stripe API to update customer balance transaction to 0 since at this point, customer should be fully refunded and delete the pending invoice associated to the canceled subscription
Does these steps above seem correct? ^
it looks correct to me, but as usual, test it out and see if everything works as expected.