Skip to content

Commit

Permalink
Merge branch 'develop' into add/prb-load-tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
malithsen authored Dec 19, 2023
2 parents b1278cd + 21ee31d commit 2c56a25
Show file tree
Hide file tree
Showing 35 changed files with 1,093 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Confirmation when cancelling order with pending authorization. Automatic order changes submission if confirmed.
5 changes: 5 additions & 0 deletions changelog/dev-fix-e2e-tests-on-wc-7-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Fix e2e tests on WC 7.7.


4 changes: 4 additions & 0 deletions changelog/e2e-7382-spec-merchant-multi-currency-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

E2E test - Merchant facing: Multi-currency setup
4 changes: 4 additions & 0 deletions changelog/fix-6782-support-phone-dev-mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Allow test phone number as Support Phone in Dev mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed a Level 3 error occurring during the capture of an authorization for amounts lower than the initial authorization amount.
5 changes: 5 additions & 0 deletions changelog/fix-7588-woopay-subscription-variation
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Edge case adding subscription_variation to WooPay button supported types


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: No changelog entry required – minor TS interface fix with no user-facing changes


4 changes: 4 additions & 0 deletions changelog/fix-apple-pay-including-tax
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed Apple Pay Double Tax Calculation Issue
5 changes: 5 additions & 0 deletions changelog/fix-jstest-regression-pr-7851
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Fix JS regression test in PR 7851


2 changes: 1 addition & 1 deletion client/components/account-balances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const AccountBalances: React.FC = () => {
currencyCode: overview.currency,
availableFunds: overview.available?.amount ?? 0,
pendingFunds: overview.pending?.amount ?? 0,
delayDays: account.deposits_schedule.delay_days,
delayDays: account?.deposits_schedule.delay_days ?? 0,
instantBalance: overview.instant,
} )
);
Expand Down
134 changes: 134 additions & 0 deletions client/order/cancel-authorization-confirm-modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/** @format */
/**
* External dependencies
*/
import * as React from 'react';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import interpolateComponents from '@automattic/interpolate-components';
import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import ConfirmationModal from 'wcpay/components/confirmation-modal';

interface CancelAuthorizationConfirmationModalProps {
originalOrderStatus: string;
}

const CancelAuthorizationConfirmationModal: React.FunctionComponent< CancelAuthorizationConfirmationModalProps > = ( {
originalOrderStatus,
} ) => {
const [
isCancelAuthorizationConfirmationModalOpen,
setIsCancelAuthorizationConfirmationModalOpen,
] = useState( true );

const closeModal = (): void => {
setIsCancelAuthorizationConfirmationModalOpen( false );
};

const handleCancelOrder = (): void => {
const orderEditForm: HTMLFormElement | null =
document.querySelector( '#order_status' )?.closest( 'form' ) ||
null;
if ( null !== orderEditForm ) {
orderEditForm.submit();
}
};

const doNotCancel = (): void => {
const orderStatusElement: HTMLInputElement | null = document.querySelector(
'#order_status'
);
if ( null !== orderStatusElement ) {
orderStatusElement.value = originalOrderStatus;
orderStatusElement.dispatchEvent( new Event( 'change' ) );
}
closeModal();
};

const cancelOrder = (): void => {
handleCancelOrder();
closeModal();
};

const buttonContent = (
<>
<Button isSecondary onClick={ doNotCancel }>
{ __( 'Do Nothing', 'woocommerce-payments' ) }
</Button>
<Button isPrimary onClick={ cancelOrder }>
{ __(
'Cancel order and authorization',
'woocommerce-payments'
) }
</Button>
</>
);

const confirmationMessage = interpolateComponents( {
mixedString: __(
'This order has been {{authorizedNotCaptured/}} yet. Changing the status to ' +
'Cancelled will also {{cancelAuthorization/}}. Do you want to continue?',
'woocommerce-payments'
),
components: {
authorizedNotCaptured: (
<a
target="_blank"
href="https://woo.com/document/woopayments/settings-guide/authorize-and-capture/#authorize-vs-capture"
rel="noopener noreferrer"
>
{ __(
'authorized but not captured',
'woocommerce-payments'
) }
</a>
),
cancelAuthorization: (
<a
target="_blank"
href="https://woo.com/document/woopayments/settings-guide/authorize-and-capture/#cancelling-authorizations"
rel="noopener noreferrer"
>
{ __( 'cancel the authorization', 'woocommerce-payments' ) }
</a>
),
doNothingBold: (
<b>{ __( 'Do Nothing', 'woocommerce-payments' ) }</b>
),
cancelOrderBold: (
<b>
{ __(
'Cancel order and authorization',
'woocommerce-payments'
) }
</b>
),
},
} );

return (
<>
{ isCancelAuthorizationConfirmationModalOpen && (
<ConfirmationModal
title={ __(
'Cancel authorization',
'woocommerce-payments'
) }
isDismissible={ false }
className="cancel-authorization-confirmation-modal"
actions={ buttonContent }
onRequestClose={ () => {
return false;
} }
>
<p>{ confirmationMessage }</p>
</ConfirmationModal>
) }
</>
);
};

export default CancelAuthorizationConfirmationModal;
27 changes: 21 additions & 6 deletions client/order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getConfig } from 'utils/order';
import { isAwaitingResponse, isUnderReview } from 'wcpay/disputes/utils';
import RefundConfirmationModal from './refund-confirm-modal';
import CancelConfirmationModal from './cancel-confirm-modal';
import CancelAuthorizationConfirmationModal from './cancel-authorization-confirm-modal';
import DisputedOrderNoticeHandler from 'wcpay/components/disputed-order-notice';

function disableWooOrderRefundButton( disputeStatus ) {
Expand Down Expand Up @@ -95,6 +96,7 @@ jQuery( function ( $ ) {

const canRefund = getConfig( 'canRefund' );
const refundAmount = getConfig( 'refundAmount' );
const hasOpenAuthorization = getConfig( 'hasOpenAuthorization' );
if (
this.value === 'wc-refunded' &&
originalStatus !== 'wc-refunded'
Expand All @@ -108,14 +110,27 @@ jQuery( function ( $ ) {
this.value === 'wc-cancelled' &&
originalStatus !== 'wc-cancelled'
) {
if ( ! canRefund || refundAmount <= 0 ) {
// If order has an uncaptured authorization, confirm
// that merchant indeed wants to cancel both the order
// and the authorization.
if ( hasOpenAuthorization ) {
renderModal(
<CancelAuthorizationConfirmationModal
originalOrderStatus={ originalStatus }
/>
);
return;
}
renderModal(
<CancelConfirmationModal
originalOrderStatus={ originalStatus }
/>
);
// If it is possible to refund an order, double check that
// merchants indeed wants to cancel, or if they just want to
// refund.
if ( canRefund && refundAmount > 0 ) {
renderModal(
<CancelConfirmationModal
originalOrderStatus={ originalStatus }
/>
);
}
}
} );

Expand Down
2 changes: 1 addition & 1 deletion client/overview/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const useSelectedCurrency = (): UseSelectedCurrencyResult => {
};

type SelectedCurrencyOverview = {
account?: AccountOverview.Account;
account?: AccountOverview.Account | null;
overview?: AccountOverview.Overview;
isLoading: boolean;
};
Expand Down
1 change: 0 additions & 1 deletion client/payment-methods-map.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import React from 'react';
import { __ } from '@wordpress/i18n';

/**
Expand Down
1 change: 0 additions & 1 deletion client/payment-methods/capability-request/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import React from 'react';
import { __ } from '@wordpress/i18n';

import CapabilityRequestList from './capability-request-map';
import CapabilityNotice from './capability-request-notice';
Expand Down
27 changes: 20 additions & 7 deletions client/settings/support-phone-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { useState, useEffect, useRef } from 'react';
/**
* Internal dependencies
*/
import { useAccountBusinessSupportPhone, useGetSavingError } from 'wcpay/data';
import {
useAccountBusinessSupportPhone,
useGetSavingError,
useDevMode,
} from 'wcpay/data';
import PhoneNumberInput from 'wcpay/settings/phone-input';

const SupportPhoneInput = ( { setInputVallid } ) => {
Expand All @@ -19,9 +23,14 @@ const SupportPhoneInput = ( { setInputVallid } ) => {

const currentPhone = useRef( supportPhone ).current;
const isEmptyPhoneValid = supportPhone === '' && currentPhone === '';
const isDevModeEnabled = useDevMode();
const isTestPhoneValid =
isDevModeEnabled &&
( supportPhone === '+1000-000-0000' ||
supportPhone === '+10000000000' );

const [ isPhoneValid, setPhoneValidity ] = useState( true );
if ( ! isPhoneValid && ! isEmptyPhoneValid ) {
if ( ! isTestPhoneValid && ! isPhoneValid && ! isEmptyPhoneValid ) {
supportPhoneError = __(
'Please enter a valid phone number.',
'woocommerce-payments'
Expand All @@ -41,6 +50,13 @@ const SupportPhoneInput = ( { setInputVallid } ) => {
}
}, [ supportPhoneError, setInputVallid ] );

let labelText = __( 'Support phone number', 'woocommerce-payments' );
if ( isDevModeEnabled ) {
labelText += __(
' (+1 000-000-0000 can be used in dev mode)',
'woocommerce-payments'
);
}
return (
<>
{ supportPhoneError && (
Expand All @@ -54,18 +70,15 @@ const SupportPhoneInput = ( { setInputVallid } ) => {
'This may be visible on receipts, invoices, and automated emails from your store.',
'woocommerce-payments'
) }
label={ __( 'Support phone number', 'woocommerce-payments' ) }
label={ labelText }
id="account-business-support-phone-input"
>
<PhoneNumberInput
onValueChange={ setSupportPhone }
value={ supportPhone }
onValidationChange={ setPhoneValidity }
inputProps={ {
ariaLabel: __(
'Support phone number',
'woocommerce-payments'
),
ariaLabel: labelText,
} }
/>
</BaseControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import { fireEvent, render, screen } from '@testing-library/react';
* Internal dependencies
*/
import SupportPhoneInput from '..';
import { useGetSavingError, useAccountBusinessSupportPhone } from 'wcpay/data';
import {
useGetSavingError,
useAccountBusinessSupportPhone,
useDevMode,
} from 'wcpay/data';

jest.mock( 'wcpay/data', () => ( {
useAccountBusinessSupportPhone: jest.fn(),
useGetSavingError: jest.fn(),
useDevMode: jest.fn(),
} ) );

describe( 'SupportPhoneInput', () => {
Expand Down Expand Up @@ -92,4 +97,17 @@ describe( 'SupportPhoneInput', () => {
container.querySelector( '.components-notice.is-error' ).textContent
).toEqual( 'Please enter a valid phone number.' );
} );

it( 'in dev mode, allow all 0s number', async () => {
useAccountBusinessSupportPhone.mockReturnValue( [
'+10000000000', // test phone number.
jest.fn(),
] );
useDevMode.mockReturnValue( true );

const { container } = render( <SupportPhoneInput /> );
expect(
container.querySelector( '.components-notice.is-error' )
).toBeNull();
} );
} );
1 change: 1 addition & 0 deletions client/settings/transactions/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jest.mock( 'wcpay/data', () => ( {
useManualCapture: jest.fn(),
useGetSavingError: jest.fn(),
useSavedCards: jest.fn(),
useDevMode: jest.fn(),
useCardPresentEligible: jest.fn(),
} ) );

Expand Down
4 changes: 1 addition & 3 deletions client/transactions/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,7 @@ export const TransactionsList = (
window.confirm( confirmMessage )
) {
try {
const {
exported_transactions: exportedTransactions,
} = await apiFetch( {
await apiFetch( {
path: getTransactionsCSV( {
userEmail,
dateAfter,
Expand Down
4 changes: 2 additions & 2 deletions client/types/account-overview.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export interface Overview {

export interface OverviewsResponse {
overviews: {
account: Account;
currencies: Array< Overview >;
account: Account | null;
currencies: Overview[];
};
isLoading: boolean;
}
Loading

0 comments on commit 2c56a25

Please sign in to comment.