🔀 Merge branch 'trunk'

# Conflicts:
#	modules/ppcp-googlepay/resources/js/GooglepayButton.js
This commit is contained in:
Philipp Stracker 2024-08-11 13:14:51 +02:00
commit a5d227c6bb
No known key found for this signature in database
9 changed files with 66 additions and 50 deletions

View file

@ -1,5 +1,22 @@
*** Changelog ***
= 2.8.3 - xxxx-xx-xx =
* Fix - Google Pay: Prevent field validation from being triggered on checkout page load #2474
* Fix - Do not add tax info into order meta during order creation #2471
* Fix - PayPal declares subscription support when for Subscription mode is set Disable PayPal for subscription #2425
* Fix - PayPal js files loaded on non PayPal pages #2411
* Fix - Google Pay: Fix the incorrect popup triggering #2414
* Fix - Add tax configurator when programmatically creating WC orders #2431
* Fix - Shipping callback compatibility with WC Name Your Price plugin #2402
* Fix - Uncaught Error: Cannot use object of type ...\Settings as array in .../AbstractPaymentMethodType.php (3253) #2334
* Fix - Prevent displaying smart button multiple times on variable product page #2420
* Fix - Prevent enabling Standard Card Button when ACDC is enabled #2404
* Fix - Use client credentials for user tokens #2491
* Fix - Apple Pay: Fix the shipping callback #2492
* Enhancement - Separate Google Pay button for Classic Checkout #2430
* Enhancement - Add Apple Pay and Google Pay support for China, simplify country-currency matrix #2468
* Enhancement - Add AMEX support for Advanced Card Processing in China #2469
= 2.8.2 - 2024-07-22 =
* Fix - Sold individually checkbox automatically disabled after adding product to the cart more than once #2415
* Fix - All products "Sold individually" when PayPal Subscriptions selected as Subscriptions Mode #2400

View file

@ -1669,8 +1669,7 @@ return array(
return new UserIdToken(
$container->get( 'api.host' ),
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'api.client-credentials' ),
$container->get( 'api.client-credentials-cache' )
$container->get( 'api.client-credentials' )
);
},
'api.sdk-client-token' => static function( ContainerInterface $container ): SdkClientToken {

View file

@ -96,18 +96,6 @@ class ApiModule implements ModuleInterface {
10,
2
);
add_action(
'wp_logout',
function( int $user_id ) use ( $c ) {
$client_credentials_cache = $c->get( 'api.client-credentials-cache' );
assert( $client_credentials_cache instanceof Cache );
if ( $client_credentials_cache->has( UserIdToken::CACHE_KEY . '-' . (string) $user_id ) ) {
$client_credentials_cache->delete( UserIdToken::CACHE_KEY . '-' . (string) $user_id );
}
}
);
}
/**

View file

@ -11,7 +11,6 @@ use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\RequestTrait;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
use WP_Error;
/**
@ -21,8 +20,6 @@ class UserIdToken {
use RequestTrait;
const CACHE_KEY = 'user-id-token-key';
/**
* The host.
*
@ -44,31 +41,21 @@ class UserIdToken {
*/
private $client_credentials;
/**
* The cache.
*
* @var Cache
*/
private $cache;
/**
* UserIdToken constructor.
*
* @param string $host The host.
* @param LoggerInterface $logger The logger.
* @param ClientCredentials $client_credentials The client credentials.
* @param Cache $cache The cache.
*/
public function __construct(
string $host,
LoggerInterface $logger,
ClientCredentials $client_credentials,
Cache $cache
ClientCredentials $client_credentials
) {
$this->host = $host;
$this->logger = $logger;
$this->client_credentials = $client_credentials;
$this->cache = $cache;
}
/**
@ -82,10 +69,6 @@ class UserIdToken {
* @throws RuntimeException If something unexpected happens.
*/
public function id_token( string $target_customer_id = '' ): string {
if ( $this->cache->has( self::CACHE_KEY . '-' . (string) get_current_user_id() ) ) {
return $this->cache->get( self::CACHE_KEY . '-' . (string) get_current_user_id() );
}
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token';
if ( $target_customer_id ) {
$url = add_query_arg(
@ -115,11 +98,6 @@ class UserIdToken {
throw new PayPalApiException( $json, $status_code );
}
$id_token = $json->id_token;
$expires_in = (int) $json->expires_in;
$this->cache->set( self::CACHE_KEY . '-' . (string) get_current_user_id(), $id_token, $expires_in );
return $id_token;
return $json->id_token;
}
}

View file

@ -644,10 +644,12 @@ class ApplepayButton {
return {
action: 'ppcp_update_shipping_method',
shipping_method: event.shippingMethod,
simplified_contact:
this.updatedContactInfo ||
this.initialPaymentRequest.shippingContact ||
this.initialPaymentRequest.billingContact,
simplified_contact: this.hasValidContactInfo(
this.updatedContactInfo
)
? this.updatedContactInfo
: this.initialPaymentRequest?.shippingContact ??
this.initialPaymentRequest?.billingContact,
product_id,
products: JSON.stringify( this.products ),
caller_page: 'productDetail',
@ -662,10 +664,12 @@ class ApplepayButton {
return {
action: 'ppcp_update_shipping_method',
shipping_method: event.shippingMethod,
simplified_contact:
this.updatedContactInfo ||
this.initialPaymentRequest.shippingContact ||
this.initialPaymentRequest.billingContact,
simplified_contact: this.hasValidContactInfo(
this.updatedContactInfo
)
? this.updatedContactInfo
: this.initialPaymentRequest?.shippingContact ??
this.initialPaymentRequest?.billingContact,
caller_page: 'cart',
'woocommerce-process-checkout-nonce': this.nonce,
};
@ -948,6 +952,12 @@ class ApplepayButton {
return btoa( utf8Str );
}
hasValidContactInfo( value ) {
return Array.isArray( value )
? value.length > 0
: Object.keys( value || {} ).length > 0;
}
}
export default ApplepayButton;

View file

@ -31,6 +31,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcSubscriptions\Endpoint\SubscriptionChangePaymentMethod;
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
/**
* Class SavePaymentMethodsModule
@ -84,6 +85,12 @@ class SavePaymentMethodsModule implements ModuleInterface {
add_filter(
'woocommerce_paypal_payments_localized_script_data',
function( array $localized_script_data ) use ( $c ) {
$subscriptions_helper = $c->get( 'wc-subscriptions.helper' );
assert( $subscriptions_helper instanceof SubscriptionHelper );
if ( ! is_user_logged_in() && ! $subscriptions_helper->cart_contains_subscription() ) {
return $localized_script_data;
}
$api = $c->get( 'api.user-id-token' );
assert( $api instanceof UserIdToken );

View file

@ -1,6 +1,6 @@
{
"name": "woocommerce-paypal-payments",
"version": "2.8.2",
"version": "2.8.3",
"description": "WooCommerce PayPal Payments",
"repository": "https://github.com/woocommerce/woocommerce-paypal-payments",
"license": "GPL-2.0",

View file

@ -4,7 +4,7 @@ Tags: woocommerce, paypal, payments, ecommerce, checkout, cart, pay later, apple
Requires at least: 5.3
Tested up to: 6.6
Requires PHP: 7.2
Stable tag: 2.8.2
Stable tag: 2.8.3
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -179,6 +179,23 @@ If you encounter issues with the PayPal buttons not appearing after an update, p
== Changelog ==
= 2.8.3 - xxxx-xx-xx =
* Fix - Google Pay: Prevent field validation from being triggered on checkout page load #2474
* Fix - Do not add tax info into order meta during order creation #2471
* Fix - PayPal declares subscription support when for Subscription mode is set Disable PayPal for subscription #2425
* Fix - PayPal js files loaded on non PayPal pages #2411
* Fix - Google Pay: Fix the incorrect popup triggering #2414
* Fix - Add tax configurator when programmatically creating WC orders #2431
* Fix - Shipping callback compatibility with WC Name Your Price plugin #2402
* Fix - Uncaught Error: Cannot use object of type ...\Settings as array in .../AbstractPaymentMethodType.php (3253) #2334
* Fix - Prevent displaying smart button multiple times on variable product page #2420
* Fix - Prevent enabling Standard Card Button when ACDC is enabled #2404
* Fix - Use client credentials for user tokens #2491
* Fix - Apple Pay: Fix the shipping callback #2492
* Enhancement - Separate Google Pay button for Classic Checkout #2430
* Enhancement - Add Apple Pay and Google Pay support for China, simplify country-currency matrix #2468
* Enhancement - Add AMEX support for Advanced Card Processing in China #2469
= 2.8.2 - 2024-07-22 =
* Fix - Sold individually checkbox automatically disabled after adding product to the cart more than once #2415
* Fix - All products "Sold individually" when PayPal Subscriptions selected as Subscriptions Mode #2400

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.8.2
* Version: 2.8.3
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* License: GPL-2.0
@ -26,7 +26,7 @@ define( 'PAYPAL_API_URL', 'https://api-m.paypal.com' );
define( 'PAYPAL_URL', 'https://www.paypal.com' );
define( 'PAYPAL_SANDBOX_API_URL', 'https://api-m.sandbox.paypal.com' );
define( 'PAYPAL_SANDBOX_URL', 'https://www.sandbox.paypal.com' );
define( 'PAYPAL_INTEGRATION_DATE', '2024-07-17' );
define( 'PAYPAL_INTEGRATION_DATE', '2024-08-07' );
define( 'PPCP_PAYPAL_BN_CODE', 'Woo_PPCP' );
! defined( 'CONNECT_WOO_CLIENT_ID' ) && define( 'CONNECT_WOO_CLIENT_ID', 'AcCAsWta_JTL__OfpjspNyH7c1GGHH332fLwonA5CwX4Y10mhybRZmHLA0GdRbwKwjQIhpDQy0pluX_P' );