woocommerce-paypal-payments/modules.local/ppcp-subscription/src/SubscriptionModule.php

43 lines
1.1 KiB
PHP
Raw Normal View History

2020-07-28 12:27:42 +03:00
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\Subscription;
use Dhii\Container\ServiceProvider;
use Dhii\Modular\Module\ModuleInterface;
2020-08-18 08:46:18 +03:00
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
2020-07-28 12:27:42 +03:00
use Interop\Container\ServiceProviderInterface;
use Psr\Container\ContainerInterface;
class SubscriptionModule implements ModuleInterface
{
public function setup(): ServiceProviderInterface
{
return new ServiceProvider(
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
}
/**
* @inheritDoc
*/
public function run(ContainerInterface $container)
{
add_action(
2020-08-18 08:46:18 +03:00
'woocommerce_scheduled_subscription_payment_' . PayPalGateway::ID,
2020-07-28 07:07:14 +03:00
static function ($amount, $order) use ($container) {
2020-07-28 12:27:42 +03:00
if (! is_a($order, \WC_Order::class)) {
return;
}
$handler = $container->get('subscription.renewal-handler');
$handler->renew($order);
},
10,
2
);
}
}