Skip to content

Notifications

LaraCommerce sends automatic notifications via email, in-app (database), and push (Firebase Cloud Messaging) channels at key customer journey moments.


Notification Events

NotificationTriggerChannels
WelcomeNotificationEmail verifiedEmail + Database + Push
OrderPlacedNotificationOrder successfully createdEmail + Database + Push
OrderConfirmedNotificationPayment confirmedEmail + Database + Push
OrderShippedNotificationOrder marked as shippedEmail + Database + Push
OrderDeliveredNotificationOrder marked as deliveredEmail + Database + Push
OrderCancelledNotificationOrder cancelledEmail + Database + Push
PaymentRequiresActionNotification3DS authentication neededEmail + Database
PaymentFailedNotificationPayment declinedEmail + Database + Push
RefundProcessedNotificationRefund completedEmail + Database + Push
ReturnRequestedNotificationReturn request initiatedEmail + Database
ReturnApprovedNotificationReturn request approvedEmail + Database + Push
ReturnRejectedNotificationReturn request rejectedEmail + Database + Push
InvoiceNotificationInvoice generatedEmail + Database
ReviewApprovedNotificationReview approved by adminEmail + Database
PasswordChangedNotificationPassword changed (includes IP/device)Email
AccountDeletedNotificationAccount deletion confirmedEmail
LowStockNotificationStock below thresholdEmail (admin)
StockBackInStockNotificationItem restockedEmail + Database + Push
NewContactNotificationNew contact form submissionEmail (admin only)

Push Notifications (Firebase Cloud Messaging)

LaraCommerce uses FCM v1 API via the kreait/laravel-firebase package to send push notifications to mobile devices.

How It Works

  1. The Flutter app registers a device token via POST /api/v1/user/push-token
  2. When an event occurs (order shipped, payment failed, etc.), the notification is sent on 3 channels: email, database, and push
  3. FCM delivers the push notification to the registered devices
  4. Invalid/expired tokens are automatically deactivated

FCM Payload Format

The payload sent to devices follows this structure, used by the Flutter app for navigation:

json
{
  "notification": {
    "title": "Colis expédié",
    "body": "Votre commande ORD-001 a été expédiée"
  },
  "data": {
    "type": "order_shipped",
    "order_number": "ORD-001"
  }
}

The data.type field is used by the Flutter app for navigation on tap.

Notification Types

TypeTitleTrigger
order_placedCommande confirméeOrder created
order_confirmedCommande en préparationPayment confirmed
order_shippedColis expédiéOrder shipped
order_deliveredColis livréOrder delivered
order_cancelledCommande annuléeOrder cancelled
payment_failedPaiement échouéPayment failed
refund_processedRemboursement effectuéRefund completed
return_approvedRetour approuvéReturn approved
return_rejectedRetour refuséReturn rejected
back_in_stockDe retour en stockProduct restocked
welcomeBienvenue !Email verified

Configuration

ini
# .env
FIREBASE_CREDENTIALS=firebase-service-account.json

Download the service account JSON from Firebase Console → Project Settings → Service accounts → Generate new private key.

Place the file at the project root. It is excluded from git via .gitignore.


Register Push Token

http
POST /api/v1/user/push-token
Authorization: Bearer {token}

Request:

json
{
  "token": "dx8iE3KeSc6tCrdnb8-qOU:APA91b...",
  "platform": "android",
  "device_id": "unique-device-id"
}
FieldTypeRequiredDescription
tokenstringYesFCM device token
platformstringYesios, android, or web
device_idstringNoUnique device identifier (used for upsert)

Response 201:

json
{
  "status": "success",
  "message": "Created"
}

Delete Push Token

http
DELETE /api/v1/user/push-token
Authorization: Bearer {token}

Request:

json
{
  "device_id": "unique-device-id"
}

Managing Notifications

List Notifications

http
GET /api/v1/user/notifications
Authorization: Bearer {token}

Response 200:

json
{
  "status": "success",
  "data": {
    "data": [
      {
        "id": 1,
        "type": "order_shipped",
        "title": "Colis expédié",
        "body": "Votre commande ORD-001 a été expédiée",
        "data": {"order_number": "ORD-001"},
        "read_at": null,
        "created_at": "2026-03-17T10:00:00Z"
      }
    ],
    "current_page": 1,
    "last_page": 1,
    "total": 1
  }
}

Mark All as Read

http
PATCH /api/v1/user/notifications/read-all
Authorization: Bearer {token}

Admin Panel

The admin panel includes a Notifications section at /admin:

PageURLFeatures
Notifications/admin/push-notificationsList all notifications, filter by type/read status, mark read/unread, send manual push
Push Tokens/admin/push-tokensList device tokens, test push, activate/deactivate, filter by platform

Send Manual Push (Admin)

From the Notifications page, click "Send Push Notification" to send a custom push to any user with an active device token.

Test Push (Admin)

From the Push Tokens page, click "Test Push" on any active token to send a test notification to that device.


Custom Webhooks

Developers can register webhooks to receive real-time event data on their own servers.

http
POST /api/v1/user/webhooks

Requires authentication.

Request:

json
{
  "url": "https://myapp.com/hooks/laracommerce",
  "events": ["order.placed", "order.shipped", "payment.completed"],
  "secret": "my-webhook-secret"
}

Supported Events:

EventDescription
order.placedNew order created
order.confirmedPayment confirmed
order.shippedOrder dispatched
order.deliveredOrder delivered
order.cancelledOrder cancelled
payment.completedPayment successful
payment.failedPayment failed
refund.processedRefund completed

Webhook Payload:

json
{
  "event": "order.shipped",
  "timestamp": "2026-03-05T14:00:00Z",
  "data": {
    "order_number": "ORD-20260305-0001",
    "tracking_number": "1Z999AA10123456784"
  }
}

All webhook requests include an X-Webhook-Signature header (HMAC-SHA256 of the payload using your secret) for verification.

List Webhooks

http
GET /api/v1/user/webhooks

Delete Webhook

http
DELETE /api/v1/user/webhooks/{id}

Delivery Logs

Each webhook delivery is logged with status, response code, and body. Admins can view and retry failed deliveries from the admin panel.

Licensed for single or extended use.