woocommerce-paypal-payments/modules.local/ppcp-webhooks/services.php

54 lines
2.1 KiB
PHP
Raw Normal View History

2020-07-06 11:04:06 +03:00
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\Webhooks;
use Inpsyde\PayPalCommerce\Webhooks\Handler\CheckoutOrderApproved;
2020-07-07 14:04:33 +03:00
use Inpsyde\PayPalCommerce\Webhooks\Handler\CheckoutOrderCompleted;
2020-07-20 12:06:45 +03:00
use Inpsyde\PayPalCommerce\Webhooks\Handler\PaymentCaptureCompleted;
2020-07-09 10:25:46 +03:00
use Inpsyde\PayPalCommerce\Webhooks\Handler\PaymentCaptureRefunded;
2020-07-10 13:21:43 +03:00
use Inpsyde\PayPalCommerce\Webhooks\Handler\PaymentCaptureReversed;
2020-07-06 11:04:06 +03:00
use Psr\Container\ContainerInterface;
return [
'webhook.registrar' => function(ContainerInterface $container) : WebhookRegistrar {
$factory = $container->get('api.factory.webhook');
$endpoint = $container->get('api.endpoint.webhook');
$restEndpoint = $container->get('webhook.endpoint.controller');
return new WebhookRegistrar(
$factory,
$endpoint,
$restEndpoint
);
},
'webhook.endpoint.controller' => function(ContainerInterface $container) : IncomingWebhookEndpoint {
2020-07-09 16:31:06 +03:00
$webhookEndpoint = $container->get('api.endpoint.webhook');
$webhookFactory = $container->get('api.factory.webhook');
2020-07-06 11:04:06 +03:00
$handler = $container->get('webhook.endpoint.handler');
$logger = $container->get('woocommerce.logger.woocommerce');
$verifyRequest = ! defined('PAYPAL_WEBHOOK_REQUEST_VERIFICATION') || PAYPAL_WEBHOOK_REQUEST_VERIFICATION;
return new IncomingWebhookEndpoint(
$webhookEndpoint,
$webhookFactory,
$logger,
$verifyRequest,
... $handler
);
2020-07-06 11:04:06 +03:00
},
'webhook.endpoint.handler' => function(ContainerInterface $container) : array {
2020-07-07 14:04:33 +03:00
$logger = $container->get('woocommerce.logger.woocommerce');
2020-07-28 07:03:15 +03:00
$prefix = $container->get('api.prefix');
$orderEndpoint = $container->get('api.endpoint.order');
2020-07-06 11:04:06 +03:00
return [
new CheckoutOrderApproved($logger, $prefix, $orderEndpoint),
2020-07-28 07:03:15 +03:00
new CheckoutOrderCompleted($logger, $prefix),
new PaymentCaptureRefunded($logger, $prefix),
new PaymentCaptureReversed($logger, $prefix),
new PaymentCaptureCompleted($logger, $prefix),
2020-07-06 11:04:06 +03:00
];
}
];