Exemple #1
0
 /**
  * 验签
  *
  * @param $params
  *
  * @return int
  */
 public static function verify($params)
 {
     //global $log;
     // 公钥
     $public_key = self::getPulbicKeyByCertId($params['certId']);
     //	echo $public_key.'<br/>';
     // 签名串
     $signature_str = $params['signature'];
     unset($params['signature']);
     $params_str = Common::coverParamsToString($params);
     //$log->LogInfo ( '报文去[signature] key=val&串>' . $params_str );
     $signature = base64_decode($signature_str);
     //	echo date('Y-m-d',time());
     $params_sha1x16 = sha1($params_str, FALSE);
     //$log->LogInfo ( '摘要shax16>' . $params_sha1x16 );
     $isSuccess = openssl_verify($params_sha1x16, $signature, $public_key, OPENSSL_ALGO_SHA1);
     //$log->LogInfo ( $isSuccess ? '验签成功' : '验签失败' );
     return $isSuccess;
 }
Exemple #2
0
 /**
  * 交易退款
  *
  * @param      $batch_no //退款的批次号
  * @param      $trade_no //商户交易号
  * @param      $amount //退款的金额
  * @param null $extra //订单退款的其他信息
  *
  * @return mixed
  */
 public function refund($batch_no, $trade_no, $amount, $extra = null)
 {
     $parameters = array('version' => '5.0.0', 'encoding' => 'utf-8', 'certId' => Secure::getSignCertId(), 'signMethod' => '01', 'txnType' => '04', 'txnSubType' => '00', 'bizType' => '000201', 'accessType' => '0', 'channelType' => '07', 'orderId' => $batch_no, 'merId' => Config::MERCHANT_ID, 'origQryId' => $extra['thirdparty_trade_no'], 'txnTime' => date('YmdHis'), 'txnAmt' => $extra['amount'] * 100, 'backUrl' => Config::SDK_BACK_NOTIFY_URL, 'reqReserved' => ' 透传信息');
     Secure::sign($parameters);
     $result = Http::sendHttpRequest(Http::getRequestParamString($parameters), Config::SDK_BACK_TRANS_URL);
     $result_arr = Common::coverStringToArray($result);
     return Secure::verify($result_arr) ? $result_arr : false;
 }