#chayse_api

1 messages · Page 1 of 1 (latest)

white hamletBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1253303800903766016

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

frozen tundra
#

What is new stripe.Stripe? Can you share that method

sweet flax
#

Of course

#

I import Stripe (using js) like this: const stripe = require("stripe"); so It's just a Stripe object.

frozen tundra
#

Hmm, just normally you'd instantiate the client via new Stripe(...)

sweet flax
#

I can certainly give that a try, though using new stripe.Stripe does work with the hardcoded secret key

frozen tundra
#

OK, then I'd imagine something is malforming the key when reading it from your secret store

sweet flax
#

I see! Reading it in console.log it's exactly the same, do you have any advice on anything I could try when parsing it to Stripe?

frozen tundra
#

How do you actually retrieve it from Google? (not familiar with that at all)

sweet flax
#

No problem,

I retrieve it from Google Secrets Manager and use a Firestore function to retrieve it, the start of my backend Stripe flow looks like this:
exports.stripePayment = onRequest({secrets: ["StripeKey"]}, async (req, res) => {

Then, I use process.env.StripeKey in order to access the string. If I console.log it, it's exactly the same, so I assumed it was a parsing to Stripe error too but I'm unsure on any way how to fix it.

frozen tundra
#

Yeah but how are you retrieving it?

sweet flax
frozen tundra
sweet flax
#

Exactly right! That looks to be the same way I'm performing the task, hence I'm unsure what else I can do

#

Like I say, I can console.log() the key and it works, but when I parse it I get TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"]

#

I've also tried with just new Stripe() instead of new stripe.Stripe to see if that was the issue, but it didn't fix it unfortunately.

frozen tundra
#

Where exactly is that error thrown? It doesn't look like an error from our SDK/API but instead Google/Firebase

sweet flax
#

The error is thrown on:
await validatedStripe.paymentIntents.create({
amount: req.body.amount,
currency: "gbp",
metadata: req.body.metadata,
}, (err, paymentIntent) => {
if (err != null) {
console.log(err);
} else {
res.json({
paymentIntent: paymentIntent.client_secret,
});
}
});

It's the err in this function I'm printing. It says:

StripeConnectionError: An error occurred with our connection to Stripe. Request was retried 1 times. at /workspace/node_modules/stripe/cjs/RequestSender.js:322:37

message: 'An error occurred with our connection to Stripe. Request was retried 1 times.',

detail: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"]

frozen tundra
#

Yeah I mean something is malforming your secret so it's not the expected format unfortunately

#

Really hard for us to pinpoint the issue as we're not Google/Firebase

sweet flax
#

Okay, if there's nothing else that can be done on your side I'll go ahead and contact them - thanks for looking into it though!

frozen tundra
#

Apologies, hope you get sorted