#bilalahmer
1 messages · Page 1 of 1 (latest)
Hi! Let me help you with this.
Could you please share the frontend code related to this?
Hi, Yeah sure.
initStripe() { const options = { clientSecret: this.intent, automatic_payment_methods: { enabled: true, }, appearance: {/*...*/}, }; this.elements = this.stripe.elements(options); const paymentElement = this.elements.create('payment'); paymentElement.mount('#payment-element'); },
async setCreditCard(e) { e.preventDefault(); const {error} = await this.stripe.confirmSetup({ //Elementsinstance that was used to create the Payment Element elements: this.elements, redirect: 'if_required', confirmParams: { } }); const messageContainer = document.querySelector('#error-message'); if (error) { messageContainer.textContent = error.message; } else { messageContainer.textContent = 'Payment method successfully added.' } },
Is this a card Setup?
Yes.
So from here I'm not sure how to pass the correct amount on the popup page(snap shared above) ?
Do we have a separate api for that or I'm missing something ?
If it's a Setup there's no amount, so it's expected. With SetupIntent you are saving the payment method info to be used for later charges. But at the moment of collection there's nothing to pay, therefore there's no amount.
Yes it is with SetupIntent .
Stripe::SetupIntent.create({customer: current_user.stripe_id})
So do i need to pass something here ☝️ ?
You can't set an amount on SetupIntent.
So were can i set it ? To show it on the popup
"show it", what do you mean by "it" in this context?
amount*
When you are just setting up a card, there's no money movement involved. So you can't set any amount anywhere. https://stripe.com/docs/payments/save-and-reuse?platform=web
If you want to charge your customer right away, you could use PaymentIntents instead: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
In the picture I shared above it shows 0 total right ?
All I'm asking how can I change it ? I want to show there my order total price.
You can't because it's a card setup. It will always be $0.
So what do you recommend how can I achieve it ?
As I mentioned earlier, if you want to charge your customer right away, you could use PaymentIntent instead: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
Please, let me know if you have any other questions.
I'm having a look will let you in few minutes, thank you.