user18472307
user18472307

Reputation:

Stripe API "No valid payment method types for this Payment Intent."

As you can imagine I'm currently setting up the payment API with using Stripe. Problem is, I've never done such thing before and am following the docs pretty much one by one.

So I require stripe using (100% the right!) key.

const stripe = require("stripe")(
  "keyhere"
);

create the intent in a method...

const paymentIntent = stripe.paymentIntents.create({
  amount: process.env.AUDIT_PRICE,
  currency: "eur",
  automatic_payment_methods: { enabled: true },
});

call that method on a certain express route:

exports.createNewCashOrder = async (req, res) => {
  const intent = await paymentIntent();
  res.json({ client_secret: intent.client_secret });
};

The rest is irrelevant for now, since my backend server doesn't even start on localhost. Actually it's live for like 0.001 seconds and than crashes with this error:

StripeInvalidRequestError: No valid payment method types for this Payment Intent. Please ensure that you have activated payment methods compatible with your chosen currency in your dashboard

It also sends back a large error object, where at the end it says that pretty much everything (also the payment methods) are undefined.

error

Now on my dashboard, I did activate card payment, but it obviously somehow does not recognize it...

Any ideas what I've done wrong? Glad for any help!

Upvotes: 23

Views: 19265

Answers (1)

RyanM
RyanM

Reputation: 2960

This is just a hunch but is your amount too small? https://stripe.com/docs/api/payment_intents/create#create_payment_intent-amount

If that is the case you get this error because you specified

automatic_payment_methods: {enabled: true}

Stripe is looking for a payment method that can handle an amount lower than the minimum so that's why you get this error. Try specifying a payment method and see if you get a different error message that indicates the amount is too low.

Remember the docs state the amount is represented as

A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).

Update

As of the Stripe API version 2023-08-16 automatic_payment_methods are enabled by default. This means you may hit this error without specifying automatic_payment_methods in your request to the Payment Intent API if you are on the latest version.

Upvotes: 58

Related Questions