Fix the intent value for single products.

This commit is contained in:
Narek Zakarian 2022-07-04 17:30:29 +04:00
parent 036e7d0c33
commit b15c03d418

View file

@ -886,7 +886,9 @@ class SmartButton implements SmartButtonInterface {
* @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException If a setting was not found. * @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException If a setting was not found.
*/ */
private function url(): string { private function url(): string {
$intent = ( $this->settings->has( 'intent' ) ) ? $this->settings->get( 'intent' ) : 'capture'; $intent = ( $this->settings->has( 'intent' ) ) ? $this->settings->get( 'intent' ) : 'capture';
$product_intent = $this->subscription_helper->current_product_is_subscription() ? 'authorize' : $intent;
$other_context_intent = $this->subscription_helper->cart_contains_subscription() ? 'authorize' : $intent;
$params = array( $params = array(
'client-id' => $this->client_id, 'client-id' => $this->client_id,
@ -895,9 +897,7 @@ class SmartButton implements SmartButtonInterface {
'components' => implode( ',', $this->components() ), 'components' => implode( ',', $this->components() ),
'vault' => $this->can_save_vault_token() ? 'true' : 'false', 'vault' => $this->can_save_vault_token() ? 'true' : 'false',
'commit' => is_checkout() ? 'true' : 'false', 'commit' => is_checkout() ? 'true' : 'false',
'intent' => ( $this->subscription_helper->cart_contains_subscription() || $this->subscription_helper->current_product_is_subscription() ) 'intent' => $this->context() === 'product' ? $product_intent : $other_context_intent,
? 'authorize'
: $intent,
); );
if ( if (
$this->environment->current_environment_is( Environment::SANDBOX ) $this->environment->current_environment_is( Environment::SANDBOX )