-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into cleanup/upe-checkout-class
- Loading branch information
Showing
14 changed files
with
437 additions
and
21 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
changelog/add-5605-cancel-authorizations-if-order-is-cancelled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
4 changes: 4 additions & 0 deletions
4
changelog/fix-6806-authorizations-level-3-data-error-while-trying-to-capture-partial-amount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
134 changes: 134 additions & 0 deletions
134
client/order/cancel-authorization-confirm-modal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.