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

61 lines
2.1 KiB
PHP
Raw Normal View History

2020-07-06 11:04:06 +03:00
<?php
2020-08-27 13:10:16 +03:00
/**
* The webhook module services.
*
2020-09-11 14:11:10 +03:00
* @package WooCommerce\PayPalCommerce\Webhooks
2020-08-27 13:10:16 +03:00
*/
2020-07-06 11:04:06 +03:00
declare(strict_types=1);
2020-09-11 14:11:10 +03:00
namespace WooCommerce\PayPalCommerce\Webhooks;
2020-07-06 11:04:06 +03:00
2020-09-11 14:11:10 +03:00
use WooCommerce\PayPalCommerce\Webhooks\Handler\CheckoutOrderApproved;
use WooCommerce\PayPalCommerce\Webhooks\Handler\CheckoutOrderCompleted;
use WooCommerce\PayPalCommerce\Webhooks\Handler\PaymentCaptureCompleted;
use WooCommerce\PayPalCommerce\Webhooks\Handler\PaymentCaptureRefunded;
use WooCommerce\PayPalCommerce\Webhooks\Handler\PaymentCaptureReversed;
2020-07-06 11:04:06 +03:00
use Psr\Container\ContainerInterface;
2020-08-27 13:10:16 +03:00
return array(
2020-07-06 11:04:06 +03:00
2020-09-11 13:38:02 +03:00
'webhook.registrar' => function( $container ) : WebhookRegistrar {
2020-08-27 13:10:16 +03:00
$factory = $container->get( 'api.factory.webhook' );
$endpoint = $container->get( 'api.endpoint.webhook' );
$rest_endpoint = $container->get( 'webhook.endpoint.controller' );
$logger = $container->get( 'woocommerce.logger.woocommerce' );
2020-08-27 13:10:16 +03:00
return new WebhookRegistrar(
$factory,
$endpoint,
$rest_endpoint,
$logger
2020-08-27 13:10:16 +03:00
);
},
2020-09-11 13:38:02 +03:00
'webhook.endpoint.controller' => function( $container ) : IncomingWebhookEndpoint {
2020-08-27 13:10:16 +03:00
$webhook_endpoint = $container->get( 'api.endpoint.webhook' );
$webhook_factory = $container->get( 'api.factory.webhook' );
$handler = $container->get( 'webhook.endpoint.handler' );
$logger = $container->get( 'woocommerce.logger.woocommerce' );
$verify_request = ! defined( 'PAYPAL_WEBHOOK_REQUEST_VERIFICATION' ) || PAYPAL_WEBHOOK_REQUEST_VERIFICATION;
2020-08-27 13:10:16 +03:00
return new IncomingWebhookEndpoint(
$webhook_endpoint,
$webhook_factory,
$logger,
$verify_request,
... $handler
);
},
2020-09-11 13:38:02 +03:00
'webhook.endpoint.handler' => function( $container ) : array {
2020-08-27 13:10:16 +03:00
$logger = $container->get( 'woocommerce.logger.woocommerce' );
$prefix = $container->get( 'api.prefix' );
$order_endpoint = $container->get( 'api.endpoint.order' );
return array(
new CheckoutOrderApproved( $logger, $prefix, $order_endpoint ),
new CheckoutOrderCompleted( $logger, $prefix ),
new PaymentCaptureRefunded( $logger, $prefix ),
new PaymentCaptureReversed( $logger, $prefix ),
new PaymentCaptureCompleted( $logger, $prefix ),
);
},
);