2020-07-06 11:04:06 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Inpsyde\PayPalCommerce\Webhooks;
|
|
|
|
|
2020-08-25 11:55:26 +03:00
|
|
|
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');
|
2020-07-09 08:29:17 +03:00
|
|
|
$logger = $container->get('woocommerce.logger.woocommerce');
|
2020-07-10 14:08:13 +03:00
|
|
|
$verifyRequest = ! defined('PAYPAL_WEBHOOK_REQUEST_VERIFICATION') || PAYPAL_WEBHOOK_REQUEST_VERIFICATION;
|
2020-07-09 08:29:17 +03:00
|
|
|
|
2020-07-10 14:08:13 +03:00
|
|
|
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');
|
2020-08-25 11:55:26 +03:00
|
|
|
$orderEndpoint = $container->get('api.endpoint.order');
|
2020-07-06 11:04:06 +03:00
|
|
|
return [
|
2020-08-25 11:55:26 +03:00
|
|
|
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
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|