#pinho

1 messages · Page 1 of 1 (latest)

tight ferryBOT
stray meadow
tight glen
#

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.

stray meadow
#

There were no attempt on that PaymentIntent.

tight glen
#

What do you mean?

stray meadow
#

That PaymentIntent didn't get confirmed yet

#

After creating the PaymentIntent how are you accepting the Payment ? using Element ?

tight glen
#

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:

brittle glacier
#

Hi 👋 jumping in as my teammate needed to step away, catching up on context

brittle glacier
tight glen
#

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:

  1. Users goes to checkout
  2. Imediatelly initialize the Stripe Elements / Form
  3. Imediatelly initialize the payment intent
  4. (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"}

brittle glacier
#

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.

tight glen
#

I'm having a hard time to explain it properly. I'm gonna try to be more clear:

  1. I entered the checkout page
  2. Filled the credit card details (mastercard)
  3. Submitted the payment
  4. Error shown: "Credit card declined"
  5. Submitted again (without reloading page) -> worked

  1. Tried again, this time with VISA card
  2. Everything work well, no error

  1. Tried again, again with mastercard
  2. Error "Credit card declined"
  3. 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:

  1. User opens checkout page, I immediately create the Stripe Form & call the $stripe->paymentIntents->create(....), is this correct?
brittle glacier
#

Yes

tight glen
#

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);`

brittle glacier
#

The Payment Method and its ID are not generated until the confirmation step is executed.

tight glen
#

So...everything I'm doing is ok.

  1. 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.

brittle glacier
#

Yup, if the intent has been created and not confirmed then it is expected to be incomplete.

tight glen
#
  1. So this means I'll have 100 incompleted intents if the user does not decide to proceed to pay?
brittle glacier
tight glen
#
  1. What is the alternative to this? Maybe I don't need the payment intent?
brittle glacier
#

If you want to process a payment then you need a Payment Intent. The alternative is the flow that I linked above.

tight glen
#

Yeah, I'm currently reading it, give me a moment please