#sxe-paymentintent
1 messages · Page 1 of 1 (latest)
Hi! You need to create a PaymentIntent with capture_method: "manual" and then confirm the PaymentIntent to see status: "requires_capture.
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
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' => [
...........
]]);```
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'
How do I see if I already have a payment method?
On event log I can't see any pm_xxx
Well it depends. Did you create a PaymentMethod?
I would recommend you to follow this guide: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
It covers how to:
- Create a Payment Intent (what your code is doing)
- Then use the client secret of the PaymentIntent on the frontend with the Payment Element, and that will create a Payment Method (what you are missing)
I have downloaded this source code.
Is there any $_POST to get submitted infos?
What do you mean? What are you trying to do?
$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
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.
this
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");
}
When you enter the payment details in the payment element and confirm the payment intent, the payment intent will automatically have a payment method.
How can I retrieve them?
$stripe->paymentMethods->create([
'type' => 'card',
'card' => [
'number' => {{card_number}}
``` ?
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?
You need to do step 4 and 5 mentioned on this documentation page to collect payment information and confirm the PaymentIntent
https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-collect-payment-details
Step 2: done.
Can you share a PaymentIntent ID that was confirmed?
I ll create a new payment and yes, I will share the id.
evt_3Kvi2lLKPu9R0yzS09htetkX
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?
Payments work fine. I just keep getting this error. Uncaught (Status 400) (Request req_odKB5Jg07XegxK) 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.
And I don't know how to fix it.
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
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.
I think you are getting confused. Can you stop coding, and read this guide from start to finish? This will help you
https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-collect-payment-details
Otherwise you could use a different approach to accept payments. For example:
- Checkout Session (that requires less code) https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout
- or Payment Links (that requires no code) https://stripe.com/docs/payments/payment-links
Currently I am using Checkout session.
But all the code you shared so far is to create a PaymentIntent, and not for Checkout Sessions.
Yes, because I use Custom payment flow
I would recommend to use Checkout or Payment Link if possible. Both are much simpler to implement.