コード例 #1
0
ファイル: feedback.php プロジェクト: Xiaoyuyexi/client-server
<?php

require_once "../../include/config.inc.php";
require_once "../../class/Logger.php";
Logger::configure("../../class/Logger.ini");
$logger = Logger::getLogger('365xs');
$now = time();
$logger->info("开始处理向上异步返回的数据({$now}) : " . print_r($_SERVER, true));
$logger->info("开始处理向上异步返回的数据({$now}) : " . print_r($_GET, true));
echo "true";
require_once "mobilerecharge.php";
recharge365xs::Feedback($_GET, "");
コード例 #2
0
 public function Recharge($data)
 {
     // 之所以这样写,是因为向上系统的时间跟我们的不一样,相差了八个小时
     $now = time() + 8 * 60 * 60;
     $logger = Logger::getLogger('365xs');
     $logger->info("开始向上充值({$now}) : " . print_r($data, true));
     $deno = $data['money'] + 0;
     // 面额
     $macid = recharge365xs::$MODE == "TEST" ? recharge365xs::$macid_TEST : recharge365xs::$macid_FORMAL;
     $orderid = $data['orderId'];
     // 合作商订单号
     $orderid = substr($orderid, 6, 20);
     // 由于向上的接口要求订单号不超过20位
     // 充值号码
     $phone = recharge365xs::$MODE == "TEST" ? recharge365xs::$phone_TEST : $data['phone'];
     // 这个私钥是向上提供的测试示例
     $privateKey = recharge365xs::$MODE == "TEST" ? recharge365xs::$privateKey_TEST : recharge365xs::$privateKey_FORMAL;
     $sign = "deno" . $deno . "macid" . $macid . "orderid" . $orderid . "phone" . $phone . "time" . $now;
     $logger->debug("正在向上充值({$now}) : 生成签名的明文({$sign})");
     $piKey = openssl_pkey_get_private($privateKey);
     $encrypted = "";
     openssl_sign($sign, $encrypted, $piKey);
     $logger->debug("正在向上充值({$now}) : 生成的密文({$encrypted})");
     $sign = urlencode(base64_encode($encrypted));
     $logger->debug("正在向上充值({$now}) : sign({$sign})");
     $url = recharge365xs::$MODE == "TEST" ? recharge365xs::$url_TEST : recharge365xs::$url_FORMAL;
     $url .= "?deno={$deno}&macid={$macid}&orderid={$orderid}&phone={$phone}&sign={$sign}&time={$now}";
     $logger->info("正在向上充值({$now}) : url({$url})");
     $maxTryCount = 3;
     $tryCount = 0;
     while ($tryCount < $maxTryCount && !$xml) {
         $tryCount++;
         $xml = simplexml_load_file($url);
     }
     if ($xml) {
         $logger->info("正在向上充值({$now}) : 经历过{$tryCount} 次尝试后,返回的结果(" . print_r($xml, true) . ")");
         $xml = xml2array($xml);
         recharge365xs::Feedback($xml, $orderId);
     } else {
         $logger->error("完成向上充值({$now}) : 经历过{$tryCount} 次尝试后,({$url}) 没有返回数据");
     }
 }