#spicey_code
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/1325785202823266427
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, let me help you with this.
Refunds won't be created automatically. You can take the PaymentIntent of the latest Invoice and create a Refund manually, with the desired amount: https://docs.stripe.com/api/refunds/create
Ahhh. I dont have a list of the subscriptions cancelled when I ran the cancellation code above. It was executed a week ago. I dont see any available filters on ListSubscriptions API to do this conveniently
I am not sure what you mean.
You can get all the cancelled Subscription by listing all with status=cancelled: https://docs.stripe.com/api/subscriptions/list#list_subscriptions-status
When I ran the subscription cancellation code above, it was easy to grab the subscription ids because all i had to put was
status=active
I cant use status=cancelled because I have old subs that were cancelled that dont necessarily need to be refunded. Only the subs I cancelled using the code is what I want to refund.
But don't you have those Subscriptions already loaded then? Why do you need to list them again?
I dont have them loaded anymore. I ran the code a week ago. Im assuming i'd have to grab the PaymentIntent from each SubscriptionId to issue the refund?
I would suggest looking at the latest_invoice of each Subscription and getting the PaymentIntent from there.
What is your criteria for the Subscriptions to be refunded? Based on that you will be able to define an appropriate filter.
Okay. I'm able to grab the subscription ids -> latest_invoice. Can you validate this please:
- get Invoice object using
latest_invoice - grab payment intent of invoice using
invoices.retrieve - issue refund using payment intent
Correct.
I tested this by grabbing the latest_invoice. Unfortunately, the latest_invoice does not contain the prorated adjustment as indicated in the screenshot above
Do you see which Invoice contains the adjustment?
Could you please share an example Subscription ID? sub_xxx
It doesnt indicate an invoice. It's set to null. Here's a sample subscription id sub_1QXxBs00jzSYwPuAA6RMe0qF
๐ taking over for my colleague. Let me catch up.
you also need to pass https://docs.stripe.com/api/subscriptions/cancel#cancel_subscription-invoice_now when you cancel the 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.
otherwise the proration will be created as a pending invoice item
can I still run this cancel subscription api call with invoice_now=true on already cancelled subscriptions? Cause I can list the subscription ids using:
for await (const subscription of stripe.subscriptions.list({
current_period_end: {
gt: Math.floor(gtStartDate.getTime() / 1000),
},
limit: 100,
status: "canceled",
}))
It seems I might not be able to anymore due to this
After itโs canceled, you can no longer update the subscription or its metadata.
Are there other options?
no that's not possible
yes you can list all pending invoice items
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 create invoices for these invoice items so that the customer would get a credit balance
if you wish to refund the customer balance after the invoices are generated and finalized you can follow these steps https://support.stripe.com/questions/refunding-credit-balance-to-customer-after-subscription-downgrade-or-cancellation#:~:text=Refunding the Customers Credit Balance
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
How do I create the invoice from the invoice item? I can confirm I can list the pending invoice items given the customer id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.