AI Prompt — End-to-End Integration

Copy this prompt into your coding assistant to generate your backend payment + webhook implementation.

You are integrating with the MagicStack Payment service.

Create backend code that does the following:
1. Creates an order in our DB with status 'pending'.
2. Calls POST //payment with headers X-Tenant-ID and X-APIKEY.
3. Stores paymentId + redirectUrl on the order.
4. Returns redirectUrl to frontend.
5. Implements POST /payment/webhook in our app.
6. In webhook handler, validate payload, update order status, and trigger fulfilment actions.
7. Use TypeScript types and parameterized SQL queries only.

Expected success response from payment service:
{
  "data": {
    "paymentId": 321,
    "redirectUrl": "https://provider-checkout-url"
  },
  "provider": "yoco | stripe | paystack"
}