#gunwantkumar_docs

1 messages ¡ Page 1 of 1 (latest)

silent mantleBOT
#

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

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

fallow crest
quick loom
#

Hi! Sorry what exactly about SCA would you like to find out for subscriptions?

fallow crest
#

hi,
Here is my old code for handle this.

            const subscriptionData: any = {
                default_payment_method: params.paymentMethodId,
                customer: params.stripeCustomerId,
                plan: plan_id,
                expand: ['latest_invoice.payment_intent'],
                payment_behavior: 'allow_incomplete',
            };

            const subscription: any = await stripe.subscriptions.create(subscriptionData);


            if (subscription?.latest_invoice?.payment_intent?.last_payment_error) {
                const error = new stripe.errors.StripeError({
                    statusCode: 500,
                    type: subscription.latest_invoice.payment_intent.last_payment_error.type,
                    code: subscription.latest_invoice.payment_intent.last_payment_error.decline_code,
                    decline_code: subscription.latest_invoice.payment_intent.last_payment_error.decline_code,
                    message: subscription.latest_invoice.payment_intent.last_payment_error.message,
                });
                throw error;
            } else if (subscription?.latest_invoice?.payment_intent) {
                response.invoiceId = subscription.latest_invoice.id;
                response.subscriptionPaymentIntentStatus = subscription.latest_invoice.payment_intent.status;
                response.paymentIntentClientSecret = subscription.latest_invoice.payment_intent.client_secret;
            }

As per this new version payment_intent field is remove from the invocie object.
Is there another way to do this?

quick loom
#

I think the main thing is that you want retrieve the Payment Intent.

You can still get the latest_invoice from the subscription [0]. Then to retrieve the payment intent from an associated invoice, you need to make a separate GET call to List all Invoice Payments API [1]. Here you can pass the Invoice ID to this endpoint [1]. It will provide you with a list of payment objects which includes the payment intent.

[0] https://docs.stripe.com/api/subscriptions/object#subscription_object-latest_invoice
[1] https://docs.stripe.com/api/invoice-payment/list#list_invoice_payments-invoice