Merge branch 'trunk' into PCP-951-could-not-retrieve-order

This commit is contained in:
emilicastells 2022-12-05 11:18:09 +01:00
commit c654786ee3
No known key found for this signature in database
GPG key ID: 1520C07081754570
11 changed files with 66 additions and 37 deletions

View file

@ -1,5 +1,17 @@
*** Changelog *** *** Changelog ***
= 2.0.1 - TBD =
* Fix - Error while syncing tracking data to PayPal -> Sync GZD Tracking #1020
* Fix - Fix product price retrieval for variable product buttons #1000
* Fix - All tabs hidden on OXXO tab visit #1048
* Fix - Woocommerce Germanized Invoice bug #1017
* Fix - Fix shipping address validation #1047
* Fix - Trigger WC JS validation on button click to highlight empty fields #1004
* Fix - Fix PHP 8.1 deprecated error #1009
* Fix - Wrong asset path Germanized compat #1051
* Fix - Fix DCC error messages handling #1035
* Enhancement - Param types removed in closure to avoid third-party issues #1046
= 2.0.0 - 2022-11-21 = = 2.0.0 - 2022-11-21 =
* Add - Option to separate JSSDK APM payment buttons into individual WooCommerce gateways #671 * Add - Option to separate JSSDK APM payment buttons into individual WooCommerce gateways #671
* Add - OXXO APM (Alternative Payment Method) #684 * Add - OXXO APM (Alternative Payment Method) #684

View file

@ -59,9 +59,9 @@ class CheckoutActionHandler {
); );
} else { } else {
errorHandler.clear(); errorHandler.clear();
if (data.data.errors.length > 0) { if (data.data.errors?.length > 0) {
errorHandler.messages(data.data.errors); errorHandler.messages(data.data.errors);
} else if (data.data.details.length > 0) { } else if (data.data.details?.length > 0) {
errorHandler.message(data.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true); errorHandler.message(data.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
} else { } else {
errorHandler.message(data.data.message, true); errorHandler.message(data.data.message, true);

View file

@ -233,8 +233,14 @@ class CreditCardRenderer {
this.spinner.unblock(); this.spinner.unblock();
this.errorHandler.clear(); this.errorHandler.clear();
if (err.details?.length) { if (err.data?.details?.length) {
this.errorHandler.message(err.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
} else if (err.details?.length) {
this.errorHandler.message(err.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true); this.errorHandler.message(err.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
} else if (err.data?.errors?.length > 0) {
this.errorHandler.messages(err.data.errors);
} else if (err.data?.message) {
this.errorHandler.message(err.data.message, true);
} else if (err.message) { } else if (err.message) {
this.errorHandler.message(err.message, true); this.errorHandler.message(err.message, true);
} else { } else {

View file

@ -27,10 +27,13 @@ class CheckoutFormValidator extends WC_Checkout {
public function validate( array $data ) { public function validate( array $data ) {
$errors = new WP_Error(); $errors = new WP_Error();
if ( isset( $data['terms-field'] ) ) { // Some plugins check their fields using $_POST,
// WC checks this field via $_POST https://github.com/woocommerce/woocommerce/issues/35328 . // also WC terms checkbox https://github.com/woocommerce/woocommerce/issues/35328 .
$_POST['terms-field'] = $data['terms-field']; foreach ( $data as $key => $value ) {
$_POST[ $key ] = $value;
} }
// And we must call get_posted_data because it handles the shipping address.
$data = $this->get_posted_data();
// It throws some notices when checking fields etc., also from other plugins via hooks. // It throws some notices when checking fields etc., also from other plugins via hooks.
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged

View file

@ -56,15 +56,6 @@ return array(
return function_exists( 'wc_gzd_get_shipments_by_order' ); // 3.0+ return function_exists( 'wc_gzd_get_shipments_by_order' ); // 3.0+
}, },
'compat.gzd.tracking_statuses_map' => function ( ContainerInterface $container ): array {
return array(
'draft' => 'ON_HOLD',
'processing' => 'SHIPPED',
'shipped' => 'SHIPPED',
'delivered' => 'DELIVERED',
);
},
'compat.module.url' => static function ( ContainerInterface $container ): string { 'compat.module.url' => static function ( ContainerInterface $container ): string {
/** /**
* The path cannot be false. * The path cannot be false.

View file

@ -130,20 +130,13 @@ class CompatModule implements ModuleInterface {
$logger = $c->get( 'woocommerce.logger.woocommerce' ); $logger = $c->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface ); assert( $logger instanceof LoggerInterface );
$status_map = $c->get( 'compat.gzd.tracking_statuses_map' );
add_action( add_action(
'woocommerce_gzd_shipment_after_save', 'woocommerce_gzd_shipment_status_shipped',
static function( Shipment $shipment ) use ( $endpoint, $logger, $status_map ) { static function( int $shipment_id, Shipment $shipment ) use ( $endpoint, $logger ) {
if ( ! apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) ) { if ( ! apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) ) {
return; return;
} }
$gzd_shipment_status = $shipment->get_status();
if ( ! array_key_exists( $gzd_shipment_status, $status_map ) ) {
return;
}
$wc_order = $shipment->get_order(); $wc_order = $shipment->get_order();
if ( ! is_a( $wc_order, WC_Order::class ) ) { if ( ! is_a( $wc_order, WC_Order::class ) ) {
return; return;
@ -156,7 +149,7 @@ class CompatModule implements ModuleInterface {
$tracking_data = array( $tracking_data = array(
'transaction_id' => $transaction_id, 'transaction_id' => $transaction_id,
'status' => (string) $status_map[ $gzd_shipment_status ], 'status' => 'SHIPPED',
); );
$provider = $shipment->get_shipping_provider(); $provider = $shipment->get_shipping_provider();
@ -169,17 +162,17 @@ class CompatModule implements ModuleInterface {
$tracking_data['tracking_number'] = $tracking_information['tracking_number'] ?? ''; $tracking_data['tracking_number'] = $tracking_information['tracking_number'] ?? '';
if ( $shipment->has_tracking() ) { if ( $shipment->get_tracking_id() ) {
$tracking_data['tracking_number'] = $shipment->get_tracking_id(); $tracking_data['tracking_number'] = $shipment->get_tracking_id();
} }
! $tracking_information ? $endpoint->add_tracking_information( $tracking_data, $wc_order->get_id() ) : $endpoint->update_tracking_information( $tracking_data, $wc_order->get_id() ); ! $tracking_information ? $endpoint->add_tracking_information( $tracking_data, $wc_order->get_id() ) : $endpoint->update_tracking_information( $tracking_data, $wc_order->get_id() );
} catch ( Exception $exception ) { } catch ( Exception $exception ) {
$logger->error( "Couldn't sync tracking information: " . $exception->getMessage() ); $logger->error( "Couldn't sync tracking information: " . $exception->getMessage() );
$shipment->add_note( "Couldn't sync tracking information: " . $exception->getMessage() );
throw $exception;
} }
} },
500,
2
); );
} }

View file

@ -168,7 +168,7 @@ return array(
CreditCardGateway::ID, CreditCardGateway::ID,
PayUponInvoiceGateway::ID, PayUponInvoiceGateway::ID,
CardButtonGateway::ID, CardButtonGateway::ID,
OXXOGateway::ID . OXXOGateway::ID,
Settings::PAY_LATER_TAB_ID, Settings::PAY_LATER_TAB_ID,
), ),
true true

View file

@ -81,12 +81,12 @@ class OXXO {
add_filter( add_filter(
'woocommerce_thankyou_order_received_text', 'woocommerce_thankyou_order_received_text',
/** /**
* Order can be null. * Param types removed to avoid third-party issues.
* *
* @psalm-suppress MissingClosureParamType * @psalm-suppress MissingClosureParamType
*/ */
function( string $message, $order ) { function( $message, $order ) {
if ( ! $order instanceof WC_Order ) { if ( ! is_string( $message ) || ! $order instanceof WC_Order ) {
return $message; return $message;
} }
@ -105,7 +105,16 @@ class OXXO {
add_action( add_action(
'woocommerce_email_before_order_table', 'woocommerce_email_before_order_table',
function ( WC_Order $order, bool $sent_to_admin ) { /**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function ( $order, $sent_to_admin ) {
if ( ! is_a( $order, WC_Order::class ) || ! is_bool( $sent_to_admin ) ) {
return;
}
if ( if (
! $sent_to_admin ! $sent_to_admin
&& $order->get_payment_method() === OXXOGateway::ID && $order->get_payment_method() === OXXOGateway::ID

View file

@ -1,6 +1,6 @@
{ {
"name": "woocommerce-paypal-payments", "name": "woocommerce-paypal-payments",
"version": "2.0.0", "version": "2.0.1",
"description": "WooCommerce PayPal Payments", "description": "WooCommerce PayPal Payments",
"repository": "https://github.com/woocommerce/woocommerce-paypal-payments", "repository": "https://github.com/woocommerce/woocommerce-paypal-payments",
"license": "GPL-2.0", "license": "GPL-2.0",
@ -14,6 +14,7 @@
"install:modules:ppcp-vaulting": "cd modules/ppcp-vaulting && yarn install", "install:modules:ppcp-vaulting": "cd modules/ppcp-vaulting && yarn install",
"install:modules:ppcp-order-tracking": "cd modules/ppcp-order-tracking && yarn install", "install:modules:ppcp-order-tracking": "cd modules/ppcp-order-tracking && yarn install",
"install:modules:ppcp-onboarding": "cd modules/ppcp-onboarding && yarn install", "install:modules:ppcp-onboarding": "cd modules/ppcp-onboarding && yarn install",
"install:modules:ppcp-compat": "cd modules/ppcp-compat && yarn install",
"build:modules:ppcp-button": "cd modules/ppcp-button && yarn run build", "build:modules:ppcp-button": "cd modules/ppcp-button && yarn run build",
"build:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn run build", "build:modules:ppcp-wc-gateway": "cd modules/ppcp-wc-gateway && yarn run build",
@ -21,6 +22,7 @@
"build:modules:ppcp-vaulting": "cd modules/ppcp-vaulting && yarn run build", "build:modules:ppcp-vaulting": "cd modules/ppcp-vaulting && yarn run build",
"build:modules:ppcp-order-tracking": "cd modules/ppcp-order-tracking && yarn run build", "build:modules:ppcp-order-tracking": "cd modules/ppcp-order-tracking && yarn run build",
"build:modules:ppcp-onboarding": "cd modules/ppcp-onboarding && yarn run build", "build:modules:ppcp-onboarding": "cd modules/ppcp-onboarding && yarn run build",
"build:modules:ppcp-compat": "cd modules/ppcp-compat && yarn run build",
"build:modules": "run-p build:modules:*", "build:modules": "run-p build:modules:*",
"watch:modules:ppcp-button": "cd modules/ppcp-button && yarn run watch", "watch:modules:ppcp-button": "cd modules/ppcp-button && yarn run watch",
@ -29,6 +31,7 @@
"watch:modules:ppcp-vaulting": "cd modules/ppcp-vaulting && yarn run watch", "watch:modules:ppcp-vaulting": "cd modules/ppcp-vaulting && yarn run watch",
"watch:modules:ppcp-order-tracking": "cd modules/ppcp-order-tracking && yarn run watch", "watch:modules:ppcp-order-tracking": "cd modules/ppcp-order-tracking && yarn run watch",
"watch:modules:ppcp-onboarding": "cd modules/ppcp-onboarding && yarn run watch", "watch:modules:ppcp-onboarding": "cd modules/ppcp-onboarding && yarn run watch",
"watch:modules:ppcp-compat": "cd modules/ppcp-compat && yarn run watch",
"watch:modules": "run-p watch:modules:*", "watch:modules": "run-p watch:modules:*",
"ddev:setup": "ddev start && ddev orchestrate", "ddev:setup": "ddev start && ddev orchestrate",

View file

@ -4,7 +4,7 @@ Tags: woocommerce, paypal, payments, ecommerce, e-commerce, store, sales, sell,
Requires at least: 5.3 Requires at least: 5.3
Tested up to: 6.1 Tested up to: 6.1
Requires PHP: 7.2 Requires PHP: 7.2
Stable tag: 2.0.0 Stable tag: 2.0.1
License: GPLv2 License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -81,6 +81,18 @@ Follow the steps below to connect the plugin to your PayPal account:
== Changelog == == Changelog ==
= 2.0.1 =
* Fix - Error while syncing tracking data to PayPal -> Sync GZD Tracking #1020
* Fix - Fix product price retrieval for variable product buttons #1000
* Fix - All tabs hidden on OXXO tab visit #1048
* Fix - Woocommerce Germanized Invoice bug #1017
* Fix - Fix shipping address validation #1047
* Fix - Trigger WC JS validation on button click to highlight empty fields #1004
* Fix - Fix PHP 8.1 deprecated error #1009
* Fix - Wrong asset path Germanized compat #1051
* Fix - Fix DCC error messages handling #1035
* Enhancement - Param types removed in closure to avoid third-party issues #1046
= 2.0.0 = = 2.0.0 =
* Add - Option to separate JSSDK APM payment buttons into individual WooCommerce gateways #671 * Add - Option to separate JSSDK APM payment buttons into individual WooCommerce gateways #671
* Add - OXXO APM (Alternative Payment Method) #684 * Add - OXXO APM (Alternative Payment Method) #684

View file

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce PayPal Payments * Plugin Name: WooCommerce PayPal Payments
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/ * Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage. * Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
* Version: 2.0.0 * Version: 2.0.1
* Author: WooCommerce * Author: WooCommerce
* Author URI: https://woocommerce.com/ * Author URI: https://woocommerce.com/
* License: GPL-2.0 * License: GPL-2.0