Skip to content

Commit

Permalink
Merge branch 'develop' into fix/7230-payments-details-mobile-view
Browse files Browse the repository at this point in the history
  • Loading branch information
shendy-a8c authored Dec 2, 2024
2 parents 7558e5e + e0b69be commit e0d8bfd
Show file tree
Hide file tree
Showing 91 changed files with 1,030 additions and 595 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/e2e-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ on:
description: "Branch to be used for running tests"

env:
E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }}
WCP_DEV_TOOLS_BRANCH: 'trunk'
WCP_SERVER_REPO: ${{ secrets.WCP_SERVER_REPO }}
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_USE_LOCAL_SERVER: false
E2E_RESULT_FILEPATH: 'tests/e2e/results.json'
WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }}
WCPAY_ARTIFACT_DIRECTORY: 'zipfile'
NODE_ENV: 'test'
FORCE_E2E_DEPS_SETUP: true
E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }}
WCP_DEV_TOOLS_BRANCH: 'trunk'
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }}
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_USE_LOCAL_SERVER: false
E2E_RESULT_FILEPATH: 'tests/e2e/results.json'
WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }}
WCPAY_ARTIFACT_DIRECTORY: 'zipfile'
NODE_ENV: 'test'
FORCE_E2E_DEPS_SETUP: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-pw-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }}
WCP_DEV_TOOLS_BRANCH: 'trunk'
WCP_SERVER_REPO: ${{ secrets.WCP_SERVER_REPO }}
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }}
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ on:
workflow_dispatch:

env:
E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }}
WCP_DEV_TOOLS_BRANCH: 'trunk'
WCP_SERVER_REPO: ${{ secrets.WCP_SERVER_REPO }}
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_USE_LOCAL_SERVER: false
E2E_RESULT_FILEPATH: 'tests/e2e/results.json'
WC_MIN_SUPPORTED_VERSION: '7.6.0'
NODE_ENV: 'test'
FORCE_E2E_DEPS_SETUP: true
E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }}
WCP_DEV_TOOLS_BRANCH: 'trunk'
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }}
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_USE_LOCAL_SERVER: false
E2E_RESULT_FILEPATH: 'tests/e2e/results.json'
WC_MIN_SUPPORTED_VERSION: '7.6.0'
NODE_ENV: 'test'
FORCE_E2E_DEPS_SETUP: true

jobs:
generate-matrix:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: PHP Compatibility

on:
pull_request
#pull_request # Workflow disabled temporarily until PHP Compatibility fixes are in place
workflow_dispatch

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions assets/images/illustrations/setup.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** WooPayments Changelog ***

= 8.5.1 - 2024-11-25 =
* Fix - fix: remove "test mode" badge from shortcode checkout.

= 8.5.0 - 2024-11-13 =
* Add - Add country-specific test card numbers for credit card testing
* Add - Add risk level information to the fraud and risk box on the order details page.
Expand Down
4 changes: 4 additions & 0 deletions changelog/add-5316-payout-trace-id
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add Bank reference key column in Payout reports. This will help reconcile WooPayments Payouts with bank statements.
4 changes: 4 additions & 0 deletions changelog/add-9556-set-support-phone-mandatory
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Set the support phone field as mandatory in the settings page.
5 changes: 5 additions & 0 deletions changelog/chore-ece-states-class-constants
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: chore: rename Payment_Request_Button_States to Express_Checkout_Element_States to reflect its usage


4 changes: 4 additions & 0 deletions changelog/chore-remove-redundant-init-for-payfororder
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Avoid getting the appearance for pay for order page with the wrong appearance key.
4 changes: 4 additions & 0 deletions changelog/dev-4293-address-additional-union-types
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Fix return types
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Ensure proper return types in the webhook processing service.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Allow redirect to the settings page from WCPay connect
4 changes: 4 additions & 0 deletions changelog/fix-9709-load-stripe-asynchronously
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Add support to load stripe js asynchronously when it is not immediately available in the global scope.
4 changes: 4 additions & 0 deletions changelog/fix-9784-ece-tracks-events
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix ECE Tracks events not triggering when WooPay is disabled.
4 changes: 4 additions & 0 deletions changelog/fix-9795-debounce-of-ece-load-events
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Ensure ECE button load events are triggered for multiple buttons on the same page.
4 changes: 4 additions & 0 deletions changelog/fix-pmme-appearance-blocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Use paragraph selector instead of label for pmme appearance
4 changes: 4 additions & 0 deletions changelog/fix-remove-shortcode-test-mode-badge-from-label
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: remove "test mode" badge from shortcode checkout.
4 changes: 4 additions & 0 deletions changelog/fix-woopay-component-spacing
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix WooPay component spacing.
4 changes: 4 additions & 0 deletions changelog/fix-woopay-trial-subscriptions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix WooPay trial subscriptions purchases.
5 changes: 5 additions & 0 deletions changelog/update-phpcompatibility-latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Update phpcompatibility to develop version to get sniffs for PHP 8. No need to include it in the changelog since it is a dev task that doesn't impact WooPayments.


5 changes: 5 additions & 0 deletions changelog/update-server-container-name
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Updates server container name used by E2E tests


9 changes: 7 additions & 2 deletions client/cart/blocks/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { select } from '@wordpress/data';
* Internal dependencies
*/
import { getAppearance, getFontRulesFromPage } from 'wcpay/checkout/upe-styles';
import { useStripeAsync } from 'wcpay/hooks/use-stripe-async';
import { getUPEConfig } from 'utils/checkout';
import WCPayAPI from '../../checkout/api';
import request from '../../checkout/utils/request';
Expand Down Expand Up @@ -47,6 +48,8 @@ const ProductDetail = ( { cart, context } ) => {

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

const stripe = useStripeAsync( api );

useEffect( () => {
async function generateUPEAppearance() {
// Generate UPE input styles.
Expand All @@ -63,6 +66,10 @@ const ProductDetail = ( { cart, context } ) => {
}
}, [ appearance ] );

if ( ! stripe ) {
return null;
}

if ( Object.keys( appearance ).length === 0 ) {
return null;
}
Expand Down Expand Up @@ -91,8 +98,6 @@ const ProductDetail = ( { cart, context } ) => {
countryCode: country, // Customer's country or base country of the store.
};

const stripe = api.getStripe();

return (
<div className="wc-block-components-bnpl-wrapper">
<Elements
Expand Down
90 changes: 54 additions & 36 deletions client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,36 @@ export default class WCPayAPI {
* @param {string} paymentMethodType The payment method type.
* @return {Object} The Stripe Object.
*/
getStripeForUPE( paymentMethodType ) {
async getStripeForUPE( paymentMethodType ) {
this.options.forceNetworkSavedCards = getUPEConfig(
'paymentMethodsConfig'
)[ paymentMethodType ].forceNetworkSavedCards;
return this.getStripe();
}

async getStripe( forceAccountRequest = false ) {
const maxWaitTime = 600 * 1000; // 600 seconds
const waitInterval = 100;
let currentWaitTime = 0;
while ( ! window.Stripe ) {
await new Promise( ( resolve ) =>
setTimeout( resolve, waitInterval )
);
currentWaitTime += waitInterval;
if ( currentWaitTime > maxWaitTime ) {
throw new Error( 'Stripe object not found' );
}
}
return this.__getStripe( forceAccountRequest );
}

/**
* Generates a new instance of Stripe.
*
* @param {boolean} forceAccountRequest True to instantiate the Stripe object with the merchant's account key.
* @return {Object} The Stripe Object.
*/
getStripe( forceAccountRequest = false ) {
__getStripe( forceAccountRequest = false ) {
const {
publishableKey,
accountId,
Expand Down Expand Up @@ -105,17 +121,15 @@ export default class WCPayAPI {
*
* @return {Promise} Promise with the Stripe object or an error.
*/
loadStripeForExpressCheckout() {
return new Promise( ( resolve ) => {
try {
// Force Stripe to be loadded with the connected account.
resolve( this.getStripe( true ) );
} catch ( error ) {
// In order to avoid showing console error publicly to users,
// we resolve instead of rejecting when there is an error.
resolve( { error } );
}
} );
async loadStripeForExpressCheckout() {
// Force Stripe to be loadded with the connected account.
try {
return this.getStripe( true );
} catch ( error ) {
// In order to avoid showing console error publicly to users,
// we resolve instead of rejecting when there is an error.
return { error };
}
}

/**
Expand Down Expand Up @@ -160,16 +174,17 @@ export default class WCPayAPI {
orderId = orderIdPartials[ 0 ];
}

const confirmPaymentOrSetup = () => {
const confirmPaymentOrSetup = async () => {
const { locale, publishableKey } = this.options;
const accountIdForIntentConfirmation = getConfig(
'accountIdForIntentConfirmation'
);

// If this is a setup intent we're not processing a woopay payment so we can
// use the regular getStripe function.
const stripe = await this.getStripe();
if ( isSetupIntent ) {
return this.getStripe().handleNextAction( {
return stripe.handleNextAction( {
clientSecret: clientSecret,
} );
}
Expand All @@ -186,7 +201,8 @@ export default class WCPayAPI {

// When not dealing with a setup intent or woopay we need to force an account
// specific request in Stripe.
return this.getStripe( true ).handleNextAction( {
const stripeWithForcedAccountRequest = await this.getStripe( true );
return stripeWithForcedAccountRequest.handleNextAction( {
clientSecret: clientSecret,
} );
};
Expand Down Expand Up @@ -251,32 +267,34 @@ export default class WCPayAPI {
* @param {string} paymentMethodId The ID of the payment method.
* @return {Promise} The final promise for the request to the server.
*/
setupIntent( paymentMethodId ) {
return this.request( getConfig( 'ajaxUrl' ), {
async setupIntent( paymentMethodId ) {
const response = await this.request( getConfig( 'ajaxUrl' ), {
action: 'create_setup_intent',
'wcpay-payment-method': paymentMethodId,
_ajax_nonce: getConfig( 'createSetupIntentNonce' ),
} ).then( ( response ) => {
if ( ! response.success ) {
throw response.data.error;
}
} );

if ( response.data.status === 'succeeded' ) {
// No need for further authentication.
return response.data;
}
if ( ! response.success ) {
throw response.data.error;
}

return this.getStripe()
.confirmCardSetup( response.data.client_secret )
.then( ( confirmedSetupIntent ) => {
const { setupIntent, error } = confirmedSetupIntent;
if ( error ) {
throw error;
}
if ( response.data.status === 'succeeded' ) {
// No need for further authentication.
return response.data;
}

return setupIntent;
} );
} );
const stripe = await this.getStripe();

const confirmedSetupIntent = await stripe.confirmCardSetup(
response.data.client_secret
);

const { setupIntent, error } = confirmedSetupIntent;
if ( error ) {
throw error;
}

return setupIntent;
}

/**
Expand Down
Loading

0 comments on commit e0d8bfd

Please sign in to comment.