Skip to content

Commit

Permalink
Merge release/6.6.0 into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoumpierre committed Oct 11, 2023
2 parents cdd14ca + 5f471fb commit 137b8be
Show file tree
Hide file tree
Showing 338 changed files with 13,669 additions and 3,428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: "Generate matrix"
id: generate_matrix
run: |
PHP_VERSIONS=$( echo "[\"$PHP_MIN_SUPPORTED_VERSION\", \"8.0\", \"8.1\"]" )
PHP_VERSIONS=$( echo "[\"7.4\", \"8.0\", \"8.1\"]" )
echo "matrix={\"woocommerce\":[\"beta\"],\"wordpress\":[\"latest\"],\"gutenberg\":[\"latest\"],\"php\":$PHP_VERSIONS}" >> $GITHUB_OUTPUT
# a dedicated job, as allowed to fail
Expand Down
4 changes: 4 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
background-image: url( '../images/payment-methods/affirm-icon.svg' );
}

.payment-method__brand--klarna {
background-image: url( '../images/payment-methods/klarna.svg' );
}

.wc_gateways tr[data-gateway_id='woocommerce_payments'] .payment-method__icon {
border: 1px solid #ddd;
border-radius: 2px;
Expand Down
11 changes: 11 additions & 0 deletions assets/images/payment-methods/klarna.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
*** WooPayments Changelog ***

= 6.6.0 - 2023-10-11 =
* Add - Add a notice on the Settings page to request JCB capability for Japanese customers.
* Add - Add current user data to the onboarding init request payload. This data is used for fraud prevention.
* Add - Added API endpoint to fetch customer's saved payment methods.
* Add - Added docs for cancel_authorization endpoint
* Add - Added documentation for create payment intent API endpoint.
* Add - Added documentation for payment methods API endpoint
* Add - Add functionality to enable WooPay first party auth behind feature flag.
* Add - Add helper function/method for raw currency amount conversion.
* Add - Add Klarna payment method
* Add - Add loading state to WooPay button
* Add - Add payment intent creation endpoint
* Add - Add the feature flag check for pay-for-order flow
* Add - Add WC blocks spinner to the WooPay checkout styles.
* Add - Behind a feature flag: dispute message added to transactions screen for disputes not needing a response.
* Add - Display dispute information, recommended resolution steps, and actions directly on the transaction details screen to help merchants with dispute resolution.
* Add - Display server error messages on Settings save
* Add - Expand the data points added to the WooCommerce SSR to include all the main WooPayments features.
* Add - Handle server-side feature flag for new UPE type enablement.
* Add - Introduce the "Subscription Relationship" column under the Orders list admin page when HPOS is enabled.
* Add - Show survey for merchants that disable WooPay.
* Fix - Add Mix and Match Products support on WooPay.
* Fix - Add multi-currency enablement check in WooPay session handling.
* Fix - Comment: Behind a feature flag: Update documentation links (new/changed docs content) when notifying merchant that a dispute needs response.
* Fix - Disable automatic currency switching and switcher widgets on pay_for_order page.
* Fix - Ensure renewal orders paid via the Block Checkout are correctly linked to their subscription.
* Fix - Ensure the order needs processing transient is deleted when a subscription order (eg renewal) is created. Fixes issues with renewal orders going straight to a completed status.
* Fix - fix: save platform checkout info on blocks
* Fix - Fix Apple Pay and Google Pay if card payments are disabled.
* Fix - Fix error when disabling WCPay with core disabled.
* Fix - Fix init WooPay and empty cart error
* Fix - Fix modal header alignment on safari browser
* Fix - Fix onboarding section on MultiCurrency settings page.
* Fix - Fix WooPay express checkout button with product bundles on product page.
* Fix - Hide tooltip related to Storefront theme in Multi-Currency settings when Storefront is not the active theme
* Fix - Improved product details script with enhanced price calculation, and fallbacks for potential undefined values.
* Fix - Improve escaping around attributes.
* Fix - Load multi-currency class on setup page.
* Fix - Missing styles on the Edit Subscription page when HPOS is enabled.
* Fix - Only request WooPay session data once on blocks pages.
* Fix - Payment method section missing for Affirm and Afterpay on transaction details page
* Fix - Prevent charging completed or processing orders with a new payment intent ID
* Fix - Prevent WooPay-related implementation to modify non-WooPay-specific webhooks by changing their data.
* Fix - Prevent WooPay multiple redirect requests.
* Fix - Redirect back to the connect page when attempting to access the new onboarding flow without a server connection.
* Fix - Redirect back to the pay-for-order page when it's pay-for-order order
* Fix - Resolved an issue that caused paying for failed/pending parent orders that include Product Add-ons to not calculate the correct total.
* Fix - Speed up capturing terminal and authorized payments.
* Fix - Store the correct subscription start date in postmeta and ordermeta when HPOS and data syncing is being used.
* Fix - Tracking conditions
* Fix - Virtual variable products no longer require shipping details when checking out with Apple Pay and Google Pay
* Fix - When HPOS is enabled, deleting a customer will now delete their subscriptions.
* Fix - When HPOS is enabled, make the orders_by_type_query filter box work in the WooCommerce orders screen.
* Fix - WooPay save my info phone number fallback for virtual products
* Update - Adapt the PO congratulations card copy for pending account status.
* Update - Allow deferred intent creation UPE to support SEPA payments.
* Update - Enhance design of bnpl payment methods status in settings screen
* Update - Increase GBP transaction limit for Afterpay
* Update - Only display the WCPay Subscriptions setting to existing users as part of deprecating this feature.
* Update - Set WooPay First Party Authentication feature flag to default on.
* Update - Store customer currencies as an option to avoid expensive calculation.
* Update - Updated Transaction Details summary with added fee breakdown tooltip for disputed transactions.
* Update - Update links that pointed to the dispute details screen to point to the transaction details screen
* Update - Update Name Your Price compatibility to use new Compatibility methods.
* Update - Update the content of modals that are displayed when deactivating the WooPayments or Woo Subscriptions plugins when the store has active Stripe Billing subscriptions.
* Update - Update URL used to communicate with WooPay from the iFrame in the merchant site.
* Dev - Added missing API docs links for payment intents and payment methods API endpoints
* Dev - Capitalize the JCB label on transactions details page.
* Dev - e2e tests for progressive onboarding
* Dev - Extracting payment metadata and level 3 data generation into services.
* Dev - Migrate away from hooking into actions in certain classes
* Dev - Move fraud related service hooks out of class constructors and into new init_hooks methods.
* Dev - Move hooks out of MultiCurrency constructor into own init_hooks method.
* Dev - Refactored request class send() method
* Dev - Refactor to move hook initialisation out of constructors.
* Dev - This work is part of a UI improvements to increase disputes response that is behind a feature flag. A changelog entry will be added to represent the work as a whole.
* Dev - Update subscriptions-core to 6.3.0.

= 6.5.1 - 2023-09-26 =
* Fix - fix incorrect payment method title for non-WooPayments gateways

Expand Down
1 change: 1 addition & 0 deletions client/additional-methods-setup/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const upeMethods = [
'affirm',
'afterpay_clearpay',
'jcb',
'klarna',
];

export const upeCapabilityStatuses = {
Expand Down
27 changes: 16 additions & 11 deletions client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class WCPayAPI {
this.stripe = null;
this.stripePlatform = null;
this.request = request;
this.isWooPayRequesting = false;
}

createStripe( publishableKey, locale, accountId = '', betas = [] ) {
Expand Down Expand Up @@ -688,17 +689,21 @@ export default class WCPayAPI {
}

initWooPay( userEmail, woopayUserSession ) {
const wcAjaxUrl = getConfig( 'wcAjaxUrl' );
const nonce = getConfig( 'initWooPayNonce' );

return this.request( buildAjaxURL( wcAjaxUrl, 'init_woopay' ), {
_wpnonce: nonce,
email: userEmail,
user_session: woopayUserSession,
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
} );
if ( ! this.isWooPayRequesting ) {
this.isWooPayRequesting = true;
const wcAjaxUrl = getConfig( 'wcAjaxUrl' );
const nonce = getConfig( 'initWooPayNonce' );
return this.request( buildAjaxURL( wcAjaxUrl, 'init_woopay' ), {
_wpnonce: nonce,
email: userEmail,
user_session: woopayUserSession,
order_id: getConfig( 'order_id' ),
key: getConfig( 'key' ),
billing_email: getConfig( 'billing_email' ),
} ).finally( () => {
this.isWooPayRequesting = false;
} );
}
}

expressCheckoutAddToCart( productData ) {
Expand Down
29 changes: 26 additions & 3 deletions client/checkout/api/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import request from 'wcpay/checkout/utils/request';
import { buildAjaxURL } from 'wcpay/payment-request/utils';
import { getConfig } from 'wcpay/utils/checkout';

jest.mock( 'wcpay/checkout/utils/request', () => jest.fn() );
jest.mock( 'wcpay/checkout/utils/request', () =>
jest.fn( () => Promise.resolve( {} ).finally( () => {} ) )
);
jest.mock( 'wcpay/payment-request/utils', () => ( {
buildAjaxURL: jest.fn(),
} ) );
Expand All @@ -15,7 +17,7 @@ jest.mock( 'wcpay/utils/checkout', () => ( {
} ) );

describe( 'WCPayAPI', () => {
test( 'initializes woopay using config params', () => {
test( 'does not initialize woopay if already requesting', async () => {
buildAjaxURL.mockReturnValue( 'https://example.org/' );
getConfig.mockImplementation( ( key ) => {
const mockProperties = {
Expand All @@ -28,7 +30,27 @@ describe( 'WCPayAPI', () => {
} );

const api = new WCPayAPI( {}, request );
api.initWooPay( '[email protected]', 'qwerty123' );
api.isWooPayRequesting = true;
await api.initWooPay( '[email protected]', 'qwerty123' );

expect( request ).not.toHaveBeenCalled();
expect( api.isWooPayRequesting ).toBe( true );
} );

test( 'initializes woopay using config params', async () => {
buildAjaxURL.mockReturnValue( 'https://example.org/' );
getConfig.mockImplementation( ( key ) => {
const mockProperties = {
initWooPayNonce: 'foo',
order_id: 1,
key: 'testkey',
billing_email: '[email protected]',
};
return mockProperties[ key ];
} );

const api = new WCPayAPI( {}, request );
await api.initWooPay( '[email protected]', 'qwerty123' );

expect( request ).toHaveBeenLastCalledWith( 'https://example.org/', {
_wpnonce: 'foo',
Expand All @@ -38,5 +60,6 @@ describe( 'WCPayAPI', () => {
key: 'testkey',
billing_email: '[email protected]',
} );
expect( api.isWooPayRequesting ).toBe( false );
} );
} );
2 changes: 2 additions & 0 deletions client/checkout/blocks/upe-split.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
PAYMENT_METHOD_NAME_SOFORT,
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_KLARNA,
} from '../constants.js';
import { getSplitUPEFields } from './upe-split-fields';
import { getDeferredIntentCreationUPEFields } from './upe-deferred-intent-creation/payment-elements';
Expand All @@ -46,6 +47,7 @@ const upeMethods = {
sofort: PAYMENT_METHOD_NAME_SOFORT,
affirm: PAYMENT_METHOD_NAME_AFFIRM,
afterpay_clearpay: PAYMENT_METHOD_NAME_AFTERPAY,
klarna: PAYMENT_METHOD_NAME_KLARNA,
};

const enabledPaymentMethodsConfig = getUPEConfig( 'paymentMethodsConfig' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
generateCheckoutEventNames,
getSelectedUPEGatewayPaymentMethod,
isLinkEnabled,
isPaymentMethodRestrictedToLocation,
isUsingSavedPaymentMethod,
togglePaymentMethodForCountry,
} from '../../utils/upe';
import {
processPayment,
Expand Down Expand Up @@ -109,8 +111,18 @@ jQuery( function ( $ ) {
) {
for ( const upeElement of $( '.wcpay-upe-element' ).toArray() ) {
await mountStripePaymentElement( api, upeElement );
restrictPaymentMethodToLocation( upeElement );
}
maybeEnableStripeLink( api );
}
}

function restrictPaymentMethodToLocation( upeElement ) {
if ( isPaymentMethodRestrictedToLocation( upeElement ) ) {
togglePaymentMethodForCountry( upeElement );
$( '#billing_country' ).on( 'change', function () {
togglePaymentMethodForCountry( upeElement );
} );
}
}
} );
2 changes: 2 additions & 0 deletions client/checkout/classic/upe-split.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
PAYMENT_METHOD_NAME_SOFORT,
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_KLARNA,
SHORTCODE_SHIPPING_ADDRESS_FIELDS,
SHORTCODE_BILLING_ADDRESS_FIELDS,
} from '../constants';
Expand Down Expand Up @@ -657,6 +658,7 @@ jQuery( function ( $ ) {
PAYMENT_METHOD_NAME_SOFORT,
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_KLARNA,
paymentMethodsConfig.card !== undefined && PAYMENT_METHOD_NAME_CARD,
].filter( Boolean );
const checkoutEvents = wcpayPaymentMethods
Expand Down
2 changes: 2 additions & 0 deletions client/checkout/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const PAYMENT_METHOD_NAME_SOFORT = 'woocommerce_payments_sofort';
export const PAYMENT_METHOD_NAME_AFFIRM = 'woocommerce_payments_affirm';
export const PAYMENT_METHOD_NAME_AFTERPAY =
'woocommerce_payments_afterpay_clearpay';
export const PAYMENT_METHOD_NAME_KLARNA = 'woocommerce_payments_klarna';
export const PAYMENT_METHOD_NAME_UPE = 'woocommerce_payments_upe';
export const PAYMENT_METHOD_NAME_PAYMENT_REQUEST =
'woocommerce_payments_payment_request';
Expand All @@ -30,6 +31,7 @@ export function getPaymentMethodsConstants() {
PAYMENT_METHOD_NAME_AFFIRM,
PAYMENT_METHOD_NAME_AFTERPAY,
PAYMENT_METHOD_NAME_CARD,
PAYMENT_METHOD_NAME_KLARNA,
];
}

Expand Down
32 changes: 32 additions & 0 deletions client/checkout/utils/upe.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,35 @@ export const getShippingDetails = ( fields ) => {

return billingAsShippingAddress;
};

/**
* Hides payment method if it has set specific countries in the PHP class.
*
* @param {Object} upeElement The selector of the DOM element of particular payment method to mount the UPE element to.
* @return {boolean} Whether the payment method is restricted to selected billing country.
**/
export const isPaymentMethodRestrictedToLocation = ( upeElement ) => {
const paymentMethodsConfig = getUPEConfig( 'paymentMethodsConfig' );
const paymentMethodType = upeElement.dataset.paymentMethodType;
return !! paymentMethodsConfig[ paymentMethodType ].countries.length;
};

/**
* @param {Object} upeElement The selector of the DOM element of particular payment method to mount the UPE element to.
**/
export const togglePaymentMethodForCountry = ( upeElement ) => {
const paymentMethodsConfig = getUPEConfig( 'paymentMethodsConfig' );
const paymentMethodType = upeElement.dataset.paymentMethodType;
const supportedCountries =
paymentMethodsConfig[ paymentMethodType ].countries;

const billingCountry = document.getElementById( 'billing_country' ).value;
const upeContainer = document.querySelector(
'.payment_method_woocommerce_payments_' + paymentMethodType
);
if ( supportedCountries.includes( billingCountry ) ) {
upeContainer.style.display = 'block';
} else {
upeContainer.style.display = 'none';
}
};
Loading

0 comments on commit 137b8be

Please sign in to comment.