NAV
cURL

Introduction

API Endpoint

https://api.muskpay.io

Thanks for choosing MuskPay! Our REST API uses common conventions and practices to make integration easily. Endpoint URLs follow resource-oriented naming conventions and can be accessed by using HTTP verbs such as GET and POST. Response will be in JSON format. All API requests must be made over HTTPS.

To manage transactions through a web client, please use our online Transaction Management System (TMS).

For quick integration, we also provide Sample Codes, SDKs, and Plugins on GitHub.

If you have any questions regarding our API or the integration process, please contact our Technical support team.

中文文档

Version

API Version

/v1.2

As with all of our products and services, our API is constantly being improved to better suit our customers’ needs. To help our customers track changes, we include versions in our API. We are currently on Version 1.2 (v1.2).

To specify a version, simply add /v1.2 namespace to the base endpoint before the resource namespace.

For example, to use Version 1.2, the full endpoint for the transactions resource would be: https://api.muskpay.io/v1.2/transactions

Authentication

Sample Request

$ curl https://api.muskpay.io/v1.2/transactions \
-H "Authorization: Bearer <TOKEN>"

Replace <TOKEN> with your bearer token generated in the TMS. See Authentication for more information.

Each request must be made over HTTPS and authenticated using your merchant credentials. Authentication is handled through the Authorization header with a Bearer token.

You can view your bearer token in TMS by logging in and going to Settings -> Certificate.

Header Description
Authorization
Required
Set authentication type as Bearer with a token obtained from the TMS.

If you believe either your merchant ID, secret key, or bearer token have been compromised, please regenerate your secret key in the TMS. Once you have a new secret key, a bearer token will be automatically regenerated. Please allow 15 minutes for the new bearer token to propagate through the system.

API Description

Payment Mode

CardPay

In CardPay, we require merchants' websites to have PCI certification. Merchants will collect users' credit card information and send request to API to finish the order.

Parameters Description

1.Amount

Amount as a positive integer of the minor unit of the currency. For Example, $10.50 in USD would be 1050, ¥100 in JPY would be 100.

2.Currency

Currently, MuskPay supported currencies:

Currency Currency Code Minor unit
US Dollar USD 2

3.Reference

An alphanumeric string up to 30 characters that must be unique to each of your transactions.

4.Vendor

Currently, MuskPay accepts vendors are:

5. Callback URL

callback_url and ipn_url must be accessible on the Internet and can't be intranet address (for example localhost) or intranet IP.

System Reserve

sys_reserve = {"vendor_id":"4200000117201806013734875340"}

8. System Reserved

sys_reserve, MuskPay system reserved, used for return vendor's transaction id or customer's info. Currently, includes:

Key Value
vendor_id Vendor's transaction id, usually showed on customer's payment receipt.

Instant Payment Notification

Asynchronous Response

After payment completed, MuskPay will return a transaction object to ipn_url using the POST method. Whenever possible, transaction data should be recorded from the IPN URL instead of the callback URL.

When executing the IPN notification, please note:

Asynchronous Response

id = 20170519103602011338
amount = 2
currency = USD
reference = 20170519103456437807
sys_reserve = {"vendor_id":"4200000117201806013734875340"}
status = success
time = 2017-05-19T10:36:32Z
note = null
verify_sign = 46072c81e3c6140d6bc92655196b247f

Asynchronous Response message

Property Description
id
string
Transaction ID.
status
string
Transaction status.
amount
int
The settlement amount uses foreign currency.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string
If set in request, your transaction note to self. Else if not set, this will be null.
sys_reserve
json
MuskPay system reservation, it's json string, See Parameters Description.
verify_sign
string
Signature value.

Sign method

verify_sign = MD5(key1=value1&key2=value2&...&keyn=valuen&MD5(TOKEN))

Verify signature

When the asynchronous notification returns, MuskPay will do the MD5 signature on the return message. After the merchant receives asynchronous notification, it will verify that the returned information is tampered with by the signature method.

Signature method:

A. The connection method between the critical message pair and the cooperative key message pair is:

B. Signature method

verify_sign = MD5(key1=value1&key2=&key3=value3...&keyn=value&MD5(Token))

Note:

CardPay

Charge a Credit Card

Definition

POST
https://api.muskpay.io/v1.2/transactions/cardpay

Request

$ curl https://api.muskpay.io/v1.2/transactions/cardpay \
-d reference="order19852245687" \
-d amount=100 \
-d currency="USD" \
-d card_number="6221558812340000" \
-d card_exp_month=11 \
-d card_exp_year=2017 \
-d card_cvv="123" \
-d card_holder="Tim Smith" \
-d phone_number="123-123-1234" \
-d phone_country_code="1" \
-d email="customer@domain.com" \
-d website="http://mywebsite.com" \
-d client_ip="180.167.25.154" \
-d description="order desc" \
-d note="some tips" \
-d billing_address_first_name="Tim" \
-d billing_address_last_name="Smith" \
-d billing_address_line1="4699 Old Ironsides Dr, Suite 278" \
-d billing_address_city="Santa Clara" \
-d billing_address_state="CA" \
-d billing_address_zip="95054" \
-d billing_address_country="US" \
-d shipping_address_first_name="Tim" \
-d shipping_address_last_name="Smith" \
-d shipping_address_line1="4699 Old Ironsides Dr, Suite 278" \
-d shipping_address_city="Santa Clara" \
-d shipping_address_state="CA" \
-d shipping_address_zip="95054" \
-d shipping_address_country="US" 

To charge a credit card directly on your website without redirecting users to the vendor, you should submit an CardPay request.

For every successful payment, a Transaction Object will be created and returned in JSON format with an assigned transaction ID. This transaction ID can be used to retrieve details, request cancellations and create refunds.

Note: Calling this interface requires merchants to have PCI qualifications.

Request

Property Description
reference
Required
An alphaNumeric string up to 30 characters that must be unique to each of your transactions.
currency
Required
The 3-letter currency code. See Parameters Description.
amount
Required
Amount as a positive integer of the minor unit of the currency. Minimum USD: $1. See Parameters Description.
card_number
Required
Credit card number. Numeric and up to 16 characters only.
card_exp_month
Required
Card expiration month with leading zero. Acceptable values are 01 through 12.
card_exp_year
Required
Card expiration year in 4 digits.
card_cvv
Required
Card verification value in 3 digits.
card_holder
Required
Cardhoder name.
phone_number
Required
Cardholder phone number.
phone_country_code
Required
Card holder phone Country code ISO digital code.
email
Required
Cardholder contact email.
website
Required
Trading website.
client_ip
Required
Customer IP
description
Optional
Arbitrary string that you can set to be displayed on the card charge.
note
Optional
Arbitrary string as note to self regarding the transaction.
Billing address
billing_address_first_name
Required
First name.
billing_address_middle_name
Optional
Middle name.
billing_address_last_name
Required
Last name.
billing_address_line1
Required
Address Line 1.
billing_address_line2
Optional
Address Line 2.
billing_address_city
Required
City.
billing_address_state
Required
State/Province.
billing_address_zip
Required
Zip code.
billing_address_country
Required
Country code ISO-3166-1 Alpha-2.
Shipping address
shipping_address_first_name
Required
First name.
shipping_address_middle_name
Optional
Middle name.
shipping_address_last_name
Required
Last name.
shipping_address_line1
Required
Address Line 1.
shipping_address_line2
Optional
Address Line 2.
shipping_address_city
Required
City.
shipping_address_state
Required
State/Province.
shipping_address_zip
Required
Zip code.
shipping_address_country
Required
Country code ISO-3166-1 Alpha-2.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "amount": 110,
    "currency": "USD",
    "captured": true,
    "time": "2015-01-11T01:01:00Z",
    "reference": "jkh25jh1348fd89sg",
    "note": null
}

Response

Returns a transaction object.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
captured
bool
Whether or not the transaction amount has been captured. true for captured and false for uncaptured or authorization.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string
If set in request, your transaction note to self. Else if not set, this will be null.

Authorize a Credit Card

Definition

POST
https://api.muskpay.io/v1.2/transactions/auth

Request

$ curl https://api.muskpay.io/v1.2/transactions/auth \
-H "Authorization: Bearer <TOKEN>" \
-d reference="order19852245687" \
-d amount=100 \
-d currency="USD" \
-d card_number="6221558812340000" \
-d card_exp_month=11 \
-d card_exp_year=2017 \
-d card_cvv="123" \
-d card_holder="Tim Smith" \
-d phone_number="123-123-1234" \
-d phone_country_code="1" \
-d email="customer@domain.com" \
-d website="http://mywebsite.com" \
-d client_ip="180.167.25.154" \
-d description="order desc" \
-d note="some tips" \
-d billing_address_first_name="Tim" \
-d billing_address_last_name="Smith" \
-d billing_address_line1="4699 Old Ironsides Dr, Suite 278" \
-d billing_address_city="Santa Clara" \
-d billing_address_state="CA" \
-d billing_address_zip="95054" \
-d billing_address_country="US" \
-d shipping_address_first_name="Tim" \
-d shipping_address_last_name="Smith" \
-d shipping_address_line1="4699 Old Ironsides Dr, Suite 278" \
-d shipping_address_city="Santa Clara" \
-d shipping_address_state="CA" \
-d shipping_address_zip="95054" \
-d shipping_address_country="US" 

Use this method to authorize a credit card payment. Now support Visa,Master,JCB,Amex,Discover,unionpay. To actually charge the funds you will need to follow up with a capture transaction

Note: Calling this interface requires merchants to have PCI qualifications.

Request

Property Description
reference
Required
An alphaNumeric string up to 30 characters that must be unique to each of your transactions.
currency
Required
The 3-letter currency code. See Parameters Description.
amount
Required
Amount as a positive integer of the minor unit of the currency. Minimum USD: $1. See Parameters Description.
card_number
Required
Credit card number. Numeric and up to 16 characters only.
card_exp_month
Required
Card expiration month with leading zero. Acceptable values are 01 through 12.
card_exp_year
Required
Card expiration year in 4 digits.
card_cvv
Required
Card verification value in 3 digits.
card_holder
Required
Cardhoder name.
phone_number
Required
Cardholder phone number.
phone_country_code
Required
Card holder phone Country code ISO digital code.
email
Required
Cardholder contact email.
website
Required
Trading website.
client_ip
Required
Customer IP
description
Optional
Arbitrary string that you can set to be displayed on the card charge.
note
Optional
Arbitrary string as note to self regarding the transaction.
Billing address
billing_address_first_name
Required
First name.
billing_address_middle_name
Optional
Middle name.
billing_address_last_name
Required
Last name.
billing_address_line1
Required
Address Line 1.
billing_address_line2
Optional
Address Line 2.
billing_address_city
Required
City.
billing_address_state
Required
State/Province.
billing_address_zip
Required
Zip code.
billing_address_country
Required
Country code ISO-3166-1 Alpha-2.
Shipping address
shipping_address_first_name
Required
First name.
shipping_address_middle_name
Optional
Middle name.
shipping_address_last_name
Required
Last name.
shipping_address_line1
Required
Address Line 1.
shipping_address_line2
Optional
Address Line 2.
shipping_address_city
Required
City.
shipping_address_state
Required
State/Province.
shipping_address_zip
Required
Zip code.
shipping_address_country
Required
Country code ISO-3166-1 Alpha-2.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "amount": 110,
    "currency": "USD",
    "captured": false,
    "time": "2015-01-11T01:01:00Z",
    "reference": "jkh25jh1348fd89sg",
    "note": null
}

Response

Returns a transaction object.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
captured
bool
false for authorization.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string
If set in request, your transaction note to self. Else if not set, this will be null.

Release a Previously Authorized

POST
https://api.muskpay.io/v1.2/transactions/{transaction_id}/release

Request

$ curl https://api.muskpay.io/v1.2/transactions/{transaction_id}/release \
-H "Authorization: Bearer <TOKEN>"

Release an authorization transaction. Authorizations not captured within 30 days will be automatically released.

Request

transaction_id as URL parameter.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "released": true,
    "transaction_id": "bn2345nb53454kjb"
}

Response

Returns a partial transaction object.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
released
bool
Whether or not the transaction amount has been successfully released.
transaction_id
string
ID of the transaction that was released.

Capture a Previously Authorized

POST
https://api.muskpay.io/v1.2/transactions/{transaction_id}/capture

Request

$ curl https://api.muskpay.io/v1.2/transactions/{transaction_id}/capture \
-H "Authorization: Bearer <TOKEN>" \
-d amount=100 \
-d currency="USD"

Use this method to capture funds for a transaction that was previously authorized. The amount cannot be higher than the original authorized amount.

Authorized not captured within 30 days are automatically released and cannot be re-captured. A new transaction will need to be created.

Request

transaction_id as URL parameter.

Property Description
amount
Required
Amount as an integer of the minor unit of the currency.
For example, $10.50 in USD would be 1050.
currency
Required
The 3-letter currency code. Currency must match the uncaptured transaction's currency.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "captured": true,
    "transaction_id": "bn2345nb53454kjb"
}

Response

Returns a partial transaction object.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
captured
bool
Whether or not the transaction amount has been successfully captured.
transaction_id
string
ID of the transaction that was captured.

Gateway Hosted Payment

POST
https://api.muskpay.io/v1.2/cardpay/checkout

Request

$ curl https://api.muskpay.io/v1.2/transactions/cardpay \
-H "Authorization: Bearer <TOKEN>" \
-d reference="order19852245687" \
-d amount=100 \
-d currency="USD" \
-d website="http://mywebsite.com" \
-d ipn_url="http://website.com/ipn"
-d description="订单描述" \
-d client_ip="180.167.25.154" \
-d note="备注信息" 

Credit card gateway payment is an asynchronous payment method that requires page redirection. After the merchant requests the MuskPay API, it will receive the payment page URL synchronously. The merchant needs to jump to the page. On the payment page, the customer enters the payment information to complete the payment. Once the payment is successful, the page will jump to the callback URL provided by the merchant. MuskPay will return the callback URL with the return parameters, which need to be obtained using the GET method.

Due to the nature of redirection and the possibility that the user closes the browser before the redirection occurs, in order to ensure that the payment result is notified to the merchant, MuskPay uses server-to-server real-time notification (IPN url) to return the transaction result. The IPN result needs to be obtained using the POST method.

Request

Property Description
reference
Required
An alphaNumeric string up to 30 characters that must be unique to each of your transactions.
currency
Required
The 3-letter currency code. See Parameters Description.
amount
Required
Amount as a positive integer of the minor unit of the currency. See Parameters Description.
website
Required
Trading website.
ipn_url
Required
Instant Payment Notification URL. Called by the API to update you on transaction information. This is where the response goes to. See Instant Payment Notification.
callback_url
Required
URL the browser will be redirected to upon completing the transaction.
description
Optional
Arbitrary string that you can set to be displayed on the card charge.
note
Optional
Arbitrary string as note to self regarding the transaction.
client_ip
Required
Customer IP

Response

{
    "redirect_url": "https://apitest.nihaopay.com/v1.2/cardpay/checkout/20100920042332106649?otp=xxx"
}

Response

Returns a 'JSON' object.

Property Description
redirect_url
string
Use this URL in the browser or webview to redirect the user to the wap or web payment page.

Refund/Query/Others

Retrieve a transaction by reference

Definition

GET
https://api.muskpay.io/v1.2/transactions/merchant/{reference}

Request

$ curl https://api.muskpay.io/v1.2/transactions/merchant/{reference} \
-H "Authorization: Bearer <TOKEN>"

Provide reference that was requested for a transaction in order to retrieve corresponding transaction’s details.

Applicable to transactions that do not receive asynchronous notifications

Request

reference as URL parameter.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "type": "charge",
    "amount": 1111,
    "currency": "USD",
    "time": "2015-01-01T01:01:01Z",
    "reference": "jkh25jh1348fd89sg",
    "note": "sample note"
}

Response

Returns a transaction object.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
type
string
Transaction type. Either charge, authorization, or capture.
vendor
string
Payment method. Include: VisaMasterJCBAmexDiscoverunionpay.
vendor_id
string
Vendor’s transaction id, usually showed on customer’s payment receipt.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string/null
If set in request, your transaction note to self. Else if not set, this will be null.

Look up a transaction

Definition

GET
https://api.muskpay.io/v1.2/transactions/{transaction_id}

Request

$ curl https://api.muskpay.io/v1.2/transactions/{transaction_id} \
-H "Authorization: Bearer <TOKEN>"

Returns details of a previously created transaction.

Provide a unique transaction ID that was returned from a previous response in order to retrieve corresponding transaction’s details. For details on Released, Cancelled, and Refunded transactions, please use TMS.

Request

transaction_id as URL parameter.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "type": "charge",
    "amount": 1111,
    "currency": "USD",
    "time": "2015-01-01T01:01:01Z",
    "reference": "jkh25jh1348fd89sg",
    "note": "sample note"

}

Response

Returns a transaction object.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
type
string
Transaction type. Either charge, authorization, or capture.
vendor
string
Payment method. Include: VisaMasterJCBAmexDiscoverunionpay.
vendor_id
string
Vendor’s transaction id, usually showed on customer’s payment receipt.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string/null
If set in request, your transaction note to self. Else if not set, this will be null.

Refund a transaction

Definition

POST
https://api.muskpay.io/v1.2/transactions/{transaction_id}/refund

Request

$ curl https://api.muskpay.io/v1.2/transactions/{transaction_id}/refund \
-H "Authorization: Bearer <TOKEN>" \
-d amount=100 \
-d currency="USD"

To issue a full or partial refund, you must create a Refund Object based on an existing transaction.

Full refunds can only be created once per transaction by specifying amount as the full amount of the transaction. Partial refunds can be created multiple times untill total refund amount reaches amount of the Transaction.

You cannot refund more than the amount of the original transaction.

Request

transaction_id as URL Parameter.

Property Description
currency
Required
The 3-letter currency code. Currency must match the original transaction's currency.
amount
Conditional
Amount to be funded in the minor unit of the currency.
Must be equal to or less than the amount of the original transaction.
reason
Optional
Arbitrary string detailing the reason for refund.

Response

{
    "id": "bn2345nb53454kjb",
    "status": "success",
    "refunded": true,
    "transaction_id": "jkh25jh1348fd89sg"   
}

Response

Returns a refund object.

Property Description
id
string
Refund ID.
status
string
Status of the refund. Either success, or failure.
refunded
bool
true
transaction_id
string
ID of the transaction that was refunded.

Refund Query

GET
https://api.muskpay.io/v1.2/transactions/refunds/{transaction_id}/

Request

$ curl https://api.muskpay.io/v1.2/transactions/refunds/{transaction_id}/ \
-H "Authorization: Bearer <TOKEN>" 

Request

transaction_id Original transaction ID as URL parameter.

Response

{
    "note": null,
    "amount": 2,
    "type": "charge",
    "refunded_amount": 2,
    "refunds": [
        {
            "refund_time": "2021-11-29T05:42:33Z",
            "refund_id": "20211129054233008405",
            "refunded_amount": 1,
            "status": "success"
        },
        {
            "refund_time": "2021-11-29T05:41:55Z",
            "refund_id": "20211129054155008404",
            "refunded_amount": 1,
            "status": "success"
        }
    ],
    "reference": "20211129134105329326",
    "vendor": "unionpay",
    "vendor_id": "512111291341178330258",
    "currency": "USD",
    "id": "20211129054117043676",
    "time": "2021-11-29T05:41:17Z",
    "status": "success"
}

Response

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, pending or closed
type
string
Transaction type. Either charge, authorization, or capture.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
Transaction currency.
time
string
Timestamp of the transaction in UTC.
reference
string
Merchant order number.
note
string
If set in request, your transaction note to self. Else if not set, this will be null.
vendor
string
Payment method. Include: VisaMasterJCBAmexDiscoverunionpay.
vendor_id
string
Vendor’s transaction id, usually showed on customer’s payment receipt.
refunded_amount
int
Total refunded amount
refunds
list
Refund records
refund_time
string
Refund time
refund_id
string
Refund ID.
refunded_amount
int
refund amount
status
string
Refund status.Either success or failure

List transactions

Definition

GET
https://api.muskpay.io/v1.2/transactions/

Request

$ curl https://api.muskpay.io/v1.2/transactions/?starting_after=2015-01-01T01:01:00Z \
-H "Authorization: Bearer <TOKEN>"

Returns a list of previously created transactions. Transactions are returned with the most recent transactions appearing first. By default, only 10 transactions are returned at a time. This can be adjusted by providing a limit argument.

For details on Released, Cancelled, and Refunded transactions, please use TMS.

By providing starting_after argument, you can retrieve transactions that were processed after the specified time.

By providing ending_before argument, you can retrieve transactions that were processed before the specified time.

By providing both, starting_after and ending_before arguments, you can retrieve transactions that were processed within the specified range.

Request

Properties as URL GET parameters.

Property Description
limit
Optional
Default: 10
Number of transactions returned for each request. Limit can range between 1 and 100.
starting_after
Optional
Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed after the specified time.
ending_before
Optional
Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed before the specified time.

Response

{
    "transactions": [
        {
            "id": "bn2345nb53454kjb",
            "status": "success",
            "type": "charge",
            "amount": 1111,
            "currency": "USD",
            "time": "2015-01-01T01:05:0Z",
            "reference": "jkh25jh1348fd89sg",
            "note": "sample note"
        },
        {
            "id": "16zfmK2eZvKYlo2C6X3",
            "status": "success",
            "type": "authorization",
            "amount": 1111,
            "currency": "USD",
            "time": "2015-01-01T01:01:01Z",
            "reference": "6LJDMbC6Ybqlt7fd",
            "note": "sample note"
        }
    ]
}

Response

Returns a transactions array of transaction objects. If no transactions are available, returns an empty array.

Property Description
id
string
Transaction ID.
status
string
Transaction status. Either success, failure, or pending.
type
string
Transaction type. Either charge, authorization, or capture.
amount
int
Amount of the transaction in the minor unit of the currency. For example, cents in USD.
currency
string
The 3-letter currency code.
time
string
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC.
reference
string
AlphaNumeric string set in request to correspond transaction ID with your original transaction request.
note
string/null
If set in request, your transaction note to self. Else if not set, this will be null.

Download transactions

GET
https://api.muskpay.io/v1.2/download/transactions

This interface enables the merchants to download the transaction list in a specific time span to reconcile transactions.

Request

$ curl https://api.muskpay.io/v1.2/download/transactions/?start_date=20170101&end_date=20170105 \
-H "Authorization: Bearer <TOKEN>"

Request

Properties as URL GET parameters.

Note: The starting and end dates should be within a 10-day interval.

Property Description
start_date
Required
The start date, formatted as YYYYMMDD
end_date
Required
The end date , formatted as YYYYMMDD

Response

Currently the interface only supports .CSV file to be downloaded.

Download billing file

GET
https://api.muskpay.io/v1.2/billing

This interface enables the merchants to download the transaction list in a specific time span to reconcile the transactions.

Closed, failed or cancelled transactions do not appear in the download file.

Request

$ curl https://api.muskpay.io/v1.2/billing/?start_date=20170101&end_date=20170105 \
-H "Authorization: Bearer <TOKEN>"

Request

Properties as URL GET parameters.

Note: The starting and end dates should be within a 10-day interval.

Property Description
start_date
Required
The start date, formatted as YYYYMMDD
end_date
Required
The end date , formatted as YYYYMMDD

Response

Currently the interface only supports .CSV file to be downloaded.

Account / Withdrawal

Inquiry account balance

GET
https://api.muskpay.io/v1.2/accounts

Request

$ curl https://api.muskpay.io/v1.2/accounts \
-H "Authorization: Bearer <TOKEN>"

Request

Properties as URL GET parameters.

Response

{
  "accounts": [
    {
      "balance": "100.00",
      "currency": "USD",
      "pending_amount": "12.40",
      "freeze_amount": "0.00"
    }
  ]
}

Response

Returns merchant account object.

Property Description
currency
string
Account currency
balance
string
Currently account balance
pending_amount
string
Currently unsettled purchase amount
freeze_amount
string
Currently unsettled refund amount

Inquiry withdrawal history

GET
https://api.muskpay.io/v1.2/withdrawal/history

Request

$ curl https://api.muskpay.io/v1.2/withdrawal/history/?start_date=20170101&end_date=20170105 \
-H "Authorization: Bearer <TOKEN>"

Request

Properties as URL GET parameters.

Property Description
start_date
Required
Start date, formatted as YYYYMMDD.
end_date
Required
End date, formatted as YYYYMMDD.

Response

{
    "withdrawal": [
        {
            "id": "bn2345nb53454kjb",
            "status": "completed",
            "amount": "100.00",
            "currency": "USD",
            "fee": "0.30",
            "fee_currency":"USD",
            "date": "20170101"
        }
    ]
}

Response

Return an array of withdrawal object. If no transactions are available, returns an empty array.

Property Description
id
string
MuskPay withdrawal ID
status
string
Withdrawal status. Included processing and completed.
amount
int
Withdrawal amount
currency
string
Withdrawal currency
fee
string
Withdrawal fee
fee_currency
string
Withdrawal fee currency type.
date
string
Withdrawal date, formatted as YYYYMMDD

Withdrawal Details

GET
https://api.muskpay.io/v1.2/withdrawal/detail/{withdrawal_id}

According to the withdrawal_id to get the corresponding data

Request

$ curl https://api.muskpay.io/v1.2/withdrawal/detail/{withdrawal_id} \
-H "Authorization: Bearer <TOKEN>"

Request

withdrawal_id : ID generated by 'Apply Withdrawal' request, and send this ID as parameter.

Resonse

Convert return data to a CSV file which conclude all the data.

Testing

Testing Endpoint

https://apitest.nihaopay.com

We have two environments for our API: Testing and Production. These two environments and their endpoints are identical, with the exception that no real money is transferred in the Testing environment. You can use the Testing endpoints as substitutes for the Production endpoints during integration.

For example, transactions in the Testing environment would be: https://apitest.nihaopay.com/v1.2/transactions

To access the TMS for transactions processed in the testing environment, please use the Testing TMS.

While using the Testing environment, bank issued cards cannot be used. We provide test credentials for you to use to simulate transactions.

To start testing, apply for a test account here

Test Cards

While using the Testing environment, bank issued cards will not work. We provide Test Cards below for you to use to simulate transactions.

Visa Credit Card 1

Card Number 4012 0000 7777 7777
CVV 997
EXP 12/2025

Visa Credit Card 2

Card Number 4264 2815 6666 6664
CVV 997
EXP 12/2025

Visa Credit Card 3

Card Number 4761 7300 0000 0011
CVV 997
EXP 12/2025

Errors

Error

{
    "code": 409,
    "label": "64",
    "message": "Refund or capture currency does not match the original transaction currency."
}

When an API request fails, MuskPay will return an error object.

MuskPay errors follow conventional HTTP status codes. A 2xx code indicates request success; therefore, you will not see any of these codes in the error object. A 4xx code indicates an error in the information provided. These could be anything from a malformed request, an unauthenticated request, or an unknown endpoint. A 5xx code indicates MuskPay’s internal server error.

There are certain features that are not yet available but are documented in this API Reference. Requesting those features from the API will result in a 501 error.

Feel free to contact our tech support team at tech_support@nihaopay.com if you encounter errors.

Error Object

Property Description
code
int
HTTP status code.
label
string
Label of the error generated by MuskPay. Support team may ask for this to help with integration questions.
message
string
A human readable message as to the cause of the encountered error.

Error List

code label message
200 00 Success
402 01 Transaction failed. Please try again.
402 02 Cardholder input an incorrect card number.
402 03 Cardholder\'s issuing bank prevented the transaction.
402 06 Customer input an expired card number.
402 11 Customer has insufficient funds available.
402 14 Cardholder input an incorrect expiration date.
402 15 Cardholder authentication failed. Please verify cardholder\'s information.
402 21 Cardholder authentication failed. Please verify cardholder\'s information.
402 22 Card state is incorrect.
402 30 The amount exceeds transaction limit placed.
400 31 Transaction reference number must be unique. Please re-submit.
400 32 This payment channel is restricted. Please contact MuskPay customer service.
409 33 Transaction failed. Information submitted in a repeat transaction must match the original attempted transaction exactly.
402 36 Transaction exceeds the cardholder\'s credit limit.
429 39 Too many transactions attempts by cardholder.
402 56 Cardholder\'s chosen payment card is not supported in this Gateway.
402 57 Cardholder has not activated online payments with their issuing bank.
404 59 Failed. Transaction have refund or chargeback.
404 60 Transaction has been cleared, please request refund.
402 61 Transaction not found.
402 62 Transaction is not within the acceptance time range.
402 63 The original transaction failed. You cannot refund, cancel, capture, or release an unsuccessful transaction.
409 64 Refund or capture currency does not match the original transaction currency.
409 65 Transaction has previously been cancelled.
409 66 Failed to refund transaction. Transaction has previously been fully refunded.
402 67 Failed to refund transaction. Refund amount exceeds original transaction amount or remaining transaction balance .
402 68 Failed to capture transaction. Transaction has previously been released.
402 69 Failed to capture transaction. Transaction has previously been captured.
402 70 Failed to capture transaction. Capture amount exceeds authorization amount.
402 71 Buyer not exist or buyer account info error
402 72 Transaction amount is exceed the limit
500 81 Merchant config error
500 82 Merchant unavailable
500 83 QRcode has expired
500 84 Service is not activated for this account
402 86 Withdrawal amount exceeds account balance
402 87 Withdrawal amount less than the minimum withdrawal amount
402 88 Invalid application, it's only available for manually withdrawal merchant
400 90 The field not valid.
500 91 Signature error
500 92 The {0} field is required.
404 93 The Exchange rate not found.
500 96 Timeout
500 97 Inner error
500 98 Vendor error
500 99 System error
401 301 Invalid merchant credentials provided

API Change Log

2024-09-18

2023-08-23

2023-08-05

2022-07-18

2020-09-01

2018-06-01

2018-05-17

2018-03-15

2017-11-10

2017-08-21

2017-05-25

2017-04-10

2017-03-07

2017-01-01