#drackosh_api
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/1463110594277146793
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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
) {
Can you share the req_xxx ID for the request(s) you've tried?
I haven't tried a request yet, I just saw the TS error, where and how can I get you that?
Now you've shared your code the issue can be explained bgy your API version. We removed the payment_intent property from the Invoice object back in the March 2025 API version: https://docs.stripe.com/changelog/basil/2025-03-31/add-support-for-multiple-partial-payments-on-invoices
So what's the way of achieving what I want to achieve now? cancel and prorate & refund?