#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/1265770769426944100
๐ 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, 2 hours ago, 13 messages
Hello
Sorry I don't know anything about Svelte
So you'll likely want to reach out to their support if you are seeing an issue with their framework.
Here is the stack trace:
I'm creating a Sveltekit app which is an online shop for a bakery.
Error: Invalid JSON received from the Stripe API
at new StripeError (/home/user/my-app/node_modules/stripe/esm/Error.js:28:9)
at new StripeAPIError (/home/user/my-app/node_modules/stripe/esm/Error.js:81:9)
at <anonymous> (/home/user/my-app/node_modules/stripe/esm/RequestSender.js:108:27)
at processTicksAndRejections (:12:39)
^[[B
As far as I can tell it's an API problem
Yeah you are going to need to narrow down where in your code this is coming from then
My guess is the svelte wrapper library you are using is not handling a certain error correctly
It seems to be from the payment intent snippet that I sent. That's where I'm creating the intent.
I don't think it's to do with svelte-stripe as this is the only Stripe import in that file: import Stripe from 'stripe';
It works fine with my test keys just not my live ones.
Can you add a log in node_modules/stripe/esm/Error.js: on line 28 before super(raw.message); and see what raw logs out there?
My guess is this is some sort of issue with how the framework you are using is making outbound requests. Something similar to https://github.com/stripe/stripe-node/issues/1519
Also do you see these requests in your Dashboard?
Or are they not reaching our API at all?
If they are, can you provide a request ID for one of them that we can look at?
StripeError raw: {
message: "Invalid JSON received from the Stripe API",
exception: 90 | this._res.on('data', (chunk) => {
91 | response += chunk;
92 | });
93 | this._res.once('end', () => {
94 | try {
95 | resolve(JSON.parse(response));
^
SyntaxError: JSON Parse error: Unrecognized token '<'
at <parse> ()
at parse (native:1:1)
at /home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/net/NodeHttpClient.js:95:34
at node:events:33:26
at emit (node:events:180:48)
at endReadableNT (node:stream:2507:27)
,
requestId: undefined,
}
Error: Invalid JSON received from the Stripe API
at new StripeError (/home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/Error.js:29:9)
at new StripeAPIError (/home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/Error.js:82:9)
at <anonymous> (/home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/RequestSender.js:108:27)
at processTicksAndRejections (:12:39)
^[[B
I'm using Sveltekit and no I don't see anything in the dashboard.
๐ stepping in for my teammate
Just let me know if you need anything.
I think you'll need to reach out to Svelte support on this. Are you sure there's nothing different in the code you're using with your test mode keys vs. live mode keys?
It is the exact same code for sure.
I'm deploying to prod but it's the exact same code.
I would test with my live keys on my local machine but I can't since you need https
Are you able to log the value of paymentIntent before the return?
Sure just give me a few minutes to re-deploy
I actually can't
StripeError raw: {
message: "Invalid JSON received from the Stripe API",
exception: 90 | this._res.on('data', (chunk) => {
91 | response += chunk;
92 | });
93 | this._res.once('end', () => {
94 | try {
95 | resolve(JSON.parse(response));
^
SyntaxError: JSON Parse error: Unrecognized token '<'
at <parse> ()
at parse (native:1:1)
at /home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/net/NodeHttpClient.js:95:34
at node:events:33:26
at emit (node:events:180:48)
at endReadableNT (node:stream:2507:27)
,
requestId: undefined,
}
That's as far as it gets
This is definitely the code causing the issue: const paymentIntent = await stripe.paymentIntents.create({
amount: total * 100,
currency: 'eur',
description: Order number: ${orderNumber},
automatic_payment_methods: {
enabled: true
}
});
Okay. Can you hard code some of these values instead (total, description)?
Yes I can, just need to deploy again
Here is the stack trace. I included the actual post request to my API root. You can ignore the order number bit that was just a test to see if it was getting the order number.
request Request (0 KB) {
method: "POST",
url: "http://www.testsite.takethecake.ie/paymentIntent",
headers: Headers {
"connection": "upgrade",
"host": "www.testsite.takethecake.ie",
"content-length": "458",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
"accept": "/",
"accept-language": "en-US,en;q=0.5",
"accept-encoding": "gzip, deflate, br, zstd",
"referer": "https://www.testsite.takethecake.ie/checkout",
"content-type": "application/json",
"origin": "https://www.testsite.takethecake.ie",
"cookie": "__stripe_mid=96b500f2-a73d-41a6-b489-484c306cb581327e7a; __stripe_sid=11efa618-7975-49d4-b055-f3d85bc3c39bdc1389",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"priority": "u=4",
}
}
orderNumber 10022
StripeError raw: {
message: "Invalid JSON received from the Stripe API",
exception: 90 | this._res.on('data', (chunk) => {
91 | response += chunk;
92 | });
93 | this._res.once('end', () => {
94 | try {
95 | resolve(JSON.parse(response));
^
SyntaxError: JSON Parse error: Unrecognized token '<'
at <parse> ()
at parse (native:1:1)
at /home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/net/NodeHttpClient.js:95:34
at node:events:33:26
at emit (node:events:180:48)
at endReadableNT (node:stream:2507:27)
,
requestId: undefined,
}
Error: Invalid JSON received from the Stripe API
at new StripeError (/home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/Error.js:29:9)
at new StripeAPIError (/home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/Error.js:82:9)
at <anonymous> (/home/deployer/Take-the-Cake-Website/node_modules/stripe/esm/RequestSender.js:108:27)
at processTicksAndRejections (:12:39)
^[[B
Can you share your code again?
const paymentIntent = await stripe.paymentIntents.create({
amount: 10000,
currency: 'eur',
description: Order number: 123,
automatic_payment_methods: {
enabled: true
}
});