#drackosh_api

1 messages ¡ Page 1 of 1 (latest)

knotty trellisBOT
#

👋 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/1463110594277146793

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

lethal burrow
#

Full code is:

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
  apiVersion: '2025-12-15.clover', // Ensure this matches your version
})

export async function cancelAndRefundSubscription(subscriptionId: string) {
  try {
    // 1. Retrieve subscription and expand the latest_invoice
    const subscription = await stripe.subscriptions.retrieve(subscriptionId, {
      expand: ['latest_invoice'],
    })

    const invoice = subscription.latest_invoice as Stripe.Invoice

    // 2. Validate subscription status and invoice payment
    if (
      subscription.status === 'active' &&
      invoice &&
      invoice.status === 'paid' &&
      invoice.payment_intent // Use payment_intent instead of charge
    ) {

tepid tartan
#

Can you share the req_xxx ID for the request(s) you've tried?

lethal burrow
#

I haven't tried a request yet, I just saw the TS error, where and how can I get you that?

tepid tartan
lethal burrow
#

So what's the way of achieving what I want to achieve now? cancel and prorate & refund?