Scaffold Ladill Woo Manager for WooCommerce order fulfillment.
Deploy Ladill Woo Manager / deploy (push) Failing after 2s
Deploy Ladill Woo Manager / deploy (push) Failing after 2s
Standalone app with SSO shell, WordPress plugin connect flow, webhook ingest, fulfillment inbox, and plugin activation API — no payment processing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\WooStore;
|
||||
use App\Services\Woo\OrderIngestService;
|
||||
use App\Services\Woo\WooWebhookVerifier;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WooWebhookController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private WooWebhookVerifier $verifier,
|
||||
private OrderIngestService $ingest,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request, string $storePublicId): JsonResponse
|
||||
{
|
||||
$store = WooStore::query()
|
||||
->where('public_id', $storePublicId)
|
||||
->where('status', WooStore::STATUS_ACTIVE)
|
||||
->first();
|
||||
|
||||
if (! $store) {
|
||||
return response()->json(['message' => 'Store not found.'], 404);
|
||||
}
|
||||
|
||||
if (! $this->verifier->verify($request, $store)) {
|
||||
return response()->json(['message' => 'Invalid signature.'], 401);
|
||||
}
|
||||
|
||||
$topic = (string) $request->header('X-WC-Webhook-Topic', '');
|
||||
if (! in_array($topic, (array) config('woo.webhook_topics', []), true)) {
|
||||
return response()->json(['ignored' => true]);
|
||||
}
|
||||
|
||||
/** @var array<string, mixed> $payload */
|
||||
$payload = $request->json()->all();
|
||||
if ($payload === []) {
|
||||
return response()->json(['ignored' => true]);
|
||||
}
|
||||
|
||||
$order = $this->ingest->ingest($store, $payload);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'order_id' => $order->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user