{
  "info": {
    "name": "CentralPay SHOP Developer Reference v2.5",
    "description": "Merchant-facing CentralPay requests used by the SHOP reference project. Fulfillment is webhook-only.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "01 Create Invoice",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/invoices.php",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "invoices.php"
          ]
        },
        "description": "สร้าง Invoice/QR",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"amount\": \"100.00\",\n  \"merchant_reference\": \"{{merchant_reference}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "02 Get Invoice",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/invoices.php?invoice_no={{invoice_no}}",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "invoices.php"
          ],
          "query": [
            {
              "key": "invoice_no",
              "value": "{{invoice_no}}"
            }
          ]
        },
        "description": "อ่านสถานะ Invoice เท่านั้น ไม่ใช้เติมเครดิต"
      }
    },
    {
      "name": "03 Cancel Invoice",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/cancel-invoice.php",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "cancel-invoice.php"
          ]
        },
        "description": "ยกเลิก Invoice ที่ยัง PENDING",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"invoice_no\": \"{{invoice_no}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "04 Get Invoices",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/invoices.php?page=1&per_page=25&status={{invoice_status}}",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "invoices.php"
          ],
          "query": [
            {
              "key": "page",
              "value": "1"
            },
            {
              "key": "per_page",
              "value": "25"
            },
            {
              "key": "status",
              "value": "{{invoice_status}}"
            }
          ]
        },
        "description": "รายการ Invoice ของ Merchant"
      }
    },
    {
      "name": "05 Get Transactions",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/transactions.php?page=1&per_page=25&status={{transaction_status}}",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "transactions.php"
          ],
          "query": [
            {
              "key": "page",
              "value": "1"
            },
            {
              "key": "per_page",
              "value": "25"
            },
            {
              "key": "status",
              "value": "{{transaction_status}}"
            }
          ]
        },
        "description": "รายการ Bank Transactions ของ Merchant"
      }
    },
    {
      "name": "06 Get Match Candidates",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/match-candidates.php?transaction_id={{transaction_id}}",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "match-candidates.php"
          ],
          "query": [
            {
              "key": "transaction_id",
              "value": "{{transaction_id}}"
            }
          ]
        },
        "description": "Candidate Inspection แบบ read-only"
      }
    },
    {
      "name": "07 Manual Match",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/manual-match.php",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "manual-match.php"
          ]
        },
        "description": "CentralPay เปลี่ยน PAID แล้วส่ง payment.paid webhook; ห้ามเติมเครดิตจาก response นี้",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"transaction_id\": \"{{transaction_id}}\",\n  \"invoice_no\": \"{{invoice_no}}\",\n  \"matched_by\": \"{{admin_username}}\",\n  \"remark\": \"{{remark}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "08 Manual Confirm",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{api_key}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{centralpay_base_url}}/api/v1/manual-confirm.php",
          "host": [
            "{{centralpay_base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "manual-confirm.php"
          ]
        },
        "description": "CentralPay เปลี่ยน PAID แล้วส่ง payment.paid webhook; ห้ามเติมเครดิตจาก response นี้",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"invoice_no\": \"{{invoice_no}}\",\n  \"confirmed_by\": \"{{admin_username}}\",\n  \"remark\": \"{{remark}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    }
  ],
  "variable": [
    {
      "key": "centralpay_base_url",
      "value": "http://localhost/payment/public"
    },
    {
      "key": "api_key",
      "value": "PUT_MERCHANT_API_KEY_HERE"
    },
    {
      "key": "invoice_no",
      "value": ""
    },
    {
      "key": "merchant_reference",
      "value": "CP-TOPUP-M1-TEST-001"
    },
    {
      "key": "invoice_status",
      "value": "PENDING"
    },
    {
      "key": "transaction_status",
      "value": "UNMATCHED"
    },
    {
      "key": "transaction_id",
      "value": ""
    },
    {
      "key": "admin_username",
      "value": "admin"
    },
    {
      "key": "remark",
      "value": "ตรวจสอบรายการแล้ว"
    }
  ]
}