#daydreamix
1 messages · Page 1 of 1 (latest)
var stripe = Stripe(stripe_data.public);
const elements = stripe.elements();
var element = document.querySelector("#card-element");
var form, buttons_element;
if (element) {
var card = elements.create('card');
form = element.closest('form[data-type="form"]');
buttons_element = form.querySelector("#payment-request-button");
card.mount('#card-element');
}```
I do use PaymentElement.
What is the best practice for creating payment intents? User experience is bad when I create it after user has finally gone through adding their email, shipping details and then finally select credit card it then loads (creating a payment intent) and then renders the credit card form.
But is it right to create payment intents earlier even if a user ends up not officially paying and then there is just a payment intent sitting in stripe?
Ideally I would have the stripe form ready when a user clicks credit card so they can immediately enter vs having to wait till it loads.
This is the Card Element iirc
Card Element is older and nowsaday we recommend PaymentElement over https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
Loading state
It's fine to create PaymentIntent beforehand, and leave it if customer decide to not pay. It's an "intent" eventually
Rendered
Oh this is PaymentElement indeed
It won't, but it can accept an existing customer id
What are the requirements to creating a payment intent?
Just a few simple and basic information like amount, currency etc. I would recommend taking a look at this
OK thanks! Gonna rework my checkout. ❤️