123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\common\library;
- use think\Controller;
- date_default_timezone_set('Asia/Shanghai');
- header('Content-type:text/html;charset=utf-8');
- require_once env('root_path').'application/common/library/shande/Common.php';
- require_once env('root_path').'application/common/library/shande/H5FastPay.php';
- require_once env('root_path').'application/common/library/shande/func.php';
- class Shande extends Controller
- {
- public static function payToCard($cardNo,$cardUserName,$amount,$orderNo,$remark=''){
- $info=array(
- 'transCode' => 'RTPM',
- 'merId' => '6888803045944',
- 'url' => '/agentpay',
- 'pt' => array(
- 'version' => '01',
- 'productId' => '00000004',
- 'orderCode' => $orderNo,
- 'tranTime' => date('YmdHis'),
- 'tranAmt' => str_pad($amount*100,12,'0',STR_PAD_LEFT),
- 'currencyCode' => '156',
- 'accAttr' => '0',
- 'accNo' => $cardNo,
- 'accType' => '4',
- 'accName' => $cardUserName,
-
- 'remark' => '提现'.$remark,
- 'payMode' => '1',
- 'channelType' => '07'
- )
- );
- try {
-
- $api = 'https://caspay.sandpay.com.cn/agent-main/openapi/';
- $publicKeyPath = '/www/wwwroot/xiang_admin.qcyjsh.com/application/common/library/shande/cert/sand.cer';
- $priKeyPath = '/www/wwwroot/xiang_admin.qcyjsh.com/application/common/library/shande/cert/6888803045944.pfx';
-
-
- $priPwd='980801';
-
- $priKey = loadPk12Cert($priKeyPath, $priPwd);
-
- $pubKey = loadX509Cert($publicKeyPath);
-
- $transCode = $info['transCode'];
- $accessType = '0';
- $merId = $info['merId'];
- $path = $info['url'];
- $pt = $info['pt'];
-
- $AESKey = aes_generate(16);
- $encryptKey = RSAEncryptByPub($AESKey, $pubKey);
-
- $encryptData = AESEncrypt($pt, $AESKey);
-
- $sign = sign($pt, $priKey);
-
- $post = array(
- 'transCode' => $transCode,
- 'accessType' => $accessType,
- 'merId' => $merId,
- 'encryptKey' => $encryptKey,
- 'encryptData' => $encryptData,
- 'sign' => $sign
- );
-
- $result = http_post_json($api . $path, $post);
- parse_str($result, $arr);
-
- $decryptAESKey = RSADecryptByPri($arr['encryptKey'], $priKey);
-
- $decryptPlainText = AESDecrypt($arr['encryptData'], $decryptAESKey);
-
- verify($decryptPlainText, $arr['sign'], $pubKey);
- } catch (\Exception $e) {
- throw $e;
- }
- $json=json_decode($decryptPlainText,true);
- return $json;
- }
- }
|