mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Remove additional paypal buttons for free trial
This commit is contained in:
parent
c701b46a40
commit
b928e5aaa4
3 changed files with 43 additions and 16 deletions
|
@ -87,6 +87,7 @@ return array(
|
|||
$payment_token_repository,
|
||||
$settings_status,
|
||||
$currency,
|
||||
$container->get( 'wcgateway.all-funding-sources' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
|
|
|
@ -135,6 +135,13 @@ class SmartButton implements SmartButtonInterface {
|
|||
*/
|
||||
private $currency;
|
||||
|
||||
/**
|
||||
* All existing funding sources.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $all_funding_sources;
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*
|
||||
|
@ -166,6 +173,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
||||
* @param SettingsStatus $settings_status The Settings status helper.
|
||||
* @param string $currency 3-letter currency code of the shop.
|
||||
* @param array $all_funding_sources All existing funding sources.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -183,6 +191,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
PaymentTokenRepository $payment_token_repository,
|
||||
SettingsStatus $settings_status,
|
||||
string $currency,
|
||||
array $all_funding_sources,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
|
||||
|
@ -200,6 +209,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
$this->payment_token_repository = $payment_token_repository;
|
||||
$this->settings_status = $settings_status;
|
||||
$this->currency = $currency;
|
||||
$this->all_funding_sources = $all_funding_sources;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
@ -893,6 +903,10 @@ class SmartButton implements SmartButtonInterface {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $this->is_free_trial_cart() ) {
|
||||
$disable_funding = array_keys( $this->all_funding_sources );
|
||||
}
|
||||
|
||||
if ( count( $disable_funding ) > 0 ) {
|
||||
$params['disable-funding'] = implode( ',', array_unique( $disable_funding ) );
|
||||
}
|
||||
|
@ -901,6 +915,11 @@ class SmartButton implements SmartButtonInterface {
|
|||
if ( $this->settings_status->pay_later_messaging_is_enabled() || ! in_array( 'credit', $disable_funding, true ) ) {
|
||||
$enable_funding[] = 'paylater';
|
||||
}
|
||||
|
||||
if ( $this->is_free_trial_cart() ) {
|
||||
$enable_funding = array();
|
||||
}
|
||||
|
||||
if ( count( $enable_funding ) > 0 ) {
|
||||
$params['enable-funding'] = implode( ',', array_unique( $enable_funding ) );
|
||||
}
|
||||
|
@ -959,7 +978,10 @@ class SmartButton implements SmartButtonInterface {
|
|||
if ( $this->load_button_component() ) {
|
||||
$components[] = 'buttons';
|
||||
}
|
||||
if ( $this->messages_apply->for_country() ) {
|
||||
if (
|
||||
$this->messages_apply->for_country()
|
||||
&& ! $this->is_free_trial_cart()
|
||||
) {
|
||||
$components[] = 'messages';
|
||||
}
|
||||
if ( $this->dcc_is_enabled() ) {
|
||||
|
|
|
@ -771,21 +771,7 @@ return array(
|
|||
>',
|
||||
'</a>'
|
||||
),
|
||||
'options' => array(
|
||||
'card' => _x( 'Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'credit' => _x( 'Pay Later', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'sepa' => _x( 'SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'bancontact' => _x( 'Bancontact', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'blik' => _x( 'BLIK', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'eps' => _x( 'eps', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'giropay' => _x( 'giropay', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'ideal' => _x( 'iDEAL', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'mercadopago' => _x( 'Mercado Pago', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'mybank' => _x( 'MyBank', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'p24' => _x( 'Przelewy24', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'sofort' => _x( 'Sofort', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'venmo' => _x( 'Venmo', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'options' => $container->get( 'wcgateway.all-funding-sources' ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_ONBOARDED,
|
||||
|
@ -2064,6 +2050,24 @@ return array(
|
|||
return $fields;
|
||||
},
|
||||
|
||||
'wcgateway.all-funding-sources' => static function( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'card' => _x( 'Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'credit' => _x( 'Pay Later', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'sepa' => _x( 'SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'bancontact' => _x( 'Bancontact', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'blik' => _x( 'BLIK', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'eps' => _x( 'eps', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'giropay' => _x( 'giropay', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'ideal' => _x( 'iDEAL', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'mercadopago' => _x( 'Mercado Pago', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'mybank' => _x( 'MyBank', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'p24' => _x( 'Przelewy24', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'sofort' => _x( 'Sofort', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
'venmo' => _x( 'Venmo', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||
);
|
||||
},
|
||||
|
||||
'wcgateway.checkout.address-preset' => static function( ContainerInterface $container ): CheckoutPayPalAddressPreset {
|
||||
|
||||
return new CheckoutPayPalAddressPreset(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue