Merge branch 'trunk' into PCP-991-detach-vaulting-from-wc-subscriptions-support

This commit is contained in:
emilicastells 2022-12-14 14:36:07 +01:00
commit 7022924d7e
No known key found for this signature in database
GPG key ID: 1520C07081754570
13 changed files with 100 additions and 42 deletions

View file

@ -1,5 +1,18 @@
*** Changelog ***
= 2.0.1 - 2022-12-13 =
* 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
* Fix - Execute WC validation only for smart buttons in checkout #1074
* Enhancement - Param types removed in closure to avoid third-party issues #1046
= 2.0.0 - 2022-11-21 =
* Add - Option to separate JSSDK APM payment buttons into individual WooCommerce gateways #671
* Add - OXXO APM (Alternative Payment Method) #684

View file

@ -59,9 +59,9 @@ class CheckoutActionHandler {
);
} else {
errorHandler.clear();
if (data.data.errors.length > 0) {
if (data.data.errors?.length > 0) {
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);
} else {
errorHandler.message(data.data.message, true);

View file

@ -233,8 +233,14 @@ class CreditCardRenderer {
this.spinner.unblock();
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);
} 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) {
this.errorHandler.message(err.message, true);
} else {

View file

@ -248,7 +248,11 @@ class CreateOrderEndpoint implements EndpointInterface {
$form_fields = $data['form'] ?? null;
if ( $this->early_validation_enabled && is_array( $form_fields ) ) {
if ( $this->early_validation_enabled
&& is_array( $form_fields )
&& 'checkout' === $data['context']
&& in_array( $payment_method, array( PayPalGateway::ID, CardButtonGateway::ID ), true )
) {
$this->validate_form( $form_fields );
}

View file

@ -27,10 +27,13 @@ class CheckoutFormValidator extends WC_Checkout {
public function validate( array $data ) {
$errors = new WP_Error();
if ( isset( $data['terms-field'] ) ) {
// WC checks this field via $_POST https://github.com/woocommerce/woocommerce/issues/35328 .
$_POST['terms-field'] = $data['terms-field'];
// Some plugins check their fields using $_POST,
// also WC terms checkbox https://github.com/woocommerce/woocommerce/issues/35328 .
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.
// 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+
},
'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 {
/**
* The path cannot be false.

View file

@ -130,20 +130,13 @@ class CompatModule implements ModuleInterface {
$logger = $c->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
$status_map = $c->get( 'compat.gzd.tracking_statuses_map' );
add_action(
'woocommerce_gzd_shipment_after_save',
static function( Shipment $shipment ) use ( $endpoint, $logger, $status_map ) {
'woocommerce_gzd_shipment_status_shipped',
static function( int $shipment_id, Shipment $shipment ) use ( $endpoint, $logger ) {
if ( ! apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) ) {
return;
}
$gzd_shipment_status = $shipment->get_status();
if ( ! array_key_exists( $gzd_shipment_status, $status_map ) ) {
return;
}
$wc_order = $shipment->get_order();
if ( ! is_a( $wc_order, WC_Order::class ) ) {
return;
@ -156,7 +149,7 @@ class CompatModule implements ModuleInterface {
$tracking_data = array(
'transaction_id' => $transaction_id,
'status' => (string) $status_map[ $gzd_shipment_status ],
'status' => 'SHIPPED',
);
$provider = $shipment->get_shipping_provider();
@ -169,17 +162,17 @@ class CompatModule implements ModuleInterface {
$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_information ? $endpoint->add_tracking_information( $tracking_data, $wc_order->get_id() ) : $endpoint->update_tracking_information( $tracking_data, $wc_order->get_id() );
} catch ( Exception $exception ) {
$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,
PayUponInvoiceGateway::ID,
CardButtonGateway::ID,
OXXOGateway::ID .
OXXOGateway::ID,
Settings::PAY_LATER_TAB_ID,
),
true

View file

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

View file

@ -360,7 +360,16 @@ class PayUponInvoice {
add_filter(
'woocommerce_gateway_description',
function( string $description, string $id ): string {
/**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function( $description, $id ): string {
if ( ! is_string( $description ) || ! is_string( $id ) ) {
return $description;
}
if ( PayUponInvoiceGateway::ID === $id ) {
ob_start();
@ -423,7 +432,16 @@ class PayUponInvoice {
add_action(
'woocommerce_after_checkout_validation',
function( array $fields, WP_Error $errors ) {
/**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function( $fields, WP_Error $errors ) {
if ( ! is_array( $fields ) ) {
return;
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$payment_method = wc_clean( wp_unslash( $_POST['payment_method'] ?? '' ) );
if ( PayUponInvoiceGateway::ID !== $payment_method ) {
@ -458,8 +476,13 @@ class PayUponInvoice {
add_filter(
'woocommerce_available_payment_gateways',
function ( array $methods ): array {
if ( State::STATE_ONBOARDED !== $this->state->current_state() ) {
/**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function ( $methods ): array {
if ( ! is_array( $methods ) || State::STATE_ONBOARDED !== $this->state->current_state() ) {
return $methods;
}

View file

@ -1,6 +1,6 @@
{
"name": "woocommerce-paypal-payments",
"version": "2.0.0",
"version": "2.0.1",
"description": "WooCommerce PayPal Payments",
"repository": "https://github.com/woocommerce/woocommerce-paypal-payments",
"license": "GPL-2.0",
@ -14,6 +14,7 @@
"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-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-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-order-tracking": "cd modules/ppcp-order-tracking && 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:*",
"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-order-tracking": "cd modules/ppcp-order-tracking && 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:*",
"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
Tested up to: 6.1
Requires PHP: 7.2
Stable tag: 2.0.0
Stable tag: 2.0.1
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -81,6 +81,19 @@ Follow the steps below to connect the plugin to your PayPal account:
== 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
* Fix - Execute WC validation only for smart buttons in checkout #1074
* Enhancement - Param types removed in closure to avoid third-party issues #1046
= 2.0.0 =
* Add - Option to separate JSSDK APM payment buttons into individual WooCommerce gateways #671
* Add - OXXO APM (Alternative Payment Method) #684

View file

@ -3,7 +3,7 @@
* Plugin Name: 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.
* Version: 2.0.0
* Version: 2.0.1
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* License: GPL-2.0