#uncle_intent-confirm-redirect

1 messages ยท Page 1 of 1 (latest)

spice anvilBOT
#

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

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

queen escarp
grizzled bane
#

Hi ๐Ÿ‘‹

Most of the time, when I see this, it's your own server doing something URL query params

#

Also we don't maintain svelte-stripe ourselves (it's a 3rd party tool) so I cannot speak to that

queen escarp
#

fair

grizzled bane
#

And just so I'm clear, this is the return_url parameter you are providing when confirming a payment?

queen escarp
#
async function submit() {
        if(processing){
            return;
        }
        processing = true;
        const result = await stripe.confirmPayment({
            elements,
            clientSecret,
            confirmParams:{
                return_url:`${PUBLIC_URL}/newLease/leaseSent?invoiceId=${data.invoice?.invoiceId}`
            }
        });
        console.log(result)
        if(result.error){
            error = result.error;
            processing = false;
        } else {
            goto('/newLease/leaseSent?invoiceId=' + data.invoice?.invoiceId);
        }

    }```
#

That's my submit function but when it does I get redirected to the payment page but without the search params

grizzled bane
#

Do you have an example Payment Intent ID I could review? It will start with pi_

queen escarp
#

pi_3QMZ9GP59R9WWDKH1zAsq6xr

grizzled bane
#

This request was not confirmed and still requires a payment method.

queen escarp
#

pi_3QMZBtP59R9WWDKH0q998PXL

grizzled bane
#

Same thing

#

no evidence there was ever an attempt to confirm this payment intent

queen escarp
#

pi_3QMZKUP59R9WWDKH1mLdPwb8

#

I just went through the payment process for that

#

here's my paymentIntent endpoint ```ts
import { stripe } from '$lib/server/stripe';
import { prisma } from '$lib/server/prisma';
import type { RequestHandler } from '@sveltejs/kit';
import { fail } from '@sveltejs/kit';

export const POST:RequestHandler = async (event) => {
const invoiceId = event.url.searchParams.get('invoiceId');
if(!invoiceId){
fail(404)
}
const invoice = await prisma.invoice.findUnique({
where:{
invoiceId:invoiceId!,
}
})
if(!invoice){
return new Response(JSON.stringify('not found'),{status:404})
}
const paymentIntent = await stripe.paymentIntents.create({
amount: invoice.invoiceAmount * 100,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
metadata:{
invoiceId,
customerId: invoice.customerId,
},
setup_future_usage: 'off_session'
})
console.log(paymentIntent.id);
return new Response(JSON.stringify(paymentIntent.client_secret), {status:200});
}

grizzled bane
#

But now the Payment Intent is in a state of requires_payment_method

#

This is when you are expected to bring a Customer on-session to provide payment method details using a Stripe UI element like the Payment Element.

#

It's only after the Customer provides their payment method details and confirms the payment, that you are redirected

queen escarp
#

right that's what I'm doing and I guess the Payment Element from Svelte-Stripe is broken somehow

#

I think I'm going to have to roll my own Svelte Payment Element

grizzled bane
#

Yes that does seem to be the issue since none of these payment intents have a /confirm request

queen escarp
#

Do you have any documentation relating to Svelte for Stripe?

grizzled bane
#

No, it isn't a platform we directly support

queen escarp
#

no worries

#

thanks for the help

grizzled bane
#

Happy to shed what ๐Ÿ’ก I can ๐Ÿ™‚