feat: Add CreateShipmentOnReadyToShip listener to handle webhook-triggered shipments
- Create new listener that fires on ReadyToShipIntent event - Register listener in EventServiceProvider - Fix log statements in ShippingController to use order UUID instead of ID - Now when Trello card moves to 'Ready to Ship', backend automatically creates shipment
This commit is contained in:
@@ -23,6 +23,7 @@ class ShippingController extends Controller
|
||||
*/
|
||||
public function createShipment(Request $request, Order $order)
|
||||
{
|
||||
Log::info('Initiating shipment creation', ['order_uuid' => $order->uuid]);
|
||||
// Guard 1: Verify packing completed with valid dimensions
|
||||
if (! $this->validatePackingGate($order)) {
|
||||
return response()->json([
|
||||
@@ -60,7 +61,7 @@ class ShippingController extends Controller
|
||||
|
||||
// Guard 4: Idempotency - if already shipped, return existing shipment
|
||||
if ($order->courier_waybill_id) {
|
||||
Log::info('Shipment already exists, returning existing', ['order_id' => $order->id]);
|
||||
Log::info('Shipment already exists, returning existing', ['order_uuid' => $order->uuid]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
@@ -90,7 +91,7 @@ class ShippingController extends Controller
|
||||
]);
|
||||
|
||||
Log::info('Shipment created with courier', [
|
||||
'order_id' => $order->id,
|
||||
'order_uuid' => $order->uuid,
|
||||
'waybill_id' => $shipmentData['waybill_id'],
|
||||
'tracking_number' => $shipmentData['tracking_number'],
|
||||
]);
|
||||
@@ -120,7 +121,7 @@ class ShippingController extends Controller
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Failed to create shipment', [
|
||||
'order_id' => $order->id,
|
||||
'order_uuid' => $order->uuid,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user