Create Order

When the customer clicks the 'Pay with Crypto' button, he/she is going to the Crypto payment page payment_url. Create Order API does two things.

Create Order API will do two things.

  • You need to provide basic payment info to display, including price_amount, title, description. e.g. 9.9 USD for the monthly membership.

  • You will have a payment_url page to direct the user. The page will contain the basic payment info.

  • You need to provide the success_url (when the payment succeeds, the user will be redirected there), and callback_url (we will tell the callback_url when the payments succeed).

This is the ONLY API needed for your website.


Definition

POST https://api.mugglepay.com/v1/orders

Body Params

Supported Tokens (Networks)

We support major stable tokens and networks, here are the popular tokens. If the pay_currency as set, the invoice page will be checkout with the selected token. Here are the commonly used tokens.

Example

Request with Curl

The easiest way to try this API: Replace API_TOKEN_GET_FROM_ADMIN_PORTAL with the one from backend portal.

curl -X POST \
  https://api.mugglepay.com/v1/orders \
  -H 'content-type: application/json' \
  -H 'token: API_TOKEN_GET_FROM_ADMIN_PORTAL' \
  -d '{
  "merchant_order_id": 100388,
  "price_amount": 10,
  "price_currency": "USD"
}'

Request with NodeJS

var request = require("request");

var options = { method: 'POST',
  url: 'https://api.mugglepay.com/v1/orders',
  headers: { 
     'token': 'API_TOKEN_GET_FROM_ADMIN_PORTAL',
     'content-type': 'application/json' 
     },
  body: { 
     merchant_order_id: '503a854998-6230-4338-adb7',
     title: "Monthly Program x 1",
     description: "Gaming for your family",
     price_amount: 1,
     price_currency: 'USD',
     pay_currency: 'USDT_ARBI',
     callback_url: "https://ecards.com/api/success",
     cancel_url: "https://ecards.com/ecardstatus?status=cancel",
     success_url: "https://ecards.com/ecardstatus?status=success",
  },
  json: true 
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

POST Body

{
  "merchant_order_id": "503a854998-6230-4338-adb7",
  "price_amount": 1.00,
  "price_currency": "USD",
  "title": "Monthly Program x 1",
  "description": "Game Pass Friends and Family, up to four players can enjoy Game Pass",
  "callback_url": "https://ecards.com/api/success",
  "cancel_url": "https://ecards.com/ecardstatus?status=cancel",
  "success_url": "https://ecards.com/ecardstatus?status=success",
  "token": "XI231SD02-SDFWE123D"
}

Result Format

200 OK

{
    "status": 201,
    "order": {
        "user_id": 32014,
        "merchant_order_id": "503a854998-6230-4338-adb7",
        "title": "Monthly Program x 1",
        "description": "Game Pass Friends and Family, up to four players can enjoy Game Pass",
        "callback_url": "https://ecards.com/api/success",
        "cancel_url": "https://ecards.com/ecardstatus?status=cancel",
        "success_url": "https://ecards.com/ecardstatus?status=success",
        "price_amount": 1,
        "price_currency": "USD",
        "pay_amount": 1,
        "pay_currency": "USD",
        "order_id": "94be2b2a-2905-4857-b701-b04e57e84593",
        "status": "NEW",
        "created_at": "2019-04-24T16:57:35.416Z",
        "updated_at": "2019-04-24T16:57:35.416Z"
    },
    "payment_url": "https://invoice.mugglepay.com/invoices?id=94be2b2a-2905-4857-b701-b04e57e84593"
}

Error Format

MugglePay Server will always return status 400. If API failed, it will return error_code and error as its object.

{
    "status": 400,
    "error_code": "PARAMETERS_MISSING",
    "error": "Missing parameters."
}

Notes

When the buyers create the order, they are redirected to payment_url, where they can see the payment amount and then pay with crypto.

Your received payments will be settled immediately if USD or stable currency is selected.

Last updated