Skip to content

Commit

Permalink
Merge branch 'develop' into fix/8232-deprecated-strtolower-on-order-r…
Browse files Browse the repository at this point in the history
…eceived-page
  • Loading branch information
reykjalin authored Mar 18, 2024
2 parents 3f93b1f + f15c223 commit 0819154
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog/payment-utils-when-amount-too-large
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: better error message when saved card and amount too large
4 changes: 4 additions & 0 deletions changelog/refactor-validator-bundle-size
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

refactor: validator package bundle size improvements
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import validator from 'validator';
import isEmail from 'validator/lib/isEmail';
import { __ } from '@wordpress/i18n';

const useExpressCheckoutProductHandler = ( api ) => {
Expand Down Expand Up @@ -49,7 +49,7 @@ const useExpressCheckoutProductHandler = ( api ) => {
if (
! data.wc_gc_giftcard_to_multiple
.split( ',' )
.every( ( email ) => validator.isEmail( email.trim() ) )
.every( ( email ) => isEmail( email.trim() ) )
) {
alert(
__(
Expand All @@ -62,7 +62,7 @@ const useExpressCheckoutProductHandler = ( api ) => {
}

if ( data.hasOwnProperty( 'wc_gc_giftcard_to' ) ) {
if ( ! validator.isEmail( data.wc_gc_giftcard_to ) ) {
if ( ! isEmail( data.wc_gc_giftcard_to ) ) {
alert(
__(
'Please type only valid emails',
Expand Down
2 changes: 2 additions & 0 deletions includes/class-wc-payments-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ public static function get_filtered_error_message( Exception $e ) {
),
wp_strip_all_tags( html_entity_decode( $price ) )
);
} elseif ( $e instanceof API_Exception && 'amount_too_large' === $e->get_error_code() ) {
$error_message = $e->getMessage();
} elseif ( $e instanceof API_Exception && 'wcpay_bad_request' === $e->get_error_code() ) {
$error_message = __( 'We\'re not able to process this request. Please refresh the page and try again.', 'woocommerce-payments' );
} elseif ( $e instanceof API_Exception && ! empty( $e->get_error_type() ) && 'card_error' !== $e->get_error_type() ) {
Expand Down

0 comments on commit 0819154

Please sign in to comment.