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

[Wallet] Apple Pay #3658

Draft
wants to merge 2 commits into
base: add/google-pay-wallet-method
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Changelog ***

= 9.1.0 - xxxx-xx-xx =
* Add - Includes Apple Pay as a new wallet payment method.
* Add - Includes Google Pay as a new wallet payment method.
* Add - Correctly handles charge expired webhook events, setting the order status to failed and adding a note.
* Fix - Allow account creation on checkout, if enabled, when purchasing subscriptions using ECE.
Expand Down
4 changes: 3 additions & 1 deletion client/blocks/upe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Object.entries( paymentMethodsConfig )
return ! [
'link',
'giropay', // Skip giropay as it was deprecated by Jun, 30th 2024.
'google_pay', // Remove Google Pay since it does not need to be passed to Stripe settings.
// Remove Google Pay and Apple Pay since they don't need to be passed to Stripe settings.
'google_pay',
'apple_pay',
].includes( upeName );
} )
.forEach( ( [ upeName, upeConfig ] ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const getStripeElementOptions = () => {
},
},
wallets: {
applePay: 'never',
applePay: paymentMethodsConfig?.apple_pay ? 'auto' : 'never',
googlePay: paymentMethodsConfig?.google_pay ? 'auto' : 'never',
},
};
Expand Down
2 changes: 1 addition & 1 deletion client/classic/upe/deferred-intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jQuery( function ( $ ) {
}
}

// On every page load and on hash change, check to see whether we should display the Voucher (Boleto/Oxxo/Multibanco) or Wallet (Google Pay/CashApp/WeChat Pay) modal.
// On every page load and on hash change, check to see whether we should display the Voucher (Boleto/Oxxo/Multibanco) or Wallet (Google Pay/Apple Pay/CashApp/WeChat Pay) modal.
// Every page load is needed for the Pay for Order page which doesn't trigger the hash change.
maybeConfirmVoucherOrWalletPayment();
$( window ).on( 'hashchange', () => {
Expand Down
2 changes: 1 addition & 1 deletion client/classic/upe/payment-processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function createStripePaymentElement( api, paymentMethodType = null ) {
...getUpeSettings(),
...getDefaultValues(),
wallets: {
applePay: 'never',
applePay: paymentMethodsConfig?.apple_pay ? 'auto' : 'never',
googlePay: paymentMethodsConfig?.google_pay ? 'auto' : 'never',
},
} );
Expand Down
2 changes: 2 additions & 0 deletions client/payment-method-icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import OxxoIcon from './oxxo';
import WechatPayIcon from './wechat-pay';
import CashAppIcon from './cashapp';
import GooglePayIcon from './google-pay';
import ApplePayIcon from './apple-pay';

export default {
alipay: AlipayIcon,
Expand All @@ -38,4 +39,5 @@ export default {
wechat_pay: WechatPayIcon,
cashapp: CashAppIcon,
google_pay: GooglePayIcon,
apple_pay: ApplePayIcon,
};
145 changes: 145 additions & 0 deletions client/payment-methods-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,151 @@ export default {
'ZMW',
],
},
apple_pay: {
id: 'apple_pay',
label: __( 'Apple Pay', 'woocommerce-gateway-stripe' ),
description: __(
'Allow customers to accept Apple Pay in iOS applications in iOS 9 and above, and on the web in Safari starting with iOS 10 or macOS Sierra.',
'woocommerce-gateway-stripe'
),
Icon: icons.apple_pay,
currencies: [
'USD',
'AED',
'AFN',
'ALL',
'AMD',
'ANG',
'AOA',
'ARS',
'AUD',
'AWG',
'AZN',
'BAM',
'BBD',
'BDT',
'BGN',
'BIF',
'BMD',
'BND',
'BOB',
'BRL',
'BSD',
'BWP',
'BYN',
'BZD',
'CAD',
'CDF',
'CHF',
'CLP',
'CNY',
'COP',
'CRC',
'CVE',
'CZK',
'DJF',
'DKK',
'DOP',
'DZD',
'EGP',
'ETB',
'EUR',
'FJD',
'FKP',
'GBP',
'GEL',
'GIP',
'GMD',
'GNF',
'GTQ',
'GYD',
'HKD',
'HNL',
'HTG',
'HUF',
'IDR',
'ILS',
'INR',
'ISK',
'JMD',
'JPY',
'KES',
'KGS',
'KHR',
'KMF',
'KRW',
'KYD',
'KZT',
'LAK',
'LBP',
'LKR',
'LRD',
'LSL',
'MAD',
'MDL',
'MGA',
'MKD',
'MMK',
'MNT',
'MOP',
'MUR',
'MVR',
'MWK',
'MXN',
'MYR',
'MZN',
'NAD',
'NGN',
'NIO',
'NOK',
'NPR',
'NZD',
'PAB',
'PEN',
'PGK',
'PHP',
'PKR',
'PLN',
'PYG',
'QAR',
'RON',
'RSD',
'RUB',
'RWF',
'SAR',
'SBD',
'SCR',
'SEK',
'SGD',
'SHP',
'SLL',
'SOS',
'SRD',
'STD',
'SZL',
'THB',
'TJS',
'TOP',
'TRY',
'TTD',
'TWD',
'TZS',
'UAH',
'UGX',
'UYU',
'UZS',
'VND',
'VUV',
'WST',
'XAF',
'XCD',
'XOF',
'XPF',
'YER',
'ZAR',
'ZMW',
],
},
ideal: {
id: 'ideal',
label: __( 'iDEAL', 'woocommerce-gateway-stripe' ),
Expand Down
2 changes: 2 additions & 0 deletions client/stripe-utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const PAYMENT_METHOD_NAME_AFTERPAY_CLEARPAY = 'stripe_afterpay_clearpay';
export const PAYMENT_METHOD_NAME_WECHAT_PAY = 'stripe_wechat_pay';
export const PAYMENT_METHOD_NAME_CASHAPP = 'stripe_cashapp';
export const PAYMENT_METHOD_NAME_GOOGLE_PAY = 'stripe_google_pay';
export const PAYMENT_METHOD_NAME_APPLE_PAY = 'stripe_apple_pay';

export function getPaymentMethodsConstants() {
return {
Expand All @@ -37,6 +38,7 @@ export function getPaymentMethodsConstants() {
wechat_pay: PAYMENT_METHOD_NAME_WECHAT_PAY,
cashapp: PAYMENT_METHOD_NAME_CASHAPP,
google_pay: PAYMENT_METHOD_NAME_GOOGLE_PAY,
apple_pay: PAYMENT_METHOD_NAME_APPLE_PAY,
};
}

Expand Down
1 change: 1 addition & 0 deletions includes/abstracts/abstract-wc-stripe-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ public function payment_icons() {
'cards' => '<img src="' . WC_STRIPE_PLUGIN_URL . '/assets/images/cards.svg" class="stripe-cards-icon stripe-icon" alt="credit / debit card" />',
WC_Stripe_Payment_Methods::CASHAPP_PAY => '<img src="' . WC_STRIPE_PLUGIN_URL . '/assets/images/cashapp.svg" class="stripe-cashapp-icon stripe-icon" alt="Cash App Pay" />',
WC_Stripe_Payment_Methods::GOOGLE_PAY => '<img src="' . WC_STRIPE_PLUGIN_URL . '/assets/images/google-pay.svg" class="stripe-google-pay-icon stripe-icon" alt="Google Pay" />',
WC_Stripe_Payment_Methods::APPLE_PAY => '<img src="' . WC_STRIPE_PLUGIN_URL . '/assets/images/apple-pay.svg" class="stripe-apple-pay-icon stripe-icon" alt="Apple Pay" />',
]
);
}
Expand Down
2 changes: 2 additions & 0 deletions includes/constants/class-wc-stripe-payment-methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class WC_Stripe_Payment_Methods {
const AFFIRM = 'affirm';
const AFTERPAY_CLEARPAY = 'afterpay_clearpay';
const ALIPAY = 'alipay';
const APPLE_PAY = 'apple_pay';
const BANCONTACT = 'bancontact';
const BOLETO = 'boleto';
const CARD = 'card';
Expand Down Expand Up @@ -56,5 +57,6 @@ class WC_Stripe_Payment_Methods {
self::CASHAPP_PAY,
self::WECHAT_PAY,
self::GOOGLE_PAY,
self::APPLE_PAY,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class WC_Stripe_UPE_Payment_Gateway extends WC_Gateway_Stripe {
WC_Stripe_UPE_Payment_Method_Wechat_Pay::class,
WC_Stripe_UPE_Payment_Method_Cash_App_Pay::class,
WC_Stripe_UPE_Payment_Method_Google_Pay::class,
WC_Stripe_UPE_Payment_Method_Apple_Pay::class,
];

/**
Expand Down Expand Up @@ -2376,7 +2377,7 @@ public function add_payment_method() {
*/
public function filter_wallets_from_available_payment_gateways( $gateways ) {
foreach ( $gateways as $key => $gateway ) {
if ( $gateway instanceof WC_Stripe_UPE_Payment_Method_Google_Pay ) {
if ( $gateway instanceof WC_Stripe_UPE_Payment_Method_Google_Pay || $gateway instanceof WC_Stripe_UPE_Payment_Method_Apple_Pay ) {
unset( $gateways[ $key ] );
}
}
Expand Down Expand Up @@ -2559,7 +2560,7 @@ private function is_refund_request() {
* Depending on the payment method used to process the payment, we may need to redirect the user to a URL for further processing.
*
* - Voucher payments (Boleto or Oxxo or Multibanco) respond with a hash URL so the client JS code can recognize the response, pull out the necessary args and handle the displaying of the voucher.
* - Wallet payments (Google pay, CashApp or WeChat) respond with a hash URL so the client JS code can recognize the response, pull out the necessary args and handle the displaying of the modal.
* - Wallet payments (Google Pay, Apple Pay, CashApp or WeChat) respond with a hash URL so the client JS code can recognize the response, pull out the necessary args and handle the displaying of the modal.
* - Other payment methods like Giropay, iDEAL, Alipay etc require a redirect to a URL provided by Stripe.
* - 3DS Card payments return a hash URL so the client JS code can recognize the response, pull out the necessary PI args and display the 3DS confirmation modal.
*
Expand Down
Loading
Loading