#Janish-PaymentIntent

1 messages · Page 1 of 1 (latest)

tawdry steppe
#

Hi there, can you copy and paste the PaymentIntent ID here?

tulip wren
#

pi_3LcNu6BpNvfedyzA1NGX29mV

tawdry steppe
#

Are you using Elements to collect the payment details?

tulip wren
#

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

tawdry steppe
#

What doesn't appear? the elements?

tulip wren
#

yes, no card number fields are there, no cvv field etc.

tawdry steppe
#

Show me your code

tulip wren
#

I just get the submit button.

#

js code?

tawdry steppe
#

Yes

tulip wren
#

<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

tawdry steppe
#

How did you initialize Stripe.js and mount the elements?

tulip wren
#

so paymentintent is created on ajax success and then the rest

#

below is the code

tulip wren
#

and I ahve jQuery so I appended the card details in payment form

tawdry steppe
#

You didn't initialize Stripe.js nor create/mount the elements, that's why it's empty.

tulip wren
#

How can I do so.

#

I have reffered docs already, I am not getting it

tawdry steppe
#

Please go through this doc, Section 4 Collect payment details tells you how to setup Stripe.js and elements

tulip wren
#

ok, I'll check

#

thank you

tawdry steppe
#

No problem.

tulip wren
#

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?

tawdry steppe
#

No, you should use stripe.confirmPayment() if you are using payment elements.

#

Please spend some time to go through the doc first.

tulip wren
#

I just need to change this in js, right?

#

no updates in php code or in html code of form?

tawdry steppe
#

In your server side (e.g., PHP), you need to change the Charges API to PaymentIntents API (See the doc I sent earlier).

#

I don't think there'll be much change to your html form.