Skip to content

API Description ​

Payment Mode ​

NihaoPay supports five payment models: SecurePay, CardPay, In-APP payment, Show QRcode and Scan QRcode.

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.

For the following products, please refer to MuskPay API Documentation ​

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.

How to use ​

AliPayWechatPayUnionPay
PC Browser
terminal=ONLINE
Standard SecurePayStandard SecurePay
Generate QRcode
SecurePay
CardPay
Mobile Browser
terminal=WAP
Standard SecurePayWechat H5 payment
Please contact BD to enable this feature
SecurePay
CardPay
Wechat Browser
terminal=WAP
NAStandard SecurePay
SecurePay
CardPay
In-APPIn-APP PaymentIn-APP PaymentIn-APP Payment
WeChat Mini-ProgramNAMini-Program PaymentNA
In-Store
Have Scanner
Scan QRcodeScan QRcodeScan QRcode
U.S. merchants only
In-StoreShow QRcode
Static QRcode
Show QRcode
Static QRcode
Show QRcode
U.S. merchants only

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, NihaoPay supported currencies:

CurrencyCurrency CodeMinor unit
US DollarUSD2
Japanese YenJPY0
Hong Kong DollarHKD2
EuroEUR2
Canadian DollarCAD2
Pound SterlingGBP2
Singapore DollarSGD2
Australian DollarAUD2

3. RMB Amount ​

Use this parameter to replace amount if merchants wish to price their product in RMB. NihaoPay will return an amount in merchant’s settlement currency when payment is successful.

RequestResponseDescription
rmb_amount=10000
currency=USD
rmb_amount=10000
amount=1441
currency=USD
Order amount is 100.00 Chinese Yuan
Settlement amount is 14.41 US Dollars
amount=10000
currency=USD
amount=10000
currency=USD
Order amount and Settlement amount
are 100.00 US Dollars

4.Reference ​

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

5. Order Product Information ​

Form request parameter example

shell
items[0][name]=T-Shirt&items[0][unitAmount]=500&items[0][quantity]=1&items[1][name]=Hat&items[1][unitAmount]=500&items[1][quantity]=2

items is an array, each element represents a product. Each element in the array contains the following fields:

Field nameDescription
itemsProduct information list, containing one or more product objects.
items[n].name
Required
Product name.
items[n].unitAmount
Required
Product unit price, corresponding to the order currency. The amount is the smallest unit in the corresponding currency. See Parameters Description for details.
items[n].quantity
Required
Quantity of goods.

The total amount of goods should be equal to the total amount of the order:

amount = (items[0].unitAmount * items[0].quantity + items[1].unitAmount * items[1].quantity + ...)

6.Vendor ​

Currently, NihaoPay accepts three vendors are unionpay, alipay, and wechatpay.

7. 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.
By default, only successful payments will redirect to callback_url. If merchants want other payment statuses to trigger redirection, please add the accept parameter to the callback_url, for example callback_url?accept=pending,failure indicates that payment failure or cancellation will also redirect to callback_url.

8.Terminal ​

Currently, acceptable values are ONLINE and WAP.

System Reserve

shell
sys_reserve = {"vendor_id":"4200000117201806013734875340"}

9. System Reserved ​

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

KeyValue
vendor_idVendor's transaction id, usually showed on customer's payment receipt.

Instant Payment Notification ​

Asynchronous Response ​

After payment completed, NihaoPay 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 example localhost) or intranet IP
  • The IPN notification may arrive ahead of browser callback.
  • The duplicated IPN notifications.
  • NihaoPay returns to ipn_url using the POST method.
  • After the program is executed, The merchant should return HTTP status code 200 upon successful processing. If not, NihaoPay 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.

Asynchronous Response

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

Asynchronous Response message ​

PropertyDescription
id
string
Transaction ID.
status
string
Transaction status. In SecurePay scenario, only success.
amount
int
The settlement amount uses foreign currency.
rmb_amount
int
Payment Renminbi Amount. Same with the Request, If the request is null, payment amount will be returned.
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
NihaoPay system reservation, it's json string, See Parameters Description.
verify_sign
string
Signature value.

Sign method

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

Verify signature ​

When the asynchronous notification returns, NihaoPay 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 <key, value> pair and the cooperative key message pair is:

  • The indication method for a single <key, value> pair is key = value. If the value corresponding to the key is null, not include the key.
  • The connection method for multiple <key, value> pairs is key1=value1&key2=&key3=value3. Sort <key, value> 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 <key, value> pair.

B. Signature method

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

Note:

  • NihaoPay 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.

Last Updated - 01/16/2025