@@ -76,11 +76,14 @@ class Pay extends Api
]
];
$data = json_encode($data, 320);
+ //获取鉴权token
+ $sign_bytes = '/3.0/hop/svc/pay/toPay.ajax' . $this->base16_encode(md5($data));
+ $hdc_token = base64_encode(hash_hmac('sha256', $sign_bytes, config('pay_appkey'), true));
$header = [
'Host:112.4.10.122:8090',
'HDC-Service:2',
'HDC-APPID:00001',
- 'HDC-Token:8e2b129d2cd3ebf40ca5a1c6048b083ce92e5fd3f305fd6c11a3ef3e35b5fa08',
+ 'HDC-Token:' . $hdc_token,
'Content-Type:application/json'
$rs = httpRequest($url, 'POST', $data, $header);
@@ -165,5 +168,5 @@ class Pay extends Api
'statusdesc' => ''
], 320);
}
-
+
@@ -2053,11 +2053,15 @@ class User extends Api
'channel' => '01'
$post_data = json_encode($post_data, 320);
+ $sign_bytes = '/3.0/hop/svc/pay/toPay.ajax' . $this->base16_encode(md5($post_data));
- /*'Host:112.4.10.122:8090',
+ 'Host:112.4.10.122:8090',
- 'HDC-Token:8e2b129d2cd3ebf40ca5a1c6048b083ce92e5fd3f305fd6c11a3ef3e35b5fa08',*/
$rs = httpRequest($url, 'POST', $post_data, $header);
@@ -425,4 +425,15 @@ class Api
+ //base16编码
+ public function base16_encode($string = '')
+ {
+ $encode = '';
+ $chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
+ for ($i = 0; $i < strlen($string); $i++) {
+ $encode .= $chars[(ord($string[$i]) & 0b11110000) >> 4] . $chars[ord($string[$i]) & 0b00001111];
+ }
+ return $encode;