{
  "info": {
    "name": "ArionPay API v1",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Set publicKey and secretKey (Dashboard > Stores > your store > API keys). Requests are signed by the collection pre-request script. Each signed request is accepted once, so wait a second before sending the same request again. Docs: https://arionpay.com/docs"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://merchant.arionpay.com"
    },
    {
      "key": "publicKey",
      "value": "pk_your_public_key"
    },
    {
      "key": "secretKey",
      "value": "sk_your_secret_key"
    },
    {
      "key": "invoiceId",
      "value": ""
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Signs every request: x-signature = hex(HMAC_SHA256(secretKey, \"<timestamp>.<raw body>\")) for POST,",
          "// or \"<timestamp>.GET <path and query>\" for GET. Requests more than 5 minutes old are rejected.",
          "const ts = Math.floor(Date.now() / 1000).toString();",
          "const secret = pm.collectionVariables.get('secretKey');",
          "const path = pm.variables.replaceIn(pm.request.url.getPathWithQuery());",
          "const body = pm.request.body && pm.request.body.raw ? pm.variables.replaceIn(pm.request.body.raw) : '';",
          "const message = pm.request.method === 'GET' ? ts + '.GET ' + path : ts + '.' + body;",
          "pm.request.headers.upsert({ key: 'x-api-key', value: pm.collectionVariables.get('publicKey') });",
          "pm.request.headers.upsert({ key: 'x-timestamp', value: ts });",
          "pm.request.headers.upsert({ key: 'x-signature', value: CryptoJS.HmacSHA256(message, secret).toString(CryptoJS.enc.Hex) });"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Create a test invoice",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"amount\": \"49.00\",\n  \"currency\": \"USD\",\n  \"orderId\": \"order-1001\",\n  \"asset\": \"USDT_TRC20\",\n  \"test\": true\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{baseUrl}}/api/v1/invoices"
      }
    },
    {
      "name": "Get an invoice",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/api/v1/invoices/{{invoiceId}}"
      }
    },
    {
      "name": "Simulate a test payment",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"scenario\": \"exact\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{baseUrl}}/api/v1/invoices/{{invoiceId}}/simulate"
      }
    },
    {
      "name": "Send a test webhook",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"eventType\": \"invoice.paid\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{baseUrl}}/api/v1/webhooks/test"
      }
    },
    {
      "name": "List coins and networks (no keys)",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/api/v1/currencies"
      }
    },
    {
      "name": "Get exchange rates (no keys)",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/api/v1/rates?currency=USD"
      }
    },
    {
      "name": "Check an address (no keys)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"address\": \"bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu\",\n  \"network\": \"BTC\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": "{{baseUrl}}/api/v1/wallets/validate"
      }
    }
  ]
}
