Skip to content

Commit

Permalink
Enable order webhook route.
Browse files Browse the repository at this point in the history
  • Loading branch information
vedanshujain committed Jan 15, 2025
1 parent 57c21d6 commit 2f9a096
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/AppRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use App\Lib\SyncService\WooCommerce\WooConnection;
use App\Lib\HotStore\ProductHotStore;
use App\Store\SettingsController;

use App\Webhooks\OrdersWebhookController;
use App\Lib\ESQuery\ESQuery;
class AppRouter {

public function __construct(
Expand Down Expand Up @@ -75,17 +76,21 @@ public function serve(): void {
$controller = new SitesController( $this->kv_store, $this->request );
$controller->serve();
} elseif ( str_starts_with( $this->request->getPathInfo(), '/webhooks' ) ) {
$auth = new WebhookAuth( $this->kv_store, $this->request );
switch ( $this->request->getPathInfo() ) {
case '/webhooks/products':
$auth = new WebhookAuth( $this->kv_store, $this->request );
$controller = new ProductsWebhookController( $this->kv_store, $this->request, $auth );
$controller->serve();
break;
case '/webhooks/payment-gateways':
$auth = new WebhookAuth( $this->kv_store, $this->request );
$controller = new PaymentGatewayWebhookController( $this->kv_store, $auth, $this->request );
$controller->serve();
break;
case '/webhooks/orders':
$es_query = new ESQuery();
$controller = new OrdersWebhookController( $this->kv_store, $this->request, $auth, $this->hot_store, $es_query );
$controller->serve();
break;
default:
send_error_and_exit( 'webhook_not_found', 404, 'Webhook not found' );
}
Expand Down

0 comments on commit 2f9a096

Please sign in to comment.