Skip to content

Commit b587aff

Browse files
committed
Merge trunk v5.1.2 into develop
2 parents a222fb6 + e902752 commit b587aff

File tree

11 files changed

+44
-15
lines changed

11 files changed

+44
-15
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
*** WooCommerce Payments Changelog ***
22

3+
= 5.1.2 - 2022-12-03 =
4+
* Fix - Import critical package instead of lazy loading.
5+
36
= 5.1.1 - 2022-12-02 =
47
* Fix - Minor patch fix to cron functionality that does not appear to have front-end ramifications for customers.
58

client/checkout/blocks/fields.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ const WCPayFields = ( {
3030
shouldSavePayment,
3131
} ) => {
3232
const [ errorMessage, setErrorMessage ] = useState( null );
33-
const [ fingerprint ] = useFingerprint();
33+
const [ fingerprint, fingerprintErrorMessage ] = useFingerprint();
34+
35+
useEffect( () => {
36+
setErrorMessage( fingerprintErrorMessage );
37+
}, [ fingerprintErrorMessage ] );
3438

3539
// When it's time to process the payment, generate a Stripe payment method object.
3640
useEffect(

client/checkout/blocks/hooks.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { useEffect, useState } from '@wordpress/element';
77
* Internal dependencies
88
*/
99
import confirmCardPayment from './confirm-card-payment.js';
10-
import { getFingerprint } from '../utils/fingerprint.js';
10+
import {
11+
getFingerprint,
12+
FINGERPRINT_GENERIC_ERROR,
13+
} from '../utils/fingerprint.js';
1114

1215
export const usePaymentCompleteHandler = (
1316
api,
@@ -45,7 +48,9 @@ export const useFingerprint = () => {
4548
const { visitorId } = await getFingerprint();
4649
setFingerprint( visitorId );
4750
} catch ( err ) {
48-
setError( err );
51+
setError(
52+
err.message ? err.message : FINGERPRINT_GENERIC_ERROR
53+
);
4954
}
5055
} )();
5156
}, [] );

client/checkout/blocks/upe-fields.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ const ConsumableWCPayFields = ( { api, ...props } ) => {
376376
getConfig( 'wcBlocksUPEAppearance' )
377377
);
378378
const [ fontRules ] = useState( getFontRulesFromPage() );
379-
const [ fingerprint ] = useFingerprint();
379+
const [ fingerprint, fingerprintErrorMessage ] = useFingerprint();
380380

381381
useEffect( () => {
382382
async function generateUPEAppearance() {
@@ -391,6 +391,11 @@ const ConsumableWCPayFields = ( { api, ...props } ) => {
391391
generateUPEAppearance();
392392
}
393393

394+
if ( fingerprintErrorMessage ) {
395+
setErrorMessage( fingerprintErrorMessage );
396+
return;
397+
}
398+
394399
if ( paymentIntentId || hasRequestedIntent || ! fingerprint ) {
395400
return;
396401
}
@@ -417,6 +422,7 @@ const ConsumableWCPayFields = ( { api, ...props } ) => {
417422
errorMessage,
418423
appearance,
419424
fingerprint,
425+
fingerprintErrorMessage,
420426
] );
421427

422428
if ( ! clientSecret ) {

client/checkout/classic/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ jQuery( function ( $ ) {
196196
fingerprint = visitorId;
197197
} catch ( error ) {
198198
// Do not mount element if fingerprinting is not available
199+
showError( error.message );
200+
199201
return;
200202
}
201203
}

client/checkout/classic/upe.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ jQuery( function ( $ ) {
189189
fingerprint = visitorId;
190190
} catch ( error ) {
191191
// Do not mount element if fingerprinting is not available
192+
showErrorCheckout( error.message );
193+
192194
return;
193195
}
194196
}

client/checkout/utils/fingerprint.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
export const getFingerprint = async () => {
2-
const FingerprintJS = await import(
3-
/* webpackChunkName: "fp_agent" */
4-
'@fingerprintjs/fingerprintjs'
5-
);
1+
/** @format */
2+
/**
3+
* Internal dependencies
4+
*/
5+
import FingerprintJS from '@fingerprintjs/fingerprintjs';
66

7+
export const FINGERPRINT_GENERIC_ERROR =
8+
'An error was encountered when preparing the payment form. Please try again later.';
9+
10+
export const getFingerprint = async () => {
711
const agent = await FingerprintJS.load( { monitoring: false } );
812

913
if ( ! agent ) {
10-
throw new Error( 'Unable to load agent.' );
14+
throw new Error( FINGERPRINT_GENERIC_ERROR );
1115
}
1216

1317
return await agent.get();

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "woocommerce-payments",
3-
"version": "5.1.1",
3+
"version": "5.1.2",
44
"main": "webpack.config.js",
55
"author": "Automattic",
66
"license": "GPL-3.0-or-later",

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: payment gateway, payment, apple pay, credit card, google pay
44
Requires at least: 5.9
55
Tested up to: 6.1
66
Requires PHP: 7.0
7-
Stable tag: 5.1.1
7+
Stable tag: 5.1.2
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -98,6 +98,9 @@ Please note that our support for the checkout block is still experimental and th
9898

9999
== Changelog ==
100100

101+
= 5.1.2 - 2022-12-03 =
102+
* Fix - Import critical package instead of lazy loading.
103+
101104
= 5.1.1 - 2022-12-02 =
102105
* Fix - Minor patch fix to cron functionality that does not appear to have front-end ramifications for customers.
103106

0 commit comments

Comments
 (0)