#putte

1 messages · Page 1 of 1 (latest)

winged folioBOT
last owl
#

Can you share the code that invokes that error?

stable crater
#

Extra info: When I console.log the stripe object, I see this:

api: {
auth: 'Bearer sk_test
******',
host: 'api.stripe.com',
port: '443',
protocol: 'https',
basePath: '/v1/',
version: '2022-11-15',
timeout: 80000,
maxNetworkRetries: 0,
agent: null,
httpClient: NodeHttpClient { _agent: undefined },
dev: false,
stripeAccount: null
},

#

Yes

#

import Stripe from "stripe";
const stripe = new Stripe(process.env.TEST_STRIPE_SECRET_KEY as string, {
apiVersion: "2022-11-15",
typescript: true
});

export default stripe

#

The function that triggers the error:

stripe.paymentIntents.search(paymentIntentQuery.query)

last owl
#

What's the value of paymentIntentQuery.query?

stable crater
#

status:\'requires_action\' AND customer:\'${stripe_customer_id}\'

#

But its not really the issue, I know the query works because I've used it thousands times. The issue is that Stripe is now rejecting my API key since I converted to ES6 instead of using commonjs require

last owl
#

It's a string? That method expects an object:

stripe.paymentIntents.search({ query: paymentIntentQuery.query })
stable crater
#

paymentIntentQuery = {query: status:\'requires_action\' AND customer:\'${stripe_customer_id}\'}

#

Yeah its an object, but hey lets not focus too much on that, if that was the error then Stripe would tell that an error occurred with the request due to formatting issues

#

The issue now is that my API key is getting rejected

last owl
#

The issue isn't that your API key is being rejected. The issue is is that your TS code is being incorrectly compiled and as such you're inadvertently overwriting the Stripe instance (and the API key). Bear with me

stable crater
#

you are absolutely right

#

Dammit

#

Sorry for my impatience, I got some really bad support yesterday

#

But you are correct, I fixed the mistake and it now works

#

The error message should point out that its a formatting issue rather than an incorrect API key though, like it would if you used require, but good, now I know

last owl
#

What was the issue?

stable crater
#

It was like you said, the stripe.paymentIntents.search expected an object and not a string, and I only passed a string

last owl
stable crater
#

Absolutely, thank you very much!