#uncle_intent-confirm-redirect
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/1308126226548002856
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I'm also using https://www.sveltestripe.com/ which I don't think has been updated for Svelte5 which is a bummer
Everything you need to access Stripe payments with Svelte
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
fair
And just so I'm clear, this is the return_url parameter you are providing when confirming a payment?
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
Do you have an example Payment Intent ID I could review? It will start with pi_
pi_3QMZ9GP59R9WWDKH1zAsq6xr
This request was not confirmed and still requires a payment method.
pi_3QMZBtP59R9WWDKH0q998PXL
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});
}
I don't think you understand how this integration is supposed to work. You created the payment intent to represent your intent to collect funds from a customer in this request: https://dashboard.stripe.com/test/logs/req_gxT5X5pZLHGkCv
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
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
Yes that does seem to be the issue since none of these payment intents have a /confirm request
Do you have any documentation relating to Svelte for Stripe?
No, it isn't a platform we directly support
Happy to shed what ๐ก I can ๐