|
@@ -25,55 +25,46 @@ class OriginBank
|
|
];
|
|
];
|
|
$data = [
|
|
$data = [
|
|
'out_no'=>$data['trade_no'],
|
|
'out_no'=>$data['trade_no'],
|
|
- 'pmt_tag'=>'WeixinBERL',
|
|
|
|
- 'ord_name'=>'小说充值',
|
|
|
|
|
|
+ 'pmt_tag'=>'WeixinOL',
|
|
|
|
+ 'ord_name'=>$data['body'],
|
|
'original_amount'=>$data['price'],
|
|
'original_amount'=>$data['price'],
|
|
'trade_amount'=>$data['price'],
|
|
'trade_amount'=>$data['price'],
|
|
- //'notify_url'=>env('ORIGINBANK_NOFITY_URL'),
|
|
|
|
|
|
+ 'notify_url'=>env('ORIGINBANK_NOFITY_URL'),
|
|
'sub_appid'=>$this->sub_appid,
|
|
'sub_appid'=>$this->sub_appid,
|
|
- 'sub_openid'=>$data['openid']
|
|
|
|
|
|
+ 'sub_openid'=>$data['openid'],
|
|
|
|
+ 'JSAPI'=>1
|
|
];
|
|
];
|
|
|
|
|
|
-// $data =[];
|
|
|
|
-// $data['out_no'] = "123456";
|
|
|
|
-// $data['pmt_tag'] = "WeixinBERL";
|
|
|
|
-// $data['original_amount'] = "1";
|
|
|
|
-// $data['trade_amount'] = "1";
|
|
|
|
-// $data['ord_name'] = "购买物品订单名称";
|
|
|
|
-
|
|
|
|
- dump($data);
|
|
|
|
$base_data['data'] = $this->encrypt(json_encode($data),$this->open_key);
|
|
$base_data['data'] = $this->encrypt(json_encode($data),$this->open_key);
|
|
- dump($data);
|
|
|
|
-
|
|
|
|
- dump($this->decrypt($base_data['data'],$this->open_key));
|
|
|
|
$base_data['sign'] = $this->signs($base_data);
|
|
$base_data['sign'] = $this->signs($base_data);
|
|
|
|
|
|
- dump('base_data');dump($base_data);
|
|
|
|
-
|
|
|
|
$response = $this->PayClient->request('POST','/mct1/payorder',['form_params'=>$base_data])->getBody()->getContents();
|
|
$response = $this->PayClient->request('POST','/mct1/payorder',['form_params'=>$base_data])->getBody()->getContents();
|
|
- dd(json_decode($response,1));
|
|
|
|
- // return $this->getPayInfo($response);
|
|
|
|
|
|
+ return $this->getPayInfo($response);
|
|
}
|
|
}
|
|
|
|
|
|
function getPayInfo($response)
|
|
function getPayInfo($response)
|
|
{
|
|
{
|
|
try{
|
|
try{
|
|
$return_info = json_decode($response,1);
|
|
$return_info = json_decode($response,1);
|
|
- //dd($return_info);
|
|
|
|
if($return_info['errcode'] == 0)
|
|
if($return_info['errcode'] == 0)
|
|
{
|
|
{
|
|
|
|
+ $data = json_decode($this->decrypt($return_info['data'],$this->open_key,true),true);
|
|
|
|
+ $trade_result = json_decode($data['trade_result'],true);
|
|
|
|
+ $wc_pay_data = json_decode($trade_result['wc_pay_data'],true);
|
|
$pay_info = [
|
|
$pay_info = [
|
|
- 'appId'=>$return_info['data']['appId'],
|
|
|
|
- 'timeStamp'=>$return_info['data']['timeStamp'],
|
|
|
|
- 'nonceStr'=>$return_info['data']['nonceStr'],
|
|
|
|
- 'signType'=>$return_info['data']['signType'],
|
|
|
|
- 'package'=>$return_info['data']['package'],
|
|
|
|
- 'paySign'=>$return_info['data']['paySign']
|
|
|
|
|
|
+ 'appId'=>$wc_pay_data['appId'],
|
|
|
|
+ 'timeStamp'=>$wc_pay_data['timeStamp'],
|
|
|
|
+ 'nonceStr'=>$wc_pay_data['nonceStr'],
|
|
|
|
+ 'signType'=>$wc_pay_data['signType'],
|
|
|
|
+ 'package'=>$wc_pay_data['package'],
|
|
|
|
+ 'paySign'=>$wc_pay_data['paySign']
|
|
];
|
|
];
|
|
return $pay_info;
|
|
return $pay_info;
|
|
}
|
|
}
|
|
}catch (\Exception $e)
|
|
}catch (\Exception $e)
|
|
{
|
|
{
|
|
|
|
+ echo $e->getMessage();
|
|
|
|
+ Log::error($response);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -96,7 +87,6 @@ class OriginBank
|
|
#加密
|
|
#加密
|
|
private function encrypt($input, $key) {
|
|
private function encrypt($input, $key) {
|
|
$size = @mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
|
|
$size = @mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
|
|
- dump('size');dump($size);
|
|
|
|
$input = $this->pkcs5_pad($input, $size);
|
|
$input = $this->pkcs5_pad($input, $size);
|
|
$td = @mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
|
$td = @mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
|
$iv = @mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
|
$iv = @mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
|
@@ -108,44 +98,6 @@ class OriginBank
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
|
|
- public function encrypt3($key, $iv, $data)
|
|
|
|
- {
|
|
|
|
- /**
|
|
|
|
- * 打开加密
|
|
|
|
- */
|
|
|
|
- $td = @mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
|
|
|
|
- /**
|
|
|
|
- * 初始化加密
|
|
|
|
- */
|
|
|
|
- @mcrypt_generic_init($td, $key, $iv);
|
|
|
|
- /**
|
|
|
|
- * 加密
|
|
|
|
- */
|
|
|
|
- $encrypted = @mcrypt_generic($td, $data);
|
|
|
|
- /**
|
|
|
|
- * 清理加密
|
|
|
|
- */
|
|
|
|
- @mcrypt_generic_deinit($td);
|
|
|
|
- /**
|
|
|
|
- * 关闭
|
|
|
|
- */
|
|
|
|
- @mcrypt_module_close($td);
|
|
|
|
- return base64_encode($encrypted);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function encrypt2($input, $key)
|
|
|
|
- {
|
|
|
|
- $data = openssl_encrypt($input, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
|
|
|
|
- $data = base64_encode($data);
|
|
|
|
- return $data;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function decrypt2($sStr, $sKey)
|
|
|
|
- {
|
|
|
|
- $decrypted = openssl_decrypt(base64_decode($sStr), 'AES-128-ECB', $sKey, OPENSSL_RAW_DATA);
|
|
|
|
- return $decrypted;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private function pkcs5_pad ($text, $blocksize) {
|
|
private function pkcs5_pad ($text, $blocksize) {
|
|
$pad = $blocksize - (strlen($text) % $blocksize);
|
|
$pad = $blocksize - (strlen($text) % $blocksize);
|
|
return $text . str_repeat(chr($pad), $pad);
|
|
return $text . str_repeat(chr($pad), $pad);
|