# Zivora Jewels Member API Documentation

**Base URL:** `https://zivoradiamonds.com/api/v1`  
**Format:** JSON  
**Auth:** Bearer Token (except Login)

---

## Authentication

Protected APIs require header:

```http
Authorization: Bearer {token}
Accept: application/json
Content-Type: application/json
```

Token validity: **30 days** from login.

---

## 1. Login

`POST /api/v1/login`  
**Auth:** No

### Request
```json
{
  "login": "ZD100001",
  "password": "your_password"
}
```

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `login` | string | Yes | Member ID / Phone / Email |
| `password` | string | Yes | Member password |

### Success `200`
```json
{
  "ok": true,
  "message": "Login successful.",
  "token": "UFTxeBGlPHQq3EitYSUQEV4gQuuRNNJcb6pf9EXWnKBdUQr38tDmw8f0tU4q",
  "token_type": "Bearer",
  "expires_at": "2026-10-14T13:59:36+00:00",
  "member": {
    "member_id": "ZD100001",
    "name": "Naresh chandra shakya",
    "email": "shaile383@gmail.com",
    "phone": "9837581754",
    "status": "Active",
    "pv": 1,
    "activation_type": "bv",
    "bv_active": true,
    "wallets": {
      "deposit": 0,
      "ewallet": 0,
      "shopping": 12500,
      "pins": 0
    }
  }
}
```

### Error `401`
```json
{ "ok": false, "message": "Invalid login or password." }
```

---

## 2. Me (Profile + Wallets + Top-up Status)

`GET /api/v1/me`  
**Auth:** Yes

### Success `200`
```json
{
  "ok": true,
  "member": { "...same as login member..." },
  "topup": {
    "eligible": true,
    "bv_active": true,
    "pv": 1,
    "activation_type": "bv",
    "pay_amount": 2500,
    "credit_amount": 12500,
    "completed_topups": 0,
    "pending_request": false,
    "allow_multiple": false,
    "message": "Eligible: ₹2500 pay karke ₹12500 Shopping Wallet milega."
  }
}
```

---

## 3. Logout

`POST /api/v1/logout`  
**Auth:** Yes

### Success `200`
```json
{ "ok": true, "message": "Logged out." }
```

---

## 4. Wallet Summary

`GET /api/v1/wallet`  
**Auth:** Yes

### Success `200`
```json
{
  "ok": true,
  "wallets": {
    "deposit": 0,
    "ewallet": 0,
    "shopping": 12500,
    "pins": 0
  },
  "topup": { "...eligibility object..." }
}
```

| Wallet | Meaning |
|--------|---------|
| `deposit` | Deposit Wallet |
| `ewallet` | Income / E-Wallet |
| `shopping` | Shopping Wallet (top-up credit) |
| `pins` | ₹1 Binary Pin balance |

---

## 5. Wallet Transactions

`GET /api/v1/wallet/transactions`  
**Auth:** Yes

### Query Params
| Param | Default | Values |
|-------|---------|--------|
| `wallet` | `all` | `all`, `deposit`, `ewallet`, `shopping` |
| `per_page` | `25` | 1–50 |

### Example
`GET /api/v1/wallet/transactions?wallet=shopping&per_page=25`

### Success `200`
```json
{
  "ok": true,
  "wallet": "shopping",
  "data": [
    {
      "id": 101,
      "member_id": "ZD100001",
      "wallet_type": "shopping",
      "type": "credit",
      "amount": "12500.00",
      "balance": "12500.00",
      "description": "Shopping Wallet credit on ₹2,500.00 top-up (ST260914135936583)",
      "reference_id": "ST260914135936583",
      "created_at": "2026-09-14T13:59:36.000000Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 1,
    "total": 1
  }
}
```

---

## 6. Shopping Top-up Eligibility

`GET /api/v1/wallet/topup/eligibility`  
**Auth:** Yes

### Business Rule
1. Member must be **1 BV Active** (`bv_active = true`)
2. Pay **₹2,500** (online or offline)
3. Get **₹12,500** Shopping Wallet credit
4. Default: **one time per ID** (`allow_multiple = false`)

### Success `200`
```json
{
  "ok": true,
  "topup": {
    "eligible": true,
    "bv_active": true,
    "pv": 1,
    "activation_type": "bv",
    "pay_amount": 2500,
    "credit_amount": 12500,
    "completed_topups": 0,
    "pending_request": false,
    "allow_multiple": false,
    "message": "Eligible: ₹2500 pay karke ₹12500 Shopping Wallet milega."
  }
}
```

---

## 7. Create Top-up Request

`POST /api/v1/wallet/topup/request`  
**Auth:** Yes  
**Content-Type:** `application/json` **or** `multipart/form-data` (if uploading proof)

### Request Fields
| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `payment_mode` | string | Yes | `online` or `offline` |
| `payment_ref` | string | No | Gateway / receipt ref |
| `utr` | string | No | UPI/Bank UTR |
| `remarks` | string | No | Optional note |
| `payment_confirmed` | boolean | No | `true` = instant credit (online) |
| `proof` | file | No | JPG/PNG max 4MB (offline slip) |

### A) Online Instant Credit
```json
{
  "payment_mode": "online",
  "payment_ref": "PAY_GATEWAY_123",
  "payment_confirmed": true,
  "remarks": "Razorpay success"
}
```

### Success `200`
```json
{
  "ok": true,
  "message": "Payment received. ₹12,500.00 Shopping Wallet mein credit ho gaya.",
  "topup": {
    "topup_no": "ST260914135936583",
    "pay_amount": 2500,
    "credit_amount": 12500,
    "payment_mode": "online",
    "status": "Completed",
    "payment_ref": "PAY_GATEWAY_123",
    "utr": null,
    "paid_at": "2026-09-14T13:59:36+00:00",
    "credited_at": "2026-09-14T13:59:36+00:00",
    "reject_reason": null,
    "created_at": "2026-09-14T13:59:36+00:00"
  },
  "wallets": {
    "shopping": 12500
  }
}
```

### B) Offline (Pending → Office Approve)
```json
{
  "payment_mode": "offline",
  "utr": "123456789012",
  "remarks": "Paid via UPI"
}
```

### Success `201`
```json
{
  "ok": true,
  "message": "Top-up request submit ho gayi. Offline payment ke liye office approve karega.",
  "topup": {
    "topup_no": "ST260914140001111",
    "pay_amount": 2500,
    "credit_amount": 12500,
    "payment_mode": "offline",
    "status": "Pending",
    "utr": "123456789012",
    "credited_at": null
  },
  "wallets": {
    "shopping": 0
  }
}
```

### Error `422`
```json
{
  "ok": false,
  "message": "Pehle ID ko 1 BV se Active karein."
}
```

Other common messages:
- `Ek Pending top-up request pehle se hai.`
- `Is ID ka ₹2500 → ₹12500 shopping top-up already mil chuka hai.`

---

## 8. Confirm Online Top-up (2-step flow)

Use when request was created without `payment_confirmed`, then gateway succeeds.

`POST /api/v1/wallet/topup/confirm`  
**Auth:** Yes

### Request
```json
{
  "topup_no": "ST260914140001111",
  "payment_ref": "GATEWAY_TXN_999"
}
```

### Success `200`
```json
{
  "ok": true,
  "message": "Shopping Wallet credited.",
  "topup": { "...Completed..." },
  "shopping_wallet": 12500
}
```

---

## 9. Top-up History

`GET /api/v1/wallet/topup/history`  
**Auth:** Yes

### Success `200`
```json
{
  "ok": true,
  "data": [
    {
      "topup_no": "ST260914135936583",
      "pay_amount": 2500,
      "credit_amount": 12500,
      "payment_mode": "online",
      "status": "Completed",
      "payment_ref": "PAY_GATEWAY_123",
      "utr": null,
      "paid_at": "2026-09-14T13:59:36+00:00",
      "credited_at": "2026-09-14T13:59:36+00:00",
      "reject_reason": null,
      "created_at": "2026-09-14T13:59:36+00:00"
    }
  ]
}
```

---

## Top-up Status Values

| Status | Meaning |
|--------|---------|
| `Pending` | Waiting office approve (offline) |
| `Completed` | ₹12500 credited to Shopping Wallet |
| `Rejected` | Office rejected |

---

## cURL Examples

### Login
```bash
curl -X POST "https://zivoradiamonds.com/api/v1/login" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"login":"ZD100001","password":"your_password"}'
```

### Wallet
```bash
curl "https://zivoradiamonds.com/api/v1/wallet" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### Online Top-up
```bash
curl -X POST "https://zivoradiamonds.com/api/v1/wallet/topup/request" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"payment_mode":"online","payment_ref":"PAY123","payment_confirmed":true}'
```

---

## Office Panel (Offline)

- URL: `/Office/shopping_topups`
- Approve / Reject pending requests
- Quick counter credit: Member ID + ₹2500 received → ₹12500 credit

---

## Configurable Settings (Office → Settings)

| Key | Default | Description |
|-----|---------|-------------|
| `shopping_topup_pay_amount` | `2500` | Amount member pays |
| `shopping_topup_credit_amount` | `12500` | Shopping wallet credit |
| `shopping_topup_allow_multiple` | `0` | `1` = allow multiple top-ups |

---

## Error Codes

| HTTP | Meaning |
|------|---------|
| 200 | Success |
| 201 | Created (pending top-up) |
| 401 | Invalid / invalid token |
| 422 | Validation / business rule fail |
| 404 | Top-up not found |
| 500 | Server error |
