{
 "info": {
  "name": "CRYPT.PE Gateway API",
  "description": "Non-custodial crypto payment gateway. Set `secret_key` to your sk_test_* (sandbox) or sk_live_* key from the dashboard Gateway card. Docs: https://crypt.pe/docs",
  "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
 },
 "variable": [
  {
   "key": "base_url",
   "value": "https://crypt.pe/api"
  },
  {
   "key": "secret_key",
   "value": "sk_test_REPLACE_ME"
  },
  {
   "key": "order_id",
   "value": ""
  }
 ],
 "auth": {
  "type": "bearer",
  "bearer": [
   {
    "key": "token",
    "value": "{{secret_key}}",
    "type": "string"
   }
  ]
 },
 "item": [
  {
   "name": "Payments",
   "item": [
    {
     "name": "Create payment",
     "event": [
      {
       "listen": "test",
       "script": {
        "exec": [
         "const d = pm.response.json();",
         "if (d.order_id) pm.collectionVariables.set('order_id', d.order_id);",
         "pm.test('order created', () => pm.expect(d.status).to.eql('pending'));"
        ],
        "type": "text/javascript"
       }
      }
     ],
     "request": {
      "method": "POST",
      "header": [
       {
        "key": "Content-Type",
        "value": "application/json"
       },
       {
        "key": "Idempotency-Key",
        "value": "demo-{{$randomUUID}}"
       }
      ],
      "body": {
       "mode": "raw",
       "raw": "{\n  \"amount_usd\": 49.99,\n  \"return_url\": \"https://your-site.com/thanks\",\n  \"webhook_url\": \"https://your-site.com/webhooks/cryptpe\",\n  \"customer_email\": \"buyer@example.com\",\n  \"metadata\": { \"cart_id\": \"1001\" }\n}"
      },
      "url": {
       "raw": "{{base_url}}/v1/payments",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "v1",
        "payments"
       ]
      },
      "description": "Creates an order and returns a hosted `checkout_url` to redirect your customer to. `accepted_coins` (optional) restricts coins; defaults to every coin your wallets support."
     }
    },
    {
     "name": "Get payment (poll status)",
     "request": {
      "method": "GET",
      "url": {
       "raw": "{{base_url}}/v1/payments/{{order_id}}",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "v1",
        "payments",
        "{{order_id}}"
       ]
      },
      "description": "Poll an order you created. Statuses: pending \u2192 paid_unconfirmed \u2192 confirmed | underpaid | overpaid | expired | cancelled | refunded."
     }
    },
    {
     "name": "Test-pay (sandbox only)",
     "request": {
      "method": "POST",
      "url": {
       "raw": "{{base_url}}/v1/payments/{{order_id}}/test-pay",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "v1",
        "payments",
        "{{order_id}}",
        "test-pay"
       ]
      },
      "description": "Simulates a completed on-chain payment. Requires an sk_test_* key and a test-mode order. Flips the order to `confirmed` and fires a real HMAC-signed `payment.confirmed` webhook."
     }
    },
    {
     "name": "Verify tx (settle by hash)",
     "request": {
      "method": "POST",
      "header": [
       {
        "key": "Content-Type",
        "value": "application/json"
       }
      ],
      "body": {
       "mode": "raw",
       "raw": "{\n  \"tx_hash\": \"0xCUSTOMER_TX_HASH\"\n}"
      },
      "url": {
       "raw": "{{base_url}}/v1/payments/{{order_id}}/verify-tx",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "v1",
        "payments",
        "{{order_id}}",
        "verify-tx"
       ]
      },
      "description": "Support-ticket escape hatch: verify a customer's tx hash on-chain against this order and settle it. Works on pending AND expired orders (if the tx was mined within the quote window). Fires payment.confirmed webhook on success."
     }
    },
    {
     "name": "Refund payment",
     "request": {
      "method": "POST",
      "header": [
       {
        "key": "Content-Type",
        "value": "application/json"
       }
      ],
      "body": {
       "mode": "raw",
       "raw": "{\n  \"tx_hash\": \"0xREFUND_TX_HASH\",\n  \"amount_crypto\": null,\n  \"reason\": \"customer request\"\n}"
      },
      "url": {
       "raw": "{{base_url}}/v1/payments/{{order_id}}/refund",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "v1",
        "payments",
        "{{order_id}}",
        "refund"
       ]
      },
      "description": "Records a refund you sent on-chain (you keep custody, so you send it from your own wallet). `amount_crypto` omitted/null = full refund."
     }
    },
    {
     "name": "Cancel payment",
     "request": {
      "method": "POST",
      "url": {
       "raw": "{{base_url}}/v1/payments/{{order_id}}/cancel",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "v1",
        "payments",
        "{{order_id}}",
        "cancel"
       ]
      },
      "description": "Cancels a still-pending order and fires `payment.cancelled`. Orders past `paid_unconfirmed` must be refunded instead."
     }
    }
   ]
  },
  {
   "name": "Hosted checkout (public, no auth)",
   "item": [
    {
     "name": "Get order (public)",
     "request": {
      "method": "GET",
      "auth": {
       "type": "noauth"
      },
      "url": {
       "raw": "{{base_url}}/orders/{{order_id}}/public",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "orders",
        "{{order_id}}",
        "public"
       ]
      },
      "description": "What the hosted checkout page reads. Expired pending orders auto-flip to `expired` on read."
     }
    },
    {
     "name": "Select coin (customer)",
     "request": {
      "method": "POST",
      "auth": {
       "type": "noauth"
      },
      "header": [
       {
        "key": "Content-Type",
        "value": "application/json"
       }
      ],
      "body": {
       "mode": "raw",
       "raw": "{ \"coin\": \"eth\" }"
      },
      "url": {
       "raw": "{{base_url}}/orders/{{order_id}}/select-coin",
       "host": [
        "{{base_url}}"
       ],
       "path": [
        "orders",
        "{{order_id}}",
        "select-coin"
       ]
      },
      "description": "Locks chosen_coin, a unique per-order crypto amount and the receiving address. Coin codes: eth, matic, arb, base, bnb, usdt-erc20, usdc-erc20, usdt-bsc, usdc-bsc, btc, sol, usdc-sol."
     }
    }
   ]
  }
 ]
}