Skip to content

Commit

Permalink
Fix conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezari committed Jan 10, 2025
2 parents 6a79190 + 82ac1b9 commit 250ab42
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 176 deletions.
4 changes: 4 additions & 0 deletions changelog/dev-10071-convert-shopper-pay-for-order-e2e-spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Add the Playwright Pay for Order spec and remove the equivalent Puppeteer spec.
4 changes: 4 additions & 0 deletions changelog/dev-10113-bump-e2e-dockerfile-php-xdebug-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Update the PHP version and the Xdebug version used in the E2E testing environment.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Converted a puppeteer spec to playwright


4 changes: 4 additions & 0 deletions changelog/fix-10033-wporg-readme-updates
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Update WordPress.org readme.txt file
5 changes: 5 additions & 0 deletions changelog/fix-tokenized-ece-applepay-delay
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: fix: ensure the "add to cart" ECE call is completed before other calls are made.


17 changes: 13 additions & 4 deletions client/express-checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ jQuery( ( $ ) => {
return;
}

let addToCartPromise = Promise.resolve();
const stripe = await api.getStripe();

const elements = stripe.elements( {
Expand Down Expand Up @@ -301,7 +302,14 @@ jQuery( ( $ ) => {
}

// Add products to the cart if everything is right.
wcpayECE.addToCart();
// we are storing the promise to ensure that the "add to cart" call is completed,
// before the `shippingaddresschange` is triggered when the dialog is opened.
// Otherwise, it might happen that the `shippingaddresschange` is triggered before the "add to cart" call is done,
// which can cause errors.
addToCartPromise = wcpayECE.addToCart();
addToCartPromise.finally( () => {
addToCartPromise = Promise.resolve();
} );
}

const clickOptions = {
Expand All @@ -319,9 +327,10 @@ jQuery( ( $ ) => {
event.resolve( clickOptions );
} );

eceButton.on( 'shippingaddresschange', async ( event ) =>
shippingAddressChangeHandler( api, event, elements )
);
eceButton.on( 'shippingaddresschange', async ( event ) => {
await addToCartPromise;
return shippingAddressChangeHandler( api, event, elements );
} );

eceButton.on( 'shippingratechange', async ( event ) =>
shippingRateChangeHandler( api, event, elements )
Expand Down
17 changes: 13 additions & 4 deletions client/tokenized-express-checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ jQuery( ( $ ) => {
* @param {Object} options ECE options.
*/
startExpressCheckoutElement: async ( options ) => {
let addToCartPromise = Promise.resolve();
const stripe = await api.getStripe();
const elements = stripe.elements( {
mode: 'payment',
Expand Down Expand Up @@ -247,7 +248,14 @@ jQuery( ( $ ) => {
}

// Add products to the cart if everything is right.
getCartApiHandler().addProductToCart();
// we are storing the promise to ensure that the "add to cart" call is completed,
// before the `shippingaddresschange` is triggered when the dialog is opened.
// Otherwise, it might happen that the `shippingaddresschange` is triggered before the "add to cart" call is done,
// which can cause errors.
addToCartPromise = getCartApiHandler().addProductToCart();
addToCartPromise.finally( () => {
addToCartPromise = Promise.resolve();
} );
}

const clickOptions = {
Expand All @@ -270,9 +278,10 @@ jQuery( ( $ ) => {
event.resolve( clickOptions );
} );

eceButton.on( 'shippingaddresschange', async ( event ) =>
shippingAddressChangeHandler( event, elements )
);
eceButton.on( 'shippingaddresschange', async ( event ) => {
await addToCartPromise;
return shippingAddressChangeHandler( event, elements );
} );

eceButton.on( 'shippingratechange', async ( event ) =>
shippingRateChangeHandler( event, elements )
Expand Down
25 changes: 9 additions & 16 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,24 @@ Features previously only available on your payment provider’s website are now

**Pay as you go**

WooPayments is **free to install**, with **no setup fees or monthly fees**. Pay-as-you-go fees start at 2.9% + $0.30 per transaction for U.S.-issued cards. [Read more about transaction fees](https://woocommerce.com/document/woopayments/fees-and-debits/fees/).
WooPayments is **free to install**, with **no setup fees or monthly fees**. Our pay-as-you-go pricing model means we're incentivized to help you succeed! [Read more about transaction fees](https://woocommerce.com/document/woopayments/fees-and-debits/fees/).

**Supported by the WooCommerce team**

Our global support team is available to answer questions you may have about WooPayments installation, setup, or use. For assistance, [open a ticket on woocommerce.com](https://woocommerce.com/my-account/create-a-ticket/?select=5278104).
Our global support team is available to answer questions you may have about WooPayments installation, setup, or use. For assistance, [open a ticket on woocommerce.com](https://woocommerce.com/my-account/contact-support/?select=5278104).

== Getting Started ==

= Requirements =

* WordPress 6.0 or newer.
* WooCommerce 7.6 or newer.
* PHP 7.3 or newer is recommended.
* PHP 7.3 or newer.

= Try it now =

To try WooPayments (previously WooCommerce Payments) on your store, simply [install it](https://wordpress.org/plugins/woocommerce-payments/#installation) and follow the prompts. Please see our [Startup Guide](https://woocommerce.com/document/woopayments/startup-guide/) for a full walkthrough of the process.

WooPayments has experimental support for the Checkout block from [WooCommerce Blocks](https://wordpress.org/plugins/woo-gutenberg-products-block/). Please check the [FAQ section](#faq) for more information.

== Installation ==

Install and activate the WooCommerce and WooPayments plugins, if you haven't already done so, then go to "Payments" in the WordPress admin menu and follow the instructions there.
Expand All @@ -56,13 +54,17 @@ Install and activate the WooCommerce and WooPayments plugins, if you haven't alr

= What countries and currencies are supported? =

If you are an individual or business based in [one of these countries](https://woocommerce.com/document/woopayments/compatibility/countries/#supported-countries), you can sign-up with WooPayments. After completing sign up, you can accept payments from customers anywhere in the world.
If you are an individual or business based in [one of these countries](https://woocommerce.com/document/woopayments/compatibility/countries/#supported-countries), you can sign-up with WooPayments. After completing sign up, you can accept payments from customers anywhere in the world, as long as they are paying with [a supported currency](https://woocommerce.com/document/woopayments/currencies/available-currencies/).

We are actively planning to expand into additional countries based on your interest. Let us know where you would like to [see WooPayments launch next](https://woocommerce.com/payments/#request-invite).

= Why is a WordPress.com account and connection required? =

WooPayments uses the WordPress.com connection to authenticate each request, connecting your store with our payments partner.
WooPayments uses the WordPress.com connection to securely communicate with our payments server. This is necessary for WooPayments to function correctly, so it's not possible to use WooPayments without connecting. Please see [this document](https://woocommerce.com/document/woopayments/our-policies/connection/) for more information.

Note that you do not need to host your site itself on WordPress.com, nor do you need to host *any* site on WordPress.com at all. You only need an account.

Note that you do not need to host your site itself on WordPress.com. You only need an account on WordPress.com to establish the connection. You can create a WordPress.com account [at this link](https://wordpress.com/start/account/user-social).

= How do I set up a store for a client? =

Expand All @@ -76,15 +78,6 @@ WooPayments is built in partnership with Stripe [Stripe](https://stripe.com/). W

You can read our Terms of Service and other policies [here](https://woocommerce.com/document/woopayments/our-policies/).

= How does the Checkout block work? =

You need the [WooCommerce Blocks](https://wordpress.org/plugins/woo-gutenberg-products-block/) plugin to be installed and active to use the Checkout block. Once you add the block to a page, WooPayments will automatically appear as an option.

Please note that our support for the checkout block is still experimental and the following features of the gateway will probably not work:

* Using saved cards and saving cards.
* Integration with WooCommerce Subscriptions.

== Screenshots ==

1. View Transactions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* External dependencies
*/
import { test, expect } from '@playwright/test';
/**
* Internal dependencies
*/
import { useMerchant } from '../../utils/helpers';
import { goToWooPaymentsSettings } from '../../utils/merchant-navigation';

test.describe(
'As a merchant, I should be prompted a confirmation modal when I try to activate the manual capture',
() => {
useMerchant();

test.beforeEach( async ( { page } ) => {
await goToWooPaymentsSettings( page );
await page.getByTestId( 'capture-later-checkbox' ).click();
} );

test( 'should show the confirmation dialog when enabling the manual capture', async ( {
page,
} ) => {
await expect(
page.getByText(
'Payments must be captured within 7 days or the authorization will expire and money will be returned to the shopper'
)
).toBeVisible( {
timeout: 10000,
} );
} );

test( 'should not show the confirmation dialog when disabling the manual capture', async ( {
page,
} ) => {
await page
.getByRole( 'button', { name: 'Enable manual capture' } )
.click();
await page.getByTestId( 'capture-later-checkbox' ).click();
await expect( page.locator( '.wcpay-modal' ) ).not.toBeVisible();
} );

test( 'should show the non-card methods disabled when manual capture is enabled', async ( {
page,
} ) => {
await page
.getByRole( 'button', { name: 'Enable manual capture' } )
.click();
const paymentMethodWarningIconElement = await page
.getByTestId( 'loadable-checkbox-icon-warning' )
.first();
await expect( paymentMethodWarningIconElement ).toHaveText(
/cannot be enabled at checkout/
);
} );
}
);
91 changes: 91 additions & 0 deletions tests/e2e-pw/specs/shopper/shopper-pay-for-order.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* External dependencies
*/
import { test, expect } from '@playwright/test';

/**
* Internal dependencies
*/
import { config } from '../../config/default';
import * as shopper from '../../utils/shopper';
import * as shopperNavigation from '../../utils/shopper-navigation';
import * as devtools from '../../utils/devtools';
import { getMerchant, getShopper } from '../../utils/helpers';

const cardTestingPreventionStates = [
{ cardTestingPreventionEnabled: false },
{ cardTestingPreventionEnabled: true },
];

test.describe( 'Shopper > Pay for Order', () => {
cardTestingPreventionStates.forEach(
( { cardTestingPreventionEnabled } ) => {
test( `should be able to pay for a failed order with card testing protection ${ cardTestingPreventionEnabled }`, async ( {
browser,
} ) => {
const { merchantPage } = await getMerchant( browser );
const { shopperPage } = await getShopper( browser );

// Enable or disable card testing protection.
if ( ! cardTestingPreventionEnabled ) {
await devtools.disableCardTestingProtection( merchantPage );
} else {
await devtools.enableCardTestingProtection( merchantPage );
}

// Attempt to pay with a declined card.
await shopper.addCartProduct( shopperPage );
await shopper.setupCheckout(
shopperPage,
config.addresses.customer.billing
);
await shopper.fillCardDetails(
shopperPage,
config.cards.declined
);
await shopper.placeOrder( shopperPage );

await expect(
shopperPage.getByText( 'Your card was declined' ).first()
).toBeVisible();

// Go to the orders page and pay with a basic card.
await shopperNavigation.goToOrders( shopperPage );

const payForOrderButton = shopperPage
.locator( '.woocommerce-button.button.pay', {
hasText: 'Pay',
} )
.first();
await payForOrderButton.click();
await shopper.fillCardDetails(
shopperPage,
config.cards.basic
);

// Check for the fraud prevenction token presence.
const token = await shopperPage.evaluate( () => {
return ( window as any ).wcpayFraudPreventionToken;
} );

if ( cardTestingPreventionEnabled ) {
expect( token ).not.toBeUndefined();
} else {
expect( token ).toBeUndefined();
}

// Click the pay for order button.
await shopper.placeOrder( shopperPage );

await expect(
shopperPage.getByText( 'Order received' ).first()
).toBeVisible();

// Disable card testing protection if necessary.
if ( cardTestingPreventionEnabled ) {
await devtools.disableCardTestingProtection( merchantPage );
}
} );
}
);
} );
40 changes: 40 additions & 0 deletions tests/e2e-pw/utils/devtools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* External dependencies
*/
import { Page, expect } from '@playwright/test';

const goToDevToolsSettings = ( page: Page ) =>
page.goto( 'wp-admin/admin.php?page=wcpaydev', {
waitUntil: 'load',
} );

const saveDevToolsSettings = async ( page: Page ) => {
await page.getByRole( 'button', { name: 'Save Changes' } ).click();
expect( page.getByText( /Settings saved/ ) ).toBeVisible();
};

const getIsCardTestingProtectionEnabled = ( page: Page ) =>
page.getByLabel( 'Card testing mitigations enabled' ).isChecked();

const toggleCardTestingProtection = ( page: Page ) =>
page
.locator( 'label[for="wcpaydev_force_card_testing_protection_on"]' )
.click();

export const enableCardTestingProtection = async ( page: Page ) => {
await goToDevToolsSettings( page );

if ( ! ( await getIsCardTestingProtectionEnabled( page ) ) ) {
await toggleCardTestingProtection( page );
await saveDevToolsSettings( page );
}
};

export const disableCardTestingProtection = async ( page: Page ) => {
await goToDevToolsSettings( page );

if ( await getIsCardTestingProtectionEnabled( page ) ) {
await toggleCardTestingProtection( page );
await saveDevToolsSettings( page );
}
};
4 changes: 2 additions & 2 deletions tests/e2e/env/wordpress-xdebug/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM wordpress:6.0.2-php7.4
RUN pecl install xdebug-2.9.8 \
FROM wordpress:php8.1
RUN pecl install xdebug \
&& echo 'xdebug.remote_enable=1' >> $PHP_INI_DIR/php.ini \
&& echo 'xdebug.remote_port=9000' >> $PHP_INI_DIR/php.ini \
&& echo 'xdebug.remote_host=host.docker.internal' >> $PHP_INI_DIR/php.ini \
Expand Down
Loading

0 comments on commit 250ab42

Please sign in to comment.