Integration Guide
This guide explains how to integrate MiraclePay into your application to accept cryptocurrency payments. The External Payments API (base path /external/v1) lets you create payment requests programmatically and redirect customers to a hosted checkout page. All requests are signed with your API key — see Authentication.
Contents:
Quick Start
Create an API key in the merchant panel under Settings → Developer → API Keys — you get a key ID (
mpay_pk_...), a secret (mpay_sk_..., shown only once) and a passphraseSign your requests with HMAC-SHA512 — see Authentication
Create a payment prompt via
POST /external/v1/payments/prompt— amounts are in cents (1099= $10.99). Standard accounts passblockchainIds; US merchant accounts omit it — see External Payments APIRedirect your customer to the returned
checkoutUrlConfirm the outcome via Webhooks or
GET /external/v1/payments/:id— never from redirect query parameters
import { createHmac, randomUUID } from "node:crypto";
const BASE_URL = "https://api.miraclecash.info";
async function createPayment() {
const method = "POST";
const path = "/external/v1/payments/prompt";
const rawBody = JSON.stringify({
amount: 1099, // $10.99 in cents
blockchainIds: ["eth-usdc"],
});
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = randomUUID();
const signature = createHmac("sha512", process.env.MPAY_SECRET!)
.update([timestamp, nonce, method, path, rawBody].join("\n"))
.digest("hex");
const response = await fetch(`${BASE_URL}${path}`, {
method,
headers: {
"Content-Type": "application/json",
"X-MP-KEY-ID": process.env.MPAY_KEY_ID!,
"X-MP-PASSPHRASE": process.env.MPAY_PASSPHRASE!,
"X-MP-TIMESTAMP": timestamp,
"X-MP-NONCE": nonce,
"X-MP-SIGNATURE": signature,
},
body: rawBody,
});
const { prompt, checkoutUrl } = await response.json();
// Redirect your customer to checkoutUrl
}