تخطى إلى المحتوى
Please login to generate your API token.

🚀 Store API

Complete REST API documentation for integrating with our store platform

v1.0
Base URL https://mousa-card.com/wp-json/mps/v1

🔐 Authentication

All API requests require authentication using a Bearer token. Include your API token in the Authorization header:

HEADER Authorization: Bearer YOUR_API_TOKEN
⚠️
Security Notice
Keep your API token secure. Never share it or expose it in client-side code. Generate a new token if compromised.

Required Headers

HeaderValueDescription
AuthorizationBearer {token}Your API authentication token
Content-Typeapplication/jsonRequired for POST requests

📦 Get Products

GET /products

Retrieve all available products. Returns a flat list where each variation is a separate product item.

Query Parameters

ParameterTypeRequiredDescription
category string Optional Filter by category slug (e.g., games, subscriptions)

Example Request

curl -X GET "https://mousa-card.com/wp-json/mps/v1/products?category=games" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response Fields

FieldTypeDescription
idstringUnique product/variation ID (use this for orders)
namestringProduct or variation name
pricestringPrice in user's currency (formatted number)
currency_namestringCurrency name (e.g., USD, USDT)
currency_symbolstringCurrency symbol (e.g., $)
availablebooleanWhether product is available for purchase
min_quantityintegerMinimum order quantity
max_quantityintegerMaximum order quantity
categoriesarrayList of category names
custom_fieldsarrayRequired fields for order (see below)
thumbnailstring|nullProduct image URL

Custom Fields Structure

FieldTypeDescription
keystringField identifier (use in order request)
labelstringDisplay label
typestringtext | number | dropdown
requiredbooleanWhether field is required
optionsarray|nullOptions list (for dropdown type only)

Example Response

{
  "success": true,
  "data": {
    "products": [
      {
        "id": "12310",
        "name": "100 Credits",
        "price": "5",
        "currency_name": "USD",
        "currency_symbol": "$",
        "available": true,
        "min_quantity": 1,
        "max_quantity": 1,
        "categories": ["Games"],
        "custom_fields": [
          {
            "key": "playerid",
            "label": "Player ID",
            "type": "text",
            "required": true,
            "options": null
          }
        ],
        "thumbnail": "https://example.com/image.png"
      },
      {
        "id": "12311",
        "name": "500 Credits",
        "price": "20",
        "currency_name": "USD",
        "currency_symbol": "$",
        "available": true,
        "min_quantity": 1,
        "max_quantity": 1,
        "categories": ["Games"],
        "custom_fields": [...],
        "thumbnail": "https://example.com/image.png"
      }
    ],
    "total": 25
  }
}
📌
Custom Fields Note
Some products may require multiple custom fields. The field key (identifier) may vary between products.
Always check each product's custom_fields array to see required fields and their keys before creating orders.

📋 Get Single Product

GET /products/{id}

Retrieve detailed information about a specific product including all its variations.

URL Parameters

ParameterTypeDescription
id string Product ID from the products list

Example Request

curl -X GET "https://mousa-card.com/wp-json/mps/v1/products/123" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Example Response

{
  "success": true,
  "data": {
    "id": "123",
    "type": "variable",
    "name": "Game Credits Pack",
    "description": "Buy game credits...",
    "price": "5",
    "currency_name": "USD",
    "currency_symbol": "$",
    "available": true,
    "min_quantity": 1,
    "max_quantity": 100,
    "custom_fields": [...],
    "thumbnail": "https://example.com/image.png",
    "variations": [
      {
        "id": 12310,
        "name": "100 Credits",
        "price": "5",
        "available": true
      },
      {
        "id": 12311,
        "name": "500 Credits",
        "price": "20",
        "available": true
      }
    ]
  }
}

Product Types

TypeDescription
simpleSingle product without variations
variableProduct with multiple variations (e.g., different amounts)
subscriptionSubscription product (returns account details when completed)
codesDigital codes product (returns codes when completed)

🛒 Create Order

POST /orders

Create a new purchase order. Balance will be deducted automatically from your account.

Request Body

ParameterTypeRequiredDescription
product_id integer Required Product/Variation ID from products list
quantity integer Optional Quantity (default: 1, check min/max_quantity)
custom_fields object If Required Custom field values (check product's custom_fields)

Example Request

curl -X POST "https://mousa-card.com/wp-json/mps/v1/orders" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": 12310,
    "quantity": 1,
    "custom_fields": {
      "playerid": "12345678"
    }
  }'
⚠️
Important
Content-Type: Must be application/json
custom_fields: Use keys from product's custom_fields array

Response Fields

FieldTypeDescription
order_idintegerCreated order ID (save this to check status)
product_idintegerPurchased product ID
quantityintegerPurchased quantity
totalstringTotal cost deducted
statusstringprocessing or completed
new_balancestringYour new balance after purchase
codesarrayCodes (only for codes products)
currency_namestringCurrency name
currency_symbolstringCurrency symbol

Example Response (Codes Product)

⚠️
Important: Codes May Not Be Instant
Codes products may return status: "processing" initially. You must poll GET /orders/{id} until status becomes completed to retrieve the codes.

Scenario 1: Instant Fulfillment (codes available immediately)

{
  "success": true,
  "data": {
    "order_id": 456,
    "product_id": 12330,
    "quantity": 2,
    "total": "10",
    "currency_name": "USD",
    "currency_symbol": "$",
    "status": "completed",
    "codes": ["ABC123-XYZ", "DEF456-XYZ"],
    "new_balance": "90"
  }
}

Scenario 2: Pending Fulfillment (requires polling)

Initial response - codes not yet available:

{
  "success": true,
  "data": {
    "order_id": 456,
    "product_id": 12330,
    "quantity": 2,
    "total": "10",
    "currency_name": "USD",
    "currency_symbol": "$",
    "status": "processing",
    "codes": [],
    "new_balance": "90"
  }
}

➡️ Poll GET /orders/456 until status is completed, then codes will be available.

Example Response (Other Products - Processing)

{
  "success": true,
  "data": {
    "order_id": 457,
    "product_id": 12310,
    "quantity": 1,
    "total": "5",
    "currency_name": "USD",
    "currency_symbol": "$",
    "status": "processing",
    "new_balance": "95"
  }
}
💡
Order Status & Polling Workflow
completed = Order fulfilled, codes/data available
processing = Order pending fulfillment

Recommended Polling Strategy:
1. Save the order_id from the response
2. If status is processing, poll GET /orders/{order_id}
3. Wait 2-5 seconds between requests
4. Continue until status becomes completed or rejected

📊 Get Order Status

GET /orders/{id}

Retrieve the current status and details of a specific order. Use this to check if processing orders are completed.

URL Parameters

ParameterTypeDescription
idintegerOrder ID from create order response

Example Request

curl -X GET "https://mousa-card.com/wp-json/mps/v1/orders/242859" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response Fields

FieldTypeDescription
order_idintegerOrder identifier
statusstringOrder status (see status values below)
product_idstringProduct identifier
product_namestringProduct name
quantityintegerOrdered quantity
totalstringTotal cost
currency_namestringCurrency name
currency_symbolstringCurrency symbol
created_atstringOrder date (Y-m-d H:i:s)
variationstringVariation name (if applicable)
codesarrayCodes array (codes products only)
subscription_detailsobjectAccount details (subscription only)

Status Values

StatusDescription
processingOrder is being processed
completedOrder fulfilled successfully
rejectedOrder was rejected
cancelledOrder was cancelled
pendingOrder is pending

Example Response (Processing)

{
  "success": true,
  "data": {
    "order_id": 242859,
    "status": "processing",
    "product_id": "12310",
    "product_name": "100 Credits",
    "quantity": 1,
    "total": "5",
    "currency_name": "USD",
    "currency_symbol": "$",
    "created_at": "2024-01-15 14:30:00"
  }
}

Example Response (Completed - Codes Product)

{
  "success": true,
  "data": {
    "order_id": 242860,
    "status": "completed",
    "product_id": "12330",
    "product_name": "Gift Card",
    "quantity": 1,
    "total": "10",
    "currency_name": "USD",
    "currency_symbol": "$",
    "created_at": "2024-01-15 14:35:00",
    "codes": ["ABCD-1234-EFGH"]
  }
}

Example Response (Completed - Subscription)

{
  "success": true,
  "data": {
    "order_id": 242861,
    "status": "completed",
    "product_id": "12420",
    "product_name": "Netflix 1 Month",
    "quantity": 1,
    "total": "15",
    "currency_name": "USD",
    "currency_symbol": "$",
    "created_at": "2024-01-15 14:40:00",
    "subscription_details": {
      "email": "[email protected]",
      "password": "pass123",
      "url": "https://netflix.com",
      "notes": "Valid for 30 days"
    }
  }
}

📋 Get Multiple Orders Status

POST /orders/status

Check the status of multiple orders in a single request. Useful for batch status checking.

Request Body

ParameterTypeDescription
order_idsarrayArray of order IDs to check (max 50)

Example Request

curl -X POST "https://mousa-card.com/wp-json/mps/v1/orders/status" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "order_ids": [242859, 242850, 242849]
  }'
⚠️
Limit
Maximum 50 orders per request. Orders you don't own will return not_found status.

Example Response

{
  "success": true,
  "data": {
    "orders": [
      {
        "order_id": 242859,
        "status": "processing",
        "product_id": "12310",
        "quantity": 1,
        "total": "5",
        "currency_name": "USD",
        "currency_symbol": "$"
      },
      {
        "order_id": 242850,
        "status": "completed",
        "product_id": "12330",
        "quantity": 1,
        "total": "10",
        "currency_name": "USD",
        "currency_symbol": "$",
        "codes": ["ABCD-1234-EFGH"]
      },
      {
        "order_id": 242849,
        "status": "not_found",
        "error": "Order not found or access denied"
      }
    ]
  }
}

💰 Check Balance

GET /balance

Get the current balance of the authenticated user. Check this before creating orders.

Example Request

curl -X GET "https://mousa-card.com/wp-json/mps/v1/balance" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response Fields

FieldTypeDescription
balancestringCurrent balance amount
currency_namestringCurrency name (e.g., USD, USDT)
currency_symbolstringCurrency symbol (e.g., $)

Example Response

{
  "success": true,
  "data": {
    "balance": "150.5",
    "currency_name": "USD",
    "currency_symbol": "$"
  }
}
💡
Tip
Balance is returned as a string to preserve decimal precision. Compare with product prices before ordering.

❌ Error Codes

All errors follow a consistent format with appropriate HTTP status codes.

CodeHTTPDescription
unauthorized401Missing or invalid API token
forbidden403Access denied to resource
not_found404Resource not found
invalid_request400Missing or invalid parameters
insufficient_balance400Not enough balance for purchase
unavailable400Product or variation not available
insufficient_stock400Not enough stock (codes products)
store_closed503Store is under maintenance
purchase_disabled403Account purchase disabled
system_error500Internal server error

Error Response Format

{
  "success": false,
  "error": {
    "code": "insufficient_balance",
    "message": "Insufficient balance",
    "required": 50.000,
    "available": 30.000,
    "currency": "$"
  }
}
Order Status Values
processing - Order is being processed
completed - Order fulfilled successfully
cancelled - Order was cancelled

Response Fields by Product Type

Product TypeExtra Fields (when completed)
Codes Productcodes - Array of code strings
Subscription Productsubscription_details - Object with email, password, url, notes
Simple/VariableNo extra fields
واتساب تيليجرام