Skip to content

๐Ÿ’ณ Payments API โ€‹

๐Ÿ’ฐ Create Stripe Payment Intent โ€‹

POST /api/payments/create-intent
Authorization: Bearer <token> (optional)

Request:

json
{
  "orderId": "order-id"
}

Response:

json
{
  "success": true,
  "data": {
    "clientSecret": "pi_xxx_secret_xxx"
  }
}

Use the clientSecret with Stripe.js on the frontend to complete payment.

๐Ÿ”” Stripe Webhook โ€‹

POST /api/payments/webhook
Content-Type: application/json (raw body)

Called by Stripe when a payment event occurs. The endpoint verifies the webhook signature using STRIPE_WEBHOOK_SECRET.

Handled events:

  • โœ… payment_intent.succeeded โ€” Marks the payment as completed and updates the order.

WARNING

This endpoint expects a raw request body (not JSON-parsed). It is registered before the JSON body parser in the middleware stack.

๐Ÿ’ต Mark Cash Payment โ€‹

POST /api/payments/cash
Authorization: Bearer <staff-token>

Request:

json
{
  "orderId": "order-id",
  "amount": 34.45
}

Staff marks that cash has been received for an order.

๐Ÿ…ฟ๏ธ Create PayPal Payment โ€‹

POST /api/payments/paypal/create
Authorization: Bearer <token> (optional)

Request:

json
{
  "orderId": "order-id"
}

Response:

json
{
  "success": true,
  "data": {
    "paypalOrderId": "PAYPAL-ORDER-ID"
  }
}

โœ… Capture PayPal Payment โ€‹

POST /api/payments/paypal/capture
Authorization: Bearer <token> (optional)

Request:

json
{
  "paypalOrderId": "PAYPAL-ORDER-ID"
}

Called after the customer approves payment on PayPal.

๐Ÿ”’ Permissions Summary โ€‹

ActionRequired Role
๐Ÿ’ณ Create Stripe intentCustomer or guest
๐Ÿ”” Stripe webhookStripe (signature verified)
๐Ÿ’ต Mark cash paymentStaff
๐Ÿ…ฟ๏ธ Create/capture PayPalCustomer or guest