#jamie_97274
1 messages ยท Page 1 of 1 (latest)
Hello
Hi Bismarck, think you helped me in the past
Hopefully I was helpful ๐
got all issues sorted out with iDeal and Card subscriptions, just not sure about Apple pay/Google wallet now because they seem to work quite different.
For iDeal I am making setup intents and turning those into payment intent, for card going straight to a payment intent.
Before we dive into your question, is there a reason you are implementing these separately instead of using Payment Element?
we have a custom design with our own payment method select box, and also we don't have a customer yet on this form so I needed some work arounds basically
Okay fair enough
So with Apple / Google Pay I'd recommend using the Express Checkout Element: https://stripe.com/docs/elements/express-checkout-element
I can not use express checkout
This is actually our newer Element that is replacing Payment Request Button
No?
Tell me more
oh wait sorry I thought that was your Checkout page
as in it goes a stripe page
express checkout is nothing like https://stripe.com/docs/payments/checkout
?
Nope
Express Checkout is an Element that will specifically show Google Pay/Apple Pay/Link/Paypal (if supported for your account) or any subset of those.
And it does embed right in your site (no redirect)
I see it mounts just like an iDeal select box would
however as we have our own custom payment method box, they can for example select Google Wallet or Apple Pay, is there a way to mount only Google Wallet
for example
const applePayElement = elements.create('applePay', options)
const googleWalletElement = elements.create('googleWallet', options)
separated, so it's not just a one-all situation for both
Hmm would you not just want to mount the relevant button based on what they select?
Like yes, you can just show one of the buttons
yes that's exactly what I want, I want to mount googlePay if they select google pay in our own select box
Gotcha then yep you use wallets: https://stripe.com/docs/js/elements_object/create_express_checkout_element#express_checkout_element_create-options-wallets
I just don't see how I can differentiate in the docs you sent
I see thanks!!
one more question
are you sure this works for subscriptions too?
(I spent a lot of time on the wrong iDeal setup for subscriptions last time)
in the end I had to create a setupintent, get their sepa_debit card from that and create a payment intent from there
Yep it works fine for Subscriptions since this just generates a Card PaymentMethod
In the part of the guide that discusses "Create a PaymentIntent" (https://stripe.com/docs/elements/express-checkout-element/accept-a-payment#create-pi) you would just create a Subscription instead
And then pass the latest_invoice.client_secret back to the frontend
great yeah I am doing that with card subscriptions
thank you for now putting me on the right track - I will be doing some testing
You must use HTTPS to test this locally? No Google pay element is mounted or appears
unlike iDeal you can use http?
Yep
These wallets require HTTPS
And you need a live card in your wallet as well
And domain registration for Apple Pay
"And you need a live card in your wallet as well"
Not for the actual element to show up I imagine as no wallet has been selected yet?
Once you mount it
The button will only show if there is a live card in the customer's wallet
You can also use the ready Event (https://stripe.com/docs/elements/express-checkout-element/accept-a-payment#ready-event) to get info on this
And then potentially show an error message or something if they don't have a card in their wallet
I am a bit confused by what you mean about the live card, because for example on a macbook, you don't know yet if I have a wallet in my apple pay or not, it should redirect or active the Apple pay to see that surely
you only get that info post button click?
The way our Elements work with these wallets is that the actual wallet button would only show up if there is a live card stored in the customer's relevant wallet.
So for instance if you are going to use your own button for your customer to indicate that they want to pay with Google Pay, but then they don't have a card in their Google Pay wallet, when they click the button and you create/mount Express Checkout Element, nothing is going to render because there is no live card stored.
Let me know if that doesn't clarify things.
The most typical flow is you would just create/mount the Express Checkout Element in your payment flow without the customer indicating they want to pay with this method. It would just be an option that would show up if they have a card stored
No worries, I got the Google Wallet button showing up now, and on click it asks me to login, so it doesn't know yet if I have a wallet or not
this is the functionality I was looking for, so it's all working out
one last question for today I promise
Apple pay, works the same as Google wallet practically? As it is a bit harder to test locally, can I somewhat assume that if Google pay is working as expected in terms of creating the payment intent etc and saving the card, Apple pay will also?
Yes, but you do have to make sure your domain is registered for Apple Pay
Otherwise the flow is the same
I'd definitely still recommend testing before you go live
yeah for sure just for me locally for now
thank you, have a good evening I will leave you for now
You too
(Sorry you are totally right and only Payment Request Button doesn't show the wallet unless you have a live card -- this was changed for Express Checkout Element and I forgot ๐ )
Sorry Bismarck but I do have another query
if you can still read this thread?
It says
"IntegrationError: Can only create one Element of type expressCheckout."
I now have
this.elementGoogleWallet = this.elements.create('expressCheckout', optionsGoogleWalletElement)
this.elementApplePay = this.elements.create('expressCheckout', optionsApplePayElement)
so two elements created one for Google Wallet and one for Apple Pay
both with different options
You would have to create multiple instances of Stripe.JS if you want to create two different Elements
But why do you want to do this exactly?
You can show both in one instance here
I do want one elements, I just want to mount only Google Wallet or only Apple Pay depending on our custom select box
so I never want to show both, I always only want to show one
Select box:
iDeal
Card
Google
Apple
on that select box I mount iDeal, or Card, or Google etc
Yeah so you just need to do this.elementWallet = this.elements.create('expressCheckout', optionsWallet)
And you specify which wallet via your optionsWallet variable
yes I get that part, but then the expressCheckout has already been created
I need to switch dynamically between the both, so in my case I already created the card and iDeal element. but I simply mount the relevant one based on the select box
like so:
if (method === 'ideal') this.elementIdeal.mount('#payment-element-ideal');
if (method === 'card') this.elementCard.mount('#payment-element-card');
if (method === 'google') this.elementGoogleWallet.mount('#payment-element-google');
if (method === 'apple') this.elementApplePay.mount('#payment-element-apple');
You mean if they initially select Google Pay but then want to use Apple Pay?
exactly yes
Gotcha
Then I believe what you want to do is destroy that Express Checkout Element using https://stripe.com/docs/js/element/other_methods/destroy and then recreate it.
The other option would be to intialize Stripe.JS twice here and then use the different instances to create different Express Checkout Element instances
And mount/unmount the one that you are using / not using