Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect if visitor can make web payments? #13

Open
billythekid opened this issue May 19, 2020 · 3 comments
Open

How to detect if visitor can make web payments? #13

billythekid opened this issue May 19, 2020 · 3 comments

Comments

@billythekid
Copy link

billythekid commented May 19, 2020

Hi all,

Yeah like the title says, is there a way, preferably server side / twig but can be JS if that's the only way, to detect if the current visitor has the capability to use web payments (so not even show the option in the gateway select dropdown if they can't use it)

In one site I have we use a select dropdown for the html form code to be used for each option. if you select the credit card gateway for example you get the sagepay form, finance gives another gateway's form, paypal gives the paypal button and apple pay / google pay gives this plugin's rendered button. With the finance option I don't show the dropdown if the cart isn't "financable" (minimum price etc.) I'd like to do something similar for the web payments option, if the visitor's browser/device doesn't support it, don't give them the option to select it in the first place.

I found the docs for apple pay and the docs for google pay to check if each is supported by the current visitor's browser/device but not sure how this is handled in the plugin already (since I don't actually get a button in a browser that doesn't support it but is that because it doesn't support it (so it's failing) or because that's been checked by the plugin.)

Is there a test we can wrap the template code in to decide whether to show it or not?

@davecosec
Copy link

davecosec commented May 23, 2020

@billythekid there it window.ApplePaySession to check if the session exist for Apple Pay. For Google Pay, I can see the method in the code but it's not accessible to window, unless i'm mistaken so I've had to do a not so nice workaround

@Adamascroft
Copy link

This would be a great feature to have to be able to show a specific section if the button(s) are available.

@davecosec
Copy link

Some of these methods do need to exposed. We need to be able to refresh the button for single page checkouts, (when the user changes their location) and we need to be able to check properly if the user can pay via google pay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants