Skip to content

Commit

Permalink
Merge branch 'develop' into fix/date-type
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaun1985 authored Oct 26, 2023
2 parents 78e1c37 + ea53700 commit d20839a
Show file tree
Hide file tree
Showing 30 changed files with 385 additions and 119 deletions.
4 changes: 4 additions & 0 deletions changelog/7466-fix-hpos-compat-order-edit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix order status inconsistency in HPOS mode on Order Edit screen.
4 changes: 4 additions & 0 deletions changelog/dev-fix-po-notice-not-appearing
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Update to properly show tooltip on Payments > Settings page when account is in PO state.
4 changes: 4 additions & 0 deletions changelog/fix-6950-fix-imp-mobile-tooltip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed tooltip alignment for mobile view in payment settings
4 changes: 4 additions & 0 deletions changelog/fix-7473-accept-dispute-loading-state-ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Show loading state when accepting a dispute from the transaction details screen.
5 changes: 5 additions & 0 deletions changelog/fix-7487-dispute-e2e-tests-failing-wc-77
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Fix dispute e2e tests that were broken for WC 7.7


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

Fix Afterpay checkout error when shipping information is missing
4 changes: 4 additions & 0 deletions changelog/fix-express-checkout-wrapper-float
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Clear floats for payment request button wrapper.
4 changes: 4 additions & 0 deletions changelog/misc-checkout-scipt-alignment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Align deferred intent creation UPE checkout script with UPE inn terms of fonts appearance
5 changes: 5 additions & 0 deletions changelog/rpp-authentication-state-meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Storing the metadata, that was forgotten in 7471


Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ import { isPreviewing } from 'wcpay/checkout/preview';

jQuery( function ( $ ) {
enqueueFraudScripts( getUPEConfig( 'fraudServices' ) );
const publishableKey = getUPEConfig( 'publishableKey' );

if ( ! publishableKey ) {
// If no configuration is present, probably this is not the checkout page.
return;
}

const api = new WCPayAPI(
{
publishableKey: getUPEConfig( 'publishableKey' ),
publishableKey: publishableKey,
accountId: getUPEConfig( 'accountId' ),
forceNetworkSavedCards: getUPEConfig( 'forceNetworkSavedCards' ),
locale: getUPEConfig( 'locale' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { getUPEConfig } from 'wcpay/utils/checkout';
import { getAppearance } from '../../upe-styles';
import { getAppearance, getFontRulesFromPage } from '../../upe-styles';
import showErrorCheckout from 'wcpay/checkout/utils/show-error-checkout';
import {
appendFingerprintInputToForm,
Expand Down Expand Up @@ -160,6 +160,7 @@ async function createStripePaymentElement( api, paymentMethodType ) {
paymentMethodCreation: 'manual',
paymentMethodTypes: paymentMethodTypes,
appearance: initializeAppearance( api ),
fonts: getFontRulesFromPage(),
};

const elements = api
Expand Down
1 change: 1 addition & 0 deletions client/checkout/express-checkout-buttons.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.wcpay-payment-request-wrapper {
margin-top: 1em;
width: 100%;
clear: both;

&:first-child {
margin-top: 0;
Expand Down
22 changes: 16 additions & 6 deletions client/components/payment-methods-list/payment-method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,29 @@ const PaymentMethod = ( {
isPoEnabled,
isPoComplete,
}: PaymentMethodProps ): React.ReactElement => {
// We want to show a tooltip if PO is enabled and not yet complete. (We make an exception to not show this for card payments).
const isPoInProgress =
isPoEnabled &&
! isPoComplete &&
status !== upeCapabilityStatuses.ACTIVE;

// APMs are disabled if they are inactive or if Progressive Onboarding is enabled and not yet complete.
const disabled =
upeCapabilityStatuses.INACTIVE === status ||
( id !== 'card' && isPoEnabled && ! isPoComplete );
upeCapabilityStatuses.INACTIVE === status || isPoInProgress;
const {
accountFees,
}: { accountFees: Record< string, FeeStructure > } = useContext(
WCPaySettingsContext
);
const [ isManualCaptureEnabled ] = useManualCapture();

const needsAttention = [
const needsMoreInformation = [
upeCapabilityStatuses.INACTIVE,
upeCapabilityStatuses.PENDING_APPROVAL,
upeCapabilityStatuses.PENDING_VERIFICATION,
].includes( status );

const needsAttention = needsMoreInformation || isPoInProgress;
const shouldDisplayNotice = id === 'sofort';

const needsOverlay =
Expand Down Expand Up @@ -190,9 +196,13 @@ const PaymentMethod = ( {
'woocommerce-payments'
) }
/* eslint-disable-next-line max-len */
href={ getDocumentationUrlForDisabledPaymentMethod(
paymentMethodId
) }
href={
isPoInProgress
? 'https://woocommerce.com/document/woopayments/startup-guide/gradual-signup/#additional-payment-methods'
: getDocumentationUrlForDisabledPaymentMethod(
paymentMethodId
)
}
/>
),
},
Expand Down
15 changes: 0 additions & 15 deletions client/components/tooltip/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@
padding: 10px;
text-align: center;

&::after {
content: ' ';
position: absolute;

// assuming all the tooltips are displayed at the top of the wrapped element.
// no need to complicate things since that's the only use case at the moment.
bottom: 0;
left: 50%;
transform: translate( -50%, 22px );
border: solid 15px transparent;
border-top-color: $gray-900;
// Ensure the tooltip arrow does not obscure the mouse target element.
pointer-events: none;
}

a {
color: var( --wp-admin-theme-color, $gutenberg-blue );
}
Expand Down
11 changes: 10 additions & 1 deletion client/components/tooltip/tooltip-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,18 @@ const TooltipBase: React.FC< TooltipBaseProps > = ( {
wrappedElement.offsetWidth / 2 + wrappedElementRect.left;
const tooltipWidth = tooltipElement.offsetWidth;
let tooltipLeft = elementMiddle - tooltipWidth / 2;
const tooltipRight =
window.innerWidth -
( wrappedElementRect.left + tooltipElement.offsetWidth );

if ( tooltipLeft < 0 ) {
tooltipLeft = 10;
// create a gap with the left edge if the element is out of view port
tooltipLeft = 45;
} else if ( tooltipRight < 0 ) {
// create a gap with the right edge if the element is out of view port
tooltipLeft = tooltipLeft - 85;
}

tooltipElement.style.left = `${ tooltipLeft }px`;

// make it visible only after all the calculations are done.
Expand Down
10 changes: 9 additions & 1 deletion client/order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ jQuery( function ( $ ) {
);

$( 'select#order_status' ).on( 'change', function () {
const originalStatus = $( 'input#original_post_status' ).val();
//get the original status of the order from post or order data.
let originalStatus =
$( 'input#original_post_status' ).val() ||
$( 'input#original_order_status' ).val();
//TODO: Remove this after https://github.com/woocommerce/woocommerce/issues/40871 is fixed.
if ( originalStatus && ! originalStatus.startsWith( 'wc-' ) ) {
originalStatus = 'wc-' + originalStatus;
}

const canRefund = getConfig( 'canRefund' );
const refundAmount = getConfig( 'refundAmount' );
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ interface AcceptDisputeProps {
/**
* Disputes and Inquiries have different text for buttons and the modal.
* They also have different icons and tracks events. This function returns the correct props.
*
* @param dispute
*/
function getAcceptDisputeProps( dispute: Dispute ): AcceptDisputeProps {
function getAcceptDisputeProps( {
dispute,
isDisputeAcceptRequestPending,
}: {
dispute: Dispute;
isDisputeAcceptRequestPending: boolean;
} ): AcceptDisputeProps {
if ( isInquiry( dispute ) ) {
return {
acceptButtonLabel: __( 'Issue refund', 'woocommerce-payments' ),
Expand Down Expand Up @@ -146,7 +150,9 @@ function getAcceptDisputeProps( dispute: Dispute ): AcceptDisputeProps {
),
},
],
modalButtonLabel: __( 'Accept dispute', 'woocommerce-payments' ),
modalButtonLabel: isDisputeAcceptRequestPending
? __( 'Accepting…', 'woocommerce-payments' )
: __( 'Accept dispute', 'woocommerce-payments' ),
modalButtonTracksEvent: wcpayTracks.events.DISPUTE_ACCEPT_CLICK,
};
}
Expand All @@ -157,7 +163,10 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
chargeCreated,
orderUrl,
} ) => {
const { doAccept, isLoading } = useDisputeAccept( dispute );
const {
doAccept,
isLoading: isDisputeAcceptRequestPending,
} = useDisputeAccept( dispute );
const [ isModalOpen, setModalOpen ] = useState( false );

const now = moment();
Expand All @@ -170,7 +179,11 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
featureFlags: { isDisputeIssuerEvidenceEnabled },
} = useContext( WCPaySettingsContext );

const onModalClose = () => {
const handleModalClose = () => {
// Don't allow the user to close the modal if the accept request is in progress.
if ( isDisputeAcceptRequestPending ) {
return;
}
setModalOpen( false );
};

Expand All @@ -188,7 +201,10 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
);
};

const disputeAcceptAction = getAcceptDisputeProps( dispute );
const disputeAcceptAction = getAcceptDisputeProps( {
dispute,
isDisputeAcceptRequestPending,
} );

const challengeButtonDefaultText = isInquiry( dispute )
? __( 'Submit evidence', 'woocommerce-payments' )
Expand Down Expand Up @@ -239,7 +255,7 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
<Link
href={
// Prevent the user navigating to the challenge screen if the accept request is in progress.
isLoading
isDisputeAcceptRequestPending
? ''
: getAdminUrl( {
page: 'wc-admin',
Expand All @@ -252,7 +268,7 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
<Button
variant="primary"
data-testid="challenge-dispute-button"
disabled={ isLoading }
disabled={ isDisputeAcceptRequestPending }
onClick={ () => {
wcpayTracks.recordEvent(
wcpayTracks.events
Expand All @@ -275,7 +291,7 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {

<Button
variant="tertiary"
disabled={ isLoading }
disabled={ isDisputeAcceptRequestPending }
data-testid="open-accept-dispute-modal-button"
onClick={ () => {
wcpayTracks.recordEvent(
Expand All @@ -295,7 +311,7 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
{ isModalOpen && (
<Modal
title={ disputeAcceptAction.modalTitle }
onRequestClose={ onModalClose }
onRequestClose={ handleModalClose }
className="transaction-details-dispute-accept-modal"
>
<p>
Expand Down Expand Up @@ -326,7 +342,10 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
>
<Button
variant="tertiary"
onClick={ onModalClose }
disabled={
isDisputeAcceptRequestPending
}
onClick={ handleModalClose }
>
{ __(
'Cancel',
Expand All @@ -335,6 +354,12 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
</Button>
<Button
variant="primary"
isBusy={
isDisputeAcceptRequestPending
}
disabled={
isDisputeAcceptRequestPending
}
data-testid="accept-dispute-button"
onClick={ () => {
wcpayTracks.recordEvent(
Expand All @@ -346,7 +371,7 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
'transaction_details',
}
);
setModalOpen( false );

/**
* Handle the primary modal action.
* If it's an inquiry, redirect to the order page; otherwise, continue with the default dispute acceptance.
Expand Down
4 changes: 3 additions & 1 deletion client/payment-details/dispute-details/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@
}
}
.transaction-details-dispute-accept-modal {
max-width: 600px;
&.components-modal__frame {
max-width: 600px;
}

.components-modal__content {
padding-top: $grid-unit-30;
Expand Down
32 changes: 2 additions & 30 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -2890,34 +2890,6 @@ public function cancel_authorization( $order ) {
];
}

/**
* Create the shipping data array to send to Stripe when making a purchase.
*
* @param WC_Order $order The order that is being paid for.
* @return array The shipping data to send to Stripe.
*/
public function get_shipping_data_from_order( WC_Order $order ): array {
return [
'name' => implode(
' ',
array_filter(
[
$order->get_shipping_first_name(),
$order->get_shipping_last_name(),
]
)
),
'address' => [
'line1' => $order->get_shipping_address_1(),
'line2' => $order->get_shipping_address_2(),
'postal_code' => $order->get_shipping_postcode(),
'city' => $order->get_shipping_city(),
'state' => $order->get_shipping_state(),
'country' => $order->get_shipping_country(),
],
];
}

/**
* Create the level 3 data array to send to Stripe when making a purchase.
*
Expand Down Expand Up @@ -3736,11 +3708,11 @@ private function upe_needs_redirection( $payment_methods ) {
*
* @param Create_And_Confirm_Intention $request The request object for creating and confirming intention.
* @param Payment_Information $payment_information The payment information object.
* @param mixed $order The order object or data.
* @param WC_Order $order The order object.
*
* @return void
*/
protected function modify_create_intent_parameters_when_processing_payment( Create_And_Confirm_Intention $request, Payment_Information $payment_information, $order ) {
protected function modify_create_intent_parameters_when_processing_payment( Create_And_Confirm_Intention $request, Payment_Information $payment_information, WC_Order $order ) {
// Do nothing.
}
}
Loading

0 comments on commit d20839a

Please sign in to comment.