#mike-willay_confirmation-token-billing-details
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1387754746621726873
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- mike-willay_code, 2 hours ago, 71 messages
Hi
Below is the code for strip initilization
const elements = this.stripe.elements(options);
this.cardNumberElement = elements.create('payment', {
fields: {
billingDetails: {
address: 'never',
},
},
wallets: {
applePay: 'auto',
googlePay: 'auto',
},
paymentMethodOrder: [
'card',
'amazon_pay',
'google_pay',
'klarna',
'affirm',
'afterpay_clearpay',
'crypto',
],
});
const el = this.cardNumberElement;
const { error, confirmationToken } =
await this.stripe.createConfirmationToken({
el,
paymentMethodParams,
});
well, el is not a property of createConfirmationToken. so that explains the error.
but we need to pass the element right
it should be called element: https://docs.stripe.com/js/confirmation_tokens/create_confirmation_token#create_confirmation_token-options-elements
I am taking it's referance from the payment initlisation
can you replace el by elements?
can you console.log the elements variable just before you pass it to createConfirmationToken?
can you share your new createConfirmationToken code?
const elements = this.cardNumberElement;
const { error, confirmationToken } =
await this.stripe.createConfirmationToken({
elements,
paymentMethodParams,
});
why did you do const elements = this.cardNumberElement;?
the elements you need to pass is the original one: const elements = this.stripe.elements(options);
Okay, let me check with that one as well
IntegrationError: You specified "never" for fields.billing_details.address when creating the payment Element, but did not pass params.payment_method_data.billing_details.address.country when calling stripe.createConfirmationToken(). If you opt out of collecting data via the payment Element using the fields option, the data must be passed in when calling stripe.createConfirmationToken().
Now throwing this error
good, so we are making progress, since now the elements is correct passed.
I think the error message you shared is pretty clear and explains how to fix things.
Yes, and it is necessary to calll await elements.submit(); method when user has clicked on pay button when we are perfroming the action from different buttons ?
before calling createConfirmationToken method
when we are perfroming the action from different buttons
what does that mean?
can you explain your flow in more details?
when user click on this button then we calling custom click event, so to proceed with createConfirmationToken method, first we need to call the elements.submit method
which documentation are you following? this one? https://docs.stripe.com/payments/build-a-two-step-confirmation
I am following this migration guide
https://docs.stripe.com/payments/payment-element/migration-ct
got it. here's the full doc about this that I recommend reading and following: https://docs.stripe.com/payments/finalize-payments-on-the-server
still I am not able to get rid of this error
IntegrationError: You specified "never" for fields.billing_details.address when creating the payment Element, but did not pass params.payment_method_data.billing_details.address.country when calling stripe.createConfirmationToken(). If you opt out of collecting data via the payment Element using the fields option, the data must be passed in when calling stripe.createConfirmationToken().
payment_method_data: {
billing_details: {
address: {
city: null,
country: 'US',
line1: null,
line2: null,
postal_code: null,
state: null,
},
},
},
return_url: this.window.location.href,
I am passing this as nill for the address
and while creating the paymetn elements
create('payment', {
fields: {
billingDetails: {
address: 'never',
},
},
I set it to never
the error message tells you the answer:
the data must be passed in when calling stripe.createConfirmationToken().
so you need to pass the full address increateConfirmationToken
if you set address: 'never', then you have to manually pass the address yourself. this is explained here: https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options-fields
We are not collenting any addrees from the user so we don;t need that such details to passed
then don't set address: 'never', and Stripe will only collect the necessary information depending on the payment method selected.
Okay let me check this