Crypto Aggregator API

Accept fiat payments and receive crypto — powered by MoonPay.

Base URL: https://fiat.macroit.org/api.php
Sandbox Mode — All transactions are simulated. No real money or crypto moves. Switch to your live API key when ready for production.

Authentication

Every request must include your API key in the X-Api-Key header.

# Example with curl
curl https://fiat.macroit.org/api.php/quote \
  -H "X-Api-Key: test_client_key_abc123" \
  -G -d cryptoCode=btc -d amount=100
Missing or invalid key returns 401 unauthorized.

Error Handling

All errors return a consistent JSON shape:

{
  "success": false,
  "error": {
    "code":    "validation_error",
    "message": "cryptoCode is required."
  }
}
HTTP StatusCodeMeaning
400validation_errorMissing or invalid request parameter
401unauthorizedMissing or invalid X-Api-Key
404not_foundEndpoint or resource not found
500upstream_errorMoonPay returned an unexpected error

GET /payment-methods

GET /api.php/payment-methods List available payment methods by region

Query Parameters

ParameterRequiredDefaultDescription
countryCodeoptionalUSAISO3 country code (e.g. USA, GBR, ZMB)
currencyCodeoptionalUSDFiat currency: USD, EUR, GBP
transactionTypeoptionalbuybuy or sell

Example Request

curl "https://fiat.macroit.org/api.php/payment-methods?countryCode=ZMB&currencyCode=USD" \
  -H "X-Api-Key: test_client_key_abc123"

Example Response

{
  "success": true,
  "data": {
    "paymentMethods": [
      {
        "type":             "credit_debit_card",
        "displayName":      "Debit Card",
        "iconUrl":          "https://static.moonpay.com/widget/payment_methods/CardGeneric.svg",
        "active":           true,
        "unavailableReason": null,
        "settlementSpeed":   "instant",
        "supportsRecurring": true,
        "limits": {
          "perTransaction": { "limit": 10000, "currencyCode": "USD" },
          "daily":          { "limit": 10000, "currencyCode": "USD" },
          "monthly":        { "limit": 50000, "currencyCode": "USD" }
        }
      }
    ],
    "country":         "ZMB",
    "currency":        "USD",
    "transactionType": "buy"
  }
}

GET /quote

GET /api.php/quote Get a real-time buy quote

Query Parameters

ParameterRequiredDefaultDescription
cryptoCoderequiredCrypto to receive: btc, eth, sol, usdc
amountrequiredPositive number (fiat or crypto depending on amountType)
amountTypeoptionalfiatfiat — spend this much fiat  |  crypto — receive this much crypto
fiatCodeoptionalusdFiat currency: usd, eur, gbp
paymentMethodoptionalcredit_debit_cardSee payment methods endpoint for options
walletAddressoptionalCustomer's wallet address

Example Request

curl "https://fiat.macroit.org/api.php/quote?cryptoCode=btc&amount=200&fiatCode=usd" \
  -H "X-Api-Key: test_client_key_abc123"

Example Response

{
  "success": true,
  "data": {
    "fiatAmount":     200,
    "fiatCurrency":   "USD",
    "cryptoAmount":   0.00286,
    "cryptoCurrency": "BTC",
    "pricePerCoin":   70007.78,
    "fees": {
      "moonpay": 4.00,
      "network": 0.20,
      "extra":   0,
      "total":   4.20
    },
    "totalCharged":  204.20,
    "paymentMethod": "credit_debit_card",
    "expiresAt":     "2026-06-03T01:45:00.000Z"
  }
}

POST /checkout

POST /api.php/checkout Create a checkout session → returns payment URL
Send JSON body with Content-Type: application/json. Redirect your customer to the returned checkoutUrl.

Request Body

FieldRequiredDescription
cryptoCoderequiredCrypto to purchase: btc, eth, sol
walletAddressrequiredCustomer's wallet address for receiving crypto
amountrequiredFiat amount to spend (e.g. 200)
fiatCodeoptionalFiat currency (default: usd)
paymentMethodoptionalDefault: credit_debit_card
emailoptionalPre-fill customer email on the payment page
redirectUrloptionalWhere to send the customer after payment

Example Request

curl -X POST "https://fiat.macroit.org/api.php/checkout" \
  -H "X-Api-Key: test_client_key_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "cryptoCode":    "btc",
    "walletAddress": "tb1q45h8zexwztmz3nyd8gmkxhpavdsva4znwwhzvs",
    "amount":        200,
    "fiatCode":      "usd",
    "redirectUrl":   "https://yourapp.com/payment/success"
  }'

Example Response

{
  "success": true,
  "data": {
    "checkoutUrl":   "https://buy.moonpay.com?apiKey=pk_test_...&currencyCode=btc&...&signature=...",
    "cryptoCode":    "BTC",
    "fiatCode":      "USD",
    "amount":        200,
    "walletAddress": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "paymentMethod": "credit_debit_card",
    "expiresIn":     "30 minutes",
    "note":          "Redirect your user to checkoutUrl to complete payment."
  }
}

GET /transaction/{id}

GET /api.php/transaction/{id} Check the status of a transaction

Path Parameters

ParameterRequiredDescription
idrequiredMoonPay transaction ID returned after payment

Example Request

curl "https://fiat.macroit.org/api.php/transaction/01KT4QC4GQWED3CPCA1Q7QW6PM" \
  -H "X-Api-Key: test_client_key_abc123"

Example Response

{
  "success": true,
  "data": {
    "id":             "01KT4QC4GQWED3CPCA1Q7QW6PM",
    "status":         "completed",
    "cryptoAmount":   0.00143,
    "cryptoCurrency": "BTC",
    "fiatAmount":     100,
    "fiatCurrency":   "USD",
    "walletAddress":  "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "paymentMethod":  "credit_debit_card",
    "createdAt":      "2026-06-03T01:10:00.000Z",
    "updatedAt":      "2026-06-03T01:15:00.000Z",
    "txHash":         "a1b2c3d4e5f6..."
  }
}

Transaction Statuses

StatusMeaning
pendingPayment accepted, crypto transfer in progress
completedCrypto delivered to wallet
failedTransaction failed, no funds transferred

Test API Keys

ClientAPI KeyEnvironment
Demo Client Atest_client_key_abc123Sandbox
Demo Client Btest_client_key_xyz789Sandbox

Test Cards (Sandbox Only)

Do NOT use real card numbers in sandbox. Use these test cards only.
Card TypeNumberExpiryCVC
Mastercard 3DS (USA)5385 3083 6013 518112/2030123
Visa Frictionless (UK)4485 0403 7153 658412/2030123
Visa 3DS (UK)4242 4242 4242 424212/2030123
Visa Declined (insufficient funds)4544 2491 6767 367012/2030123