@@ -84,7 +85,7 @@ describe( 'ExpressCheckout', () => {
} );
it( 'has the correct href links to the express checkout settings pages', async () => {
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'link' ] ] );
@@ -112,7 +113,7 @@ describe( 'ExpressCheckout', () => {
} );
it( 'hide link payment if card payment method is inactive', async () => {
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'link' ] ] );
@@ -126,7 +127,7 @@ describe( 'ExpressCheckout', () => {
} );
it( 'show link payment if card payment method is active', async () => {
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'link' ] ] );
@@ -140,7 +141,7 @@ describe( 'ExpressCheckout', () => {
} );
it( 'test stripe link checkbox checked', async () => {
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'link' ] ] );
@@ -154,7 +155,7 @@ describe( 'ExpressCheckout', () => {
} );
it( 'test stripe link checkbox not checked', async () => {
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card' ] ] );
@@ -172,7 +173,7 @@ describe( 'ExpressCheckout', () => {
useWooPayEnabledSettings.mockReturnValue(
getMockWooPayEnabledSettings( false, updateIsWooPayEnabledHandler )
);
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'link' ] ] );
@@ -200,7 +201,7 @@ describe( 'ExpressCheckout', () => {
useWooPayEnabledSettings.mockReturnValue(
getMockWooPayEnabledSettings( false, updateIsWooPayEnabledHandler )
);
- const context = { featureFlags: { woopay: true } };
+ const context = { accountStatus: {}, featureFlags: { woopay: true } };
useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'link' ] ] );
diff --git a/client/settings/google-pay-test-mode-compatibility-notice.tsx b/client/settings/google-pay-test-mode-compatibility-notice.tsx
new file mode 100644
index 00000000000..00c02220350
--- /dev/null
+++ b/client/settings/google-pay-test-mode-compatibility-notice.tsx
@@ -0,0 +1,52 @@
+/**
+ * External dependencies
+ */
+import { __ } from '@wordpress/i18n';
+import { ExternalLink } from '@wordpress/components';
+import interpolateComponents from '@automattic/interpolate-components';
+import React, { useContext } from 'react';
+
+/**
+ * Internal dependencies
+ */
+import { usePaymentRequestEnabledSettings, useTestMode } from 'wcpay/data';
+import InlineNotice from 'wcpay/components/inline-notice';
+import WCPaySettingsContext from 'wcpay/settings/wcpay-settings-context';
+
+const GooglePayTestModeCompatibilityNotice = () => {
+ const [ isTestModeEnabled ] = useTestMode();
+ const [ isPaymentRequestEnabled ] = usePaymentRequestEnabledSettings();
+ const {
+ accountStatus: { isLive: isLiveAccount },
+ } = useContext( WCPaySettingsContext );
+
+ if ( ! isLiveAccount ) {
+ return null;
+ }
+
+ if ( ! isTestModeEnabled ) {
+ return null;
+ }
+
+ if ( ! isPaymentRequestEnabled ) {
+ return null;
+ }
+
+ return (
+
+ { interpolateComponents( {
+ mixedString: __(
+ 'Google Pay is incompatible with test mode when using production credentials. {{learnMore}}Learn more{{/learnMore}}.',
+ 'woocommerce-payments'
+ ),
+ components: {
+ learnMore: (
+
+ ),
+ },
+ } ) }
+
+ );
+};
+
+export default GooglePayTestModeCompatibilityNotice;
diff --git a/client/settings/payment-methods-list/payment-method.tsx b/client/settings/payment-methods-list/payment-method.tsx
index 18f978a6caa..d6611a77ed9 100644
--- a/client/settings/payment-methods-list/payment-method.tsx
+++ b/client/settings/payment-methods-list/payment-method.tsx
@@ -130,7 +130,7 @@ const PaymentMethod = ( {
upeCapabilityStatuses.INACTIVE === status || isPoInProgress;
const {
accountFees,
- }: { accountFees: Record< string, FeeStructure > } = useContext(
+ }: { accountFees?: Record< string, FeeStructure > } = useContext(
WCPaySettingsContext
);
const [ isManualCaptureEnabled ] = useManualCapture();
diff --git a/client/settings/wcpay-settings-context.js b/client/settings/wcpay-settings-context.js
index 531e806ff27..92a92427908 100644
--- a/client/settings/wcpay-settings-context.js
+++ b/client/settings/wcpay-settings-context.js
@@ -3,15 +3,6 @@
*/
import { createContext } from 'react';
-const WCPaySettingsContext = createContext( {
- accountFees: {},
- accountLoans: {},
- accountStatus: {},
- featureFlags: {
- isAuthAndCaptureEnabled: false,
- isDisputeIssuerEvidenceEnabled: false,
- woopay: false,
- },
-} );
+const WCPaySettingsContext = createContext( window.wcpaySettings );
export default WCPaySettingsContext;
diff --git a/client/tokenized-express-checkout/blocks/index.js b/client/tokenized-express-checkout/blocks/index.js
index d2cefd85eb7..b8b8a6f9529 100644
--- a/client/tokenized-express-checkout/blocks/index.js
+++ b/client/tokenized-express-checkout/blocks/index.js
@@ -39,9 +39,7 @@ export const tokenizedExpressCheckoutElementApplePay = ( api ) => ( {
return false;
}
- return new Promise( ( resolve ) => {
- checkPaymentMethodIsAvailable( 'applePay', cart, resolve );
- } );
+ return checkPaymentMethodIsAvailable( 'applePay', cart );
},
} );
@@ -77,9 +75,7 @@ export const tokenizedExpressCheckoutElementGooglePay = ( api ) => {
return false;
}
- return new Promise( ( resolve ) => {
- checkPaymentMethodIsAvailable( 'googlePay', cart, resolve );
- } );
+ return checkPaymentMethodIsAvailable( 'googlePay', cart );
},
};
};
diff --git a/client/tokenized-express-checkout/utils/checkPaymentMethodIsAvailable.js b/client/tokenized-express-checkout/utils/checkPaymentMethodIsAvailable.js
index b592169da22..5beb7e32942 100644
--- a/client/tokenized-express-checkout/utils/checkPaymentMethodIsAvailable.js
+++ b/client/tokenized-express-checkout/utils/checkPaymentMethodIsAvailable.js
@@ -14,71 +14,75 @@ import WCPayAPI from 'wcpay/checkout/api';
import { getUPEConfig } from 'wcpay/utils/checkout';
export const checkPaymentMethodIsAvailable = memoize(
- ( paymentMethod, cart, resolve ) => {
- // Create the DIV container on the fly
- const containerEl = document.createElement( 'div' );
+ ( paymentMethod, cart ) => {
+ return new Promise( ( resolve ) => {
+ // Create the DIV container on the fly
+ const containerEl = document.createElement( 'div' );
- // Ensure the element is hidden and doesn’t interfere with the page layout.
- containerEl.style.display = 'none';
+ // Ensure the element is hidden and doesn’t interfere with the page layout.
+ containerEl.style.display = 'none';
- document.querySelector( 'body' ).appendChild( containerEl );
+ document.querySelector( 'body' ).appendChild( containerEl );
- const root = ReactDOM.createRoot( containerEl );
+ const root = ReactDOM.createRoot( containerEl );
- const api = new WCPayAPI(
- {
- publishableKey: getUPEConfig( 'publishableKey' ),
- accountId: getUPEConfig( 'accountId' ),
- forceNetworkSavedCards: getUPEConfig(
- 'forceNetworkSavedCards'
- ),
- locale: getUPEConfig( 'locale' ),
- isStripeLinkEnabled: isLinkEnabled(
- getUPEConfig( 'paymentMethodsConfig' )
- ),
- },
- request
- );
+ const api = new WCPayAPI(
+ {
+ publishableKey: getUPEConfig( 'publishableKey' ),
+ accountId: getUPEConfig( 'accountId' ),
+ forceNetworkSavedCards: getUPEConfig(
+ 'forceNetworkSavedCards'
+ ),
+ locale: getUPEConfig( 'locale' ),
+ isStripeLinkEnabled: isLinkEnabled(
+ getUPEConfig( 'paymentMethodsConfig' )
+ ),
+ },
+ request
+ );
- root.render(
-
- resolve( false ) }
+ root.render(
+ {
- let canMakePayment = false;
- if ( event.availablePaymentMethods ) {
- canMakePayment =
- event.availablePaymentMethods[ paymentMethod ];
- }
- resolve( canMakePayment );
- root.unmount();
- containerEl.remove();
- } }
- />
-
- );
+ >
+ resolve( false ) }
+ options={ {
+ paymentMethods: {
+ amazonPay: 'never',
+ applePay:
+ paymentMethod === 'applePay'
+ ? 'always'
+ : 'never',
+ googlePay:
+ paymentMethod === 'googlePay'
+ ? 'always'
+ : 'never',
+ link: 'never',
+ paypal: 'never',
+ },
+ } }
+ onReady={ ( event ) => {
+ let canMakePayment = false;
+ if ( event.availablePaymentMethods ) {
+ canMakePayment =
+ event.availablePaymentMethods[
+ paymentMethod
+ ];
+ }
+ resolve( canMakePayment );
+ root.unmount();
+ containerEl.remove();
+ } }
+ />
+
+ );
+ } );
}
);
diff --git a/client/transactions/filters/config.ts b/client/transactions/filters/config.ts
index 8485dbe771d..45a53ca2859 100644
--- a/client/transactions/filters/config.ts
+++ b/client/transactions/filters/config.ts
@@ -442,43 +442,46 @@ export const getAdvancedFilters = (
},
channel: {
labels: {
- add: __( 'Channel', 'woocommerce-payments' ),
+ add: __( 'Sales channel', 'woocommerce-payments' ),
remove: __(
- 'Remove transaction channel filter',
+ 'Remove transaction sales channel filter',
'woocommerce-payments'
),
rule: __(
- 'Select a transaction channel filter match',
+ 'Select a transaction sales channel filter match',
'woocommerce-payments'
),
- /* translators: A sentence describing a Transaction Channel filter. */
title:
wooCommerceVersion < 7.8
? __(
- '{{title}}Channel{{/title}} {{rule /}} {{filter /}}',
+ '{{title}}Sales channel{{/title}} {{rule /}} {{filter /}}',
'woocommerce-payments'
)
: __(
- 'Channel ',
+ 'Sales channel ',
'woocommerce-payments'
),
filter: __(
- 'Select a transaction channel',
+ 'Select a transaction sales channel',
'woocommerce-payments'
),
},
rules: [
{
value: 'is',
- /* translators: Sentence fragment, logical, "Is" refers to searching for transactions matching a chosen transaction channel type. */
- label: _x( 'Is', 'Channel', 'woocommerce-payments' ),
+ /* translators: Sentence fragment, logical, "Is" refers to searching for transactions matching a chosen transaction sales channel type. */
+ label: _x(
+ 'Is',
+ 'Sales channel',
+ 'woocommerce-payments'
+ ),
},
{
value: 'is_not',
- /* translators: Sentence fragment, logical, "Is not" refers to searching for transactions that don\'t match a chosen transaction channel type. */
+ /* translators: Sentence fragment, logical, "Is not" refers to searching for transactions that don\'t match a chosen transaction sales channel type. */
label: _x(
'Is not',
- 'Channel',
+ 'Sales channel',
'woocommerce-payments'
),
},
diff --git a/client/transactions/filters/test/__snapshots__/index.tsx.snap b/client/transactions/filters/test/__snapshots__/index.tsx.snap
index 7feb3c5bb55..61210139d09 100644
--- a/client/transactions/filters/test/__snapshots__/index.tsx.snap
+++ b/client/transactions/filters/test/__snapshots__/index.tsx.snap
@@ -5,13 +5,18 @@ HTMLOptionsCollection [
,
,
+ ,
]
`;
diff --git a/client/transactions/filters/test/index.tsx b/client/transactions/filters/test/index.tsx
index a958629edca..cd5779f3744 100644
--- a/client/transactions/filters/test/index.tsx
+++ b/client/transactions/filters/test/index.tsx
@@ -356,15 +356,15 @@ describe( 'Transactions filters', () => {
let ruleSelector: HTMLElement;
beforeEach( () => {
- addAdvancedFilter( 'Channel' );
+ addAdvancedFilter( 'Sales channel' );
ruleSelector = screen.getByRole( 'combobox', {
- name: /transaction channel filter/i,
+ name: /transaction sales channel filter/i,
} );
} );
test( 'should render all types', () => {
const typeSelect = screen.getByRole( 'combobox', {
- name: /transaction channel$/i,
+ name: /transaction sales channel$/i,
} ) as HTMLSelectElement;
expect( typeSelect.options ).toMatchSnapshot();
} );
@@ -372,10 +372,9 @@ describe( 'Transactions filters', () => {
test( 'should filter by is', () => {
user.selectOptions( ruleSelector, 'is' );
- // need to include $ in name, otherwise "Select a transaction type filter" is also matched.
user.selectOptions(
screen.getByRole( 'combobox', {
- name: /transaction channel$/i,
+ name: /transaction sales channel$/i,
} ),
'online'
);
@@ -390,7 +389,7 @@ describe( 'Transactions filters', () => {
// need to include $ in name, otherwise "Select a transaction type filter" is also matched.
user.selectOptions(
screen.getByRole( 'combobox', {
- name: /transaction channel$/i,
+ name: /transaction sales channel$/i,
} ),
'in_person'
);
diff --git a/client/transactions/list/index.tsx b/client/transactions/list/index.tsx
index eefa7cf183c..acd9ee7b530 100644
--- a/client/transactions/list/index.tsx
+++ b/client/transactions/list/index.tsx
@@ -159,8 +159,8 @@ const getColumns = (
},
{
key: 'channel',
- label: __( 'Channel', 'woocommerce-payments' ),
- screenReaderLabel: __( 'Channel', 'woocommerce-payments' ),
+ label: __( 'Sales channel', 'woocommerce-payments' ),
+ screenReaderLabel: __( 'Sales channel', 'woocommerce-payments' ),
required: true,
isLeftAligned: true,
},
diff --git a/client/transactions/list/test/__snapshots__/index.tsx.snap b/client/transactions/list/test/__snapshots__/index.tsx.snap
index 755d4e59383..76920851ef5 100644
--- a/client/transactions/list/test/__snapshots__/index.tsx.snap
+++ b/client/transactions/list/test/__snapshots__/index.tsx.snap
@@ -291,12 +291,12 @@ exports[`Transactions list renders correctly when can filter by several currenci
- Channel
+ Sales channel
- Channel
+ Sales channel
- Online
+ Online store
|
- Online
+ Online store
|
- Channel
+ Sales channel
- Channel
+ Sales channel
|
- Online
+ Online store
|
- Online
+ Online store
|
- Channel
+ Sales channel
- Channel
+ Sales channel
|
- Online
+ Online store
|
- Channel
+ Sales channel
- Channel
+ Sales channel
|
- Online
+ Online store
|
- Online
+ Online store
|
- Channel
+ Sales channel
- Channel
+ Sales channel
|
- Online
+ Online store
|
- Online
+ Online store
|
- Channel
+ Sales channel
- Channel
+ Sales channel
|
- Online
+ Online store
|
- Online
+ Online store
|
{
if ( ! accountFees ) return <>>;
diff --git a/client/utils/charge/index.ts b/client/utils/charge/index.ts
index 0169a45b4e0..ee87ac6428f 100755
--- a/client/utils/charge/index.ts
+++ b/client/utils/charge/index.ts
@@ -173,14 +173,14 @@ export const getChargeAmounts = ( charge: Charge ): ChargeAmounts => {
};
/**
- * Displays the transaction's channel: Online | In-Person | In-Person (POS).
+ * Displays the transaction's sales channel: Online store | In-Person | In-Person (POS).
* This method is called on the list of transactions page.
*
* In the list of transactions, the type holds the brand of the payment method, so we aren't passing it.
* Instead, we pass the transaction.channel directly, which might be in_person|in_person_pos|online.
*
* @param {string} channel The transaction channel.
- * @return {string} Online, In-Person, or In-Person (POS).
+ * @return {string} Online store, In-Person, or In-Person (POS).
*/
export const getTransactionChannel = ( channel: string ): string => {
switch ( channel ) {
@@ -189,12 +189,12 @@ export const getTransactionChannel = ( channel: string ): string => {
case 'in_person_pos':
return __( 'In-Person (POS)', 'woocommerce-payments' );
default:
- return __( 'Online', 'woocommerce-payments' );
+ return __( 'Online store', 'woocommerce-payments' );
}
};
/**
- * Displays the channel based on the charge data from Stripe and metadata for a transaction: Online | In-Person | In-Person (POS).
+ * Displays the sales channel based on the charge data from Stripe and metadata for a transaction: Online store | In-Person | In-Person (POS).
* This method is called in the individual transaction page.
*
* In the individual transaction page, we are getting the data from Stripe, so we pass the charge.type
@@ -204,8 +204,7 @@ export const getTransactionChannel = ( channel: string ): string => {
*
* @param {string} type The transaction charge type, which can be card_present or interac_present for In-Person payments.
* @param {Record} metadata The transaction metadata, which may include ipp_channel indicating the channel source.
- * @return {string} Returns 'Online', 'In-Person', or 'In-Person (POS)' based on the transaction type and metadata.
- *
+ * @return {string} Returns 'Online store', 'In-Person', or 'In-Person (POS)' based on the transaction type and metadata.
*/
export const getChargeChannel = (
type: string,
@@ -218,5 +217,5 @@ export const getChargeChannel = (
return __( 'In-Person', 'woocommerce-payments' );
}
- return __( 'Online', 'woocommerce-payments' );
+ return __( 'Online store', 'woocommerce-payments' );
};
diff --git a/client/utils/charge/test/index.js b/client/utils/charge/test/index.js
index 07b7f64f312..a0fbd6b2913 100755
--- a/client/utils/charge/test/index.js
+++ b/client/utils/charge/test/index.js
@@ -499,14 +499,14 @@ describe( 'Charge utilities / get channel string', () => {
expect( result ).toBe( 'In-Person' );
} );
- test( 'should return "Online" for online channel', () => {
+ test( 'should return "Online store" for online channel', () => {
const result = utils.getTransactionChannel( 'online' );
- expect( result ).toBe( 'Online' );
+ expect( result ).toBe( 'Online store' );
} );
- test( 'should return "Online" for null channel', () => {
+ test( 'should return "Online store" for null channel', () => {
const result = utils.getTransactionChannel( null );
- expect( result ).toBe( 'Online' );
+ expect( result ).toBe( 'Online store' );
} );
} );
@@ -530,11 +530,11 @@ describe( 'Charge utilities / get channel string', () => {
expect( result ).toBe( 'In-Person' );
} );
- test( 'should return "Online" for online type', () => {
+ test( 'should return "Online store" for online type', () => {
const result = utils.getChargeChannel( 'online', {
ipp_channel: 'mobile_pos',
} );
- expect( result ).toBe( 'Online' );
+ expect( result ).toBe( 'Online store' );
} );
} );
} );
diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php
index 518d189addd..d21fca9376d 100644
--- a/includes/class-wc-payments-account.php
+++ b/includes/class-wc-payments-account.php
@@ -351,6 +351,7 @@ public function get_account_status_data(): array {
'status' => $account['status'],
'created' => $account['created'] ?? '',
'testDrive' => $account['is_test_drive'] ?? false,
+ 'isLive' => $account['is_live'] ?? false,
'paymentsEnabled' => $account['payments_enabled'],
'detailsSubmitted' => $account['details_submitted'] ?? true,
'deposits' => $account['deposits'] ?? [],
diff --git a/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php b/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php
index 413b51aa064..073e09b0ad9 100644
--- a/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php
+++ b/includes/express-checkout/class-wc-payments-express-checkout-button-handler.php
@@ -307,6 +307,7 @@ public function scripts() {
}
wp_localize_script( 'WCPAY_EXPRESS_CHECKOUT_ECE', 'wcpayExpressCheckoutParams', $express_checkout_params );
+ wp_localize_script( 'WCPAY_BLOCKS_CHECKOUT', 'wcpayExpressCheckoutParams', $express_checkout_params );
wp_set_script_translations( 'WCPAY_EXPRESS_CHECKOUT_ECE', 'woocommerce-payments' );
diff --git a/tests/js/jest.config.js b/tests/js/jest.config.js
index 7665524e08d..f6afe00fa8d 100644
--- a/tests/js/jest.config.js
+++ b/tests/js/jest.config.js
@@ -45,6 +45,14 @@ module.exports = {
'/docker/',
'/tests/e2e',
],
+ watchPathIgnorePatterns: [
+ '/node_modules/',
+ '/vendor/',
+ '/.*/build/',
+ '/.*/build-module/',
+ '/docker/',
+ '/tests/e2e',
+ ],
transform: {
...tsjPreset.transform,
'^.+\\.(jpg|svg|png|gif)(\\?.*)?$': '/tests/js/fileMock.js',
diff --git a/tests/unit/test-class-wc-payments-incentives-service.php b/tests/unit/test-class-wc-payments-incentives-service.php
index 9c8921289ab..9b12a949853 100644
--- a/tests/unit/test-class-wc-payments-incentives-service.php
+++ b/tests/unit/test-class-wc-payments-incentives-service.php
@@ -406,7 +406,9 @@ function ( $value, $expiration ) {
$this->assertSame( 'yes', $value );
// Ensure the cache is set to expire in 90 days - 30 days = 60 days.
- $this->assertSame( 60 * DAY_IN_SECONDS, $expiration );
+ $expected_expiration = 60 * DAY_IN_SECONDS;
+ // Allowing 5-second difference to avoid flaky tests due to time() precision.
+ $this->assertLessThanOrEqual( 5, abs( $expected_expiration - $expiration ), 'Expiration time should be within 5 second of expected value' );
return $value;
},
|