mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
commit
79e2dd2ef5
28 changed files with 2784 additions and 73 deletions
|
@ -72,7 +72,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'webhook.current' => function( $container ) : ?Webhook {
|
||||
'webhook.current' => function( ContainerInterface $container ) : ?Webhook {
|
||||
$data = (array) get_option( WebhookRegistrar::KEY, array() );
|
||||
if ( empty( $data ) ) {
|
||||
return null;
|
||||
|
@ -91,18 +91,18 @@ return array(
|
|||
}
|
||||
},
|
||||
|
||||
'webhook.is-registered' => function( $container ) : bool {
|
||||
'webhook.is-registered' => function( ContainerInterface $container ) : bool {
|
||||
return $container->get( 'webhook.current' ) !== null;
|
||||
},
|
||||
|
||||
'webhook.status.registered-webhooks' => function( $container ) : array {
|
||||
'webhook.status.registered-webhooks' => function( ContainerInterface $container ) : array {
|
||||
$endpoint = $container->get( 'api.endpoint.webhook' );
|
||||
assert( $endpoint instanceof WebhookEndpoint );
|
||||
|
||||
return $endpoint->list();
|
||||
},
|
||||
|
||||
'webhook.status.registered-webhooks-data' => function( $container ) : array {
|
||||
'webhook.status.registered-webhooks-data' => function( ContainerInterface $container ) : array {
|
||||
$empty_placeholder = __( 'No webhooks found.', 'woocommerce-paypal-payments' );
|
||||
|
||||
$webhooks = array();
|
||||
|
@ -139,7 +139,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'webhook.status.simulation' => function( $container ) : WebhookSimulation {
|
||||
'webhook.status.simulation' => function( ContainerInterface $container ) : WebhookSimulation {
|
||||
$webhook_endpoint = $container->get( 'api.endpoint.webhook' );
|
||||
$webhook = $container->get( 'webhook.current' );
|
||||
return new WebhookSimulation(
|
||||
|
@ -150,13 +150,13 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'webhook.status.assets' => function( $container ) : WebhooksStatusPageAssets {
|
||||
'webhook.status.assets' => function( ContainerInterface $container ) : WebhooksStatusPageAssets {
|
||||
return new WebhooksStatusPageAssets(
|
||||
$container->get( 'webhook.module-url' )
|
||||
);
|
||||
},
|
||||
|
||||
'webhook.endpoint.resubscribe' => static function ( $container ) : ResubscribeEndpoint {
|
||||
'webhook.endpoint.resubscribe' => static function ( ContainerInterface $container ) : ResubscribeEndpoint {
|
||||
$registrar = $container->get( 'webhook.registrar' );
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
|
||||
|
@ -166,7 +166,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'webhook.endpoint.simulate' => static function ( $container ) : SimulateEndpoint {
|
||||
'webhook.endpoint.simulate' => static function ( ContainerInterface $container ) : SimulateEndpoint {
|
||||
$simulation = $container->get( 'webhook.status.simulation' );
|
||||
$request_data = $container->get( 'button.request-data' );
|
||||
|
||||
|
@ -175,7 +175,7 @@ return array(
|
|||
$request_data
|
||||
);
|
||||
},
|
||||
'webhook.endpoint.simulation-state' => static function ( $container ) : SimulationStateEndpoint {
|
||||
'webhook.endpoint.simulation-state' => static function ( ContainerInterface $container ) : SimulationStateEndpoint {
|
||||
$simulation = $container->get( 'webhook.status.simulation' );
|
||||
|
||||
return new SimulationStateEndpoint(
|
||||
|
@ -183,7 +183,7 @@ return array(
|
|||
);
|
||||
},
|
||||
|
||||
'webhook.module-url' => static function ( $container ): string {
|
||||
'webhook.module-url' => static function ( ContainerInterface $container ): string {
|
||||
return plugins_url(
|
||||
'/modules/ppcp-webhooks/',
|
||||
dirname( __FILE__, 3 ) . '/woocommerce-paypal-payments.php'
|
||||
|
|
|
@ -50,7 +50,7 @@ class CheckoutOrderApproved implements RequestHandler {
|
|||
/**
|
||||
* The event types a handler handles.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function event_types(): array {
|
||||
return array(
|
||||
|
|
|
@ -39,7 +39,7 @@ class CheckoutOrderCompleted implements RequestHandler {
|
|||
/**
|
||||
* The event types a handler handles.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function event_types(): array {
|
||||
return array(
|
||||
|
|
|
@ -40,7 +40,7 @@ class PaymentCaptureCompleted implements RequestHandler {
|
|||
/**
|
||||
* The event types a handler handles.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function event_types(): array {
|
||||
return array( 'PAYMENT.CAPTURE.COMPLETED' );
|
||||
|
|
|
@ -39,7 +39,7 @@ class PaymentCaptureRefunded implements RequestHandler {
|
|||
/**
|
||||
* The event types a handler handles.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function event_types(): array {
|
||||
return array( 'PAYMENT.CAPTURE.REFUNDED' );
|
||||
|
|
|
@ -42,7 +42,7 @@ class PaymentCaptureReversed implements RequestHandler {
|
|||
/**
|
||||
* The event types a handler handles.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function event_types(): array {
|
||||
return array(
|
||||
|
|
|
@ -17,7 +17,7 @@ interface RequestHandler {
|
|||
/**
|
||||
* The event types a handler handles.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function event_types(): array;
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ class IncomingWebhookEndpoint {
|
|||
/**
|
||||
* Returns the event types, which are handled by the endpoint.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function handled_event_types(): array {
|
||||
$event_types = array();
|
||||
|
|
|
@ -47,14 +47,14 @@ class WebhooksStatusPageAssets {
|
|||
'ppcp-webhooks-status-page-style',
|
||||
$this->module_url . '/assets/css/status-page.css',
|
||||
array(),
|
||||
1
|
||||
'1'
|
||||
);
|
||||
|
||||
wp_register_script(
|
||||
'ppcp-webhooks-status-page',
|
||||
$this->module_url . '/assets/js/status-page.js',
|
||||
array(),
|
||||
1,
|
||||
'1',
|
||||
true
|
||||
);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class WebhookSimulation {
|
|||
*
|
||||
* @throws Exception If failed to start simulation.
|
||||
*/
|
||||
public function start() {
|
||||
public function start(): void {
|
||||
if ( ! $this->webhook ) {
|
||||
throw new Exception( 'Webhooks not registered' );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue