Skip to content

Commit

Permalink
Merge branch 'develop' into update/5713-failed-orders-should-include-…
Browse files Browse the repository at this point in the history
…more-info-on-transaction-details-page
  • Loading branch information
mgascam authored Dec 17, 2024
2 parents b49c33b + eb54bb9 commit 27806c8
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 19 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/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: 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: '[email protected]' },
{ 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: '[email protected]' },
{ 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: '[email protected]' },
{ 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: '[email protected]' },
{ 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woocommerce-payments",
"version": "8.6.0",
"version": "8.6.1",
"main": "webpack.config.js",
"author": "Automattic",
"license": "GPL-3.0-or-later",
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.3
Stable tag: 8.6.0
Stable tag: 8.6.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -94,6 +94,11 @@ Please note that our support for the checkout block is still experimental and th

== 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
2 changes: 1 addition & 1 deletion woocommerce-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* WC tested up to: 9.4.0
* Requires at least: 6.0
* Requires PHP: 7.3
* Version: 8.6.0
* Version: 8.6.1
* Requires Plugins: woocommerce
*
* @package WooCommerce\Payments
Expand Down

0 comments on commit 27806c8

Please sign in to comment.