mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Move vaulted subscriptions intent logic to module
This commit is contained in:
parent
80cc94939d
commit
7d17e4a892
3 changed files with 24 additions and 7 deletions
|
@ -1547,16 +1547,14 @@ class SmartButton implements SmartButtonInterface {
|
|||
* @throws NotFoundException If intent is not found.
|
||||
*/
|
||||
private function intent(): string {
|
||||
$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;
|
||||
|
||||
$subscription_mode = $this->settings->has( 'subscriptions_mode' ) ? $this->settings->get( 'subscriptions_mode' ) : '';
|
||||
if ( $this->subscription_helper->need_subscription_intent( $subscription_mode ) ) {
|
||||
return 'subscription';
|
||||
}
|
||||
|
||||
return $this->context() === 'product' ? $product_intent : $other_context_intent;
|
||||
$intent = $this->settings->has( 'intent' ) ? $this->settings->get( 'intent' ) : 'capture';
|
||||
|
||||
return strtolower( apply_filters( 'woocommerce_paypal_payments_saved_payment_subscription_intent', $intent ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue