Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
173 stars 69 forks source link

Merchants occasionally cannot accept payments via Google Pay while in test mode #4083

Open csmcneill opened 2 years ago

csmcneill commented 2 years ago

Describe the bug

Occasionally, if a merchant attempts to test a purchase via Google Pay, they are unable to, because of the following console error:

DEVELOPER_ERROR in loadPaymentData: Invalid stripe:publishableKey for current environment. Make sure you are using Stripe's test key.

To Reproduce

I have been unable to reproduce intentionally. If you attempt to make a purchase on my test site using Google Pay, you can reproduce the issue: https://justfortestingwcpay.com/

Login credentials for testing on this site can be found in p1648671585459649-slack-C7U3Y3VMY

Screenshots

Markup on 2022-04-04 at 10:20:40

Markup on 2022-04-04 at 10:21:12

Expected behavior

Merchants should be able to test Google Pay via WCPay without encountering this issue.

Desktop (please complete the following information):

Additional context

Affected ticket: 4902883-zd-woothemes

Recent request: p1648671585459649-slack-C7U3Y3VMY

Previous incidents where this issue has occurred:

jessy-p commented 2 years ago

Looks like this is fixed now p1649090720690789-slack-CGGCLBN58, so closing the issue

csmcneill commented 2 years ago

@jessy-p Thanks for sharing! Is there anything that the user needs to do to remedy this issue?

When I test this on cmtestwoo.wpcomstaging.com, I still encounter the error:

Markup on 2022-04-07 at 10:28:29

I've tried disabling and re-enabling test mode, disabling and re-enabling express checkouts, flushing the cache via CLI, and clearing the WCPay account cache without success.

jessy-p commented 2 years ago

Hi @csmcneill, Thanks for reporting this issue. While the issue three days ago affected all test mode requests and has been resolved, there is still an older issue that affected Google Pay checkout using live accounts in test mode, you can read more about it here - p1649090720690789-slack-CGGCLBN58

csmcneill commented 1 year ago

I encountered this issue again when testing an Apple Pay issue in 5713486-zen.

I could also reproduce the issue on justfortestingwcpay.com and another HE could reproduce the issue on wooooooo.mystagingwebsite.com, but another HE couldn't reproduce the issue on their site with a live account in test mode.

Further discussion in p1668561282349669-slack-C3NCP7ZJ6

Same console error:

DEVELOPER_ERROR in loadPaymentData: Invalid stripe:publishableKey for current environment. Make sure you are using Stripe's test key.
F @ pay.js:130

Reopening.

thracefulton commented 1 year ago

Another instance of the same issue in 5782069-zen.

haszari commented 1 year ago

DEVELOPER_ERROR in loadPaymentData: Invalid stripe:publishableKey for current environment. Make sure you are using Stripe's test key.

This error message looks like a config error. The error is saying that the API / Stripe key passed by the site is a production one, and this doesn't match the site being in test mode. Maybe the merchant needs to reconnect in some way? As I understand in WCPay we don't have a UI for specifying keys, this is handled by onboarding => connection process.

Perhaps this is a caching issue. The site may have recently switch from live to test (or vice versa) and WCPay is using the wrong key:

https://github.com/Automattic/woocommerce-payments/blob/c339ae2a3a3563823e020b284ebe6646f85550d6/includes/class-wc-payments-account.php#L114-L126

haszari commented 1 year ago

According to Pc2DNy-3z-p2, this falls in Fusion @anu-rock. Tagging as a part of Gamma Porter duties PcreKM-yM-p2.

Tagging in @anu-rock – is this something Fusion can investigate?

Next steps

csmcneill commented 1 year ago

It's worth noting that this doesn't affect all WCPay accounts.

I can reproduce this consistently on my test site, which uses a live account (but stays in test mode). If needed, I can provide access to the site @anu-rock

sverleis commented 1 year ago

Can also replicate this on a live test site, whereas it works without issues on a site that is in dev mode. Happy to provide access if needed.

anu-rock commented 1 year ago

@haszari and @csmcneill - Thanks for your inputs. I've added this issue to our backlog. We might be able to look into it this week. Related thread - p1683012879607679/1649090720.690789-slack-CGGCLBN58.

aheckler commented 1 year ago

I was trying to update our Google Pay testing docs per this request:

p1678420538296579-slack-CSP74N77C

However, I ran into the same error eventually on my own test site. :( I'm not sure how I (or possibly any merchant?) can test Google Pay right now.

Notably, one thing I don't see in this thread is a mention of Google's doc here:

https://developers.google.com/pay/api/android/guides/resources/test-card-suite

... which instructs you to join a special Google Group. The effect of that is seeing their test cards in the Google Pay modal instead of actual cards:

Screenshot taken on 2023-05-23 at 10 54 08 UTC

Sadly, "purchasing" with the test card does not yield a different result. I get the same error.

So TLDR: it's still unclear whether any live merchants can test Google Pay with WC Pay in test mode, but I suspect they won't be able to?

aheckler commented 1 year ago

This bug came up in this thread: pe2Jlk-VR-p2#comment-1175 where Google has been giving us some feedback on our Google Pay doc for WC Pay.

They asked us to mention the test cards in the doc, but frankly if A) I can't really verify how testing it is supposed to work (due to this bug) and B) I suspect no actual live merchants can actually test Google Pay, then there's not much use in acting on their feedback.

sverleis commented 1 year ago

New instance: 6349311-zen.

Brianmitchtay commented 1 year ago

Seeing this again in 6781666-zen

Brianmitchtay commented 1 year ago

Now seeing this issue on my testing site as well. Very vexing to try and debug anything with express payments while issues like these linger.

Brianmitchtay commented 1 year ago

Another instance 6815123-zen

simplysaru commented 11 months ago

Another user with the same error here

battouly commented 11 months ago

Another case here: 7132135-zen

csmcneill commented 10 months ago

After some discussion with @mordeth, it seems as though reproducing this issue likely requires using a live account that is in test mode. When I attempted to test this while in dev mode, I was unable to reproduce.

mordeth commented 10 months ago

I investigated and can confirm the error is not happening due to cached live keys. I'm looking for possible limitations of test keys used for Google Pay. However, Google Pay is working as expected with test accounts and dev-test keys.

More context: p1698144503463069-slack-C9976E5MJ

mordeth commented 10 months ago

There is a limitation that requires live accounts to be internally connected to a test mode in order to use test keys. There is an ongoing discussion on how to proceed with that issue.

More context: p1698349022422829/1698144503.463069-slack-C9976E5MJ

cc @frosso

geektzu commented 10 months ago

When we were onboarding WooPayments with Joola, both live test and dev accounts did not work for Google Pay.

shaunkuschel commented 10 months ago

Received another report of this on 7238008-zen.

mordeth commented 10 months ago

The issue is blocked until a lasting solution to address the limitation of Google Pay with test keys becomes available.

More context: paJDYF-bdT-p2

frosso commented 10 months ago

I asked the Stripe team for additional details p1699442127812389/1698144503.463069-slack-C9976E5MJ

pierorocca commented 10 months ago

To recap , the core problems stems from two issues:

  1. WooPayments concept of Test (in Live mode) differs from Stripe's Test mode (equals Woo's dev mode).
  2. Merchants do not have to create a Stripe Test account. If they do, they must go through two onboarding flows repeating the exact same information.

For merchants that only create a Live Stripe account and attempt to test Google Pay in Woo's Test mode, there's a key mismatch as there's no Stripe Test account and the testing fails.

The short term workaround is that merchants must create a Stripe Test account in dev_mode

The long term fix, that improves the UX, is for Stripe to automatically create a Test account whenever a new Live account is created. I suspect this would require some WooPayments code changes once Stripe builds the feature.

pierorocca commented 10 months ago

Stripe answer to if this same set of circumstances would impact Apple Pay:

The same issue that affects GPay when there’s no Stripe Test account, does that also impact Apple Pay?

Luckily, no. Apple's integration implicitly understands that if an account is connected to a platform in live mode, the platform will have access to test mode as well on that connected account. Google is different in this case.

pierorocca commented 8 months ago

Noting for @elizaan36 that the problem statement noted here https://github.com/Automattic/woocommerce-payments/issues/4083#issuecomment-1813374722, is a good candidate for consideration in the merchant settings design work, and overall how we approach setting and communicating Test Mode vs Dev Mode in the merchant setting UI. It's a bit scattered currently and the topic is complex.

cc @vladolaru

vladolaru commented 8 months ago

For context, we are changing "dev mode" to "sandbox mode" everywhere: https://github.com/Automattic/woocommerce-payments/pull/8004 to make more clear what is it about and letting test mode mean "live account in test mode".