Skip to content

Commit

Permalink
Merge branch 'develop' into fix/tokenized-ece-updates-on-total-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gpressutto5 authored Feb 24, 2025
2 parents cd849f8 + 7199fbb commit 9de982a
Show file tree
Hide file tree
Showing 36 changed files with 278 additions and 622 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** WooPayments Changelog ***

= 8.9.2 - 2025-02-21 =
* Fix - Fixed WooPay opt-in race condition

= 8.9.1 - 2025-02-07 =
* Fix - Ensures that the tokenised cart for ECE implementation is disabled by default.

Expand Down
4 changes: 4 additions & 0 deletions changelog/add-10382-adds-store-id-to-tracker-request-body
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Adds store_id property to body of WooPay tracker events.
5 changes: 5 additions & 0 deletions changelog/chore-remove-unused-strings-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: chore: remove unused strings file.


4 changes: 4 additions & 0 deletions changelog/cleanup-new-payment-process
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Remove routing to the partially re-engineered payment process"
4 changes: 4 additions & 0 deletions changelog/fix-10379-woo-logo-size-test-drive-onboarding
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Update the size of Woo logo on the test drive onboarding page.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Prevent fatal errors when subscription is deactivated due outdated version.
4 changes: 4 additions & 0 deletions changelog/fix-redundant-pmme-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Avoid PMME init for unavailable BNPL use-cases.
4 changes: 4 additions & 0 deletions changelog/fix-woopay-opt-in-race-condition
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed WooPay opt-in race condition
5 changes: 5 additions & 0 deletions changelog/update-10172-csv-export-tracks-event
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Add a single tracks event - wcadmin_wcpay_csv_export_click to track export requests of transactions, payouts and disputes, using the new async export method. See - https://github.com/Automattic/woocommerce-payments/issues/9969


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

Add a notice indicating that overview page needs to be reloaded after completing the requirements in the embedded component.
9 changes: 9 additions & 0 deletions client/cart/blocks/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ const ProductDetail = ( { cart, context } ) => {
wcSettings.currency.precision
);

if ( ! window.wcpayStripeSiteMessaging ) {
return null;
}

const {
country,
paymentMethods,
currencyCode,
shouldInitializePMME,
} = window.wcpayStripeSiteMessaging;

if ( ! shouldInitializePMME ) {
return null;
}

const amount = parseInt( cartTotal, 10 ) || 0;

const options = {
Expand Down
29 changes: 23 additions & 6 deletions client/components/woopay/save-user/checkout-page-save-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,34 @@ const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => {
isBlocksCheckout,
] );

useEffect( () => {
if (
! getConfig( 'forceNetworkSavedCards' ) ||
! isWCPayWithNewTokenChosen ||
isRegisteredUser
) {
// Clicking the place order button sets the extension data in backend. If user changes the payment method
// due to an error, we need to clear the extension data in backend.
if ( isBlocksCheckout && userDataSent ) {
sendExtensionData( true );
}
clearValidationError( errorId );
}
}, [
clearValidationError,
errorId,
isBlocksCheckout,
isRegisteredUser,
isWCPayWithNewTokenChosen,
sendExtensionData,
userDataSent,
] );

if (
! getConfig( 'forceNetworkSavedCards' ) ||
! isWCPayWithNewTokenChosen ||
isRegisteredUser
) {
// Clicking the place order button sets the extension data in backend. If user changes the payment method
// due to an error, we need to clear the extension data in backend.
if ( isBlocksCheckout && userDataSent ) {
sendExtensionData( true );
}
clearValidationError( errorId );
return null;
}

Expand Down
7 changes: 3 additions & 4 deletions client/connect-account-page/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@

img.logo {
position: absolute;
height: 40px;
width: 40px;
top: 18px;
left: 36px;
width: 64px;
top: 24px;
left: 24px;
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions client/deposits/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ export const DepositsList = (): JSX.Element => {

const downloadable = !! rows.length;

const onDownload = async () => {
recordEvent( 'wcpay_deposits_download', {
exported_deposits: rows.length,
total_deposits: depositsSummary.count,
const { path } = getQuery();
const onExport = async () => {
recordEvent( 'wcpay_csv_export_click', {
row_type: 'payouts',
source: path,
exported_row_count: depositsSummary.count,
} );

const userEmail = wcpaySettings.currentUserEmail;
Expand Down Expand Up @@ -302,7 +304,7 @@ export const DepositsList = (): JSX.Element => {
key="download"
isDisabled={ isLoading || isExportInProgress }
isBusy={ isExportInProgress }
onClick={ onDownload }
onClick={ onExport }
/>
),
] }
Expand Down
11 changes: 6 additions & 5 deletions client/disputes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,17 @@ export const DisputesList = (): JSX.Element => {
const downloadable = !! rows.length;

const onDownload = async () => {
recordEvent( 'wcpay_disputes_download', {
exported_disputes: rows.length,
total_disputes: disputesSummary.count,
} );

// We destructure page and path to get the right params.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { page, path, ...params } = getQuery();
const userEmail = wcpaySettings.currentUserEmail;

recordEvent( 'wcpay_csv_export_click', {
row_type: 'disputes',
source: path,
exported_row_count: disputesSummary.count,
} );

const userLocale = wcpaySettings.userLocale.code;
const {
date_before: dateBefore,
Expand Down
30 changes: 30 additions & 0 deletions client/overview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
} from '@stripe/react-connect-js';
import { recordEvent } from 'wcpay/tracks';
import StripeSpinner from 'wcpay/components/stripe-spinner';
import { getAdminUrl } from 'wcpay/utils';

const OverviewPageError = () => {
const queryParams = getQuery();
Expand Down Expand Up @@ -98,6 +99,11 @@ const OverviewPage = () => {
const [ stripeComponentLoading, setStripeComponentLoading ] = useState(
true
);
// Variable to memoize the count of Stripe notifications.
const [
stripeNotificationsCountToAddressMemo,
setStripeNotificationsCountToAddressMemo,
] = useState( 0 );

const isTestModeOnboarding = wcpaySettings.testModeOnboarding;
const { isLoading: settingsIsLoading } = useSettings();
Expand Down Expand Up @@ -216,6 +222,28 @@ const OverviewPage = () => {
// Do something related to notifications that don't require action.
setNotificationsBannerMessage( 'The items below are in review.' );
} else {
// This is the case where we addressed everything and previously had some notifications to address.
// We recommend the merchant to reload the page in this case.
if ( stripeNotificationsCountToAddressMemo > 0 ) {
dispatch( 'core/notices' ).createSuccessNotice(
__(
'Updates take a moment to appear. Please refresh the page in a minute.',
'woocommerce-payments'
),
{
actions: [
{
label: __( 'Refresh', 'woocommerce-payments' ),
url: getAdminUrl( {
page: 'wc-admin',
path: '/payments/overview',
} ),
},
],
explicitDismiss: true,
}
);
}
setNotificationsBannerMessage( '' );
}
if ( response.actionRequired > 0 || response.total > 0 ) {
Expand All @@ -224,6 +252,8 @@ const OverviewPage = () => {
action_required_count: response.actionRequired,
total_count: response.total,
} );
// Memoize the notifications count to be able to compare it with the fresh count when this function is called one more time.
setStripeNotificationsCountToAddressMemo( response.total );
}
// If the component inits successfully, this function is always called.
// It's safe to set the loading false here rather than onLoaderStart, because it happens too early and the UX is not smooth.
Expand Down
45 changes: 0 additions & 45 deletions client/overview/strings.tsx

This file was deleted.

57 changes: 26 additions & 31 deletions client/product-details/bnpl-site-messaging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ export const initializeBnplSiteMessaging = async () => {
paymentMethods,
currencyCode,
isCart,
isCartBlock,
cartTotal,
isBnplAvailable,
shouldShowPMME,
} = window.wcpayStripeSiteMessaging;

let amount;
Expand All @@ -64,48 +63,44 @@ export const initializeBnplSiteMessaging = async () => {
'payment-method-message'
);

if ( isCart || isCartBlock ) {
if ( isCart ) {
amount = parseInt( cartTotal, 10 ) || 0;
elementLocation = 'bnplClassicCart';
} else {
amount = parseInt( productVariations.base_product.amount, 10 ) || 0;

if ( ! isBnplAvailable ) {
if ( ! shouldShowPMME ) {
paymentMessageContainer.style.setProperty( 'display', 'none' );
}
}

let paymentMessageElement;

if ( ! isCartBlock ) {
const api = new WCPayAPI(
{
publishableKey: publishableKey,
accountId: accountId,
locale: locale,
},
apiRequest
);
const api = new WCPayAPI(
{
publishableKey: publishableKey,
accountId: accountId,
locale: locale,
},
apiRequest
);

const options = {
amount: amount,
currency: currencyCode || 'USD',
paymentMethodTypes: paymentMethods || [],
countryCode: country, // Customer's country or base country of the store.
};
const options = {
amount: amount,
currency: currencyCode || 'USD',
paymentMethodTypes: paymentMethods || [],
countryCode: country, // Customer's country or base country of the store.
};

const elementsOptions = {
appearance: await initializeAppearance( api, elementLocation ),
fonts: getFontRulesFromPage(),
};
const elementsOptions = {
appearance: await initializeAppearance( api, elementLocation ),
fonts: getFontRulesFromPage(),
};

const stripe = await api.getStripe();
const stripe = await api.getStripe();

paymentMessageElement = stripe
.elements( elementsOptions )
.create( 'paymentMethodMessaging', options );
paymentMessageElement.mount( '#payment-method-message' );
}
const paymentMessageElement = stripe
.elements( elementsOptions )
.create( 'paymentMethodMessaging', options );
paymentMessageElement.mount( '#payment-method-message' );

// This function converts relative units (rem/em) to pixels based on the current font size.
function convertToPixels( value, baseFontSize ) {
Expand Down
12 changes: 11 additions & 1 deletion client/product-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ jQuery( async function ( $ ) {
return;
}

const { shouldInitializePMME } = window.wcpayStripeSiteMessaging;

if ( ! shouldInitializePMME ) {
const paymentMessageContainer = document.getElementById(
'payment-method-message'
);
paymentMessageContainer.style.setProperty( 'display', 'none' );
return;
}

const {
productVariations,
productId,
Expand Down Expand Up @@ -81,7 +91,7 @@ jQuery( async function ( $ ) {
if ( totalAmount <= 0 || ! currency ) {
return;
}
bnplPaymentMessageElement.update( { amount: totalAmount, currency } );
bnplPaymentMessageElement?.update( { amount: totalAmount, currency } );
};

/**
Expand Down
Loading

0 comments on commit 9de982a

Please sign in to comment.