Preorder Validation API Testing

API-PPO-001: Create Preorder with CREDIT Payment Method

1
2
POST /api/preorder/create
Authorization: Bearer <token>

Request Body

1
2
3
4
5
6
7
8
9
10
11
12
{
  "customerId": "CUST-DEMO-078",
  "items": [
    {
      "productCode": "PROD-001",
      "quantity": 8,
      "unitPrice": 750000
    }
  ],
  "paymentMethod": "CREDIT",
  "orderDate": "2026-06-30"
}

Expected Response (Success + Credit Impact)

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "success": true,
  "statusCode": 201,
  "preorderId": "PO-20260630-089",
  "status": "SUBMITTED",
  "totalAmount": 6000000,
  "message": "Preorder created successfully",
  "creditImpact": {
    "previousLimit": 8000000,
    "deductedAmount": 6000000,
    "remainingLimit": 2000000
  }
}

API-PPO-002: Validate Customer Credit Limit After Preorder

1
GET /api/customer/CUST-DEMO-078/credit-limit

Expected Response

1
2
3
4
5
6
7
8
{
  "customerId": "CUST-DEMO-078",
  "previousAvailableLimit": 8000000,
  "currentAvailableLimit": 2000000,
  "usedLimit": 6000000,
  "lastUpdated": "2026-06-30T08:25:00",
  "recentPreorderId": "PO-20260630-089"
}

API-PPO-003: Attempt Preorder When Credit Limit is Insufficient

1
POST /api/preorder/create

Request Body

1
2
3
4
5
6
7
8
9
10
{
  "customerId": "CUST-DEMO-078",
  "items": [
    {
      "productCode": "PROD-001",
      "quantity": 15
    }
  ],
  "paymentMethod": "CREDIT"
}

Expected Response (Blocked)

1
2
3
4
5
6
7
8
{
  "success": false,
  "statusCode": 403,
  "message": "Insufficient credit limit for this Preorder",
  "availableLimit": 2000000,
  "requiredAmount": 11250000,
  "errorCode": "CREDIT_LIMIT_EXCEEDED"
}

API-PPO-004: Validate Pricing Calculation

1
POST /api/preorder/calculate

Request Body

1
2
3
4
5
6
7
8
9
{
  "customerId": "CUST-DEMO-078",
  "items": [
    {
      "productCode": "PROD-001",
      "quantity": 8
    }
  ]
}

Expected Response

1
2
3
4
5
6
7
{
  "subtotal": 6000000,
  "discount": 0,
  "ppn": 660000,
  "finalTotal": 6660000,
  "availableCreditLimit": 8000000
}

API Testing Coverage

No Scenario Endpoint Method Expected
1 Create Preorder + Credit Deduction /api/preorder/create POST Success + limit deducted
2 Check Updated Credit Limit /api/customer/{id}/credit-limit GET Remaining limit updated
3 Preorder when limit exceeded /api/preorder/create POST 403 Forbidden
4 Pricing Calculation /api/preorder/calculate POST Correct total

Back to Project