Skip to content

Commit

Permalink
Merge branch 'develop' into fix/woopay-theme-support-from-classic-che…
Browse files Browse the repository at this point in the history
…ckout
  • Loading branch information
malithsen authored Aug 28, 2024
2 parents 627386c + 8963777 commit 2a45294
Show file tree
Hide file tree
Showing 41 changed files with 531 additions and 628 deletions.
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* Fix - Fix uncaught error on the block based Cart page when WooPayments is disabled.
* Fix - Fix WooPay checkboxes while signed in.
* Fix - If a payment method fails to be created in the frontend during checkout, forward the errors to the server so it can be recorded in an order.
* Fix - Migrate to Docker Compose V2 for test runner environment setup scripts
* Fix - Reverts changes related to Direct Checkout that broke the PayPal extension.
* Fix - Translate hardcoded strings on the Connect page
* Update - refactor: separate BNPL methods from settings list
Expand All @@ -32,6 +31,7 @@
* Dev - Match the Node version in nvm with the minimum version in package.json.
* Dev - Remove unnecessary console.warn statements added in #9121.
* Dev - Update bundle size checker workflow to support node v20
* Dev - Migrate to Docker Compose V2 for test runner environment setup scripts

= 8.0.2 - 2024-08-07 =
* Fix - Add opt-in checks to prevent blocking customers using other payment methods.
Expand Down
4 changes: 4 additions & 0 deletions changelog/as-fix-max-height-allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Ensure 55px is the maximum height for Apple Pay button.
4 changes: 4 additions & 0 deletions changelog/chore-disable-custom-checkout-field-detection
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Disables custom checkout field detection due to compatibility issues and false positives.
5 changes: 5 additions & 0 deletions changelog/dev-correct-docker-compose-v2-changelog-entry
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Placeholder changelog entry - making a correction to previous changelog entry 'Fix - Migrate to Docker Compose V2 for test runner environment setup scripts'


5 changes: 5 additions & 0 deletions changelog/dev-fix-e2e-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Fix some aspects of the e2e tests scripts.


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Disables testing instructions clipboard button on HTTP sites when navigator.clipboard is undefined.
4 changes: 4 additions & 0 deletions changelog/fix-ece-shortcode-get-shipping-rates
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix shipping rates retrieval method for shortcode cart/checkout.
4 changes: 4 additions & 0 deletions changelog/fix-remove-apple-pay-admin-notice-for-live-account
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Remove obsolete ApplePay warning on wp-admin for test sites.
5 changes: 5 additions & 0 deletions changelog/fix-send-blog-timezone-to-woopay
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Send blog timezone to WooPay.


4 changes: 4 additions & 0 deletions changelog/fix-testing-instructions-dark-theme-support
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: testing instructions dark theme support
4 changes: 4 additions & 0 deletions changelog/fix-woopay-themeing-on-email-flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Pass appearance data when initiating WooPay via the email input flow
4 changes: 4 additions & 0 deletions changelog/update-jetpack-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: update

Update Jetpack packages to the latest versions
1 change: 1 addition & 0 deletions client/checkout/blocks/payment-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const PaymentElements = ( { api, ...props } ) => {
errorMessage={ errorMessage }
fingerprint={ fingerprint }
onLoadError={ setPaymentProcessorLoadErrorMessage }
theme={ appearance?.theme }
{ ...props }
/>
</Elements>
Expand Down
6 changes: 5 additions & 1 deletion client/checkout/blocks/payment-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { useEffect, useRef } from 'react';
import classNames from 'classnames';

/**
* Internal dependencies
Expand Down Expand Up @@ -64,6 +65,7 @@ const PaymentProcessor = ( {
shouldSavePayment,
fingerprint,
onLoadError = noop,
theme,
} ) => {
const stripe = useStripe();
const elements = useElements();
Expand Down Expand Up @@ -267,7 +269,9 @@ const PaymentProcessor = ( {
<>
{ isTestMode && (
<p
className="content"
className={ classNames( 'content', {
[ `theme--${ theme }` ]: theme,
} ) }
dangerouslySetInnerHTML={ {
__html: testingInstructions,
} }
Expand Down
9 changes: 8 additions & 1 deletion client/checkout/classic/payment-processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,20 @@ async function createStripePaymentElement(
) {
const amount = Number( getUPEConfig( 'cartTotal' ) );
const paymentMethodTypes = getPaymentMethodTypes( paymentMethodType );
const appearance = await initializeAppearance( api, elementsLocation );
document
.querySelector(
`.wcpay-upe-element[data-payment-method-type="${ paymentMethodType }"]`
)
?.closest( '.wc_payment_method' )
?.classList.add( `theme--${ appearance.theme || 'stripe' }` );
const options = {
mode: amount < 1 ? 'setup' : 'payment',
currency: getUPEConfig( 'currency' ).toLowerCase(),
amount: amount,
paymentMethodCreation: 'manual',
paymentMethodTypes: paymentMethodTypes,
appearance: await initializeAppearance( api, elementsLocation ),
appearance,
fonts: getFontRulesFromPage(),
};

Expand Down
9 changes: 8 additions & 1 deletion client/checkout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
vertical-align: middle;
border-radius: 0;
border: none !important;
background-color: transparent;
// some themes might override the color on all `button`s - whose selector has higher specificity and our class selector.
background-color: transparent !important;
padding: 3px;

i {
Expand All @@ -26,4 +27,10 @@
&:active i {
transform: scale( 0.9 );
}

.theme--night & {
i {
filter: invert( 100% ) hue-rotate( 180deg );
}
}
}
50 changes: 30 additions & 20 deletions client/checkout/utils/copy-test-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,38 @@ document.addEventListener(
const copyNumberButton = event.target?.closest(
'.js-woopayments-copy-test-number'
);
if ( copyNumberButton ) {
event.preventDefault();
const number = copyNumberButton.parentElement.querySelector(
'.js-woopayments-test-number'
).innerText;
navigator.clipboard.writeText( number );
if ( ! copyNumberButton ) {
return;
}

event.preventDefault();
const number = copyNumberButton.parentElement.querySelector(
'.js-woopayments-test-number'
).innerText;

window.wp?.data
?.dispatch( 'core/notices' )
?.createInfoNotice(
__(
'Test number copied to your clipboard!',
'woocommerce-payments'
),
{
// the unique `id` prevents the JS from creating multiple notices with the same text before they're dismissed.
id: 'woopayments/test-number-copied',
type: 'snackbar',
context: 'wc/checkout/payments',
}
);
if ( ! navigator.clipboard ) {
prompt(
__( 'Copy the test number:', 'woocommerce-payments' ),
number
);
return;
}
navigator.clipboard.writeText( number );

window.wp?.data
?.dispatch( 'core/notices' )
?.createInfoNotice(
__(
'Test number copied to your clipboard!',
'woocommerce-payments'
),
{
// the unique `id` prevents the JS from creating multiple notices with the same text before they're dismissed.
id: 'woopayments/test-number-copied',
type: 'snackbar',
context: 'wc/checkout/payments',
}
);
},
false
);
6 changes: 6 additions & 0 deletions client/checkout/woopay/email-input-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { getConfig } from 'wcpay/utils/checkout';
import { recordUserEvent, getTracksIdentity } from 'tracks';
import request from '../utils/request';
import { buildAjaxURL } from 'utils/express-checkout';
import { getAppearance } from 'checkout/upe-styles';
import {
getTargetElement,
getAppearanceType,
validateEmail,
appendRedirectionParams,
shouldSkipWooPay,
Expand Down Expand Up @@ -177,6 +179,7 @@ export const handleWooPayEmailInput = async (
iframe.addEventListener( 'load', () => {
// Set the initial value.
iframeHeaderValue = true;
const appearanceType = getAppearanceType();

if ( getConfig( 'isWoopayFirstPartyAuthEnabled' ) ) {
request(
Expand All @@ -186,6 +189,9 @@ export const handleWooPayEmailInput = async (
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
appearance: getConfig( 'isWooPayGlobalThemeSupportEnabled' )
? getAppearance( appearanceType )
: null,
}
).then( ( response ) => {
if ( response?.data?.session ) {
Expand Down
5 changes: 0 additions & 5 deletions client/data/settings/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,6 @@ export const useWooPayShowIncompatibilityNotice = () =>
select( STORE_NAME ).getShowWooPayIncompatibilityNotice()
);

export const useExpressCheckoutShowIncompatibilityNotice = () =>
useSelect( ( select ) =>
select( STORE_NAME ).getShowExpressCheckoutIncompatibilityNotice()
);

export const useStripeBilling = () => {
const { updateIsStripeBillingEnabled } = useDispatch( STORE_NAME );

Expand Down
7 changes: 0 additions & 7 deletions client/data/settings/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,6 @@ export const getShowWooPayIncompatibilityNotice = ( state ) => {
return getSettings( state ).show_woopay_incompatibility_notice || false;
};

export const getShowExpressCheckoutIncompatibilityNotice = ( state ) => {
return (
getSettings( state ).show_express_checkout_incompatibility_notice ||
false
);
};

export const getIsStripeBillingEnabled = ( state ) => {
return getSettings( state ).is_stripe_billing_enabled || false;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ const adjustButtonHeights = ( buttonOptions, expressPaymentMethod ) => {
// Apple Pay has a nearly imperceptible height difference. We increase it by 1px here.
if ( buttonOptions.buttonTheme.applePay === 'black' ) {
if ( expressPaymentMethod === 'applePay' ) {
buttonOptions.buttonHeight = buttonOptions.buttonHeight + 0.4;
// The maximum allowed size is 55px.
buttonOptions.buttonHeight = Math.min(
buttonOptions.buttonHeight + 0.4,
55
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ const ExpressCheckoutContainer = ( props ) => {
};

return (
<Elements stripe={ stripePromise } options={ options }>
<ExpressCheckoutComponent { ...props } />
</Elements>
<div style={ { minHeight: '40px' } }>
<Elements stripe={ stripePromise } options={ options }>
<ExpressCheckoutComponent { ...props } />
</Elements>
</div>
);
};

Expand Down
7 changes: 2 additions & 5 deletions client/express-checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ jQuery( ( $ ) => {
}

return options.displayItems
.filter(
( i ) =>
i.label === __( 'Shipping', 'woocommerce-payments' )
)
.filter( ( i ) => i.key === 'total_shipping' )
.map( ( i ) => ( {
id: `rate-${ i.label }`,
amount: i.amount,
Expand All @@ -228,7 +225,7 @@ jQuery( ( $ ) => {
// Relying on what's provided in the cart response seems safest since it should always include a valid shipping
// rate if one is required and available.
// If no shipping rate is found we can't render the button so we just exit.
if ( options.requestShipping && ! shippingRates ) {
if ( options.requestShipping && ! shippingRates.length ) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import GeneralPaymentRequestButtonSettings from './general-payment-request-butto
import {
usePaymentRequestEnabledSettings,
usePaymentRequestLocations,
useExpressCheckoutShowIncompatibilityNotice,
} from 'wcpay/data';
import { ExpressCheckoutIncompatibilityNotice } from 'wcpay/settings/settings-warnings/incompatibility-notice';

const PaymentRequestSettings = ( { section } ) => {
const [
Expand All @@ -42,15 +40,10 @@ const PaymentRequestSettings = ( { section } ) => {
}
};

const showIncompatibilityNotice = useExpressCheckoutShowIncompatibilityNotice();

return (
<Card>
{ section === 'enable' && (
<CardBody>
{ showIncompatibilityNotice && (
<ExpressCheckoutIncompatibilityNotice />
) }
<CheckboxControl
checked={ isPaymentRequestEnabled }
onChange={ updateIsPaymentRequestEnabled }
Expand Down
3 changes: 0 additions & 3 deletions client/settings/express-checkout-settings/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jest.mock( '../../../data', () => ( {
.fn()
.mockReturnValue( [ [ true, true, true ], jest.fn() ] ),
useWooPayShowIncompatibilityNotice: jest.fn().mockReturnValue( false ),
useExpressCheckoutShowIncompatibilityNotice: jest
.fn()
.mockReturnValue( false ),
} ) );

jest.mock( '@wordpress/data', () => ( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
usePaymentRequestButtonSize,
usePaymentRequestButtonTheme,
useWooPayEnabledSettings,
useExpressCheckoutShowIncompatibilityNotice,
} from '../../../data';

jest.mock( '../../../data', () => ( {
Expand All @@ -29,7 +28,6 @@ jest.mock( '../../../data', () => ( {
usePaymentRequestButtonSize: jest.fn().mockReturnValue( [ 'small' ] ),
usePaymentRequestButtonTheme: jest.fn().mockReturnValue( [ 'dark' ] ),
useWooPayEnabledSettings: jest.fn(),
useExpressCheckoutShowIncompatibilityNotice: jest.fn(),
useWooPayShowIncompatibilityNotice: jest.fn().mockReturnValue( false ),
useWooPayGlobalThemeSupportEnabledSettings: jest
.fn()
Expand Down Expand Up @@ -260,28 +258,4 @@ describe( 'PaymentRequestSettings', () => {
updatePaymentRequestLocationsHandler
).toHaveBeenLastCalledWith( [ 'checkout', 'product' ] );
} );

it( 'triggers the hooks when the enable setting is being interacted with', () => {
useExpressCheckoutShowIncompatibilityNotice.mockReturnValue( true );

render( <PaymentRequestSettings section="enable" /> );

expect(
screen.queryByText(
'Your custom checkout fields may not be compatible with these payment methods.'
)
).toBeInTheDocument();
} );

it( 'triggers the hooks when the enable setting is being interacted with', () => {
useExpressCheckoutShowIncompatibilityNotice.mockReturnValue( false );

render( <PaymentRequestSettings section="enable" /> );

expect(
screen.queryByText(
'Your custom checkout fields may not be compatible with these payment methods.'
)
).not.toBeInTheDocument();
} );
} );
Loading

0 comments on commit 2a45294

Please sign in to comment.