braintree / braintree-web-drop-in

Braintree Drop-in for the web
MIT License
200 stars 127 forks source link

GooglePay Button Doesn't Work In Sandbox or Production #896

Closed nickjohnson closed 1 year ago

nickjohnson commented 1 year ago

We can't get the GooglePay button to work in the UI in sandbox or production with a google merchant id. It acts like it wants to but just wont.

Here is a 2 min screen recording demonstrating the issue:

https://v.usetapes.com/3NxyxkdYSs

Staging Environment: https://demo.pigeonpay.io/plan/subscribe/hreqm?trim=1

Production Environment: https://min.skiinfo.no/plan/subscribe/uhoaj?trim=1

nickjohnson commented 1 year ago

An addendum the original issue. When I choose PayPal first, which works, then go to GooglePay and select a payment option, then it works. See this demonstrated here:

https://v.usetapes.com/ywinJGB19U

nickjohnson commented 1 year ago

I included some event feedback in the console to aid in troubleshooting the issue.

https://demo.pigeonpay.io/plan/subscribe/hreqm?trim=1

https://v.usetapes.com/jQII18Q46d

jplukarski commented 1 year ago

Hey @nickjohnson , thanks for your patience while we looked into your issue, as well as proactively providing a test site and video.

We are able to reproduce the behavior on your test site, but not in our own test integration. Moreover, we have not received widespread report of this issue with GooglePay in the Drop-in.

After inspecting your site, I believe the issue might lie in this codeblock:

gpay

It looks like you are listening for a change in the active view of the Drop-In and using JQuery to reset the paymentMethodRequestable the form to paymentMethodRequestable: false on this line:

form.data('paymentMethodRequestable',false);

When we get a response back from Google with a tokenized payment method, we switch the payment view from googlePay to methods, so that block is executing even after a successful response from Google. I can suggest looking at refactoring that block to not reset the paymentMethodRequestable to false when we get a successful response back from Google.

I hope that is useful information to help you troubleshoot your integration. Since this is likely not a bug with the Drop-In, we are going to close out this issue. If you continue running into errors when integrating with the Drop-in, please feel free to reach out to our Support team to help you with your integration -> https://developer.paypal.com/braintree/help/. Also, feel free to open up a new issue if you suspect you have run into a bug with the Drop-In.

Thanks!

nickjohnson commented 1 year ago

Thanks for pointing that out. While that was not the issue directly, it did clue me in on a path that provided a fix. I put the updateConfiguration() method there because we need to update the price based on option changes on the page. Setting the paymentMethodRequestable to false told our form not to allow for submitting until all required information is set. That worked correctly. But I added some conditions that prevented the updateConfiguration() from running after picking a payment method. That resolved the issue.