> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seyaha.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Bookings & Payments

> Create bookings and process payments via Moyasar or Stripe.

The affiliate booking flow: create a booking (status `Booking Attempt`) → process
payment → booking moves to `Paid by Customer` automatically.

## Create a booking

```
POST /api/v1/affiliates/users/add-booking
```

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.seyaha.net/api/v1/affiliates/users/add-booking \
    -H "Authorization: Bearer $AFFILIATE_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "activity_id": "6744810075becd2ef8c140f7",
      "variation_id": "6751ad2d7533f379c9a1711b",
      "promoCode": "SUMMER20",
      "customer_details": {
        "name": "Fatima Al-Zahra",
        "email": "fatima@example.com",
        "phone": "+966509876543"
      },
      "booking_details": {
        "booking_date": "2026-07-15",
        "booking_time": "10:00",
        "currency": "SAR",
        "guests": { "adult": 2, "child": 1, "infant": 0, "senior": 0 },
        "pickup_address": {
          "address": "King Abdullah Financial District",
          "lat": 24.7640,
          "lng": 46.6382
        }
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch(
    'https://api.seyaha.net/api/v1/affiliates/users/add-booking',
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${affiliateJwt}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        activity_id: activityId,
        variation_id: varId,
        customer_details: {
          name: 'Fatima Al-Zahra',
          email: 'fatima@example.com',
          phone: '+966509876543',
        },
        booking_details: {
          booking_date: '2026-07-15',
          booking_time: '10:00',
          currency: 'SAR',
          guests: { adult: 2, child: 1, infant: 0, senior: 0 },
        },
      }),
    }
  );
  const { data: booking } = await res.json();
  // booking._id — save this for the payment call
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": 1,
  "data": {
    "_id": "67c896a6639e6ff76dd2f882",
    "status": "Booking Attempt",
    "partnerConfirmation": "Not Required",
    "price": {
      "individuals": {
        "adults": { "number": 2, "price": 500 },
        "children": { "number": 1, "price": 300 }
      },
      "value": 800,
      "discountPercentage": 0
    },
    "bookingDate": "2026-07-15",
    "bookingTime": "10:00",
    "configurations": { "currency": "SAR", "serviceFee": 5, "taxes": 15 }
  }
}
```

***

## Process payment

```
POST /api/v1/affiliates/create-payment
```

### Moyasar (credit card)

Submit card details directly. A `transaction_url` is returned when 3DS verification
is required — redirect the user to complete it.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.seyaha.net/api/v1/affiliates/create-payment \
    -H "Authorization: Bearer $AFFILIATE_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "callback_url": "https://yourapp.com/payment/callback",
      "method": "Moyasar",
      "source": {
        "type": "creditcard",
        "name": "Fatima Al-Zahra",
        "number": "4111111111111111",
        "cvc": "123",
        "month": "07",
        "year": "28"
      },
      "meta_data": { "booking_id": "67c896a6639e6ff76dd2f882" }
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch('https://api.seyaha.net/api/v1/affiliates/create-payment', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${affiliateJwt}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      callback_url: 'https://yourapp.com/payment/callback',
      method: 'Moyasar',
      source: {
        type: 'creditcard',
        name: 'Fatima Al-Zahra',
        number: '4111111111111111',
        cvc: '123',
        month: '07',
        year: '28',
      },
      meta_data: { booking_id: bookingId },
    }),
  });
  const { data: payment } = await res.json();
  if (payment.source?.transaction_url) {
    // 3DS required — redirect user
    window.location.href = payment.source.transaction_url;
  }
  ```
</CodeGroup>

### Stripe (redirect)

Stripe always redirects to a Stripe-hosted checkout page. You must redirect the user
to `data.source.transaction_url` to complete payment.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.seyaha.net/api/v1/affiliates/create-payment \
    -H "Authorization: Bearer $AFFILIATE_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "callback_url": "https://yourapp.com/payment/callback",
      "method": "Stripe",
      "meta_data": { "booking_id": "67c896a6639e6ff76dd2f882" }
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch('https://api.seyaha.net/api/v1/affiliates/create-payment', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${affiliateJwt}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      callback_url: 'https://yourapp.com/payment/callback',
      method: 'Stripe',
      meta_data: { booking_id: bookingId },
    }),
  });
  const { data: payment } = await res.json();
  // Always redirect for Stripe
  window.location.href = payment.source.transaction_url;
  ```
</CodeGroup>

**Payment response:**

```json theme={null}
{
  "success": 1,
  "data": {
    "success": true,
    "status": "initiated",
    "id": "pay_abc123",
    "source": {
      "transaction_url": "https://checkout.stripe.com/pay/cs_live_..."
    },
    "paymentMethod": "Stripe"
  }
}
```

***

## Payment providers reference

| Provider | `method` value | Card details needed   | Redirect required |
| -------- | -------------- | --------------------- | ----------------- |
| Moyasar  | `Moyasar`      | Yes — `source` object | Only for 3DS      |
| Stripe   | `Stripe`       | No                    | Always            |

<Note>
  Use Moyasar test cards (`4111111111111111`) in the sandbox environment. Check
  [Moyasar's test docs](https://moyasar.com/docs/testing/) for the full list.
</Note>
