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
MuskPay supports five payment models: CardPay, SecurePay, In-APP payment, Show QRcode and Scan QRcode.
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.
The following four payment products can be found in NihaoPay API Documentation
SecurePay
In Securepay, users will be redirected to the payment tunnel and finish rest of payment steps in the official payment page.
APP Payment
In-APP Payment will ask merchants to call the selected payment model while users are checking out.
Show QRcode
Our API will return a QRcode URL containing information merchant requested. Merchants will be able to show this URL on mobiles or PC web browsers, thereby enabling users to scan the QR code and pay.
Scan QRcode
In the Scan QRcode, merchants are able to sacn user's QRcode to finish the transaction.
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:
- Visa
- Master
- JCB
- Amex
- Discover
- unionpay
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:
ipn_url
must be accessible on the Internet and can't be intranet address (for examplelocalhost
) or intranet IP- The IPN notification may arrive ahead of browser callback.
- The duplicated IPN notifications.
- MuskPay returns to
ipn_url
using thePOST
method. - After the program is executed, the IPN page must print “ok” (without quote). If not, MuskPay server will keep re-sending notification.
- Generally, there will be 8 notifications within 2 hours (Frequency: 0m,1m,2m,4m,8m,20m,30m).
- After the program is executed, there should not be any redirecting operation on the page, for MuskPay will not recognize an “ok” string; therefore, it would be regarded as an error, and MuskPay system will just keep sending the notification.
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. |
amountint |
The settlement amount uses foreign currency. |
currencystring |
The 3-letter currency code. |
timestring |
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring |
AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring |
If set in request, your transaction note to self. Else if not set, this will be null . |
sys_reservejson |
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
- The indication method for a single
pair is key = value. If the value corresponding to the key is null, not include the key. - The connection method for multiple
pairs is key1=value1&key2=&key3=value3. Sort pairs in the signature in an ascending order in accordance with key values. - The connection method of cooperative key messages is key1=value1&key2=&key3=value3&MD5(Token), The token, after MD5 calculation, is connected to the end of the
pair.
B. Signature method
verify_sign = MD5(key1=value1&key2=&key3=value3...&keyn=value&MD5(Token))
Note:
- MuskPay uses UTF-8 as charset.
- Parameters without a value can be excluded from sign;
- The MD5's output is lowercase when comparing signatures, please ignore case.
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 |
---|---|
referenceRequired |
An alphaNumeric string up to 30 characters that must be unique to each of your transactions. |
currencyRequired |
The 3-letter currency code. See Parameters Description. |
amountRequired |
Amount as a positive integer of the minor unit of the currency. Minimum USD: $1. See Parameters Description. |
card_numberRequired |
Credit card number. Numeric and up to 16 characters only. |
card_exp_monthRequired |
Card expiration month with leading zero. Acceptable values are 01 through 12 . |
card_exp_yearRequired |
Card expiration year in 4 digits. |
card_cvvRequired |
Card verification value in 3 digits. |
card_holderRequired |
Cardhoder name. |
phone_numberRequired |
Cardholder phone number. |
phone_country_codeRequired |
Card holder phone Country code ISO digital code. |
emailRequired |
Cardholder contact email. |
websiteRequired |
Trading website. |
client_ipRequired |
Customer IP |
descriptionOptional |
Arbitrary string that you can set to be displayed on the card charge. |
noteOptional |
Arbitrary string as note to self regarding the transaction. |
Billing address |
|
billing_address_first_nameRequired |
First name. |
billing_address_middle_nameOptional |
Middle name. |
billing_address_last_nameRequired |
Last name. |
billing_address_line1Required |
Address Line 1. |
billing_address_line2Optional |
Address Line 2. |
billing_address_cityRequired |
City. |
billing_address_stateRequired |
State/Province. |
billing_address_zipRequired |
Zip code. |
billing_address_countryRequired |
Country code ISO-3166-1 Alpha-2. |
Shipping address |
|
shipping_address_first_nameRequired |
First name. |
shipping_address_middle_nameOptional |
Middle name. |
shipping_address_last_nameRequired |
Last name. |
shipping_address_line1Required |
Address Line 1. |
shipping_address_line2Optional |
Address Line 2. |
shipping_address_cityRequired |
City. |
shipping_address_stateRequired |
State/Province. |
shipping_address_zipRequired |
Zip code. |
shipping_address_countryRequired |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
amountint |
Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring |
The 3-letter currency code. |
capturedbool |
Whether or not the transaction amount has been captured. true for captured and false for uncaptured or authorization. |
timestring |
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC |
referencestring |
AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring |
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 |
---|---|
referenceRequired |
An alphaNumeric string up to 30 characters that must be unique to each of your transactions. |
currencyRequired |
The 3-letter currency code. See Parameters Description. |
amountRequired |
Amount as a positive integer of the minor unit of the currency. Minimum USD: $1. See Parameters Description. |
card_numberRequired |
Credit card number. Numeric and up to 16 characters only. |
card_exp_monthRequired |
Card expiration month with leading zero. Acceptable values are 01 through 12 . |
card_exp_yearRequired |
Card expiration year in 4 digits. |
card_cvvRequired |
Card verification value in 3 digits. |
card_holderRequired |
Cardhoder name. |
phone_numberRequired |
Cardholder phone number. |
phone_country_codeRequired |
Card holder phone Country code ISO digital code. |
emailRequired |
Cardholder contact email. |
websiteRequired |
Trading website. |
client_ipRequired |
Customer IP |
descriptionOptional |
Arbitrary string that you can set to be displayed on the card charge. |
noteOptional |
Arbitrary string as note to self regarding the transaction. |
Billing address |
|
billing_address_first_nameRequired |
First name. |
billing_address_middle_nameOptional |
Middle name. |
billing_address_last_nameRequired |
Last name. |
billing_address_line1Required |
Address Line 1. |
billing_address_line2Optional |
Address Line 2. |
billing_address_cityRequired |
City. |
billing_address_stateRequired |
State/Province. |
billing_address_zipRequired |
Zip code. |
billing_address_countryRequired |
Country code ISO-3166-1 Alpha-2. |
Shipping address |
|
shipping_address_first_nameRequired |
First name. |
shipping_address_middle_nameOptional |
Middle name. |
shipping_address_last_nameRequired |
Last name. |
shipping_address_line1Required |
Address Line 1. |
shipping_address_line2Optional |
Address Line 2. |
shipping_address_cityRequired |
City. |
shipping_address_stateRequired |
State/Province. |
shipping_address_zipRequired |
Zip code. |
shipping_address_countryRequired |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
amountint |
Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring |
The 3-letter currency code. |
capturedbool |
false for authorization. |
timestring |
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC |
referencestring |
AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
releasedbool |
Whether or not the transaction amount has been successfully released. |
transaction_idstring |
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 |
---|---|
amountRequired |
Amount as an integer of the minor unit of the currency. For example, $10.50 in USD would be 1050. |
currencyRequired |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
capturedbool |
Whether or not the transaction amount has been successfully captured. |
transaction_idstring |
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 |
---|---|
referenceRequired |
An alphaNumeric string up to 30 characters that must be unique to each of your transactions. |
currencyRequired |
The 3-letter currency code. See Parameters Description. |
amountRequired |
Amount as a positive integer of the minor unit of the currency. See Parameters Description. |
websiteRequired |
Trading website. |
ipn_urlRequired |
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_urlRequired |
URL the browser will be redirected to upon completing the transaction. |
descriptionOptional |
Arbitrary string that you can set to be displayed on the card charge. |
noteOptional |
Arbitrary string as note to self regarding the transaction. |
client_ipRequired |
Customer IP |
Response
{
"redirect_url": "https://apitest.nihaopay.com/v1.2/cardpay/checkout/20100920042332106649?otp=xxx"
}
Response
Returns a 'JSON' object.
Property | Description |
---|---|
redirect_urlstring |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
typestring |
Transaction type. Either charge , authorization , or capture . |
vendorstring |
Payment method. Include: Visa 、Master 、JCB 、Amex 、Discover 、unionpay . |
vendor_idstring |
Vendor’s transaction id, usually showed on customer’s payment receipt. |
amountint |
Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring |
The 3-letter currency code. |
timestring |
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring |
AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring/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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
typestring |
Transaction type. Either charge , authorization , or capture . |
vendorstring |
Payment method. Include: Visa 、Master 、JCB 、Amex 、Discover 、unionpay . |
vendor_idstring |
Vendor’s transaction id, usually showed on customer’s payment receipt. |
amountint |
Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring |
The 3-letter currency code. |
timestring |
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring |
AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring/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 |
---|---|
currencyRequired |
The 3-letter currency code. Currency must match the original transaction's currency. |
amountConditional |
Amount to be funded in the minor unit of the currency. Must be equal to or less than the amount of the original transaction. |
reasonOptional |
Arbitrary string detailing the reason for refund. |
Response
{
"id": "bn2345nb53454kjb",
"status": "success",
"refunded": true,
"transaction_id": "jkh25jh1348fd89sg"
}
Response
Returns a refund object.
Property | Description |
---|---|
idstring |
Refund ID. |
statusstring |
Status of the refund. Either success , or failure . |
refundedbool |
true |
transaction_idstring |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , pending or closed |
typestring |
Transaction type. Either charge , authorization , or capture . |
amountint |
Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring |
Transaction currency. |
timestring |
Timestamp of the transaction in UTC. |
referencestring |
Merchant order number. |
notestring |
If set in request, your transaction note to self. Else if not set, this will be null. |
vendorstring |
Payment method. Include: Visa 、Master 、JCB 、Amex 、Discover 、unionpay . |
vendor_idstring |
Vendor’s transaction id, usually showed on customer’s payment receipt. |
refunded_amountint |
Total refunded amount |
refundslist |
Refund records |
refund_timestring |
Refund time |
refund_idstring |
Refund ID. |
refunded_amountint |
refund amount |
statusstring |
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 |
---|---|
limitOptional Default: 10 |
Number of transactions returned for each request. Limit can range between 1 and 100. |
starting_afterOptional |
Time in UTC format yyyy-mm-ddThh:mm:ssZ. Used to retrieve transactions processed after the specified time. |
ending_beforeOptional |
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 |
---|---|
idstring |
Transaction ID. |
statusstring |
Transaction status. Either success , failure , or pending . |
typestring |
Transaction type. Either charge , authorization , or capture . |
amountint |
Amount of the transaction in the minor unit of the currency. For example, cents in USD. |
currencystring |
The 3-letter currency code. |
timestring |
Timestamp of the transaction in UTC. Ex: 2015-01-01T01:01:00Z is Jan 1, 2015 1:01:00 UTC. |
referencestring |
AlphaNumeric string set in request to correspond transaction ID with your original transaction request. |
notestring/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_dateRequired |
The start date, formatted as YYYYMMDD |
end_dateRequired |
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_dateRequired |
The start date, formatted as YYYYMMDD |
end_dateRequired |
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 |
---|---|
currencystring |
Account currency |
balancestring |
Currently account balance |
pending_amountstring |
Currently unsettled purchase amount |
freeze_amountstring |
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_dateRequired |
Start date, formatted as YYYYMMDD. |
end_dateRequired |
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 |
---|---|
idstring |
MuskPay withdrawal ID |
statusstring |
Withdrawal status. Included processing and completed . |
amountint |
Withdrawal amount |
currencystring |
Withdrawal currency |
feestring |
Withdrawal fee |
fee_currencystring |
Withdrawal fee currency type. |
datestring |
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 |
---|---|
codeint |
HTTP status code. |
labelstring |
Label of the error generated by MuskPay. Support team may ask for this to help with integration questions. |
messagestring |
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
- Add CardPay
2023-08-23
- SecurePay supports returning data in json format
2023-08-05
- Add Profit Sharing Interface ProfitSharing
2022-07-18
- Add interface Alipay A+
2020-09-01
- Update currencies list
- Support UnionPay customs declaration
2018-06-01
- Add customs declaration
- Add vendor's transaction in IPN
2018-05-17
- In-App payment support WeChatPay.
- Scan QRcode support UnionPay QRcode, U.S. merchants only.
2018-03-15
- Add interface
Static Omni-Channel QRcode
- Add interface
Static AliPay QRcode
2017-11-10
- Add interface
WeChat Mini-program payment
2017-08-21
- Add interface
Download transactions
- Add interface
Static QRcode
- Add interface
Inquiry account balance
- Add interface
Apply withdrawal
- Add interface
Inquiry withdrawal history
2017-05-25
- Add In-Store Payment API
- Add In-App Payment API
- Add verify signature in IPN notification
- Change IPN notification frequency
2017-04-10
- Update Error list
- Add parameter
rmb_amount
in SecurePay and ExpressPay request field list.
2017-03-07
- Add Chinese document
- Add parameter
client_ip
in ExpressPay request field list - Add interface
Query Exchange Rate
- Add interface
Download Billing
2017-01-01
- Upgrade to
v1.2