Skip to content

Commit

Permalink
Merge branch 'develop' into fix/tokenized-cart-subscription-signup-fee
Browse files Browse the repository at this point in the history
  • Loading branch information
frosso authored Dec 18, 2024
2 parents 654da38 + 99db1fb commit a860126
Show file tree
Hide file tree
Showing 40 changed files with 850 additions and 184 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** WooPayments Changelog ***

= 8.6.1 - 2024-12-17 =
* Fix - Checkout: Fix error when wc_address_i18n_params does not have data for a given country
* Fix - Skip mysqlcheck SSL Requirement during E2E environment setup

= 8.6.0 - 2024-12-04 =
* Add - Add Bank reference key column in Payout reports. This will help reconcile WooPayments Payouts with bank statements.
* Add - Display credit card brand icons on order received page.
Expand Down
4 changes: 4 additions & 0 deletions changelog/as-fix-ece-variable-subs-free-trial
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Enable ECE for Virtual Variable Subscriptions with Free Trials.
4 changes: 4 additions & 0 deletions changelog/fix-9421-auto-enable-woopay-in-sandbox-mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Ensure WooPay 'enabled by default' value is correctly set in sandbox mode.
4 changes: 4 additions & 0 deletions changelog/fix-9716-disputes-api-requests
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Performance improvements for Disputes Needing Response task shown in WooCommerce admin.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix inconsistent alignment of the download button across transactions, payouts, and disputes reporting views for a more cohesive user interface.
4 changes: 4 additions & 0 deletions changelog/fix-9794-refresh-page-when-ece-dismissed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: add

Refresh the cart and checkout pages when ECE is dismissed and the shipping options were modified in the payment sheet.
4 changes: 4 additions & 0 deletions changelog/fix-allow-addresses-from-woo-supported-countries
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Checkout: Fix error when wc_address_i18n_params does not have data for a given country
5 changes: 5 additions & 0 deletions changelog/fix-tokenized-cart-multiple-variations
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: fix: tokenized cart & multiple variations.


4 changes: 4 additions & 0 deletions changelog/fix-unhandled-promises
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Fix payment method filtering when billing country changes in Blocks checkout.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Add support for utilizing NOX capabilities as URL parameters during account creation.
5 changes: 0 additions & 5 deletions changelog/update-server-container-name

This file was deleted.

138 changes: 131 additions & 7 deletions client/checkout/utils/test/upe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
isUsingSavedPaymentMethod,
dispatchChangeEventFor,
togglePaymentMethodForCountry,
isBillingInformationMissing,
} from '../upe';

import { getPaymentMethodsConstants } from '../../constants';
Expand All @@ -22,11 +23,134 @@ jest.mock( 'wcpay/utils/checkout' );

jest.mock( '../../constants', () => {
return {
...jest.requireActual( '../../constants' ),
getPaymentMethodsConstants: jest.fn(),
};
} );

function buildForm( fields ) {
const form = document.createElement( 'form' );
fields.forEach( ( field ) => {
const input = document.createElement( 'input' );
input.id = field.id;
input.value = field.value;
form.appendChild( input );
} );
return form;
}

describe( 'UPE checkout utils', () => {
describe( 'isBillingInformationMissing', () => {
beforeAll( () => {
window.wc_address_i18n_params = {
locale: {
US: {},
HK: {
postcode: { required: false },
},
default: {
address_1: { required: true },
postcode: { required: true },
},
},
};
} );

beforeEach( () => {
getUPEConfig.mockImplementation( ( argument ) => {
if ( argument === 'enabledBillingFields' ) {
return {
billing_first_name: {
required: true,
},
billing_last_name: {
required: true,
},
billing_company: {
required: false,
},
billing_country: {
required: true,
},
billing_address_1: {
required: true,
},
billing_address_2: {
required: false,
},
billing_city: {
required: true,
},
billing_state: {
required: true,
},
billing_postcode: {
required: true,
},
billing_phone: {
required: true,
},
billing_email: {
required: true,
},
};
}
} );
} );

it( 'should return false when the billing information is not missing', () => {
const form = buildForm( [
{ id: 'billing_first_name', value: 'Test' },
{ id: 'billing_last_name', value: 'User' },
{ id: 'billing_email', value: 'test@example.com' },
{ id: 'billing_country', value: 'US' },
{ id: 'billing_address_1', value: '123 Main St' },
{ id: 'billing_city', value: 'Anytown' },
{ id: 'billing_postcode', value: '12345' },
] );
expect( isBillingInformationMissing( form ) ).toBe( false );
} );

it( 'should return true when the billing information is missing', () => {
const form = buildForm( [
{ id: 'billing_first_name', value: 'Test' },
{ id: 'billing_last_name', value: 'User' },
{ id: 'billing_email', value: 'test@example.com' },
{ id: 'billing_country', value: 'US' },
{ id: 'billing_address_1', value: '123 Main St' },
{ id: 'billing_city', value: 'Anytown' },
{ id: 'billing_postcode', value: '' },
] );
expect( isBillingInformationMissing( form ) ).toBe( true );
} );

it( 'should use the defaults when there is no specific locale data for a country', () => {
const form = buildForm( [
{ id: 'billing_first_name', value: 'Test' },
{ id: 'billing_last_name', value: 'User' },
{ id: 'billing_email', value: 'test@example.com' },
{ id: 'billing_country', value: 'MX' },
{ id: 'billing_address_1', value: '123 Main St' },
{ id: 'billing_city', value: 'Anytown' },
{ id: 'billing_postcode', value: '' },
] );
expect( isBillingInformationMissing( form ) ).toBe( true );
} );

it( 'should return false when the locale data for a country has no required fields', () => {
const form = buildForm( [
{ id: 'billing_first_name', value: 'Test' },
{ id: 'billing_last_name', value: 'User' },
{ id: 'billing_email', value: 'test@example.com' },
{ id: 'billing_country', value: 'HK' },
{ id: 'billing_address_1', value: '123 Main St' },
{ id: 'billing_city', value: 'Anytown' },
{ id: 'billing_postcode', value: '' },
] );
expect( isBillingInformationMissing( form ) ).toBe( true );
} );
} );

describe( 'getSelectedUPEGatewayPaymentMethod', () => {
let container;

Expand Down Expand Up @@ -54,7 +178,7 @@ describe( 'UPE checkout utils', () => {
} );

test( 'Selected UPE Payment Method is card', () => {
container.innerHTML = `<input
container.innerHTML = `<input
id="payment_method_woocommerce_payments"
value="woocommerce_payments"
name="payment_method"
Expand All @@ -67,12 +191,12 @@ describe( 'UPE checkout utils', () => {

test( 'Selected UPE Payment Method is bancontact', () => {
container.innerHTML = `
<input
id="payment_method_woocommerce_payments_bancontact"
value="woocommerce_payments_bancontact"
name="payment_method"
type="radio"
class="input-radio"
<input
id="payment_method_woocommerce_payments_bancontact"
value="woocommerce_payments_bancontact"
name="payment_method"
type="radio"
class="input-radio"
checked
></input>
`;
Expand Down
4 changes: 2 additions & 2 deletions client/checkout/utils/upe.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ export const isBillingInformationMissing = ( form ) => {
if ( country && locale && fieldName !== 'billing_email' ) {
const key = fieldName.replace( 'billing_', '' );
isRequired =
locale[ country ][ key ]?.required ??
locale.default[ key ]?.required;
locale[ country ]?.[ key ]?.required ??
locale.default?.[ key ]?.required;
}

const hasValue = field?.value;
Expand Down
19 changes: 13 additions & 6 deletions client/connect-account-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const ConnectAccountPage: React.FC = () => {
}
};

const checkAccountStatus = () => {
const checkAccountStatus = ( extraQueryArgs = {} ) => {
// Fetch account status from the cache.
apiFetch( {
path: `/wc/v3/payments/accounts`,
Expand All @@ -188,18 +188,22 @@ const ConnectAccountPage: React.FC = () => {
loaderProgressRef.current > 95
) {
setTestDriveLoaderProgress( 100 );

// Redirect to the Connect URL and let it figure it out where to point the merchant.
window.location.href = addQueryArgs( connectUrl, {
const queryArgs = {
test_drive: 'true',
'wcpay-sandbox-success': 'true',
source: determineTrackingSource(),
from: 'WCPAY_CONNECT',
redirect_to_settings_page:
urlParams.get( 'redirect_to_settings_page' ) || '',
};

// Redirect to the Connect URL and let it figure it out where to point the merchant.
window.location.href = addQueryArgs( connectUrl, {
...queryArgs,
...extraQueryArgs,
} );
} else {
setTimeout( checkAccountStatus, 2000 );
setTimeout( () => checkAccountStatus( extraQueryArgs ), 2000 );
}
} );
};
Expand All @@ -211,6 +215,7 @@ const ConnectAccountPage: React.FC = () => {

const customizedConnectUrl = addQueryArgs( connectUrl, {
test_drive: 'true',
capabilities: urlParams.get( 'capabilities' ) || '',
} );

const updateProgress = setInterval( updateLoaderProgress, 2500, 40, 5 );
Expand Down Expand Up @@ -264,7 +269,9 @@ const ConnectAccountPage: React.FC = () => {
// The account has been successfully onboarded.
if ( !! connectionSuccess ) {
// Start checking the account status in a loop.
checkAccountStatus();
checkAccountStatus( {
'wcpay-connection-success': '1',
} );
} else {
// Redirect to the response URL, but attach our test drive flags.
// This URL is generally a Connect page URL.
Expand Down
8 changes: 2 additions & 6 deletions client/express-checkout/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ const expressCheckoutElementApplePay = ( api ) => ( {
return false;
}

return new Promise( ( resolve ) => {
checkPaymentMethodIsAvailable( 'applePay', cart, resolve );
} );
return checkPaymentMethodIsAvailable( 'applePay', cart );
},
} );

Expand Down Expand Up @@ -77,9 +75,7 @@ const expressCheckoutElementGooglePay = ( api ) => {
return false;
}

return new Promise( ( resolve ) => {
checkPaymentMethodIsAvailable( 'googlePay', cart, resolve );
} );
return checkPaymentMethodIsAvailable( 'googlePay', cart );
},
};
};
Expand Down
10 changes: 10 additions & 0 deletions client/express-checkout/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ import {
normalizeShippingAddress,
normalizeLineItems,
getExpressCheckoutData,
updateShippingAddressUI,
} from './utils';
import {
trackExpressCheckoutButtonClick,
trackExpressCheckoutButtonLoad,
} from './tracking';

let lastSelectedAddress = null;

export const shippingAddressChangeHandler = async ( api, event, elements ) => {
try {
const response = await api.expressCheckoutECECalculateShippingOptions(
Expand All @@ -29,6 +32,9 @@ export const shippingAddressChangeHandler = async ( api, event, elements ) => {
elements.update( {
amount: response.total.amount,
} );

lastSelectedAddress = event.address;

event.resolve( {
shippingRates: response.shipping_options,
lineItems: normalizeLineItems( response.displayItems ),
Expand Down Expand Up @@ -171,5 +177,9 @@ export const onCompletePaymentHandler = () => {
};

export const onCancelHandler = () => {
if ( lastSelectedAddress ) {
updateShippingAddressUI( lastSelectedAddress );
}
lastSelectedAddress = null;
unblockUI();
};
Loading

0 comments on commit a860126

Please sign in to comment.