#mochihealth
1 messages · Page 1 of 1 (latest)
also for refunds do i want to use the refunds api or the credit_note api
When a subscription is cancelled, the balance will be credited to the customer's balance and not refunded by default: https://stripe.com/docs/billing/customer/balance
The steps for refunding the customer's credit will be:
- Look for amount on customer's credit
- Use List Invoice API with
subscriptionset and expandchargefield to find charges of invoices on the subscription: https://stripe.com/docs/api/invoices/list - If there's any associated charge, create the refund on the charges up to amount of customer's balance
- Update customer's balance to 0: https://stripe.com/docs/api/customers/update#update_customer-balance
For above steps, cancelling subscription will be required in order to generate the customer's balance
but when I cancel a subscription through the stripe dashboard it makes a delete request to the subscription id and a post request to credit notes
and it has a refund amount in it
?
Could you share the request ID (req_xxx) of your screenshot?
Ah yes! If the subscription is cancelled in dashboard and issuing credit card with refunding to customer's payment method, then remaining balance will be refunded
However, cancelling subscription in this flow will cancel the subscription first, then refund to the customer
It's not possible to have a successful refund first, then cancel the subscription
so what happens if i cancel the subscription and then an error occurs with the refund
When the refund fails, this is likely that the payment method is not applicable to refund or something goes wrong. In this case, your system has to refund to customer through other means such as issuing voucher or other forms of refund outside of Stripe
so which refund flow should i follow
the one that you initially laid out or the one that i saw on the stripe dash
Both ways work!
You can either refund manually on the charges of invoices or use credit notes on the subscription invoices.
can you explain to me the lines field on the credit note
like if a subscription had a price where the quantity was 2 would i have to put quantity 2 here
how would i refund a custom amount
is the line item field and the refund amount linked in anyway
line field not line item
You can use lines.type: 'custom_line_item' for custom amount. For example,
const creditNote = await stripe.creditNotes.create({
invoice: "in_xxx",
lines: [{
description: "Custom credit lalala",
quantity: 1,
type: "custom_line_item",
unit_amount: 7500,
}],
refund_amount: 7500,
});
Thanks for waiting! Quantity is the number that you would like to reflect in the invoice whereas unit_amount is the amount of that line items
the sum of unit_amount in lines should be the same as refund_amount
the sum of unit_amount?
you mean like the product of unit_amount and quantity should be the same as refund_amount
still a bit confused on this
For example, if you have multiple lines, the total unit_amount of each line should be the same as refund_amount
like each individually or cumulatively
invoice: "in_xxxi",
refund_amount: 250, // integer
lines: [{
description: "Refund A",
quantity: 1, // integer
type: "custom_line_item",
unit_amount: 100, // integer
}, {
description: "Refund B",
quantity: 1, // integer
type: "custom_line_item",
unit_amount: 150, // integer
}],
}
In this example, the unit_amount (100) of Refund A + unit_amount (150) of Refund B must be equal to refund_amount (250)
100+150=250
when would there be multiple lines on a refund
like if there were multiple subscription items?
This is just an example. It's up to you how you would like to credit note to be a lump sum of total refund or breaking down into the individual items
Ultimately, it's on your business decision about how to show in as the lines in the invoice
so is the lines field more of a meta data field or does it actually have an impact on the refund
The lines field are for display purpose on the invoice
The total amount of lines have to tally the total amount of refunding, otherwise the API will fail
gotcha
and where would i get the li_xxx object
and also what is the difference of the first two approaches and just calling charges/ch_3MbSVcBPM36OC3gX1aNwPKfD/refund
Checking it how li_xxx was generated in req_woNZnIpqJdGkGB
also what is the difference of the first two approaches and just calling charges/ch_3MbSVcBPM36OC3gX1aNwPKfD/refund
The first approach I proposed is technically this charges/ch_3MbSVcBPM36OC3gX1aNwPKfD/refund (Step 3 more exact). With direct refunding, it won't show any refund entry on the invoice
il_1MbTDNBPM36OC3gXWcHxeJMj in req_woNZnIpqJdGkGB refers to the invoice line created in https://dashboard.stripe.com/test/events/evt_1MbTDPBPM36OC3gXx2gW096i
This means that you will refund the full amount on this invoice line item.
ah ok so if i plan on refund the full amount i should use the line item or is it ok to do custom_line item with the same amount
sorry for all the questions you are being very helpful!
for subscription upgrades i want the update to start on the next cycle and for subscription downgrades I also want it to start on the next cycle and not right away should I use subscription schedules for this?
ah ok so if i plan on refund the full amount i should use the line item or is it ok to do custom_line item with the same amount
You can do either way!
for subscription upgrades i want the update to start on the next cycle and for subscription downgrades I also want it to start on the next cycle and not right away should I use subscription schedules for this?
Yes! Subscription schedule is the way to do it!
if i wanted to increase or decrease the quantity of a price in a subscription would i just do that with a standard post request to subscription api or with the schedule api