{
  "info": {
    "name": "Codinfy API Collection",
    "_postman_id": "0f9d7a18-codinfy-collection-2026",
    "description": "Collection Postman pour l API Codinfy : auth, features, checkout, webhooks et validation de licences.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "http://localhost:8000" },
    { "key": "bearerToken", "value": "" },
    { "key": "sharedSecret", "value": "test-shared-secret" },
    { "key": "productId", "value": "1" }
  ],
  "item": [
    {
      "name": "Auth Register",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": "{{baseUrl}}/api/auth/register",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Codinfy User\",\n  \"username\": \"codinfy-user\",\n  \"email\": \"user@example.com\",\n  \"password\": \"password123\"\n}"
        }
      }
    },
    {
      "name": "Auth Login",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": "{{baseUrl}}/api/auth/login",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"user@example.com\",\n  \"password\": \"password123\"\n}"
        }
      }
    },
    {
      "name": "Get Feature Flags",
      "request": {
        "method": "GET",
        "header": [{ "key": "Authorization", "value": "Bearer {{bearerToken}}" }],
        "url": "{{baseUrl}}/api/settings/features"
      }
    },
    {
      "name": "Create Checkout",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "Authorization", "value": "Bearer {{bearerToken}}" }
        ],
        "url": "{{baseUrl}}/api/payments/checkout",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"product_id\": {{productId}},\n  \"license_type\": \"standard\",\n  \"gateway\": \"stripe\",\n  \"currency\": \"XOF\"\n}"
        }
      }
    },
    {
      "name": "Create Checkout CinetPay",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "Authorization", "value": "Bearer {{bearerToken}}" }
        ],
        "url": "{{baseUrl}}/api/payments/checkout",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"product_id\": {{productId}},\n  \"license_type\": \"standard\",\n  \"gateway\": \"cinetpay\",\n  \"currency\": \"XOF\",\n  \"coupon_code\": \"WELCOME25\"\n}"
        }
      }
    },
    {
      "name": "Create Checkout TouchPay",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "Authorization", "value": "Bearer {{bearerToken}}" }
        ],
        "url": "{{baseUrl}}/api/payments/checkout",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"product_id\": {{productId}},\n  \"license_type\": \"standard\",\n  \"gateway\": \"touchpay\",\n  \"currency\": \"XOF\",\n  \"phone\": \"+2250700000000\",\n  \"touchpay_channel\": \"om\",\n  \"coupon_code\": \"WELCOME25\"\n}"
        }
      }
    },
    {
      "name": "Create Checkout Wallet",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "Authorization", "value": "Bearer {{bearerToken}}" }
        ],
        "url": "{{baseUrl}}/api/payments/checkout",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"product_id\": {{productId}},\n  \"license_type\": \"standard\",\n  \"gateway\": \"stripe\",\n  \"currency\": \"XOF\",\n  \"use_wallet_balance\": true\n}"
        }
      }
    },
    {
      "name": "Webhook Probe CinetPay",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/payments/webhooks/cinetpay"
      }
    },
    {
      "name": "Webhook Probe TouchPay",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/payments/webhooks/touchpay"
      }
    },
    {
      "name": "Payment Webhook Stripe",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": "{{baseUrl}}/api/payments/webhooks/stripe",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"type\": \"checkout.session.completed\",\n  \"data\": {\n    \"object\": {\n      \"id\": \"cs_test_001\",\n      \"metadata\": {\n        \"invoice_id\": \"1\"\n      }\n    }\n  }\n}"
        }
      }
    },
    {
      "name": "Payment Webhook TouchPay",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "x-touchpay-secret", "value": "your-touchpay-secret" }
        ],
        "url": "{{baseUrl}}/api/payments/webhooks/touchpay",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"transactionId\": \"tp_tx_001\",\n  \"idFromClient\": \"CDF-20260410-ABC123\",\n  \"status\": \"PENDING\"\n}"
        }
      }
    },
    {
      "name": "Payment Webhook KKiaPay",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "x-kkiapay-secret", "value": "your-webhook-secret" }
        ],
        "url": "{{baseUrl}}/api/payments/webhooks/kkiapay",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"transactionId\": \"kk_tx_001\",\n  \"isPaymentSucces\": true,\n  \"partnerId\": \"CDF-20260410-ABC123\",\n  \"stateData\": {\n    \"invoice_id\": 1,\n    \"invoice_number\": \"CDF-20260410-ABC123\"\n  },\n  \"event\": \"transaction.success\"\n}"
        }
      }
    },
    {
      "name": "Validate License",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-Codinfy-Signature", "value": "{{computedSignature}}" }
        ],
        "url": "{{baseUrl}}/api/admin/validate",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"purchase_code\": \"00000000-0000-0000-0000-000000000000\",\n  \"domain\": \"monsite.com\",\n  \"product_id\": 42,\n  \"script_version\": \"2.1.0\",\n  \"timestamp\": 1735000000\n}"
        }
      },
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "exec": [
              "const body = pm.request.body.raw;",
              "const secret = pm.collectionVariables.get('sharedSecret');",
              "const signature = CryptoJS.HmacSHA256(body, secret).toString();",
              "pm.variables.set('computedSignature', signature);"
            ],
            "type": "text/javascript"
          }
        }
      ]
    }
  ]
}
