API List
1. Create Order Interface
The gateway URL: https://a.mypaynz.com/api/online
Request Method: POST
Parameter | Type | Nullable | Description |
---|---|---|---|
mid | int(4) | No | Merchant ID |
total_fee | int(10) | No | Amount, Unit: Cent |
rmb_fee | int(10) | Yes | Amount, Unit: Cent. Only used when pay_type is IE0012 or IE0013. Use this parameter to replace total_fee if partner wish to price their product in RMB. If total_fee is used, rmb_fee should not be set. They are mutual exclusive. |
goods | string(64) | No | Item name, must not contain any special characters |
goods_detail | string(128) | No | Item descripion, must not contain any special characters |
out_trade_no | string(64) | No | Order number, should be unique, recommend using date(YYYYmmddHHiiss) + 18 digit random number |
pay_type | string(8) | No | IE0011 = qrcode_alipay; IE0012 = web_alipay; IE0013 = wap_alipay; IE0015 = app_alipay; IE0021 = qrcode_wechat; IE0022 = wap_wechat; IE0023 = wap_wechat_quickpay; IE0025 = app_wechat; IE0031 = UNION; IE0041 = POLI; |
expired | int(8) | Yes | Expiration time, Unit: second. default: 3600 |
return_url | string(512) | Yes | After the payment is done, the result is returned to this url via the URL redirect. |
notify_url | string(512) | Yes | The URL for receiving asynchronous notifications after the payment is done. |
version | string(4) | No | 'v1' |
pay_rate | int(4) | Yes | Default merchant rate if null, range 0 - 30 |
sign | string(32) | No | Signature, please refer to signature explaination section |
Return Success
{
"is_success": "TRUE",
"message": "SUCCESS",
"extra": {
"mid": "10224",
"pay_type": "IE0012",
"out_trade_no": "201808170123245622346777231",
"pay_url": "https://intlmapi.alipay.com/gateway.do?_input_charset=utf-8¤cy=NZD¬ify_url=https://a.mypaynz.com/api/alipay_push_notify_web&order_gmt_create=2018-07-26 07:00:27&order_valid_time=3600&out_trade_no=201808170123245622346777231&partner=2088421400772571&return_url=http://www.amazon.com/syn&secondary_merchant_id=10224&secondary_merchant_industry=0742&secondary_merchant_name=merchant&service=create_forex_trade&subject=123312&supplier=merchant&total_fee=1&sign=da41c17de81b5981d376a1b32c382d04"
}
}
Return Fail
{
"is_success": "FALSE",
"message": "ORDER_CREATED",
"extra": {
"mid": "10224",
"pay_url": "https://intlmapi.alipay.com/gateway.do?_input_charset=utf-8¤cy=NZD¬ify_url=https://a.mypaynz.com/api/alipay_push_notify_web&order_gmt_create=2018-07-26 07:03:43&order_valid_time=3600&out_trade_no=2018081701232456223467772311&partner=2088421400772571&return_url=http://www.amazon.com/syn&rmb_fee=0.12&secondary_merchant_id=10224&secondary_merchant_industry=0742&secondary_merchant_name=merchant&service=create_forex_trade&subject=123312&supplier=merchant&sign=be411b88522a162290bf4f45412d43ad",
"pay_type": "IE0012",
"out_trade_no": "2018081701232456223467772311"
}
}
Synchronized result notification
Once a payment succeeds, there will be a synchronized notification which redirects the end user to a return_url. It is recommended that synchronized notification only be used for user interaction. All variables passed to API https://a.mypaynz.com/api/online will be also returned.
$url = $return_url
Asynchronized result notification
The merchant needs to return 'SUCCESS' once they received an asynchronized notification. otherwise IE PAY will keep sending asynchronized notifications for 12 hours. Please note it is possible you get more than one notification at the same time so please make sure the order number is unique
$url = $notify_url."?out_trade_no=".$out_trade_no."&trade_no=".$trade_no."&trade_status=SUCCESS&pay_type=".$pay_type."&sign=".$sign;
$sign = md5($trade_no.$out_trade_no.'SUCCESS'.$api_key);
2. Check Order Interface
The gateway URL: https://a.mypaynz.com/api/check_order_status
Request Method: POST
Parameter | Type | Nullable | Description |
---|---|---|---|
mid | int(4) | No | Merchant ID |
pay_type | string(8) | No | IE0011 = qrcode_alipay; IE0012 = web_alipay; IE0013 = wap_alipay; IE0015 = app_alipay; IE0021 = qrcode_wechat; IE0022 = wap_wechat; IE0025 = app_wechat; IE0031 = UNION; IE0041 = POLI; |
out_trade_no | string(64) | No | Order number |
version | string(4) | No | 'v1' |
sign | string(32) | No | Signature, please refer to signature explaination section |
return
{
'is_success':'FALSE'
'message': 'SIGN_ERROR'
}
{
'is_success':'FALSE'
'message': 'COMBINE_ERROR'
}
{
'is_success':'TRUE'
'message': 'SUCCESS',
'extra': {
'pay_type': 'IE0011'
'trade_no' : '201809191132544236',
'out_trade_no' :'20180919113254423851060785271346',
'order_status' :'0',
'total_fee' :'1.5',
'goods' : 'goods',
'pay_url' : 'https://qr.alipay.com/bax08230wcpl6ihwsmfd40d0',
'return_url' :'****'
}
}
Order Status :
- 0 : UNPAY;
- 1 = PAID;
- 2 = REFUND;
- 3 = SETTLED;
3. Refund Order Interface
The gateway URL: https://a.mypaynz.com/api/refund
Request Method: POST
Parameter | Type | Nullable | Description |
---|---|---|---|
mid | int(4) | No | Merchant ID |
out_trade_no | string(64) | No | Order number |
pay_type | string(8) | No | IE0011 = qrcode_alipay; IE0012 = web_alipay; IE0013 = wap_alipay; IE0015 = app_alipay; IE0021 = qrcode_wechat; IE0022 = wap_wechat; IE0025 = app_wechat; IE0031 = UNION; IE0041 = POLI; |
refund_amount | int(10) | No | Refund Amount, Unit: Cent |
version | string(4) | No | 'v1' |
sign | string(32) | No | Signature, please refer to signature explaination section |
return
{
'is_success':'FALSE',
'message': 'SIGN_ERROR'
}
{
'is_success':'FALSE',
'message': 'ERROR_PAYMENT_STATUS'
}
{
'is_success':'TRUE',
'message': 'SUCCESS'
}
4.Signature explaination
Parameters to Sign
In the list of request and response parameters, all of them need to be signed except sign and sign_type. (sign_type also needs to be signed in some cases in the list of request parameters)
Generate pre-sign string For following data set:
string[] parameters={
"mid=10209",
"pay_type=IE0014",
"refund_amount=1",
"out_trade_no=20180402112304123210122312",
"out_trade_no=6741334835157966",
"reference='refund memo'"
};
Rearrange parameters in the data set alphabetically and connect rearranged parameters with &:
mid=10224&out_trade_no=20180402112304123210122312&pay_type=IE0014&reference=refund memo&refund_amount=1
This is the pre-sign string. Note: Parameters without a value, must be included from sign; Charset in sign must be consistent with the charset used previously * If _input charset is passed, it must also be signed. According to the applicable HTTP protocol, special characters like ‘&’ and ‘@’ need URL encoding, so that the request receiver can get the correct value. In this situation, pre-sign string shall be the original value instead of the encoded one. For example: when calling a particular API you need to sign the parameter email, the pre-sign string shall be email=test@msn.com, rather than email=test%40msn.com. Signature Generation.
MD5 Signature
A private key is necessary for an MD5 signature. The MD5 private key is the 32-byte string which is composed of English letters and numbers. A Partner can log on the Merchant Service Centre (https://a.mypaynz.com) to check the private key.
Sign for request
After the partner receives the pre-sign string during requesting, the private key should be appended to the pre-sign string to generate the new string. Then this new string would be calculated with the MD5 signature algorithm by the MD5 signature function. Thus, the resulting 32-byte string is the signature result string. (the value is given to parameter “sign”)
result:
Sign = Md5(PRE SIGN + API KEY)
example:
md5(mid=10224&out_trade_no=20180402112304123210122312&pay_type=IE0014&reference=refund memo&refund_amount=1e560fb2e61e4d1fe6a11c278388cb965)
result:
f45a1a2db58b43b48d51ab2fc18e0914