#azuken_code
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/1468928386150694922
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Here is my function :
async initStripeCheckout(clientSecret: string, fromInApp = false, refresh = false): Promise<StripeCheckout | null> {
if (!this.stripeCheckout || refresh) {
if (!this.stripeClient) await this.initStripeClient();
if (this.stripeClient) {
console.debug('Initializing Stripe checkout...');
[...]
this.stripeCheckout = this.stripeClient.initCheckout({
adaptivePricing: {
allowed: this.isAdaptivePricing,
},
clientSecret,
elementsOptions,
});
this.stripeCheckout.on('change', (checkoutSession) => (this.checkoutSession = checkoutSession));
const loadActionsResult = await this.stripeCheckout.loadActions();
if (loadActionsResult.type === 'success') {
this.checkoutActions = loadActionsResult.actions;
this.checkoutSession = this.checkoutActions.getSession();
console.debug('Stripe checkout initialized.');
} else {
console.error('Failed to load Stripe checkout actions', loadActionsResult);
const cartStore = useCartStore();
console.debug('Trying to recreate checkout session...');
await cartStore.createCheckoutSession(fromInApp);
}
}
}
return this.stripeCheckout;
},
And createCheckoutSession can call this init function, to reload UI components, but if an error occurs again, it's the begining of the loop
hey there ๐ taking a look into this
is it possible for you to share the request ID (req_123) for the 'No such payment_page' error you got?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
I'll try to find it
It's not an API call made by me, it's when I load action from stripe checkout instance
I do not see it in logs
I try to find it in devtools
https://api.stripe.com/v1/payment_pages/cs_test_b1mgu0PP3w7VbfibPSVXKFbIkNkVaunrrQaCbu5VVvCzDVxUsrGIjeJtGv/init
Request Method
POST
Status Code
404 Not Found
req_rMmIV6sfROnSRt
I have it
ah nice, thanks for this!
reviewing your flow though, there isn't really a recommended way to automatically handle this situation in the way you described (i.e. identifying the reason for the error, fixing the issue, and retrying)
we don't document error types for loadActions, and while the code=null isn't really helpful, overall we don't recommend trying to automate the process of fixing the issue and recreating the session like this
instead, for errors like this, the recommended approach is to get ahead of them through testing and fixing your integration
for instance, the issue here is an API key mismatch, so the recommendation would be to ensure that your code uses the right credentials in the right places to avoid this error happening in the first place
Yes, for this use case we don't want to manage it, but show an error to user, and manage integration issues with other ways
But I have at least one case when I must handle CS creation on failure, it's when it's expired
Because we are associating a CS to a user cart when he creates it, and recreate it when user update it. As CS can expire, and user can leave its cart and go back 24h later, we must manage this case (we have done a migration from payment intents to CS to access to adaptive pricing features)
(if there is other cases when a load actions is failing, I'll be happy to know)
Ok I see. Are you looking for a specific flag in the response that indicates when you should not retry the failed request, or something else?
A flag or a code, to put a condition before trying to recreate session
I'm curious how the 404 error in req_rMmIV6sfROnSRt can be remediated by recreating the session? This is entirely an integration issue โ you're trying to init the session with the keys of a different account
But no, what you want is not supported today. It's valid feedback and I'll share it with the product team
I think I didn't explain correctly
I cannot remediate this error, indeed if there is a misconfiguration I cannot recreate a proper session
You can, you init the session using the correct key. It's not a terminal error
So I want to know that if it's this case, I don't call my create API. But if it's an expiration error, then I want to manage an automatic creation
And as I said, that's not possible today
Yes yes, I just want to have the right condition for my expiration case
I did this code to manage expiration of a checkout session. But we had this infinite loop case with the misconfiguration, so in this case, I must not try to recreate session (and fix the configuration after, for example, a user is reaching us with an error message)
I just want to know what are the possible values of code property in error case, then do my condition to run or not my create checkout session
Are you using short-lived sessions or something? Why not just persist the expires_at timestamp?
I do not persist any session data to avoid managing extra updates in our data, I just have the ID. I have the checkout session data only after loading actions, so I cannot have this timestamp before error occurs
Yeah I mean the code values aren't documented so we won't be sharing them. I suggest designing an alternative solution that isn't reliant on them
Ok, so how can I manage to have this session expiration from front before loading actions, or even init checkout ?
(I just checked the source and code is always null โ so something we'd need to improve)
Understood, because parsing your error message isn't a clean solution too
Sorry, missed this question. You may need to retrieve the session server-side and return it to the frontend so you can it's expires_at