#Janish-PaymentIntent
1 messages · Page 1 of 1 (latest)
pi_3LcNu6BpNvfedyzA1NGX29mV
Are you using Elements to collect the payment details?
no, I have custom form
and if I put the form code of stripe, where stripe js will add elements, that form doesn't appear
What doesn't appear? the elements?
yes, no card number fields are there, no cvv field etc.
Show me your code
Yes
<form id="payment-form">
<div id="payment-element">
<!-- Elements will create form elements here -->
</div>
<button id="submit">Submit</button>
<div id="error-message">
<!-- Display error message to your customers here -->
</div>
</form>
this is form code
I am doing this on ajax call
How did you initialize Stripe.js and mount the elements?
stripe js is enuque in function file of wordpress
and I ahve jQuery so I appended the card details in payment form
You didn't initialize Stripe.js nor create/mount the elements, that's why it's empty.
Please go through this doc, Section 4 Collect payment details tells you how to setup Stripe.js and elements
No problem.
https://stripe.com/docs/payments/payment-intents/migration I'll also recommend this doc, it tells you the different between Charges API and PaymentIntent API
const options = {
clientSecret: clientSecret
};
// Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in step 2
const elements = stripe.elements(options);
// Create and mount the Payment Element
const paymentElement = elements.create('payment');
paymentElement.mount('#payment-element');
stripe.confirmCardPayment(
clientSecret,
{
payment_method: {
card: paymentElement
}
}
).then(function(result) {
alert('22222222222');
alert(result);
if (result.error) {
// Display error.message in your UI.
alert('error');
} else {
alert('success');
// The payment has succeeded
// Display a success message
}
});
Is this the right?
No, you should use stripe.confirmPayment() if you are using payment elements.
Please spend some time to go through the doc first.