#surajkumar8781
1 messages · Page 1 of 1 (latest)
Hi there, I don't think you need to specify a currency when creating a SetupIntent
- You should set the
filedon the payment element, not elements. See https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields
Sorry i didn’t get your point, import {Elements} from '@stripe/react-stripe-js'; we are using Elements.
<Elements stripe={stripePromise} options={{ clientSecret, fields: { billingDetails: 'never' } }}> <CheckoutForm /> </Elements>
I mean the fields isn't for <Elements> component, you should set fields on the <PaymentElement>'s options props.
Ohh thanks its working, i think document has to be updated, it create a confusion.
What is the use of field currency in case of creating SetupIntent through Stripe payment element? If we create a payment element for currency USD can we use it for payment in EUR?.
This way we are finding only relevant payment options so thats why are thinking to use it.
https://stripe.com/docs/js/elements_object/create_without_intent#stripe_elements_no_intent-options-currency are you talking about this field?
Yes
I know it make sense in case of paymentIntents but i would like to know the use case for setupIntent
If you read the doc, it says conditionally required. You don't need to set the currency if the mode is setup
Yes i understand, but it also works for mode setup
so if we pass currency: 'usd' then only us options are visible to US and if we set currency: 'eur only Europe options are visible to us
mean sepa_debit
And can you share you complete code?
For US its US Bank
yes
allow me 1 min
`import {useEffect, useState} from 'react';
import {Elements} from '@stripe/react-stripe-js';
import CheckoutForm from './CheckoutForm'
function Payment(props) {
const { stripePromise } = props;
const [ clientSecret, setClientSecret ] = useState('');
useEffect(() => {
// Create PaymentIntent as soon as the page loads
fetch("/create-payment-intent")
.then((res) => res.json())
.then(({clientSecret}) => setClientSecret(clientSecret));
}, []);
return (
<>
<h1>Payment</h1>
{clientSecret && stripePromise && (
<Elements stripe={stripePromise} options={{ clientSecret,
currency: 'usd',
}}>
<CheckoutForm />
</Elements>
)}
</>
);
}
export default Payment;
`
OK, got it.
So the payment method options to be rendered are based on the currency that you set here. Since you set eur, the Payment Element will display the payment methods that supports eur currency
got it.
we are using subscription lets assume we saved a payment method using currency as EUR but we want to charge in USD is it possible?
If the payment method that you collected doesn't work for USD, then you can't use this payment method for subscription.