#ghost64
1 messages · Page 1 of 1 (latest)
No that would not be expected - can you share an example of a CHeckout Session ID where you see this happening?
This is my code
const session = await stripe.checkout.sessions.create(
{
line_items: [
{
price: price.id,
quantity: 1,
},
],
metadata: {
restroId,
orderId,
isPayFirst,
items: JSON.stringify(itemIdArray),
tax,
serviceCharge,
discount,
tip,
priceId: price.id,
},
mode: "payment",
success_url: `https://restro.dev/customer?success=true&&orderId=${orderId}`,
cancel_url: `https://restro.dev/api/order/stripeCanceled?canceled=true&&priceId=${price.id}`,
payment_intent_data: {
application_fee_amount: 10,
},
},
{
stripeAccount: stripeAccountId,
}
);
res.json({ url: session.url });
await updatePaymentHold(restroSchema, orderId, itemIdArray, true)
.then(() => {
const timer = setTimeout(async () => {
await updatePaymentHold(restroSchema, orderId, itemIdArray, false)
.then(async () => {
console.log("session deleted");
await stripe.checkout.sessions.expire(session.id);
timers.delete(price.id);
})
.catch((error: Error) => {
console.log(error);
});
}, 1 * 60 * 1000);
timers.set(price.id, timer);
})
.catch((Error) => {
console.error();
});
}
cs_test_a13xFnrF7Rl5oydb4hfzIYD7T16teTfz51I23i3dlbb9dLK04ftbh36ySJ
Are you sure your CHeckout Session expiration code is being run? I don't see any recent expiration requests happening for that accuont at all
Yeah seems I get StripeInvalidRequestError: No such checkout session: 'cs_test_a13xFnrF7Rl5oydb4hfzIYD7T16teTfz51I23i3dlbb9dLK04ftbh36ySJ'
But according to the code session.id should be giving me that id that I just created, shouldnt it?
Can you share the request ID that's giving you the "No such checkout session" error?
req_HnYM21dUPYooL3
Ah I see the issue - when you created the CHeckoutSession you set stripeAccount: stripeAccountId,
You need to do the same for your code that expires the Checkout Session
Because right now your request is being made on the platform account, but the Checkout Session was created on the connected account
Ahh ok, so how do I do it
We give examples of how to do that here (https://stripe.com/docs/connect/authentication#stripe-account-header) - but also you already did it for your Checkout Session creation code. You just have to do the same thing and add stripeAccount to your call to await stripe.checkout.sessions.expire(session.id); now
Yeah but the session expire says it doesnt take any parameters
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
try it with this?
var stripe = Stripe('{{PLATFORM_PUBLISHABLE_KEY}}', {
stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
});
It's not a parameter, you need to specify it in a separate hash - probably something like this:
await stripe.checkout.sessions.expire(session.id, { stripeAccount: stripeAccountId, } );
ahh nice that makes sense. Thank you will check now
Is there any way I can redirect the page to the previous page if the session expires
No that I know of
Ahh thats enough for me. Thank you soo much for your help. Really appreciate it.