#sxe-paymentintent

1 messages · Page 1 of 1 (latest)

clear marten
#

Hi! You need to create a PaymentIntent with capture_method: "manual" and then confirm the PaymentIntent to see status: "requires_capture.

polar cargo
#

Hi.

#

But I am doing that.

clear marten
polar cargo
#

I just keep getting this error instead.

#

(Request req_LTZMBXgzgffBNA) This PaymentIntent could not be captured because it has a status of requires_payment_method. Only a PaymentIntent with one of the following statuses may be captured: requires_capture.

#
  $paymentIntent = \Stripe\PaymentIntent::create([
          'amount' => $Price*100,
          'currency' => 'ron',
          'payment_method_types' => ['card'],
          'capture_method' => 'manual',
          'metadata' => [
...........
]]);```
clear marten
#

Yes, that's normal. You first need to collect the payment details (like the card number).

#

Usually you do that on the frontend by using the Payment Element.

#

Or if you already have a payment method you should pass it when you create the PaymentIntent like this: payment_method: 'pm_xxx'

polar cargo
#

On event log I can't see any pm_xxx

clear marten
#

Well it depends. Did you create a PaymentMethod?

polar cargo
polar cargo
#

Is there any $_POST to get submitted infos?

clear marten
#

What do you mean? What are you trying to do?

polar cargo
#
$stripe->paymentMethods->create([
  'type' => 'card',
  'card' => [
    'number' => $_POST['number'],
    'exp_month' => $_POST['month'],
    'exp_year' => $_POST['year'],
    'cvc' => $_POST['cvc'],
  ],
]);
#

I'm trying to create the payment method

clear marten
#

This is not the recommended way, and if you do this your company needs to be PCI compliant.
Have you looked at the link I shared before? Use the client_secret of the PaymentIntent, and then use the Payment Element on the frontend to collect the payment information.

polar cargo
#

Well

#

As I can see

#

I do have the payment element.

#
async function initialize() {
  const { clientSecret } = await fetch("create.php", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ items }),
  }).then((r) => r.json());

  elements = stripe.elements({ clientSecret });

  const paymentElement = elements.create("payment");
  paymentElement.mount("#payment-element");
}
clear marten
#

When you enter the payment details in the payment element and confirm the payment intent, the payment intent will automatically have a payment method.

polar cargo
#

How can I retrieve them?

#
$stripe->paymentMethods->create([
  'type' => 'card',
  'card' => [
    'number' => {{card_number}}
``` ?
clear marten
#

Step 1: create the PaymentIntent
Step 2: collect payment information on the frontend and confirm the payment intent
Step 3: capture the PaymentIntent (if needed)

#

Have you done Step 2?

#

If so, can you share a PaymentIntent ID that was confirmed?

polar cargo
#

Step 1: done.

#

Step 2: done.

clear marten
#

Step 2: done.
Can you share a PaymentIntent ID that was confirmed?

polar cargo
#

I ll create a new payment and yes, I will share the id.

#

evt_3Kvi2lLKPu9R0yzS09htetkX

clear marten
#

This PaymentIntent failed because you used a wrong test card. Can you retry and use 4242424242424242 instead for the card?

#

And then share the PaymentIntent ID?

polar cargo
#

And I don't know how to fix it.

polar cargo
#

evt_3KvfOQLKPu9R0yzS1RmC9ag2

clear marten
#

And I don't know how to fix it.
What you are currently doing: 1. create the payment intent 2. capture it (errror) 3. confirm it
What you should do instead: 1. create the payment intent 2. confirm it 3. capture it

polar cargo
#

Can I add
'confirm' => true to create intent?

#
$stripe->paymentIntents->confirm(
  'code',
  ['payment_method' => 'pm_card_visa']
);
#

as I can see, this is the way I must do it.

clear marten
polar cargo
#

Currently I am using Checkout session.

clear marten
#

But all the code you shared so far is to create a PaymentIntent, and not for Checkout Sessions.

polar cargo
#

Yes, because I use Custom payment flow

clear marten
#

I would recommend to use Checkout or Payment Link if possible. Both are much simpler to implement.