#paul-geoghegan_error

1 messages ยท Page 1 of 1 (latest)

slim ventureBOT
#

๐Ÿ‘‹ 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.

celest sphinxBOT
#

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.

round gale
#

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.

versed sage
#

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

round gale
#

Yeah you are going to need to narrow down where in your code this is coming from then

slim ventureBOT
round gale
#

My guess is the svelte wrapper library you are using is not handling a certain error correctly

versed sage
#

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.

round gale
#

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?

#

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?

versed sage
#

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.

proper ice
#

๐Ÿ‘‹ stepping in for my teammate

versed sage
#

Just let me know if you need anything.

proper ice
#

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?

versed sage
#

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

proper ice
#

Are you able to log the value of paymentIntent before the return?

versed sage
#

Sure just give me a few minutes to re-deploy

versed sage
#

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
}
});

proper ice
#

Okay. Can you hard code some of these values instead (total, description)?

versed sage
#

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

proper ice
#

Can you share your code again?

versed sage
#

const paymentIntent = await stripe.paymentIntents.create({
amount: 10000,
currency: 'eur',
description: Order number: 123,
automatic_payment_methods: {
enabled: true
}
});

proper ice
#

Just to be clear, for the description value, are you using single quotes or `` ?

#

I think Discord is reformatting this; you should be using single quotes

versed sage
#

I can change it sure

#

Exact same error

proper ice
#

Okay so yes, looks like there's an issue with the framework and outbound requests as that's a pretty basic request to make a PaymentIntent

#

Still strange that you see different behavior between live mode and test mode

#

Do you have an example PaymentIntent from test mode?