{
  "info": {
    "name": "CedarPay API v1",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "CedarPay merchant API. Set baseUrl (e.g. https://pay.example/api/v1), publicKey and secretKey in the collection variables. Sandbox keys (cpk_test_…) never move real money. Keep secret keys out of shared workspaces."
  },
  "auth": {
    "type": "basic",
    "basic": [
      {
        "key": "username",
        "value": "{{publicKey}}",
        "type": "string"
      },
      {
        "key": "password",
        "value": "{{secretKey}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:8000/api/v1"
    },
    {
      "key": "publicKey",
      "value": "cpk_test_REPLACE_ME"
    },
    {
      "key": "secretKey",
      "value": "csk_test_REPLACE_ME"
    },
    {
      "key": "collectionId",
      "value": ""
    },
    {
      "key": "payoutId",
      "value": ""
    },
    {
      "key": "refundId",
      "value": ""
    },
    {
      "key": "settlementId",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Account",
      "item": [
        {
          "name": "Ping",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/ping",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "ping"
              ]
            },
            "description": "Check credentials and environment."
          }
        },
        {
          "name": "Payment methods",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/payment-methods",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "payment-methods"
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Collections",
      "item": [
        {
          "name": "Create collection",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/collections",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "collections"
              ]
            },
            "description": "Sandbox: the last digit of the phone number picks the outcome (1 success, 2 insufficient funds, 3 declined, 4 no response, 5 timeout, 6 duplicate callbacks, 7 late callback, 8 operator error, 9 not registered, 0 success).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_reference\": \"ORDER-{{$timestamp}}\",\n  \"amount\": 10000,\n  \"currency\": \"UGX\",\n  \"provider\": \"mtn_uganda\",\n  \"customer\": {\n    \"phone\": \"256772000001\",\n    \"name\": \"Test Customer\"\n  },\n  \"description\": \"Order payment\",\n  \"metadata\": {\n    \"order_id\": \"100045\"\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const j = pm.response.json();",
                  "if (j.success) { pm.collectionVariables.set('collectionId', j.data.id); }",
                  "pm.test('202 Accepted', () => pm.response.to.have.status(202));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get collection",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/collections/{{collectionId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "collections",
                "{{collectionId}}"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Collection status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/collections/{{collectionId}}/status",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "collections",
                "{{collectionId}}",
                "status"
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Transactions & balance",
      "item": [
        {
          "name": "List transactions",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/transactions?limit=25",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "transactions"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "25"
                }
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Balance",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/balance",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "balance"
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Payouts",
      "item": [
        {
          "name": "Request payout",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/payouts",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "payouts"
              ]
            },
            "description": "Sandbox: beneficiary last digit picks the outcome. Takes amount + fee from your available balance.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"merchant_reference\": \"PO-{{$timestamp}}\",\n  \"amount\": 20000,\n  \"currency\": \"UGX\",\n  \"beneficiary\": {\n    \"phone\": \"256772000001\",\n    \"name\": \"Jane Supplier\"\n  },\n  \"description\": \"Supplier payment\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "List payouts",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/payouts",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "payouts"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Get payout",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/payouts/{{payoutId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "payouts",
                "{{payoutId}}"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Payout status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/payouts/{{payoutId}}/status",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "payouts",
                "{{payoutId}}",
                "status"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Cancel payout (awaiting approval)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/payouts/{{payoutId}}/cancel",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "payouts",
                "{{payoutId}}",
                "cancel"
              ]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Refunds",
      "item": [
        {
          "name": "Refund collection",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/refunds",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "refunds"
              ]
            },
            "description": "Full refunds only, where the operator supports them (Airtel Money; sandbox simulator).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"collection_id\": \"{{collectionId}}\",\n  \"merchant_reference\": \"RF-{{$timestamp}}\",\n  \"reason\": \"Customer request\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Get refund",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/refunds/{{refundId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "refunds",
                "{{refundId}}"
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Settlements",
      "item": [
        {
          "name": "List settlements",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/settlements",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "settlements"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Get settlement",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/settlements/{{settlementId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "settlements",
                "{{settlementId}}"
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "List endpoints",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/webhooks",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks"
              ]
            },
            "description": ""
          }
        },
        {
          "name": "Create endpoint",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/webhooks",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks"
              ]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://your-server.example/webhooks/cedarpay\",\n  \"events\": [\n    \"collection.successful\",\n    \"collection.failed\"\n  ],\n  \"description\": \"Order service\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Delete endpoint",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/webhooks/we_REPLACE_ME",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks",
                "we_REPLACE_ME"
              ]
            },
            "description": ""
          }
        }
      ]
    },
    {
      "name": "Sandbox",
      "item": [
        {
          "name": "Force outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/sandbox/collections/{{collectionId}}/simulate",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "sandbox",
                "collections",
                "{{collectionId}}",
                "simulate"
              ]
            },
            "description": "outcome: successful | failed | expired | reversed",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"outcome\": \"successful\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Simulate payout outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/sandbox/payouts/{{payoutId}}/simulate",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "sandbox",
                "payouts",
                "{{payoutId}}",
                "simulate"
              ]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"outcome\": \"failed\",\n  \"failure_code\": \"insufficient_funds\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Simulate refund outcome",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/sandbox/refunds/{{refundId}}/simulate",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "sandbox",
                "refunds",
                "{{refundId}}",
                "simulate"
              ]
            },
            "description": "",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"outcome\": \"successful\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    }
  ]
}