#pinho
1 messages · Page 1 of 1 (latest)
Hi there!
Can you share the ID (req_xxx) of the failing API request?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
Hi
pi_3NDB09CENMAgnvaD1g7jb6vR
I'm using PHP with StripeClient library and I'm calling it this way:
`public function createPaymentIntent(int|float $amount): array
{
$result = $this->stripe->paymentIntents->create(
[
'amount' => $amount * 100,
'currency' => 'eur',
'payment_method_types' => ['card'],
]);
return [$result->id, $result->client_secret];
}`
Also, notice: the error only occurs on Mastercard, when I tried VISA there was no error.
There were no attempt on that PaymentIntent.
That PaymentIntent didn't get confirmed yet
After creating the PaymentIntent how are you accepting the Payment ? using Element ?
Sorry, I had to go somewhere
this is how I initialize Stripe through javascript:
`const publicKey = StripePayment.getPublicKey();
const paymentIntentToken = StripePayment.getPaymentIntentToken();
stripe = Stripe(publicKey);
const options =
{
clientSecret: paymentIntentToken,
locale: 'pt',
fonts: [{ cssSrc: 'https://fonts.googleapis.com/css?family=Poppins:400,500' }],
appearance:
{
theme: 'stripe',
variables:
{
fontFamily: 'Poppins, sans-serif',
fontWeightNormal: 500,
fontSizeBase: '14px',
fontSizeSm: '14px',
}
},
};
stripeElements = stripe.elements(options);
const paymentElement = stripeElements.create('payment');
paymentElement.mount('#stripe-payment-element');`
And when the user pays:
`const elements = stripeElements;
// https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements&html-or-react=html#web-submit-payment
const { error } = await stripe.confirmPayment(
{
elements,
confirmParams:
{
return_url: successUrl,
},
});`
Hi 👋 jumping in as my teammate needed to step away, catching up on context
As my teammate mentioned, we don't see a confirmation attempt for this Payment Intent. It looks like this part of your code did run for this payment, do you know that your customer clicked on the pay/submit button that triggers the payment confirmation?
Yes, I'm the one trying. I never had any issue in test mode, I just switched to production mode and it started showing errors. Here's my workflow:
- Users goes to checkout
- Imediatelly initialize the Stripe Elements / Form
- Imediatelly initialize the payment intent
- (User may leave the page or just continue the checkout process)
For example, I just entered the checkout page and generated a Payment Intent, this is the result:
{"public_key":"xxxx","payment_intent_id":"pi_3NDSjpCENMAgnvaD1X03CbaT","payment_intent_token":"pi_3NDSjpCENMAgnvaD1X03CbaT_secret_bADvGAMSq0jx6YltDiUtFTi4N"}
I'm not sure I'm grasping the concern here, I see that you created the Payment Intent you referenced in your most recent message, but I don't see a confirmation attempt for it.
I'm having a hard time to explain it properly. I'm gonna try to be more clear:
- I entered the checkout page
- Filled the credit card details (mastercard)
- Submitted the payment
- Error shown: "Credit card declined"
- Submitted again (without reloading page) -> worked
- Tried again, this time with VISA card
- Everything work well, no error
- Tried again, again with mastercard
- Error "Credit card declined"
- Submitted again (without reloading page) -> worked
I went to Stripe Dashboard and saw all this "Incomplete" status, probably has something to do with it.
So, I'm asking you to clear me on this steps, please:
- User opens checkout page, I immediately create the Stripe Form & call the
$stripe->paymentIntents->create(....), is this correct?
Yes
Ok, nice. I just logged the output of this function:
Stripe\PaymentIntent JSON: { "id": "pi_3NDSvHCENMAgnvaD1khTF6eA", "object": "payment_intent", "amount": 9959, "amount_capturable": 0, "amount_details": { "tip": [] }, "amount_received": 0, "application": null, "application_fee_amount": null, "automatic_payment_methods": null, "canceled_at": null, "cancellation_reason": null, "capture_method": "automatic", "charges": { "object": "list", "data": [], "has_more": false, "total_count": 0, "url": "\/v1\/charges?payment_intent=pi_3NDSvHCENMAgnvaD1khTF6eA" }, "client_secret": "pi_3NDSvHCENMAgnvaD1khTF6eA_secret_tlG5xI7zaEUMZ3bUt9vt0yKWy", "confirmation_method": "automatic", "created": 1685454555, "currency": "eur", "customer": null, "description": null, "invoice": null, "last_payment_error": null, "latest_charge": null, "livemode": true, "metadata": [], "next_action": null, "on_behalf_of": null, "payment_method": null, "payment_method_options": { "card": { "installments": null, "mandate_options": null, "network": null, "request_three_d_secure": "automatic" } }, "payment_method_types": [ "card" ], "processing": null, "receipt_email": null, "review": null, "setup_future_usage": null, "shipping": null, "source": null, "statement_descriptor": null, "statement_descriptor_suffix": null, "status": "requires_payment_method", "transfer_data": null, "transfer_group": null }
As you can see the field payment_method is null, isn't this a problem?
Also, the status is "requires_payment_method"
Am I missing some parameter during the creation of payment intent?
`$result = $this->stripe->paymentIntents->create(
[
'amount' => $amount * 100,
'currency' => 'eur',
'payment_method_types' => ['card'],
]);
\Log::debug($result);`
No, if you haven't provided a Payment Method to the Payment Intent during its creation it is expected for that field to be null after creation, and you wouldn't provide the ID of a Payment Method if you're using a frontend to collect payment method details.
The Payment Method and its ID are not generated until the confirmation step is executed.
So...everything I'm doing is ok.
- Does it make sense for Stripe Dashboard to show immediatelly the "Incomplete" status?
Remember: I have not pressed pay or anything, I just initialized the Stripe.
Yup, if the intent has been created and not confirmed then it is expected to be incomplete.
- So this means I'll have 100 incompleted intents if the user does not decide to proceed to pay?
Yup, unless you switch to our newer flow that delays the creation of the Payment Intent to later in the process to avoid this behavior:
https://stripe.com/docs/payments/accept-a-payment-deferred
- What is the alternative to this? Maybe I don't need the payment intent?
If you want to process a payment then you need a Payment Intent. The alternative is the flow that I linked above.
Yeah, I'm currently reading it, give me a moment please