UnionPay Business H5 Payment Interface Document: Document address
1: H5 Payment Interface Address:
1: Alipay payment
Test address: http://58.247.0.18:29015/v1/netpay/trade/h5-pay
Official address: https://api-mop.chinaums.com/...
2: UnionPayment
Test address: http://58.247.0.18:29015/v1/netpay/uac/order
Official address: https://api-mop.chinaums.com/...
II: Basic parameters required by the interface
The interface uses get parameters, which are directly put into the interface address. The interface is jumped directly from the browser to the interface.
(1)authorization
Authentication, Fill in directly: OPEN-FORM-PARAM
(2)appId
UnionPay Business User H5 Payment Product AppID
(3)timestamp
Timestamp in yyyyMMddHmmss format, such as 20191001121212
(4)nonce
random number
(5)content
Business content, in json format, and url encoding is required. Specific internal information is described below.
(6)signature
Signature requires url encoding, such as: Base64_Encode (HmacSHA256 (appId + timestamp + nonce + SHA256_HEX (content), AppKey)
Business content content parameter internal specific parameter description:
1: requestTimestamp
Message request time in yyyy-MM-dd HH:mm:ss format, such as 2019-10-01 12:12:12
2: merOrderId
The order number generated by the merchant itself, note here: we need to prefix 1017 before the order number generated by ourselves.
3: mid
Business Number of H5 Payment Products by UnionPay Business Users
4: tid
Terminal Number of H5 Payment Products for UnionPay Business Users
5: instMid
Business Type, Fill in directly: H5DEFAULT
6: totalAmount
Payment of the total amount shall be divided into units.
7: expireTime
Order expiration time in yyyy-MM-dd HH:mm:ss format, such as 2019-10-02 12:12:12
8: notifyUrl
Payment Result Notification Address
9: returnUrl
Page Jump Address
Three: H5 payment Alipay payment example
$appId = '10037e6f6a4e6da4016a670fd4530012'; $appKey = 'f7a74b6c02ae4e1e94aaba311c04acf2'; $mid = '898310148160568'; $tid = '88880001'; //Business content $time = time(); $content = [ 'requestTimestamp' => date('Y-m-d H:i:s', $time),//Message request time 'merOrderId' => '1017' . date('YmdHis'),//Merchant Order Number 'mid' => $mid,//Merchant number 'tid' => $tid,//Terminal number 'instMid' => 'H5DEFAULT',//Business type 'totalAmount' => '1',//Payment of total amount 'expireTime' => date('Y-m-d H:i:s', strtotime('+1 day', $time)),//Expiration date 'notifyUrl' => '',//Payment Notification Address 'returnUrl' => ''//Page Jump Address ]; $timestamp = date('YmdHis', $time); //random number $str = md5(uniqid(mt_rand(), true)); $uuid = substr($str, 0, 8) . '-'; $uuid .= substr($str, 8, 4) . '-'; $uuid .= substr($str, 12, 4) . '-'; $uuid .= substr($str, 16, 4) . '-'; $uuid .= substr($str, 20, 12); $nonce = $uuid; //autograph $hash = bin2hex(hash('sha256', json_encode($content), true)); $hashStr = $appId . $timestamp . $nonce . $hash; $signature = base64_encode((hash_hmac('sha256', $hashStr, $appKey, true))); //AppKey Payment Products by AppKey UnionPay Merchant H5 $data = [ 'timestamp' => $timestamp,//time stamp 'authorization' => 'OPEN-FORM-PARAM',//Authentication method 'appId' => $appId,//APPID 'nonce' => $nonce,//random number 'content' => urlencode(json_encode($content)),//Business content 'signature' => urlencode($signature),//autograph ]; //Interface return information //Alipay: http://58.247.0.18:29015/v1/netpay/trade/h5-pay //UnionPay Online Cardless: http://58.247.0.18:29015/v1/netpay/qmf/h5-pay //UnionPay: http://58.247.0.18:29015/v1/netpay/uac/order $options = ''; foreach ($data as $key => $value) { $options .= $key . '=' . $value .'&'; } $options = rtrim($options, '&'); //If there is an escape character, then remove the escape character if(get_magic_quotes_gpc()){ $options = stripslashes($options); } $url = 'http://58.247.0.18:29015/v1/netpay/trade/h5-pay?' . $options;