Merge branch 'trunk' of github.com:woocommerce/woocommerce-paypal-payments into PCP-3827-implement-block-button-styles-for-google-pay-button

This commit is contained in:
Daniel Dudzic 2024-11-07 01:16:51 +01:00
commit f51c41d222
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
151 changed files with 31242 additions and 63060 deletions

View file

@ -11,21 +11,21 @@
],
"dependencies": {
"@paypal/paypal-js": "^6.0.0",
"core-js": "^3.25.0"
"core-js": "^3.39"
},
"devDependencies": {
"@babel/core": "^7.19",
"@babel/preset-env": "^7.19",
"@babel/preset-react": "^7.18.6",
"@wordpress/i18n": "^5.6.0",
"@woocommerce/dependency-extraction-webpack-plugin": "^2.2.0",
"babel-loader": "^8.2",
"@babel/core": "^7.26",
"@babel/preset-env": "^7.26",
"@babel/preset-react": "^7.25",
"@wordpress/i18n": "^5.11",
"@woocommerce/dependency-extraction-webpack-plugin": "2.2.0",
"babel-loader": "^9.2",
"cross-env": "^7.0.3",
"file-loader": "^6.2.0",
"sass": "^1.42.1",
"sass-loader": "^12.1.0",
"webpack": "^5.76",
"webpack-cli": "^4.10"
"sass": "^1.80",
"sass-loader": "^16",
"webpack": "^5.96",
"webpack-cli": "^5"
},
"scripts": {
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",

View file

@ -249,59 +249,45 @@ class GooglepayButton extends PaymentButton {
/**
* @inheritDoc
*/
validateConfiguration( silent = false ) {
const validEnvs = [ 'PRODUCTION', 'TEST' ];
registerValidationRules( invalidIf, validIf ) {
invalidIf(
() =>
! [ 'TEST', 'PRODUCTION' ].includes(
this.buttonConfig.environment
),
`Invalid environment: ${ this.buttonConfig.environment }`
);
const isInvalid = ( ...args ) => {
if ( ! silent ) {
this.error( ...args );
}
return false;
};
validIf( () => this.isPreview );
if ( ! validEnvs.includes( this.buttonConfig.environment ) ) {
return isInvalid(
'Invalid environment:',
this.buttonConfig.environment
);
}
invalidIf(
() => ! this.googlePayConfig,
'No API configuration - missing configure() call?'
);
// Preview buttons only need a valid environment.
if ( this.isPreview ) {
return true;
}
invalidIf(
() => ! this.transactionInfo,
'No transactionInfo - missing configure() call?'
);
if ( ! this.googlePayConfig ) {
return isInvalid(
'No API configuration - missing configure() call?'
);
}
invalidIf(
() => ! this.contextHandler?.validateContext(),
`Invalid context handler.`
);
if ( ! this.transactionInfo ) {
return isInvalid(
'No transactionInfo - missing configure() call?'
);
}
invalidIf(
() =>
this.buttonAttributes?.height &&
isNaN( parseInt( this.buttonAttributes.height ) ),
'Invalid height in buttonAttributes'
);
// Add buttonAttributes validation
if ( this.buttonAttributes ) {
if (
this.buttonAttributes.height &&
isNaN( parseInt( this.buttonAttributes.height ) )
) {
return isInvalid( 'Invalid height in buttonAttributes' );
}
if (
this.buttonAttributes.borderRadius &&
isNaN( parseInt( this.buttonAttributes.borderRadius ) )
) {
return isInvalid( 'Invalid borderRadius in buttonAttributes' );
}
}
if ( ! typeof this.contextHandler?.validateContext() ) {
return isInvalid( 'Invalid context handler.', this.contextHandler );
}
invalidIf(
() =>
this.buttonAttributes?.borderRadius &&
isNaN( parseInt( this.buttonAttributes.borderRadius ) ),
'Invalid borderRadius in buttonAttributes'
);
return true;
}

View file

@ -106,6 +106,7 @@ return array(
'FR', // France
'DE', // Germany
'GR', // Greece
'HK', // Hong Kong
'HU', // Hungary
'IE', // Ireland
'IT', // Italy
@ -119,6 +120,7 @@ return array(
'PL', // Poland
'PT', // Portugal
'RO', // Romania
'SG', // Singapore
'SK', // Slovakia
'SI', // Slovenia
'ES', // Spain

View file

@ -218,6 +218,20 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
}
);
add_filter(
'woocommerce_paypal_payments_selected_button_locations',
function( array $locations, string $setting_name ): array {
$gateway = WC()->payment_gateways()->payment_gateways()[ GooglePayGateway::ID ] ?? '';
if ( $gateway && $gateway->enabled === 'yes' && $setting_name === 'smart_button_locations' ) {
$locations[] = 'checkout';
}
return $locations;
},
10,
2
);
return true;
}
}

File diff suppressed because it is too large Load diff