Skip to content

Commit

Permalink
Merge branch 'develop' into fix/9794-refresh-page-when-ece-dismissed
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelzaleski authored Dec 16, 2024
2 parents 5ca6d08 + db8947f commit 959eb6e
Show file tree
Hide file tree
Showing 42 changed files with 792 additions and 382 deletions.
4 changes: 4 additions & 0 deletions changelog/add-6924-migrate-test-drive-capabilities
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Migrate active capabilities from test-drive account when switching to live account.
4 changes: 4 additions & 0 deletions changelog/add-jetpack-config-callback
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Added conditional use of Jetpack Config callback to avoid i18n notices.
4 changes: 4 additions & 0 deletions changelog/as-fix-ece-variable-subs-free-trial
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Enable ECE for Virtual Variable Subscriptions with Free Trials.
4 changes: 4 additions & 0 deletions changelog/compat-9727-avoid-early-translations
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Remove translations during initialization, preventing unnecessary warnings.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed an issue where order metadata was not updated when capturing an order in the processing state.
4 changes: 4 additions & 0 deletions changelog/fix-9421-auto-enable-woopay-in-sandbox-mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Ensure WooPay 'enabled by default' value is correctly set in sandbox mode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix inconsistent alignment of the download button across transactions, payouts, and disputes reporting views for a more cohesive user interface.
4 changes: 4 additions & 0 deletions changelog/fix-9806-ECE-subscription-checkout-signed-out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Ensure ECE login confirmation dialog is shown on Blocks.
5 changes: 5 additions & 0 deletions changelog/fix-tokenized-cart-error-notice-json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: fix: tokenized cart error notice json


4 changes: 4 additions & 0 deletions changelog/replace-from-url-query
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Fix Jetpack onboarding URL query from "woocommerce-payments" to "woocommerce-core-profiler"
5 changes: 5 additions & 0 deletions changelog/update-9910-transaction-id-label
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Change ID to uppercase in the 'Transaction ID' column label for consistency with similar unique IDs in the UI.


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

Add support for utilizing NOX capabilities as URL parameters during account creation.
19 changes: 13 additions & 6 deletions client/connect-account-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const ConnectAccountPage: React.FC = () => {
}
};

const checkAccountStatus = () => {
const checkAccountStatus = ( extraQueryArgs = {} ) => {
// Fetch account status from the cache.
apiFetch( {
path: `/wc/v3/payments/accounts`,
Expand All @@ -188,18 +188,22 @@ const ConnectAccountPage: React.FC = () => {
loaderProgressRef.current > 95
) {
setTestDriveLoaderProgress( 100 );

// Redirect to the Connect URL and let it figure it out where to point the merchant.
window.location.href = addQueryArgs( connectUrl, {
const queryArgs = {
test_drive: 'true',
'wcpay-sandbox-success': 'true',
source: determineTrackingSource(),
from: 'WCPAY_CONNECT',
redirect_to_settings_page:
urlParams.get( 'redirect_to_settings_page' ) || '',
};

// Redirect to the Connect URL and let it figure it out where to point the merchant.
window.location.href = addQueryArgs( connectUrl, {
...queryArgs,
...extraQueryArgs,
} );
} else {
setTimeout( checkAccountStatus, 2000 );
setTimeout( () => checkAccountStatus( extraQueryArgs ), 2000 );
}
} );
};
Expand All @@ -211,6 +215,7 @@ const ConnectAccountPage: React.FC = () => {

const customizedConnectUrl = addQueryArgs( connectUrl, {
test_drive: 'true',
capabilities: urlParams.get( 'capabilities' ) || '',
} );

const updateProgress = setInterval( updateLoaderProgress, 2500, 40, 5 );
Expand Down Expand Up @@ -264,7 +269,9 @@ const ConnectAccountPage: React.FC = () => {
// The account has been successfully onboarded.
if ( !! connectionSuccess ) {
// Start checking the account status in a loop.
checkAccountStatus();
checkAccountStatus( {
'wcpay-connection-success': '1',
} );
} else {
// Redirect to the response URL, but attach our test drive flags.
// This URL is generally a Connect page URL.
Expand Down
7 changes: 7 additions & 0 deletions client/express-checkout/blocks/hooks/use-express-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useStripe, useElements } from '@stripe/react-stripe-js';
* Internal dependencies
*/
import {
displayLoginConfirmation,
getExpressCheckoutButtonStyleSettings,
getExpressCheckoutData,
normalizeLineItems,
Expand Down Expand Up @@ -52,6 +53,12 @@ export const useExpressCheckout = ( {

const onButtonClick = useCallback(
( event ) => {
// If login is required for checkout, display redirect confirmation dialog.
if ( getExpressCheckoutData( 'login_confirmation' ) ) {
displayLoginConfirmation( event.expressPaymentType );
return;
}

const options = {
lineItems: normalizeLineItems( billing?.cartTotalItems ),
emailRequired: true,
Expand Down
23 changes: 19 additions & 4 deletions client/express-checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ jQuery( ( $ ) => {
} );

if ( getExpressCheckoutData( 'button_context' ) === 'product' ) {
wcpayECE.attachProductPageEventListeners( elements );
wcpayECE.attachProductPageEventListeners( elements, eceButton );
}
},

Expand Down Expand Up @@ -414,7 +414,7 @@ jQuery( ( $ ) => {
return api.expressCheckoutECEGetSelectedProductData( data );
},

attachProductPageEventListeners: ( elements ) => {
attachProductPageEventListeners: ( elements, eceButton ) => {
// WooCommerce Deposits support.
// Trigger the "woocommerce_variation_has_changed" event when the deposit option is changed.
// Needs to be defined before the `woocommerce_variation_has_changed` event handler is set.
Expand All @@ -437,6 +437,18 @@ jQuery( ( $ ) => {

$.when( wcpayECE.getSelectedProductData() )
.then( ( response ) => {
// We do not support variable subscriptions with variations
// that require shipping and include a free trial.
if (
getExpressCheckoutData( 'product' )
.product_type === 'variable-subscription' &&
response.needs_shipping &&
response.has_free_trial
) {
eceButton.destroy();
return;
}

const isDeposits = wcpayECE.productHasDepositOption();
/**
* If the customer aborted the express checkout,
Expand All @@ -449,8 +461,11 @@ jQuery( ( $ ) => {
! wcpayECE.paymentAborted &&
getExpressCheckoutData( 'product' )
.needs_shipping === response.needs_shipping;

if ( ! isDeposits && needsShipping ) {
if (
! isDeposits &&
needsShipping &&
! ( eceButton._destroyed ?? false )
) {
elements.update( {
amount: response.total.amount,
} );
Expand Down
1 change: 1 addition & 0 deletions client/express-checkout/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface WCPayExpressCheckoutParams {
product: {
needs_shipping: boolean;
currency: string;
product_type: string;
shippingOptions: {
id: string;
label: string;
Expand Down
2 changes: 2 additions & 0 deletions client/onboarding/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ export const createAccountSession = async (
data: OnboardingFields,
isPoEligible: boolean
): Promise< AccountKycSession > => {
const urlParams = new URLSearchParams( window.location.search );
return await apiFetch< AccountKycSession >( {
path: addQueryArgs( `${ NAMESPACE }/onboarding/kyc/session`, {
self_assessment: fromDotNotation( data ),
capabilities: urlParams.get( 'capabilities' ) || '',
progressive: isPoEligible,
} ),
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useStripe, useElements } from '@stripe/react-stripe-js';
* Internal dependencies
*/
import {
displayLoginConfirmation,
getExpressCheckoutButtonStyleSettings,
getExpressCheckoutData,
normalizeLineItems,
Expand Down Expand Up @@ -52,6 +53,12 @@ export const useExpressCheckout = ( {

const onButtonClick = useCallback(
( event ) => {
// If login is required for checkout, display redirect confirmation dialog.
if ( getExpressCheckoutData( 'login_confirmation' ) ) {
displayLoginConfirmation( event.expressPaymentType );
return;
}

const options = {
lineItems: normalizeLineItems( billing?.cartTotalItems ),
emailRequired: true,
Expand Down
23 changes: 15 additions & 8 deletions client/tokenized-express-checkout/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,23 @@ export const onConfirmHandler = async (
completePayment( redirectUrl );
}
} catch ( e ) {
// API errors are not parsed, so we need to do it ourselves.
if ( e.json ) {
e = e.json();
}

return abortPayment(
event,
getErrorMessageFromNotice( e.message ) ||
e.payment_result?.payment_details.find(
( detail ) => detail.key === 'errorMessage'
)?.value ||
__(
'There was a problem processing the order.',
'woocommerce-payments'
)
getErrorMessageFromNotice(
e.message ||
e.payment_result?.payment_details.find(
( detail ) => detail.key === 'errorMessage'
)?.value ||
__(
'There was a problem processing the order.',
'woocommerce-payments'
)
)
);
}
};
Expand Down
4 changes: 3 additions & 1 deletion client/tokenized-express-checkout/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export const getExpressCheckoutData = <
* @param notice Error notice.
* @return Error messages.
*/
export const getErrorMessageFromNotice = ( notice: string ) => {
export const getErrorMessageFromNotice = ( notice: string | undefined ) => {
if ( ! notice ) return '';

const div = document.createElement( 'div' );
div.innerHTML = notice.trim();
return div.firstChild ? div.firstChild.textContent : '';
Expand Down
2 changes: 1 addition & 1 deletion client/transactions/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const getColumns = (
[
{
key: 'transaction_id',
label: __( 'Transaction Id', 'woocommerce-payments' ),
label: __( 'Transaction ID', 'woocommerce-payments' ),
visible: false,
isLeftAligned: true,
},
Expand Down
52 changes: 0 additions & 52 deletions client/transactions/list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,56 +153,4 @@ $gap-small: 12px;
height: auto;
}
}

.components-card__header {
// These styles improve the overflow behaviour of the Search component within the TableCard, when many tags are selected. Used for transaction list views. See PR #8996
.woocommerce-search.woocommerce-select-control
.woocommerce-select-control__listbox {
position: relative;
top: 5px;
}
.woocommerce-table__actions {
justify-content: space-between;

& > div {
width: 85%;
margin-right: 0;
}

button.woocommerce-table__download-button {
@include breakpoint( '<1040px' ) {
.woocommerce-table__download-button__label {
display: none;
}
}
}

.woocommerce-select-control.is-focused
.woocommerce-select-control__control {
flex-wrap: wrap;

.woocommerce-select-control__tags {
white-space: wrap;
}
}
.woocommerce-select-control__tags {
overflow-x: auto;
white-space: nowrap;
scrollbar-width: none;
margin-right: 25px;
}

.woocommerce-select-control.is-focused
.components-base-control
.components-base-control__field {
flex-basis: 45%;
}

@include breakpoint( '<960px' ) {
.woocommerce-search {
margin: 0;
}
}
}
}
}
2 changes: 1 addition & 1 deletion client/transactions/list/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ describe( 'Transactions list', () => {
getByRole( 'button', { name: 'Download' } ).click();

const expected = [
'"Transaction Id"',
'"Transaction ID"',
'"Date / Time (UTC)"',
'Type',
'Channel',
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"require": {
"php": ">=7.3",
"ext-json": "*",
"automattic/jetpack-connection": "2.12.4",
"automattic/jetpack-config": "2.0.4",
"automattic/jetpack-autoloader": "3.0.10",
"automattic/jetpack-sync": "3.8.0",
"automattic/jetpack-connection": "6.2.0",
"automattic/jetpack-config": "3.0.0",
"automattic/jetpack-autoloader": "5.0.0",
"automattic/jetpack-sync": "4.1.0",
"woocommerce/subscriptions-core": "6.7.1"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 959eb6e

Please sign in to comment.