Skip to content

Commit

Permalink
Merge branch 'develop' into dev/8750-migrate-mccy-e2e-tests-to-playwr…
Browse files Browse the repository at this point in the history
…ight
  • Loading branch information
cesarcosta99 authored Aug 20, 2024
2 parents 0845c7e + 26a0122 commit 2fed4d8
Show file tree
Hide file tree
Showing 110 changed files with 2,954 additions and 2,018 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WooCommerce Payments
# WooPayments

This is a feature plugin for accepting payments via a WooCommerce-branded payment gateway.

Expand Down Expand Up @@ -31,9 +31,9 @@ Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+

To fix this up, follow the link provided in the prompt and paste the token into the terminal window to continue.

### Extending WooCommerce Payments
### Extending WooPayments

If you are extending WooCommerce Payments, or building on top of it, please refer to the [core docs](includes/core/README.md) and directory (`includes/core`) for guides and recommended ways of doing it.
If you are extending WooPayments, or building on top of it, please refer to the [core docs](includes/core/README.md) and directory (`includes/core`) for guides and recommended ways of doing it.

## Setup

Expand Down
3 changes: 3 additions & 0 deletions assets/images/icons/copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 21 additions & 22 deletions bin/docker-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ redirect_output() {
fi
}

# --user xfs forces the wordpress:cli container to use a user with the same ID as the main wordpress container. See:
# https://hub.docker.com/_/wordpress#running-as-an-arbitrary-user
cli()
{
INTERACTIVE=''
if [ -t 1 ] ; then
INTERACTIVE='-it'
fi
redirect_output docker run $INTERACTIVE --env-file default.env --rm --user xfs --volumes-from $WP_CONTAINER --network container:$WP_CONTAINER wordpress:cli "$@"

redirect_output docker exec $INTERACTIVE --env-file default.env --user www-data $WP_CONTAINER "$@"
}

set +e
# Wait for containers to be started up before the setup.
# The db being accessible means that the db container started and the WP has been downloaded and the plugin linked
# The db being accessible means that the db container started and the WP has been downloaded and the plugin linked
cli wp db check --path=/var/www/html --quiet > /dev/null
while [[ $? -ne 0 ]]; do
echo "Waiting until the service is ready..."
Expand All @@ -40,7 +39,7 @@ cli wp plugin is-active woocommerce-payments > /dev/null
if [[ $? -eq 0 ]]; then
set -e
echo
echo "WCPay is installed and active"
echo "WooPayments is installed and active"
echo "SUCCESS! You should now be able to access http://${SITE_URL}/wp-admin/"
echo "You can login by using the username and password both as 'admin'"
exit 0
Expand All @@ -52,9 +51,6 @@ echo
echo "Setting up environment..."
echo

echo "Pulling the WordPress CLI docker image..."
docker pull wordpress:cli > /dev/null

echo "Setting up WordPress..."
cli wp core install \
--path=/var/www/html \
Expand All @@ -72,19 +68,19 @@ echo "Updating the WordPress database..."
cli wp core update-db --quiet

echo "Configuring WordPress to work with ngrok (in order to allow creating a Jetpack-WPCOM connection)";
cli config set DOCKER_HOST "\$_SERVER['HTTP_X_ORIGINAL_HOST'] ?? \$_SERVER['HTTP_HOST'] ?? 'localhost'" --raw
cli config set DOCKER_REQUEST_URL "( ! empty( \$_SERVER['HTTPS'] ) ? 'https://' : 'http://' ) . DOCKER_HOST" --raw
cli config set WP_SITEURL DOCKER_REQUEST_URL --raw
cli config set WP_HOME DOCKER_REQUEST_URL --raw
cli wp config set DOCKER_HOST "\$_SERVER['HTTP_X_ORIGINAL_HOST'] ?? \$_SERVER['HTTP_HOST'] ?? 'localhost'" --raw
cli wp config set DOCKER_REQUEST_URL "( ! empty( \$_SERVER['HTTPS'] ) ? 'https://' : 'http://' ) . DOCKER_HOST" --raw
cli wp config set WP_SITEURL DOCKER_REQUEST_URL --raw
cli wp config set WP_HOME DOCKER_REQUEST_URL --raw

echo "Enabling WordPress debug flags"
cli config set WP_DEBUG true --raw
cli config set WP_DEBUG_DISPLAY true --raw
cli config set WP_DEBUG_LOG true --raw
cli config set SCRIPT_DEBUG true --raw
cli wp config set WP_DEBUG true --raw
cli wp config set WP_DEBUG_DISPLAY true --raw
cli wp config set WP_DEBUG_LOG true --raw
cli wp config set SCRIPT_DEBUG true --raw

echo "Enabling WordPress development environment (enforces Stripe testing mode)";
cli config set WP_ENVIRONMENT_TYPE development
cli wp config set WP_ENVIRONMENT_TYPE development

echo "Updating permalink structure"
cli wp rewrite structure '/%postname%/'
Expand Down Expand Up @@ -114,26 +110,29 @@ cli wp plugin install wordpress-importer --activate
echo "Importing some sample data..."
cli wp import wp-content/plugins/woocommerce/sample-data/sample_products.xml --authors=skip

echo "Activating the WooCommerce Payments plugin..."
echo "Activating the WooPayments plugin..."
cli wp plugin activate woocommerce-payments

echo "Setting up WooCommerce Payments..."
echo "Setting up WooPayments..."
if [[ "0" == "$(cli wp option list --search=woocommerce_woocommerce_payments_settings --format=count)" ]]; then
echo "Creating WooCommerce Payments settings"
echo "Creating WooPayments settings"
cli wp option add woocommerce_woocommerce_payments_settings --format=json '{"enabled":"yes"}'
else
echo "Updating WooCommerce Payments settings"
echo "Updating WooPayments settings"
cli wp option update woocommerce_woocommerce_payments_settings --format=json '{"enabled":"yes"}'
fi

echo "Installing and activating Disable WordPress Updates..."
cli wp plugin install disable-wordpress-updates --activate

echo "Installing dev tools plugin..."
set +e
git clone git@github.com:Automattic/woocommerce-payments-dev-tools.git docker/wordpress/wp-content/plugins/woocommerce-payments-dev-tools
if [[ $? -eq 0 ]]; then
cli wp plugin activate woocommerce-payments-dev-tools
else
echo
echo "WARN: Could not access the dev tools repository. Skipping the install."
echo "WARN: Could not clone the dev tools repository. Skipping the install."
fi;
set -e

Expand Down
4 changes: 4 additions & 0 deletions changelog/add-global-theme-support-flag
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: add

Add WooPay global theme support flag
4 changes: 4 additions & 0 deletions changelog/add-test-drive-mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Enhance Sandbox mode onboarding by skipping KYC and making it fully automated for all supported countries.
4 changes: 4 additions & 0 deletions changelog/as-fix-ece-spacing
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Fix spacing on Express Checkout buttons.
4 changes: 4 additions & 0 deletions changelog/as-fix-woopay-data-mismatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Update cache after persisting the User session via WooPay
4 changes: 4 additions & 0 deletions changelog/fix-9202-ece-gpay-missing-on-safari
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix GooglePay button missing in Safari.
5 changes: 5 additions & 0 deletions changelog/fix-9254-docker-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: We update the Docker setup script to work with the latest WP CLI image.


3 changes: 3 additions & 0 deletions changelog/fix-9288-fix-qit-error-escape-output
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Significance: patch
Type: fix
Comment: Fix QIT error "EscapeOutput.OutputNotEscaped"
4 changes: 4 additions & 0 deletions changelog/fix-checkout-floating-labels-and-test-mode-copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Updates test mode instructions copy for cards at checkout.
5 changes: 5 additions & 0 deletions changelog/fix-disable-woopay-component-placing-an-order
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Disable WooPay component while placing an order.


5 changes: 5 additions & 0 deletions changelog/fix-tooltip-link-contrast-ratio
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: fix: tooltip link color contrast ratio


4 changes: 4 additions & 0 deletions changelog/fix-undefined-platform-global-theme-index-notice
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: platform_global_theme_support_enabled undefined index
4 changes: 4 additions & 0 deletions changelog/fix-wcpay-tracking-cookie-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix caching with tracking cookie.
4 changes: 4 additions & 0 deletions changelog/refactor-payment-methods-list-bnpl-separation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: update

refactor: separate BNPL methods from settings list
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import CurrencyInformationForMethods from './currency-information-for-methods';
import { getMissingCurrenciesTooltipMessage } from 'wcpay/multi-currency/missing-currencies-message';
import { upeCapabilityStatuses, upeMethods } from '../constants';
import paymentMethodsMap from '../../payment-methods-map';
import ConfirmPaymentMethodActivationModal from 'wcpay/payment-methods/activation-modal';
import ConfirmPaymentMethodActivationModal from 'wcpay/settings/payment-methods-list/activation-modal';
import './add-payment-methods-task.scss';
import PAYMENT_METHOD_IDS from 'wcpay/constants/payment-method';

Expand Down
4 changes: 3 additions & 1 deletion client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ export default class WCPayAPI {

return this.request( buildAjaxURL( wcAjaxUrl, 'init_woopay' ), {
_wpnonce: nonce,
appearance: getAppearance( appearanceType ),
appearance: getConfig( 'isWooPayGlobalThemeSupportEnabled' )
? getAppearance( appearanceType )
: null,
email: userEmail,
user_session: woopayUserSession,
order_id: getConfig( 'order_id' ),
Expand Down
23 changes: 22 additions & 1 deletion client/checkout/api/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ describe( 'WCPayAPI', () => {
getConfig.mockImplementation( ( key ) => {
const mockProperties = {
initWooPayNonce: 'foo',
appearance: mockAppearance,
order_id: 1,
key: 'testkey',
billing_email: 'test@example.com',
isWooPayGlobalThemeSupportEnabled: true,
};
return mockProperties[ key ];
} );
Expand Down Expand Up @@ -114,4 +114,25 @@ describe( 'WCPayAPI', () => {
foo: 'bar',
} );
} );

test( 'WooPay should not support global theme styles', async () => {
buildAjaxURL.mockReturnValue( 'https://example.org/' );
getConfig.mockImplementation( ( key ) => {
const mockProperties = {
initWooPayNonce: 'foo',
isWooPayGlobalThemeSupportEnabled: false,
};
return mockProperties[ key ];
} );

const api = new WCPayAPI( {}, request );
await api.initWooPay( 'foo@bar.com', 'qwerty123' );

expect( request ).toHaveBeenLastCalledWith( 'https://example.org/', {
_wpnonce: 'foo',
appearance: null,
email: 'foo@bar.com',
user_session: 'qwerty123',
} );
} );
} );
18 changes: 17 additions & 1 deletion client/checkout/blocks/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ button.wcpay-stripelink-modal-trigger:hover {
}

#remember-me {
margin-top: 36px;
margin: 36px 0 0 0;
padding: 0;
border: 0;

h2 {
font-size: 18px;
Expand Down Expand Up @@ -108,5 +110,19 @@ button.wcpay-stripelink-modal-trigger:hover {
}
}

button.copy-icon {
display: inline-block;
height: 1.2em;
width: 1.2em;
line-height: 1.2em;
vertical-align: middle;
margin-left: -0.1em;
padding: 0;
border-radius: 0;
border: none !important;
background: url( 'assets/images/icons/copy.svg?asset' );
background-size: cover;
}

@import '../woopay/style';
@import '../../components/loadable/style';
14 changes: 14 additions & 0 deletions client/checkout/classic/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,17 @@ li.wc_payment_method:has( .input-radio:checked
}
}
}

button.copy-icon {
display: inline-block;
height: 1.2em;
width: 1.2em;
line-height: 1.2em;
vertical-align: middle;
margin-left: -0.1em;
padding: 0;
border-radius: 0;
border: none !important;
background: url( 'assets/images/icons/copy.svg?asset' );
background-size: cover;
}
23 changes: 14 additions & 9 deletions client/checkout/express-checkout-buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@
margin-top: 1em;
width: 100%;
clear: both;
margin-bottom: 1.5em;

.woocommerce-cart & {
margin-bottom: 0;
}

&:first-child {
.woocommerce-checkout & {
margin-top: 0;
}

> div {
margin-bottom: 12px;

&:last-of-type {
margin-bottom: 0;
}
}
}

// This fixes width calculation issues inside the iframe for blocks and shortcode pages.
Expand All @@ -16,11 +29,3 @@
}
list-style: none;
}

.woocommerce-checkout .wcpay-payment-request-wrapper {
margin-bottom: 1.5em;
}

.wcpay-payment-request-wrapper > div:not( :last-child ) {
margin-bottom: 1em;
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export const expressCheckoutIframe = async ( api, context, emailSelector ) => {
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
appearance: getAppearance( appearanceType ),
appearance: getConfig( 'isWooPayGlobalThemeSupportEnabled' )
? getAppearance( appearanceType )
: null,
}
).then( ( response ) => {
if ( response?.data?.session ) {
Expand Down
1 change: 0 additions & 1 deletion client/checkout/woopay/express-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { getConfig } from 'utils/checkout';
import { WoopayExpressCheckoutButton } from './woopay-express-checkout-button';
import WCPayAPI from '../../api';
import request from '../../utils/request';
import '../../express-checkout-buttons.scss';

const oldWoopayContainers = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ export const WoopayExpressCheckoutButton = ( {
}
WooPayFirstPartyAuth.getWooPaySessionFromMerchant( {
_ajax_nonce: getConfig( 'woopaySessionNonce' ),
appearance: getAppearance( appearanceType ),
appearance: getConfig(
'isWooPayGlobalThemeSupportEnabled'
)
? getAppearance( appearanceType )
: null,
} )
.then( async ( response ) => {
if (
Expand Down Expand Up @@ -273,7 +277,9 @@ export const WoopayExpressCheckoutButton = ( {
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
appearance: getAppearance( appearanceType ),
appearance: getConfig( 'isWooPayGlobalThemeSupportEnabled' )
? getAppearance( appearanceType )
: null,
} )
.then( async ( response ) => {
if ( response?.blog_id && response?.data?.session ) {
Expand Down
4 changes: 3 additions & 1 deletion client/checkout/woopay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const renderSaveUserSection = () => {
);

if ( blocksCheckout.length ) {
const checkoutPageSaveUserContainer = document.createElement( 'div' );
const checkoutPageSaveUserContainer = document.createElement(
'fieldset'
);
const paymentOptions = document.getElementsByClassName(
'wp-block-woocommerce-checkout-payment-block'
)?.[ 0 ];
Expand Down
Loading

0 comments on commit 2fed4d8

Please sign in to comment.