mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Make event type param
This commit is contained in:
parent
ea2f728cd8
commit
8c52c815c8
2 changed files with 14 additions and 3 deletions
|
@ -144,7 +144,8 @@ return array(
|
|||
$webhook = $container->get( 'webhook.current' );
|
||||
return new WebhookSimulation(
|
||||
$webhook_endpoint,
|
||||
$webhook
|
||||
$webhook,
|
||||
'PAYMENT.AUTHORIZATION.CREATED'
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -39,18 +39,28 @@ class WebhookSimulation {
|
|||
*/
|
||||
private $webhook;
|
||||
|
||||
/**
|
||||
* The event type that will be simulated, such as CHECKOUT.ORDER.APPROVED.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $event_type;
|
||||
|
||||
/**
|
||||
* WebhookSimulation constructor.
|
||||
*
|
||||
* @param WebhookEndpoint $webhook_endpoint The webhooks endpoint.
|
||||
* @param Webhook|null $webhook Our registered webhook.
|
||||
* @param string $event_type The event type that will be simulated, such as CHECKOUT.ORDER.APPROVED.
|
||||
*/
|
||||
public function __construct(
|
||||
WebhookEndpoint $webhook_endpoint,
|
||||
Webhook $webhook
|
||||
Webhook $webhook,
|
||||
string $event_type
|
||||
) {
|
||||
$this->webhook_endpoint = $webhook_endpoint;
|
||||
$this->webhook = $webhook;
|
||||
$this->event_type = $event_type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +73,7 @@ class WebhookSimulation {
|
|||
throw new Exception( 'Webhooks not registered' );
|
||||
}
|
||||
|
||||
$event = $this->webhook_endpoint->simulate( $this->webhook, 'PAYMENT.AUTHORIZATION.CREATED' );
|
||||
$event = $this->webhook_endpoint->simulate( $this->webhook, $this->event_type );
|
||||
|
||||
$this->save(
|
||||
array(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue