#paul-geoghegan_error
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/1266126356845166592
đ 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.
- paul-geoghegan_error, 20 hours ago, 49 messages
- paul-geoghegan_error, 1 day ago, 13 messages
It is related to both of those but I managed to replicate the problem on my local machine and log the response from stripe.
Hi, can you share the request id where this request failed? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
It actually doesn't have one: const paymentIntentPayload = {
amount: total * 100,
currency: 'eur',
description: Order number: ${orderNumber},
automatic_payment_methods: {
enabled: true
}
};
console.log('Creating payment intent with payload:', paymentIntentPayload);
const paymentIntent =
await stripe.paymentIntents.create(paymentIntentPayload);
StripeError raw: {
message: "Invalid JSON received from the Stripe API",
exception: 91 | response += chunk;
92 | });
93 | this._res.once('end', () => {
94 | try {
95 | console.log('response', response);
96 | resolve(JSON.parse(response));
^
SyntaxError: JSON Parse error: Unrecognized token '<'
at <parse> ()
at parse (native:1:1)
at C:\Users\mrpau\OneDrive\Dokumenter\GitHub\Take-the-Cake-Website\node_modules\stripe\esm\net\NodeHttpClient.js:96:34
at node:events:33:26
at emit (node:events:180:48)
at endReadableNT (node:stream:2507:27)
,
requestId: undefined,
}
Can you paste the exact error you're seeing?
I see it
Thank you
I see a similar report when using Bun: https://github.com/oven-sh/bun/issues/10975 which was resolved by adding '--conditions=worker'. It is odd that it works in dev server and not in build server. The above issue indicates that there is a bug on http/https implementation. I'm still looking
I recommend that you raise a bug at https://github.com/sveltejs/kit.
I asked in their server and haven't heard anything yet. I'll try the fix for bun now.
No, I tried that and I got the same response.
Hello, trying to catch up. Is that 403 HTML page coming back from Stripe after you send us something? I have not seen us error like that before.
Or I guess, how exactly are you accessing that response?
Yes, I'm trying to make a payment intent and that's what I'm getting back.
I printed that response by adding a console.log inside node_modules/stripe/net/NodeHttpClient.js on line 96 before it tries to parse the json response.
Gotcha, I am not sure what this may be, reaching out to my colleagues and will get back with what we can find.
Perfect thanks so much. It has delayed the launch of a new site for 3 days so any help would be great.
Would it be worth my time trying the request with axios instead to see if it is an issue with the stripe NPM package?
Yeah if you can try making the same request with something else, that could help narrow down what is happening here
And do you know what broadly the differences are between dev and build here? And are there any differences in how your code sets up the stripe client based on dev vs build?
I'm not super famileir with how Sveltekit works behind the scenes but it pretty much just optomises all of the code and compiles it in to one big build folder with as many things as possable staticly rendered. No there is nothing different in my code for build vs dev.
Using axios to send the post request did not fix the issue
Interesting, so it is a different in how HTTP(S) requests are made in that environment in general?
No, I don't think so. I'm making many other api/database calls and they all work fine.
Is there a way that I could work around this? I need to get the users address and email back from stripe though so I don't think I can just embed the checkout right?
I just really need to get this site up so any solution is better than no solution.
Embed the checkout as in put the Payment Element within an iframe? Or something else?
I'm not sure. I thought you could somehow embed a checkout instead of using payment elements.
Yep, you can definitely do that. Though it is a similar flow that would require making an API request to us at some point. https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=embedded-form
Okay, then that probably wouldn't fix it.
I tried it on my production server and I got the same issue. I'm using Nginx. Is there anything I can do to make it use https for the Stripe request. It is using https for inbound traffic. It's just a test server but here is the link if you want it: https://takethecake.envisionly.tech/
We sell freshly baked cakes, cupcakes, pies and other desserts, using nothing but the finest ingredients. Nothing is made until you order it! We can customize a cake with an image, printed message, or other decoration. Browse our selection of cakes perfect for your celebration.
I am still trying to figure out the underlying issue here. So to be clear as far as you know is your backend that you are making this stripe-node call on just a standard node setup? Would it be possible to send us a small node project to run that reproduces this? I think we may need to file this with the people who make our node library
I'm actually using bun but I'm about to try it on node.
Gotcha, I'd say file another issue with bun. It sounds like there may still be some issue with the underlying node:http implementation that they use. If you can switch backends to use stripe-node with node that sounds like it may be a great solution
I'll try it now. That way we can tell if bun is the issue.
Yes, Bun was the issue.
That's fine don't worry. No thank you for your help. You have saved me!
As far as the bun issue said I think it is an issue with the Stripe package but I don't care if I can get it to work.
Hm, am I wrong in interpreting this PR as an attempt to resolve this issue? https://github.com/stripe/stripe-node/pull/2118
I think that resolved the issue that was mentioned in the issue created in May but my issue seems to be different somehow.
The temporary fix proposed in the issue didn't work for me so I think it's different.
I see
I recommend filing another issue with Bun or chiming in here to say that the fix outlined in that issue didn't resolve the issue for you: https://github.com/oven-sh/bun/issues/10975
I just commented there. Hopefuly they can get that fixed.