Automattic / woocommerce-payments

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

[ECE] Apple Pay session cannot be created for Express Checkout Element unless domain is registered with new endpoint #9098

Closed ricardo closed 1 month ago

ricardo commented 1 month ago

Describe the bug

When clicking the Apple Pay button with the _wcpay_feature_stripe_ece option set to 1, the Apple Pay dialog closes and an error is thrown in the console:

Could not create Apple Pay session. Please make sure you have registered this Stripe account. For more information, see https://stripe.com/docs/apple-pay#web.

This is because we need to register the domain first with this new endpoint: https://api.stripe.com/v1/payment_method_domains (src).

We might want to consider setting applePay to auto instead of always when rendering the button to make sure it's not available in case the domain verification has failed or the button shouldn't be displayed for some reason.

To fix this, we can update or add a new endpoint to the server and trigger domain registrations when WooPayments gets updated: https://github.com/Automattic/woocommerce-payments/blob/ff072f5f1e28be9c7667d1c484d62f93b629d2c7/includes/class-wc-payments-apple-pay-registration.php#L83

To Reproduce

  1. Enable the ECE flag.
  2. Change your domain with JT/ngrok.
  3. As a shopper on Safari, try to checkout with Apple Pay.
  4. Notice the Apple Pay modal opens up, but closes shortly after.
bborman22 commented 1 month ago

Hey team! Please add your planning poker estimate with Zenhub @rafaelzaleski @ricardo

bborman22 commented 1 month ago

Just noting that as part of this issue, let's also remove the now unnecessary limitation on Apple Pay registration in test mode. This way it's easier to test Apple Pay going forward.