justinbeaty / module-gene-braintree

OpenMage compatible fork of Gene_Braintree module
7 stars 5 forks source link

GooglePay doesn't work, getting JS Error: Cannot read properties of undefined #4

Closed plumrocket closed 2 years ago

plumrocket commented 2 years ago

Hello Justin,

Thanks for updating the Braintree extension! We have installed it on OpenMage and tried enabling Google Pay, but always get error messages.

Here is screenshots: image

image

image

Openmage version: 20.0.13

Error Message:

TypeError: Cannot read properties of undefined (reading 'submitCheckout') at vzero-googlepay.min.js?v=1629405722:formatted:96

      o.loadPaymentData(t).then(function(t) {
          return t,
          n.parseResponse(t)
      }).then(function(t) {
          $("googlepay-payment-nonce").value = t.nonce,
          this.vzero.integration.submitCheckout()
      }
      .bind(this)).catch(function(t) {
          console.error(t)
      })

Do you have any idea what could be wrong? Thanks!

justinbeaty commented 2 years ago

Hi @plumrocket,

I haven’t used Google Pay, but the first thing I would check is if the original Gene extension also throws this error or not.

You can get the original code from the very first commit in this repo, or flyingmana has shared it once on the OpenMage Discord. There is also an older version in the OpenMage module fostering repos.

I did not change any of the JS in the module, because I’m actually using OpenMage as a headless cart with a Vue frontend, so I use the latest Braintree JS lib there. So technically I haven’t tested this repo with the stock frontend; the main changes I made were updating the Braintree PHP SDK.

I’m away from my computer today, but I’ll look at the error more closely this weekend.

plumrocket commented 2 years ago

Hi @justinbeaty. Thanks for a quick response :)

Ok, I guess we will try to debug a little more tomorrow. If you get a chance to look at it too, we will appreciate any help.

Happy Holidays! Alex

justinbeaty commented 2 years ago

@plumrocket I did some light digging in the JS source code of this module, and one possible issue might be if you have the credit card payment method turned off. I am not positive that is the problem, but I figured I'd ask before digging any further.

plumrocket commented 2 years ago

Hey Justin! That was an excellent hint! I just tried enabling the credit card payments in the backend, and it worked like a charm :)! Thanks a lot for your help! Alex

justinbeaty commented 2 years ago

@plumrocket Excellent! I'm not sure why it's required, but I noticed that the this.vzero.integration object only is initialized when the Hosted Fields form is there, so it was just a guess!

Glad you got it working.

KeenEthika commented 1 year ago

Hey Justin! That was an excellent hint! I just tried enabling the credit card payments in the backend, and it worked like a charm :)! Thanks a lot for your help! Alex

How and where did you turn on the "Credit Card Payment"? Do you remember?

justinbeaty commented 1 year ago

@KeenEthika It is at:

System > Configuration > Payment Methods Braintree Payments - Credit Card

You must set Enabled to Yes.