#paulc7053_api

1 messages ยท Page 1 of 1 (latest)

astral brookBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

pulsar solar
#

Hi!

safe stream
#

๐Ÿ‘‹
Could you please share more details ?

pulsar solar
#

I am confused about wether the user will be charged if they change the card within their Apple Pay/Google Pay

#

for example, a user subscribes with they Apple Pay

#

The underlying card in Apple Pay has expird and the user has attached a new card. Will my charges go through?

#

their**

#

This is how I handle the onConfirm within my ECE `const subscriptionRes = await fetch('/api/subscriptions/create', {
method: 'POST',
body: formData
});

    const subscriptionData = await subscriptionRes.json();
    const clientSecret = subscriptionData.clientSecret;

    if (!clientSecret) {
        console.log("No immediate payment required due to trial period.");
    }

    const { error } = await stripe.confirmSetup({
        elements,
        clientSecret,
        confirmParams: {
            return_url: returnUrl
        },
    });`
#

And I create the stripe subscription with export async function createStripeSubscription({ customerId, currency, productId, amount, interval = 'year', metadata = {}, trialDays = 7 }) { return await stripe.subscriptions.create({ customer: customerId, items: [{ price_data: { currency: currency.toLowerCase(), product: productId, unit_amount: Math.round(amount * 100), recurring: { interval } } }], payment_behavior: 'default_incomplete', payment_settings: { save_default_payment_method: 'on_subscription' }, expand: ['latest_invoice.payment_intent', 'pending_setup_intent'], metadata, trial_period_days: trialDays }); }

safe stream
#

The underlying card in Apple Pay has expird and the user has attached a new card. Will my charges go through?
Yes it should be updated automatically, as Stripe store Apple Pay token and not the underlying PaymentMethod

#

In worst case, it will requires another re-auth (3ds) I would say.

pulsar solar
#

I don't know if you looked at the above code snippets, but when I create the stripe subscription in the backend, I use payment_settings: { save_default_payment_method: 'on_subscription' }. I am not sure if I should add the network token `payment_settings: {
save_default_payment_method: 'on_subscription',
payment_method_options: {
card: {
network_token: {
preferred: true
}
}
}
},

safe stream
#

No need for specifying the network token no.

#

It's optional, but not required here.

pulsar solar
#

Yeah, I didn't see it being mentioned anywhere. for some reason all LLMs talk about it

#

Could you please expand more on the possible re-auth thing?

safe stream
#

Actually, it's regardless of Apple Pay or normal card payment, but card bank issuers may request a 3DS auth sometimes even if the PaymentMethod is correctly saved at Stripe Side (or any other payment provider)

#

Or you can enable Stripe to automatically emails customer to update their payment methods if one has failed

#

(Please refer to the section Manage failed payments)

pulsar solar
safe stream
#

If you opt for the email option, then yes Stripe will provide a hosted page.

pulsar solar
#

Okay, great!

#

Thanks a lot!

#

with the risk of being annoying so just to double check: stripe automatically updates the apple pay token when the user changes the card, did I get this right?

safe stream
#

Yes it should be updated intenally.

#

And for worst cases, make sure to activate the remediation emails and/or webhooks in order to collect new PaymentMethod if there is an issue.

pulsar solar
#

and what would I do within the function triggered by the webhook? Doesnt stripe already handle everything under the hood? I only store the stripe customer and subscription IDs

safe stream
#

You use the webhook, in case you want to create your remediation plane: send a custom email with a custom UI/dashboard to enter a payment method...

pulsar solar
#

Ah I see.

#

Got it!

#

Thanks a lot for your time @safe stream !