#spicey_code

1 messages ยท Page 1 of 1 (latest)

civic thornBOT
#

๐Ÿ‘‹ 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.

deft crystal
#

Hi, let me help you with this.

glacial jasper
#

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

deft crystal
#

I am not sure what you mean.

glacial jasper
#

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.

deft crystal
#

But don't you have those Subscriptions already loaded then? Why do you need to list them again?

glacial jasper
#

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?

deft crystal
#

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.

glacial jasper
#

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
deft crystal
#

Correct.

glacial jasper
#

I tested this by grabbing the latest_invoice. Unfortunately, the latest_invoice does not contain the prorated adjustment as indicated in the screenshot above

deft crystal
#

Do you see which Invoice contains the adjustment?
Could you please share an example Subscription ID? sub_xxx

glacial jasper
#

It doesnt indicate an invoice. It's set to null. Here's a sample subscription id sub_1QXxBs00jzSYwPuAA6RMe0qF

civic thornBOT
lone storm
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

#

otherwise the proration will be created as a pending invoice item

glacial jasper
#

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?

lone storm
#

yes you can list all pending invoice items

#

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

glacial jasper
#

How do I create the invoice from the invoice item? I can confirm I can list the pending invoice items given the customer id

lone storm