#mathew
1 messages · Page 1 of 1 (latest)
var paymentElement = elements.create('payment', {
layout: {
type: 'tabs',
defaultCollapsed: false
},
paymentMethodOrder: allowedPaymentMethods
});
paymentElement.unmount();
paymentElement.mount('#payment-element');
can i set paymentMethodOrder dynamically
var allowedPaymentMethods = ['card'];
if (isGpayorAPay) {
allowedPaymentMethods.push('google_pay', 'apple_pay');
} else {
// Exclude Apple Pay and Google Pay
}
so i only want ot see gpay and applepay based on a condition
that's not how it works, there's no such thing as google_pay or apple_pay payment methods, they are included as part of card.
only want ot see gpay and applepay based on a condition
you would use thewalletsoption to control the appearance of those : https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-wallets
oh okk
var paymentElement = elements.create('payment', {
layout: {
type: 'tabs',
defaultCollapsed: false
},
wallets:{
applePay:isGpayorAPay?'auto':'never',
googlePay: isGpayorAPay ? 'auto' : 'never'
}
@,paymentMethodOrder: allowedPaymentMethods@
});
so it should work with this
possibly, did you try it out?
i did but weirdly it displays inconsistently
what does that mean exactly?
sometimes it shows me card only sometimes even if isGpayorAPay =true
let me reconfirm this anyways
it will only show the buttons if you're in a browser that supports them and you saved cards in your Google/Apple account, and if the page is hosted on a https URL. There can also be 'rate limiting' from the browser function involved in displaying the buttons if you load the same page very often
currently im trying this in test mode, will it be same issue with live mode
even though im passing the wallets: it doesnt load on the screen , i need to refresh screen couple of times to get it displayed
it should just work, if you have concerns maybe ask a colleague to load your payment page fresh to confirm.