#eliasknudsen

1 messages ยท Page 1 of 1 (latest)

chilly mesaBOT
weak crane
#

Hi ๐Ÿ‘‹

Yes this is possbile. have you tested it out?

distant harness
#

Yes, I got an error when i tested it out, let me reproduce the error and send here

#

Error: (node:11448) UnhandledPromiseRejectionWarning: Error: Invalid value type: {:address1=>"Vaekero Terrasse 9F", :address2=>"", :country_code_str=>"+47", :phone=>"96913407", :country=>"Norway", :shipment_method=>"STANDARD", :zip=>"0282", :state_code=>"", :city=>"Oslo", :country_code=>"NO", :name=>"Elias Knudsen"} must be a string Code: ```if (!result.error) {
const paymentIntent = await stripe.paymentIntents.create({
amount: parseInt((result.estimate.result.costs.total * 100).toFixed(0)),
currency: "usd",
automatic_payment_methods: {
enabled: true,
},

            metadata: { email: req.oidc.user.email, ...result.metadata }
        });

        res.send({
            message: "Payment intent created",
            error: false,
            clientSecret: paymentIntent.client_secret,
            price: result,
        });
    } else {
        res.send(result)
    }```
weak crane
#

Are you using typescript?

distant harness
weak crane
#

Okay you will need to cast the nested data as a string before attempting to pass it in as metadata. I recommend creating the payload and logging in before you call the intent creation function

distant harness
#

ok, so a json stringfy will suffice?

weak crane
#

That should work.

distant harness
#

Yea it worked, but now i have a character limit error, but thanks for the help, i will figure out the rest myself:)

weak crane
#

Yeah there is a hard limit on the number of characters you can provide

distant harness
#

Yea, it sucks a little since i am going to need to verify that the webhook was from stripe, and i have some urls that only the servers i communicate with should access, which means i am passing a privatekey. But i will figure something out. Thanks for the help

weak crane
#

Happy to shed what ๐Ÿ’ก I can ๐Ÿ™‚

distant harness
#

One more thing. What is the purpose of an idempotency key?

weak crane
#

It is so you can make a request multiple times (in case of network failure) and only trigger a single response.

#

So if you attempted to confirm a charge and there was a network drop-out and you didn't get the resposne from the API, you could call it again using the same idempotency key and if we didn't receive it we would process the confirmation but if we did we would just return the result of the last request

distant harness
#

Ok, so it is a key i need to store and compare against webhooks from stripe?

weak crane
#

No

#

If you are trying to validate Stripe webhooks you should use our signature verification approach

distant harness
#

Yea, I am already using that. But i was just wondering what the idempotency key was and if it is something i have to handle or not?

weak crane
#

No, Stripe client libraries like stripe-node use them automatically

distant harness
#

Ok, so it is not something i have to worry about?

weak crane
#

Nope, not really

#

Some people like to define their own and use them because they run on buggy networks and that's their practice

#

So we expose the option

distant harness
#

Oh ok, so it is for servers than run on unstable networks?

weak crane
distant harness
#

Ok thanks for the help. Have a nice day:)