#supriya
1 messages · Page 1 of 1 (latest)
Hi there, how can I help?
I have one question if i am using const paymentElement = elements.create("card", paymentElementOptions);
paymentElement.mount("#payment-element");
i am able to create the payment method id
but layout will be comming like :
Is there a public URL that I can visit ane reproduce the problem?
I want this design instaed of above one
and need to created payment method UI side and need to send that id to Server side
Jack ,can you help me on that
Okay ,Then while creating the payment method how i need to send the all card elements
const result = await stripe.createPaymentMethod({
type: 'card',
** card: paymentElement,**
billing_details: {
// Include any additional collected billing details.
name: 'Jenny Rosen',
},
})
You just need to pass any one of the elements
I tried if i pass cardnumber element card number field only showing
can you share me the one example with multple card elements
Can you show me your code?
const paymentElement = elements.create("cardExpiryElement ", paymentElementOptions);
paymentElement.mount("#payment-element");
const btnsubmit = document.getElementById('submit');
btnsubmit.addEventListener('click', async (event) => {
// We don't want to let default form submission happen here,
// which would refresh the page.
event.preventDefault();
const result = await stripe.createPaymentMethod({
type: 'card',
card: paymentElement,
billing_details: {
// Include any additional collected billing details.
name: 'Jenny Rosen',
},
})
/*return result.paymentMethod.id;*/
//stripePaymentMethodHandler(result);
});
are you using paymentElement ?
Instaed of payment element I have to use card element ?
Yes
Okay
Can you please provide the payment method code in javascript if i am using like cardexpiry,cardCvc
this is create the card element
but my question was how to send the card elements while creating the payment method
As I said before, you just need to replace paymentElement with cardNumberElement in your code
Give me moment i am checking
same like as you suggest
const cardElement = elements.create("cardNumber ", paymentElementOptions);
cardElement.mount("#card-element");
const btnsubmit = document.getElementById('submit');
btnsubmit.addEventListener('click', async (event) => {
// We don't want to let default form submission happen here,
// which would refresh the page.
event.preventDefault();
const result = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
billing_details: {
// Include any additional collected billing details.
name: 'Jenny Rosen',
},
})
I am using like this
I am getting this error :A valid Element name must be provided. Valid Elements are:
card, cardNumber, cardExpiry, cardCvc, postalCode, paymentRequestButton, iban, idealBank, p24Bank, auBankAccount, fpxBank, affirmMessage, afterpayClearpayMessage, paymentMethodMessaging; you passed: cardNumber .
elements.create("cardNumber ", there's an extra space after cardNumber, you should remove it
Okay
if i use like this i got this error
Uncaught (in promise) IntegrationError: The selector you specified (#card-element) applies to no DOM elements that are currently on the page.
Make sure the element exists on the page before calling mount().
That error, means that there is no element in your page that has #card-element as an Id