Exemplo n.º 1
0
function firstStep()
{
    validateParameters($_POST);
    $planId = "basic";
    $passThrough = array("address" => $_POST['addr'], "extended_addr" => $_POST['extended_addr'], "city" => $_POST['city'], "state" => $_POST['state'], "zip_code" => $_POST['zip_code']);
    try {
        /*
         * Calling ChargeBee Checkout new Hosted Page API to checkout a new subscription
         * by passing plan id the customer would like to subscribe and also passing customer 
         * first name, last name, email and phone details. The resposne returned by ChargeBee
         * has hosted page url and the customer will be redirected to that url.
         * 
         * Note: Parameter embed(Boolean.TRUE) can be shown in iframe
         *       whereas parameter embed(Boolean.FALSE) can be shown as seperate page.
         * Note : Here customer object received from client side is sent directly 
         *        to ChargeBee.It is possible as the html form's input names are 
         *        in the format customer[<attribute name>] eg: customer[first_name] 
         *        and hence the $_POST["customer"] returns an associative array of the attributes.              
         */
        $hostUrl = getHostUrl();
        $result = Chargebee_HostedPage::CheckoutNew(array("subscription" => array("planId" => $planId), "customer" => $_POST['customer'], "embed" => "false", "passThruContent" => json_encode($passThrough), "redirectUrl" => $hostUrl . "/checkout_two_step/redirect_handler", "cancelUrl" => $hostUrl . "/checkout_two_step/signup.html"));
        $redirectUrl = $result->hostedPage()->url;
        $jsonResponse = array("forward" => $redirectUrl);
        print json_encode($jsonResponse, true);
    } catch (ChargeBee_InvalidRequestException $e) {
        handleInvalidRequestErrors($e, "subscription[plan_id]");
    } catch (Exception $e) {
        handleGeneralErrors($e);
    }
}
Exemplo n.º 2
0
 /**
  * 新用户从微信注册
  */
 public function getNewOpenID()
 {
     $weObj = new \System\lib\Wechat\Wechat($this->config("WEIXIN_CONFIG"));
     $this->weObj = $weObj;
     if (empty($_GET['code']) && empty($_GET['state'])) {
         $callback = getHostUrl();
         $reurl = $weObj->getOauthRedirect($callback, "1");
         redirect($reurl, 0, '正在发送验证中...');
         exit;
     } elseif (intval($_GET['state']) == 1) {
         $accessToken = $weObj->getOauthAccessToken();
         $mobile = $_GET['phone'];
         //用户信息
         $userInfo = $this->getUserInfo($accessToken);
         $saveUser = $this->saveUser($userInfo, $mobile);
         //插入新会员数据
         if (!$saveUser) {
             $this->R('', '40001');
         }
         header("LOCATION:http://onebuy.ping-qu.com");
     } else {
         //用户取消授权
         $this->R('', '90006');
     }
 }
/**
 * Gets the base (absolute) URL for top-level script.
 * 
 * @return string the base URL
 */
function getBaseUrl()
{
    static $base_url = null;
    if ($base_url === null) {
        $base_url = getHostUrl() . dirname($_SERVER['SCRIPT_NAME']) . '/';
    }
    return $base_url;
}
function updateCardHostedPage()
{
    /*
     * Calling the ChargeBee Update Card Hosted Page API to update card for 
     * a customer by passing the particular customers' customer id.
     * 
     * Note : To use this API return url for Update Card API's page must be set.
     */
    $hostUrl = getHostUrl();
    $result = ChargeBee_HostedPage::updatePaymentMethod(array("customer" => array("id" => $_GET['customer_id']), "embed" => "false", "redirectUrl" => $hostUrl . "/update_payment_method/redirect_handler", "cancelUrl" => $hostUrl . "/update_payment_method/profile?customer_id=" . urlencode($_GET['customer_id'])));
    $url = $result->hostedPage()->url;
    header("Location: {$url}");
}
 /**
  * 授权
  */
 private function getOpenID()
 {
     if (isset($_GET['wechat_refer'])) {
         //回跳地址
         $_SESSION['wechat_refer'] = urldecode($_GET['wechat_refer']);
     }
     $weObj = new \System\lib\Wechat\Wechat($this->config("WEIXIN_CONFIG"));
     $this->weObj = $weObj;
     if (empty($_GET['code']) && empty($_GET['state'])) {
         $callback = getHostUrl();
         $reurl = $weObj->getOauthRedirect($callback, "1");
         redirect($reurl, 0, '正在发送验证中...');
         exit;
     } elseif (intval($_GET['state']) == 1) {
         $accessToken = $weObj->getOauthAccessToken();
         $isUser = $this->getUserInfo($accessToken);
         $_SESSION['userInfo'] = ['openid' => $isUser['openid'], 'nickname' => $isUser['nickname']];
         // header("LOCATION:".$_SESSION['wechat_refer']);
     } else {
         //用户取消授权
         $this->R('', '90006');
     }
 }
function updateCard()
{
    $hostUrl = getHostUrl();
    $customerId = getCustomerId();
    try {
        $result = ChargeBee_HostedPage::updatePaymentMethod(array("customer" => array("id" => $customerId), "redirect_url" => $hostUrl . "/ssp-php/redirect_handler", "cancel_url" => $hostUrl . "/ssp-php/subscription", "embed" => "false"));
        $url = $result->hostedPage()->url;
        header("Location: " . $url);
    } catch (ChargeBee_InvalidRequestException $e) {
        error_log($e->getMessage());
        $errorResponse = array();
        if ($e->getParam() != null && $e->getApiErrorCode() == "resource_not_found" && $e->getParam() == "customer[id]") {
            customError404($e);
        } else {
            customError400($e);
        }
    } catch (ChargeBee_APIError $e) {
        error_log($e->getMessage());
        customError400($e);
    } catch (Exception $e) {
        error_log($e->getMessage());
        customError500($e);
    }
}
<?php

/*
 * Adding ChargeBee php libraries and configuration files.
 */
require_once dirname(__FILE__) . "/Config.php";
require_once dirname(__FILE__) . "/Util.php";
require_once dirname(__FILE__) . "/ErrorHandler.php";
/* Checkouts the existing subscription to active state for the passed 
 * subscription id which is in trial state.
 */
if ($_POST) {
    validateParameters($_POST);
    try {
        /* Request the ChargeBee server to get the hosted page url.
         * Passing Timestamp as ZERO to the trial end will immediately change the 
         * subscription from trial state to active state.
         * Note: Parameter embed specifies the returned hosted page URL 
         *       is shown in iframe or as seperate page.
         */
        $hostUrl = getHostUrl();
        $result = Chargebee_HostedPage::checkoutExisting(array("subscription" => array("id" => $_POST["subscription_id"], "trial_end" => 0), "embed" => "false", "redirect_url" => $hostUrl . "/checkout_existing/redirect_handler", "cancel_url" => $hostUrl . "/checkout_existing/profile.html"));
        $redirectURL = $result->hostedPage()->url;
        /* 
         * This will redirect to the ChargeBee server.
         */
        header("Location: {$redirectURL}");
    } catch (Exception $e) {
        customError500($e);
    }
}
}
session_start();
$base_url = getBaseUrl();
$xnatview = getXnatViewOptions();
$in_frame = isset($_REQUEST['in_frame']) && (bool) $_REQUEST['in_frame'];
$deeplink_url = $_SERVER['PHP_SELF'];
// strip '/' (plus the default whitespace characters)
$path_info = trim($_SERVER['PATH_INFO'], "/ \t\n\r\v");
$path_info = array_filter(explode('/', $path_info));
if (count($path_info) < 4) {
    _fatal_error("Invalid scan URL.");
} else {
    list($project, $subject, $experiment, $scan) = $path_info;
}
// construct the deeplink url
$deeplink_url = getHostUrl() . $_SERVER['REQUEST_URI'];
$qpos = strpos($deeplink_url, "?");
if ($qpos !== false) {
    $deeplink_url = substr($deeplink_url, 0, $qpos);
}
$qpos = strpos($deeplink_url, "#");
if ($qpos !== false) {
    $deeplink_url = substr($deeplink_url, 0, $qpos);
}
$xnatview['config']['galleryScanLink'] = $deeplink_url;
// FIXME: check for the particular project/scan/etc
$is_authorized = isset($_SESSION['xnatview.authinfo']);
if (!$is_authorized) {
    if (!$in_frame) {
        header('Location: ' . $base_url . 'login.php?target=' . urlencode($_SERVER['PHP_SELF']));
        return;
Exemplo n.º 9
0
 /**
  * 新用户从微信注册
  */
 public function getNewOpenID()
 {
     $refer = $_GET['refer'];
     $weObj = new \System\lib\Wechat\Wechat($this->config("WEIXIN_CONFIG"));
     $this->weObj = $weObj;
     if (empty($_GET['code']) && empty($_GET['state'])) {
         $callback = getHostUrl();
         $reurl = $weObj->getOauthRedirect($callback, "1");
         redirect($reurl, 0, '正在发送验证中...');
         exit;
     } elseif (intval($_GET['state']) == 1) {
         $accessToken = $weObj->getOauthAccessToken();
         $mobile = $_GET['phone'];
         $user = $this->table('user')->where(['is_on' => 1, 'phone' => $mobile])->get(['id'], true);
         if (!$user) {
             //用户信息
             $userInfo = $this->getUserInfo($accessToken);
             $saveUser = $this->saveUser($userInfo, $mobile);
             //插入新会员数据
             if (!$saveUser) {
                 $this->R('', '40001');
             }
             //header("LOCATION:".getHost()."/Api/User/getOpenID");
             $userInfo = $this->getUserInfo($accessToken);
             // 是否有用户记录
             $isUser = $this->table('user')->where(["openid" => $accessToken['openid'], "is_on" => 1])->get(null, true);
             /*var_dump($isUser);exit();*/
             if ($isUser == null) {
                 //没有此用户跳转至输入注册的页面
                 header("LOCATION:" . getHost() . "/register.html?refer=" . $_GET['refer']);
             } else {
                 $userID = $isUser['id'];
                 $updateUser = $this->table('user')->where(['id' => $userID])->update(['last_login' => time(), 'last_ip' => ip2long(getClientIp()), 'nickname' => $userInfo['nickname'], 'user_img' => $userInfo['headimgurl']]);
                 $_SESSION['userInfo'] = ['openid' => $isUser['openid'], 'userid' => $isUser['id'], 'nickname' => $isUser['nickname'], 'user_img' => $isUser['user_img']];
                 header("LOCATION:" . $refer);
                 //进入网站成功
             }
         } else {
             $this->R('', '70000');
             //手机已注册
         }
     } else {
         //用户取消授权
         $this->R('', '90006');
     }
 }
Exemplo n.º 10
0
<?php

if (!defined('THINK_PATH')) {
    exit;
}
$DB = (require "config.inc.php");
//数据库配置
//系统配置
$system = array('URL_MODEL' => 3, 'URL_ROUTER_ON' => true, 'SESSION_AUTO_START' => true, 'DEFAULT_TIMEZONE' => 'Asia/Shanghai', 'VAR_PAGE' => 'p', 'DEFAULT_THEME' => 'default', 'TMPL_ACTION_SUCCESS' => 'public:success', 'TMPL_ACTION_ERROR' => 'public:error', 'TMPL_PARSE_STRING' => array('__FILES__' => 'data/files', '__STATICS__' => 'statics/admin_old'), 'OUTPUT_ENCODE' => false, 'HOST_URL' => getHostUrl(), 'APP_INFO' => array('id' => 1, 'name' => '上海主站'));
function getHostUrl()
{
    $s = 'http://' . $_SERVER['HTTP_HOST'];
    if ($_SERVER['SERVER_PORT'] != '80') {
        $s .= ':' . $_SERVER['SERVER_PORT'];
    }
    $s .= dirname($_SERVER['SCRIPT_NAME']) . '/';
    return $s;
}
return array_merge($DB, $system);
Exemplo n.º 11
0
 /**
  * 新用户从微信注册
  */
 public function getNewOpenID()
 {
     $weObj = new \System\lib\Wechat\Wechat($this->config("WEIXIN_CONFIG"));
     $this->weObj = $weObj;
     if (empty($_GET['code']) && empty($_GET['state'])) {
         $callback = getHostUrl();
         $reurl = $weObj->getOauthRedirect($callback, "1");
         redirect($reurl, 0, '正在发送验证中...');
         exit;
     } elseif (intval($_GET['state']) == 1) {
         $accessToken = $weObj->getOauthAccessToken();
         $mobile = $_GET['phone'];
         $user = $this->table('user')->where(['is_on' => 1, 'phone' => $mobile])->get(['id'], true);
         if (!$user) {
             //用户信息
             $userInfo = $this->getUserInfo($accessToken);
             $saveUser = $this->saveUser($userInfo, $mobile);
             //插入新会员数据
             if (!$saveUser) {
                 $this->R('', '40001');
             }
             header("LOCATION:" . getHost() . "/Api/User/getOpenID");
             //
         } else {
             $this->R('', '70000');
             //手机已注册
         }
     } else {
         //用户取消授权
         $this->R('', '90006');
     }
 }