#jitendra_code

1 messages ¡ Page 1 of 1 (latest)

shy pelicanBOT
#

👋 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/1399720578918908076

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

violet dome
#

how can i setup conditional payment methods? when customer first time purchase then i want only card option but if he is already client and try to second purchase then want card and SEPA both as payment method
There is no built feature for this in Stripe APIs. You need to do this check before initializing the PaymentElement..

shy pelicanBOT
violet dome
#

You check if the customer have an existing Subscription or not

near hollow
#

how can i check before initiate payment element?

wide moat
#

hi there!

near hollow
#

<Elements> can i?

#

now we don't have any subscription feature

wide moat
#

I don't understand your question, sorry.

near hollow
#

import {useStripe, useElements, PaymentElement} from '@stripe/react-stripe-js';
const elements = useElements();
const {error, paymentMethod} = await stripe.createPaymentMethod({elements});
this API returning payment methods. should i setup anything in elements so it will return only requird payment methofs?

wide moat
#

I don't understand sorry. what do you mean by "required payment method"?

near hollow
#

i mean card or sepa

wide moat
#

can you explain in a full paragraph exactly what you are trying to do?

near hollow
#

i am using @stripe/react-stripe-js and @stripe/stripe-js
i did implementation based on https://docs.stripe.com/sdks/stripejs-react#setup guideline
i am using custom checkout page by Stripe
by default when checkout screen load its showing Card and SEPA as payment options
i want them conditionally in some cased i need only Card and in some cases card and sepa both
is there any way i can show/hide payment methods?

Learn about React components for Stripe.js and Stripe Elements.

wide moat
near hollow
#

i am not initializing any checkout sessions

wide moat
#

you said

i am using custom checkout

#

so what are you using? PaymentIntent?

near hollow
#

i think i find solution

#

when we create <Elements stripe={stripeKey} options={options} /> at that time we can pass options array if paymentMethodTypes

import {Elements} from "@stripe/react-stripe-js";
const [options, setOptions] = useState({
mode: 'payment',
currency: 'eur',
locale: language,
setupFutureUsage: 'off_session',
paymentMethodCreation: 'manual',
appearance: {
theme: 'stripe',
},
paymentMethodTypes: ['card','sepa_debit']
})

#

can you please tell me what's value for google pay and apple pay i tried google_pay and apple_pay but its not working

wide moat
#

oh, you are using the defered intent flow? in this case yes you can use paymentMethodTypes on the Payment Element

#

can you please tell me what's value for google pay and apple pay i tried google_pay and apple_pay but its not working
there isn't a value for Apple/Google Pay. they are automatically included when you use card.

near hollow
#

ok then how can i test it?

wide moat
#

test what?

near hollow
#

Apple/Google pay

#

when i open its not showing to pay via apple/google pay

wide moat