1
votes

my issue is I'm a beginner in Stripe API but I'm learning. My issue is that I would like to create a payment intent using Postman. It works but in paymebt dashboard I've got the incomplete icon and a message

The customer has not entered their payment method

Here is a screenshot of postman and what I'm sending :

enter image description here

When I looked for payment_method,

ID of the payment method used in this PaymentIntent.

I guess it's the card token to be used but when I use it I have the following error

{
    "error": {
        "message": "A token may not be passed in as a PaymentMethod. Instead, use payment_method_data with type=card and card[token]=tok_1IL4SzF4hKd41bgRRGY0rM3f.",
        "param": "payment_method",
        "type": "invalid_request_error"
    }
}

Any idea please ?

1

1 Answers

0
votes

I would recommend following this guide [1]. You may swap out certain POST calls using Postman if that makes it easier to test, but the core idea is that a PaymentMethod should be collected using Stripe.js and Elements. This is done securely and gives you the minimum PCI burden. Then, once you have a PaymentMethod (with id format pm_xxx) you can use that to do things like create and confirm a PaymentIntent.

If you would like to simply test the API there are other options too. You can create a PaymentMethod directly against the API like so (you could replicate this in Postman):

curl https://api.stripe.com/v1/payment_methods \
  -u sk_test_xxx: \
  -d type=card \
  -d "card[number]"=4242424242424242 \
  -d "card[exp_month]"=2 \
  -d "card[exp_year]"=2022 \
  -d "card[cvc]"=314

And then pass the resulting ID to the payment_method of the PaymentIntent. Or even use a pre-baked payment method pm_card_visa, many of those are listed on this page if you choose the payment method tab [2], and then create a PaymentIntent using it:

curl https://api.stripe.com/v1/payment_intents \
  -u sk_test_xxx: \
  -d amount=2000 \
  -d currency=eur \
  -d "payment_method_types[]"=card \
  -d payment_method='pm_card_visa' \
  -d confirm=true

[1] https://stripe.com/docs/payments/integration-builder

[2] https://stripe.com/docs/testing