#gunwantkumar_docs
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/1379331595021979688
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Doc not update as per the latest version: https://docs.stripe.com/billing/migration/strong-customer-authentication#scenario-2
Hi! Sorry what exactly about SCA would you like to find out for subscriptions?
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?
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