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 Status | Code | Meaning |
|---|---|---|
| 400 | validation_error | Missing or invalid request parameter |
| 401 | unauthorized | Missing or invalid X-Api-Key |
| 404 | not_found | Endpoint or resource not found |
| 500 | upstream_error | MoonPay returned an unexpected error |
GET /payment-methods
GET
/api.php/payment-methods
List available payment methods by region
Query Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
| countryCode | optional | USA | ISO3 country code (e.g. USA, GBR, ZMB) |
| currencyCode | optional | USD | Fiat currency: USD, EUR, GBP |
| transactionType | optional | buy | buy or sell |
Example Request
curl "https://fiat.macroit.org/api.php/payment-methods?countryCode=ZMB¤cyCode=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
| Parameter | Required | Default | Description |
|---|---|---|---|
| cryptoCode | required | — | Crypto to receive: btc, eth, sol, usdc… |
| amount | required | — | Positive number (fiat or crypto depending on amountType) |
| amountType | optional | fiat | fiat — spend this much fiat | crypto — receive this much crypto |
| fiatCode | optional | usd | Fiat currency: usd, eur, gbp |
| paymentMethod | optional | credit_debit_card | See payment methods endpoint for options |
| walletAddress | optional | — | Customer'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
| Field | Required | Description |
|---|---|---|
| cryptoCode | required | Crypto to purchase: btc, eth, sol… |
| walletAddress | required | Customer's wallet address for receiving crypto |
| amount | required | Fiat amount to spend (e.g. 200) |
| fiatCode | optional | Fiat currency (default: usd) |
| paymentMethod | optional | Default: credit_debit_card |
| optional | Pre-fill customer email on the payment page | |
| redirectUrl | optional | Where 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_...¤cyCode=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
| Parameter | Required | Description |
|---|---|---|
| id | required | MoonPay 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
| Status | Meaning |
|---|---|
pending | Payment accepted, crypto transfer in progress |
completed | Crypto delivered to wallet |
failed | Transaction failed, no funds transferred |
Test API Keys
| Client | API Key | Environment |
|---|---|---|
| Demo Client A | test_client_key_abc123 | Sandbox |
| Demo Client B | test_client_key_xyz789 | Sandbox |
Test Cards (Sandbox Only)
Do NOT use real card numbers in sandbox. Use these test cards only.
| Card Type | Number | Expiry | CVC |
|---|---|---|---|
| Mastercard 3DS (USA) | 5385 3083 6013 5181 | 12/2030 | 123 |
| Visa Frictionless (UK) | 4485 0403 7153 6584 | 12/2030 | 123 |
| Visa 3DS (UK) | 4242 4242 4242 4242 | 12/2030 | 123 |
| Visa Declined (insufficient funds) | 4544 2491 6767 3670 | 12/2030 | 123 |