Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Automattic/woocommerce-payments …
Browse files Browse the repository at this point in the history
…into add/duplicates-detection
  • Loading branch information
Timur Karimov committed Apr 8, 2024
2 parents 18f7d6d + 01be26a commit 480adaa
Show file tree
Hide file tree
Showing 232 changed files with 2,200 additions and 1,100 deletions.
36 changes: 36 additions & 0 deletions assets/images/payment-activity-empty-state.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/images/payment-methods/afterpay-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion assets/images/payment-methods/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions changelog/2024-03-30-01-19-36-005298
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Add an instructive error message when customer tries to use 2 different currencies for Stripe Billing subscriptions.
4 changes: 4 additions & 0 deletions changelog/8499-fix-js-error-on-gpay-click
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix JS error when clicking GPay button on blocks checkout with subscription (w/sign up fee) in cart.
4 changes: 4 additions & 0 deletions changelog/add-8144-bnpl-cart-summary
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add BNPL messaging to cart page.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Remove ToS acceptance copy from all entrypoints in MOX
4 changes: 4 additions & 0 deletions changelog/add-8557-empty-state-payment-widget
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Not user-facing: hidden behind feature flag. Add an empty state view for the Payments Activity widget. This is shown when the merchant is yet to have any transactions over WooPayments.
4 changes: 4 additions & 0 deletions changelog/feat-8516-total-payment-activity
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Payments Activity - add scaffolding for Total Payment Volume.
4 changes: 4 additions & 0 deletions changelog/fix-7866-tos-decline-busy
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix Decline button state for Accept loading on ToS modal
4 changes: 4 additions & 0 deletions changelog/fix-8093-onboarding-collides-with-jitm-banners
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix collision between WooPayments header and Woo Express survey banner.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Change IP country rule after country settings are changed in WC settings page
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix Fatal Error showing when connect to Jetpack on localhost
4 changes: 4 additions & 0 deletions changelog/fix-8386-remove-utc-label
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Remove incorrect "UTC" label from the time column of Transactions page
4 changes: 4 additions & 0 deletions changelog/fix-8465-fix-phpcs-reports
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Fixed phpcs errors
4 changes: 4 additions & 0 deletions changelog/fix-8567-connect-page-payment-methods
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix payment icons on connect page (Klarna, Afterpay)
5 changes: 5 additions & 0 deletions changelog/fix-8571-payment-activity-card-safari-visual-bug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Not user-facing: hidden behind feature flag. Fixes payment activity visual bug in safari.


4 changes: 4 additions & 0 deletions changelog/fix-afterpay-logo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed Afterpay logo size on settings page
4 changes: 4 additions & 0 deletions changelog/fix-filesystem-phpcs-reports
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Ignore alternative function WordPress PHPCS sniffs in the GH workflows and tests
5 changes: 5 additions & 0 deletions changelog/fix-migrate-woopay-skipped-tracks-event
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Complete WooPay Tracks event migration and cleanup migration related code


4 changes: 4 additions & 0 deletions changelog/fix-optional-zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed optional billing field validation
4 changes: 4 additions & 0 deletions changelog/refactor-8389-remove-unwanted-css-classes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: update

Remove unwanted css overrides on the Payment activity widget wrapper
4 changes: 4 additions & 0 deletions changelog/refactor-shortcode-checkout-wp-data-dependency
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

refactor: reduce wp-data dependency on shortcode checkout
4 changes: 4 additions & 0 deletions changelog/replace-deprecated-input-filter-constant
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Replace deprecated filter.
4 changes: 4 additions & 0 deletions changelog/tweak-revert-phpcs-update-revert-pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Updated PHPCS and sniffs used for static analysis
4 changes: 4 additions & 0 deletions changelog/update-link-by-stripe-logo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Updated Link by Stripe logo
12 changes: 12 additions & 0 deletions client/cart/blocks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Internal dependencies
*/
import { renderBNPLCartMessaging } from './product-details';

const { registerPlugin } = window.wp.plugins;

// Register BNPL site messaging on the cart block.
registerPlugin( 'bnpl-site-messaging', {
render: renderBNPLCartMessaging,
scope: 'woocommerce-checkout',
} );
117 changes: 117 additions & 0 deletions client/cart/blocks/product-details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* External dependencies
*/
import {
Elements,
PaymentMethodMessagingElement,
} from '@stripe/react-stripe-js';
import { select } from '@wordpress/data';

/**
* Internal dependencies
*/
import { getAppearance, getFontRulesFromPage } from 'wcpay/checkout/upe-styles';
import { getUPEConfig } from 'utils/checkout';
import WCPayAPI from '../../checkout/api';
import request from '../../checkout/utils/request';
import { useEffect, useState } from 'react';

// Create an API object, which will be used throughout the checkout.
const api = new WCPayAPI(
{
publishableKey: getUPEConfig( 'publishableKey' ),
accountId: getUPEConfig( 'accountId' ),
forceNetworkSavedCards: getUPEConfig( 'forceNetworkSavedCards' ),
locale: getUPEConfig( 'locale' ),
},
request
);

const isInEditor = () => {
const editorStore = select( 'core/editor' );

return !! editorStore;
};

// BNPL only supports 2 decimal places.
const normalizeAmount = ( amount, decimalPlaces = 2 ) => {
return amount * Math.pow( 10, 2 - decimalPlaces );
};

const { ExperimentalOrderMeta } = window.wc.blocksCheckout;

const ProductDetail = ( { cart, context } ) => {
const [ appearance, setAppearance ] = useState(
getUPEConfig( 'upeBnplCartBlockAppearance' ) || {}
);

const [ fontRules ] = useState( getFontRulesFromPage() );

useEffect( () => {
async function generateUPEAppearance() {
// Generate UPE input styles.
let upeAppearance = getAppearance( 'bnpl_cart_block' );
upeAppearance = await api.saveUPEAppearance(
upeAppearance,
'bnpl_cart_block'
);
setAppearance( upeAppearance );
}

if ( Object.keys( appearance ).length === 0 ) {
generateUPEAppearance();
}
}, [ appearance ] );

if ( Object.keys( appearance ).length === 0 ) {
return null;
}

if ( context !== 'woocommerce/cart' ) {
return null;
}

const cartTotal = normalizeAmount(
cart.cartTotals.total_price,
wcSettings.currency.precision
);

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

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

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

const stripe = api.getStripe();

return (
<div className="wc-block-components-bnpl-wrapper">
<Elements
stripe={ stripe }
options={ { appearance, fonts: fontRules } }
>
<PaymentMethodMessagingElement options={ options } />
</Elements>
</div>
);
};

export const renderBNPLCartMessaging = () => {
if ( isInEditor() ) {
return null;
}
return (
<ExperimentalOrderMeta>
<ProductDetail />
</ExperimentalOrderMeta>
);
};
2 changes: 1 addition & 1 deletion client/checkout/blocks/payment-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { useEffect, useRef } from 'react';
import { usePaymentCompleteHandler } from './hooks';
import {
getStripeElementOptions,
useCustomerData,
blocksShowLinkButtonHandler,
getBlocksEmailValue,
isLinkEnabled,
} from 'wcpay/checkout/utils/upe';
import { useCustomerData } from './utils';
import enableStripeLinkPaymentMethod from 'wcpay/checkout/stripe-link';
import { getUPEConfig } from 'wcpay/utils/checkout';
import { validateElements } from 'wcpay/checkout/classic/payment-processing';
Expand Down
3 changes: 1 addition & 2 deletions client/checkout/blocks/test/payment-processor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { PaymentElement } from '@stripe/react-stripe-js';
jest.mock( 'wcpay/checkout/classic/payment-processing', () => ( {
validateElements: jest.fn().mockResolvedValue(),
} ) );
jest.mock( 'wcpay/checkout/utils/upe', () => ( {
...jest.requireActual( 'wcpay/checkout/utils/upe' ),
jest.mock( 'wcpay/checkout/blocks/utils', () => ( {
useCustomerData: jest.fn().mockReturnValue( { billingAddress: {} } ),
} ) );
jest.mock( '../hooks', () => ( {
Expand Down
Loading

0 comments on commit 480adaa

Please sign in to comment.