mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
init subscriptions
This commit is contained in:
parent
b5b29b8e58
commit
c1991e9153
16 changed files with 412 additions and 46 deletions
|
@ -28,23 +28,18 @@ return [
|
|||
$notice = $container->get('wcgateway.notice.authorize-order-action');
|
||||
$settings = $container->get('wcgateway.settings');
|
||||
|
||||
$smartButton = $container->get('button.smart-button');
|
||||
$supportsSubscription = $smartButton->canSaveVaultToken();
|
||||
return new WcGateway(
|
||||
$settingsRenderer,
|
||||
$orderProcessor,
|
||||
$authorizedPayments,
|
||||
$notice,
|
||||
$settings,
|
||||
$supportsSubscription
|
||||
$settings
|
||||
);
|
||||
},
|
||||
'wcgateway.disabler' => static function (ContainerInterface $container): DisableGateways {
|
||||
$sessionHandler = $container->get('session.handler');
|
||||
$settings = $container->get('wcgateway.settings');
|
||||
$smartButton = $container->get('button.smart-button');
|
||||
$subscriptionDisable = ! $smartButton->canSaveVaultToken() && $smartButton->hasSubscription();
|
||||
return new DisableGateways($sessionHandler, $settings, $subscriptionDisable);
|
||||
return new DisableGateways($sessionHandler, $settings);
|
||||
},
|
||||
'wcgateway.settings' => static function (ContainerInterface $container): Settings {
|
||||
return new Settings();
|
||||
|
@ -496,6 +491,34 @@ return [
|
|||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'client_id' => [
|
||||
'title' => __('Client Id', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'label' => __('Enable logging', 'woocommerce-paypal-commerce-gateway'),
|
||||
'description' => __('Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => false,
|
||||
'screens' => [
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
'client_secret' => [
|
||||
'title' => __('Secret Id', 'woocommerce-paypal-commerce-gateway'),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'label' => __('Enable logging', 'woocommerce-paypal-commerce-gateway'),
|
||||
'description' => __('Enable logging of unexpected behavior. This can also log private data and should only be enabled in a development or stage environment.', 'woocommerce-paypal-commerce-gateway'),
|
||||
'default' => false,
|
||||
'screens' => [
|
||||
State::STATE_START,
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
],
|
||||
'requirements' => [],
|
||||
],
|
||||
];
|
||||
},
|
||||
];
|
||||
|
|
|
@ -13,16 +13,13 @@ class DisableGateways
|
|||
|
||||
private $sessionHandler;
|
||||
private $settings;
|
||||
private $subscriptionDisable;
|
||||
public function __construct(
|
||||
SessionHandler $sessionHandler,
|
||||
ContainerInterface $settings,
|
||||
bool $subscriptionDisable
|
||||
ContainerInterface $settings
|
||||
) {
|
||||
|
||||
$this->sessionHandler = $sessionHandler;
|
||||
$this->settings = $settings;
|
||||
$this->subscriptionDisable = $subscriptionDisable;
|
||||
}
|
||||
|
||||
public function handler(array $methods): array
|
||||
|
@ -38,11 +35,6 @@ class DisableGateways
|
|||
return $methods;
|
||||
}
|
||||
|
||||
if ($this->subscriptionDisable) {
|
||||
unset($methods[WcGateway::ID]);
|
||||
return $methods;
|
||||
}
|
||||
|
||||
if (! $this->needsToDisableGateways()) {
|
||||
return $methods;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ class WcGateway extends \WC_Payment_Gateway
|
|||
OrderProcessor $orderProcessor,
|
||||
AuthorizedPaymentsProcessor $authorizedPayments,
|
||||
AuthorizeOrderActionNotice $notice,
|
||||
ContainerInterface $config,
|
||||
bool $supportsSubscription
|
||||
ContainerInterface $config
|
||||
) {
|
||||
|
||||
$this->id = self::ID;
|
||||
|
@ -51,8 +50,8 @@ class WcGateway extends \WC_Payment_Gateway
|
|||
$this->notice = $notice;
|
||||
$this->settingsRenderer = $settingsRenderer;
|
||||
$this->config = $config;
|
||||
if ($supportsSubscription) {
|
||||
$this->supports = array('subscriptions', 'products');
|
||||
if ($this->config->has('vault_enabled') && $this->config->get('vault_enabled')) {
|
||||
$this->supports = array('subscriptions', 'products', 'subscription_date_changes');
|
||||
}
|
||||
|
||||
$this->method_title = __('PayPal Payments', 'woocommerce-paypal-commerce-gateway');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue