Ejemplo n.º 1
0
 /**
  * 给param赋值的方法
  *
  * @param BaseParam $param
  */
 public function setParam(BaseParam &$param)
 {
     foreach ($this->params as $key => $value) {
         $method = String::convertKeyToFuncName($key);
         if (method_exists($param, $method)) {
             call_user_func_array(array($param, $method), array($value));
         }
     }
     Logger::addInfo('alipay_wap_handler_base', 'setParam', array('res' => (string) $param));
 }
Ejemplo n.º 2
0
 /**
  * @return Config
  */
 public function getConfig()
 {
     $config = new Config();
     $tmp = (include "{$this->config_file_path}");
     Logger::addInfo('alipay_wap_handler_phpfileconfig', 'load the confing array', array('config_file_path' => $this->config_file_path, 'config_array' => $tmp));
     foreach ($tmp as $key => $val) {
         $config->{$key} = $val;
     }
     return $config;
 }
Ejemplo n.º 3
0
 /**
  * @return PayParam
  */
 public function getPayParam()
 {
     $pay_param = new PayParam();
     foreach ($this->params as $key => $val) {
         $method = $this->getKeySetMethod($key);
         if (method_exists($pay_param, $method)) {
             call_user_func_array(array($pay_param, $method), array($val));
         }
     }
     Logger::addInfo('alipay_wap_handler_arraypayparam', 'getPayParam', array('res' => (string) $pay_param));
     return $pay_param;
 }
Ejemplo n.º 4
0
 /**
  * 获取post方法的返回值
  *
  * @param        $url
  * @param        $cacert
  * @param        $para
  * @param string $input_charset
  *
  * @return string
  */
 public static function getHttpResponse($method, $url, $cacert, $para, $input_charset = '')
 {
     if (trim($input_charset) != '') {
         $url = $url . "_input_charset=" . $input_charset;
     }
     if ($method == 'post') {
         $result = \Requests::post($url, array(), $para, array('verify' => $cacert));
     } else {
         $result = \Requests::get($url, array(), array('verify' => $cacert));
     }
     Logger::addInfo('alipay_wap_submit', 'getHttpResponse', array('method' => $method, 'url' => $url, 'cacert' => $cacert, 'para' => $para, 'result' => $result->body));
     return $result->body;
 }
Ejemplo n.º 5
0
 /**
  * @return Config
  */
 public function getConfig()
 {
     $config = new Config();
     $tmp = (include "{$this->config_file_path}");
     Logger::addInfo('alipay_wap_handler_phpfileconfig', 'load the confing array', array('config_file_path' => $this->config_file_path, 'config_array' => $tmp));
     foreach ($tmp as $key => $val) {
         $method = String::convertKeyToFuncName($key);
         if (method_exists($config, $method)) {
             call_user_func_array(array($config, $method), array($val));
         }
         //$config->$key = $val;
     }
     return $config;
 }
Ejemplo n.º 6
0
 public function decrypt($content)
 {
     $key = file_get_contents($this->private_key_path);
     $res = openssl_get_privatekey($key);
     $content = base64_decode($content);
     $result = '';
     for ($i = 0; $i < strlen($content) / 128; $i++) {
         $data = substr($content, $i * 128, 128);
         openssl_private_decrypt($data, $decrypt, $res);
         $result .= $decrypt;
     }
     openssl_free_key($res);
     Logger::addInfo('alipay_wap_encryption_rsa', 'decrypt', array('key' => $res, 'result' => $result));
     return $result;
 }
Ejemplo n.º 7
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Api;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArrayCallbackParamHandler as CallbackParamHander;
use HuNanZai\Component\Log\Service as Logger;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$callback_param_handler = new CallbackParamHander($_GET);
$callback_param = $callback_param_handler->getParam();
$alipay_api = new Api($config);
$res = $alipay_api->verifyCallback($callback_param);
Logger::addInfo('alipay_wap_demo', 'callback', array('get' => $_GET, 'res' => $res));
if ($res) {
    header("Location: https://www.baidu.com");
    die;
} else {
    header("Location: http://www.ci123.com");
    die;
}
Ejemplo n.º 8
0
 public function getResponse($notify_id)
 {
     $transport = strtolower(trim($this->config->transport));
     $partner = trim($this->config->partner);
     $verify_url = $transport == 'https' ? $this->https_verify_url : $this->http_verify_url;
     $verify_url .= "partner={$partner}&notify_id={$notify_id}";
     $response = \Requests::get($verify_url, array(), array('verify' => $this->config->cacert));
     Logger::addInfo('alipay_wap_notify', 'getResponse', array('notify_id' => $notify_id, 'transport' => $transport, 'verify_url' => $verify_url, 'result' => $response->body));
     return $response->body;
 }
Ejemplo n.º 9
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Api;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArrayNotifyParamHandler as NotifyParamHandler;
use HuNanZai\Component\Log\Service as Logger;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$notify_param_handler = new NotifyParamHandler($_POST);
$notify_param = $notify_param_handler->getParam();
$alipay_api = new Api($config);
$res = $alipay_api->verifyNotify($notify_param);
Logger::addInfo('alipay_wap_demo', 'notify', array('post' => $_POST, 'res' => $res));
if ($res) {
    echo "success";
} else {
    echo "fail";
}
Ejemplo n.º 10
0
 /**
  * @param $data
  *
  * @return string
  */
 public function sign($data)
 {
     $sign = md5($data . $this->key);
     Logger::addInfo('alipay_wap_encryption_md5', 'sign', array('data' => $data, 'key' => $this->key, 'sign' => $sign));
     return $sign;
 }