#yen6305

1 messages ยท Page 1 of 1 (latest)

chrome wadiBOT
knotty crag
#

Can you share the example PaymentIntent?

shell mountain
#

Yes ofcourse

#
 const paymentIntent = await stripe.paymentIntents.create({
      amount: totalAmount,
      currency: "eur",
      payment_method_types: ['card', 'ideal', 'paypal'],
    //   capture_method: 'manual',
      // automatic_payment_methods: {
      //   enabled: true,
      // },
      metadata: metadata,
    });
knotty crag
#

Ah I meant, PaymentIntent ID (pi_xxx)

Or a request ID (req_xx) should work too

shell mountain
#

Ooh

#

"pi_3NjqfjD7Shm9DtKO0fNXEpdZ"

#

This is the most recent one

knotty crag
#

thanks, let me check..

shell mountain
#

Oh whut

#

That's weird

knotty crag
#

Can you restart your server and create a new PaymentIntent?
A fresh example would help

shell mountain
#

Okay

knotty crag
#

also try providing a higher amount (currently you're only setting 0.50)

shell mountain
#

Oh the problem might be that the amount is too low?

#

Please give me a sec

#

I've set it on 0.50 on purpose tho, cause i am also testing on production

knotty crag
#

I see. We strongly recommend against testing in production.
Card networks don't really like that.

shell mountain
#

No I meant, I tested it locally first with the Stripe CLI

#

After that I checked if it worked on production

#

Is that a bad practicw?

knotty crag
#

Ah I thought you meant you're using your Live API keys for testing.

Using Live API keys for testing is against card network recommendations.
You can use your Test API keys to run test scenarios in production environment.

shell mountain
#

Oh eh shit yeah I have been using live API keys for testing on production. Because I was wondering if it worked with real credit card details

#

Is that wrong?

knotty crag
#

Yeah.. If the code works in test mode with test cards, it should work just fine with live mode.

shell mountain
#

Ah so, okay ill stop testing with real card details

#

Actually, what happens with the card network if you do tho?

#

Because ive done it multiple times, just to check if the real credit details were working or not

knotty crag
shell mountain
#

Ah oki

#

Could you help me with something?

#

Can you see why I get this error https://api.stripe.com/v1/payment_intents/pi_3NkTYbD7Shm9DtKO1vdtIBYo/confirm 400

#

Everything worked yesterday and i havent changed my code since then so i am not sure why this error is occuring

knotty crag
shell mountain
#

Oh, wait

knotty crag
#

You're setting it on PaymentIntent creation

shell mountain
#

Yeah here right?

 const paymentIntent = await stripe.paymentIntents.create({
      amount: totalAmount,
      currency: "eur",
      payment_method_types: ['card', 'ideal', 'paypal'],
    //   capture_method: 'manual',
      // automatic_payment_methods: {
      //   enabled: true,
      // },
      metadata: metadata,
    });
  
knotty crag
#

yup

shell mountain
#

But I've commented out automatic_payment_methods

knotty crag
#

You are using deferred intent flow where you collect payment method information before creating a PaymentIntent.

if you don't set paymetnMethodTypes when you create elements then that means you're using automatic payment methods client-side
https://stripe.com/docs/js/elements_object/create_without_intent#stripe_elements_no_intent-options-paymentMethodTypes

So the PaymentMethod you collected was collected with automatic_payment_method: true by default on client-side which doesn't match payment_method_types: ['card', 'ideal', 'paypal'], server-side

#

Either you'd need to pass payment method types on both (client-side and server-side) OR remove it from server-side call

shell mountain
#

Ah okay

#

I am using Payment Element tho

#

Is it possible to pass it in the options? (client-side)

#

Like this:

   const paymentElementOptions = {
        layout: "tabs",
        paymentMethodTypes: ['card', 'ideal', 'paypal'],
    };
#

And then

#
<PaymentElement id="payment-element" options={paymentElementOptions} />
#

Okay this doesnt work lol

knotty crag
#

You'd pass it to elements instance, not PaymentElement

shell mountain
#

Oh shi it works! Thanks a lot ๐Ÿ™‚

knotty crag
#

NP! ๐Ÿ™‚ Happy to help