#Vincent_92-card
1 messages · Page 1 of 1 (latest)
Hello
so each time the page load, I have an intent "incomplete" in stripe dashboard, so I guess I do not use stripe the right way ?
We expect you to create a Payment Intent at the start of your Checkout process, and keep it until they're ready to checkout - ideally, you wouldn't need to create a new Payment Intent if you already have one you want to be using
How can you keep the paiment intent of the personn
each time the page load it create this on stripe
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => calculateOrderAmount($json_obj->items),
'currency' => 'eur',
'payment_method_types' => ['card'],
'description' => $_GET['formation'],
'metadata' => [
$explode_formations
],
'setup_future_usage' => 'off_session',
'customer' => $customerId,
]);
$output = ['clientSecret' => $paymentIntent->client_secret,];
this is the php page that is called from client.js
checkout.php (containt stripe card element and client.js )
client.js fetch a page called "create.php" that containt the code i mention up
So my question is : It is possible to fetch and create payment intent only when the user has click on the button "purchase" for example ?
Because in your document example (https://stripe.com/docs/payments/quickstart)
your process create a payment intent each time the page is loaded
Our documentation is really meant to just be a starting point - you can leave it as is (and have new payment intents created each time) and just make sure to cancel any dangling incomplete payment intents that are never completed. Alternatively, you could implement something that ties the user's "cart" to the specific payment intent they need to pay for. Instead of creating a new Payment intent each time, you'd see that they already have a Payment Intent tied to their cart and can just use the existing one. This would be something you'd have to implement yourself
Ok gonna dig, but i found curious that stripe do not provide and example that prevent creating a payment each time the page is loaded
and the problem is how to "tie" the user with the payment intent
Our samples are really just meant to cover the very basics - implementing something like that can be done a nunmber of different ways, and it really depends on the needs of your integration
because it is not a website where the user have an account
anybody can go the website and enter his card number without creating an account
so i wonder how to tie the user with the payement intent
is it possible to build a process, where the payment intent is created only if the user click on the purchase button ?
I'm gonna seach, thank for your support
is it possible to build a process, where the payment intent is created only if the user click on the purchase button ?
It would be possible with the Card element, but not the newer Payment Element (this one needs the Payment Intent to be created beforehand)
That would be following this guide: https://stripe.com/docs/payments/accept-card-payments?platform=web&ui=elements
Ok thank you
Just a question : why there is 2 way to collect a payment ( Card element and Payment intent) Whats the difference and purpose of each ?
Do you mean Card element vs Payment element? Or do you really mean card element vs payment intent?
I guess Card element vs Payment element
I think for now i'm using Payement element ( that create payement intent)
Gotcha - so Payment element is very new (just released in the last couple of weeks) and is easier to use if you want to integrate with multiple different payment method types all in one place (for example: this element can collect card information and things like bank information). The Card element is older and only works with cards
Ok , for my need , I will need to on the page to have an input box to collect a payment via bank card, and also an option with google pay or Apple pay
So I have to use one of the method for all those need or I can make a mix by coding ?
If you want Apple + Google Pay you'd need to use the Card element + a payment request button (https://stripe.com/docs/stripe-js/elements/payment-request-button), or the Payment Element can handle both for you.
So i guess its better to do it with "payment element" if its handle everything, can be more simple no ?
Yeah, I'd just suggest you just go with the Payment Request button and then cancel any incomplete Payment Intents you have. It'll be much simpler for you to implement Apple + Google Pay that way
but if I use the method "Payment element" I don't need payment request button, right ? ( but it will create a lot of payement intent each the page is loaded )
Yes - if you use Payment Element you do not need to separately implement the Payment Request Button
Ok thanks i'm gonna read documentation about that, and try that way, thank you