Esempio n. 1
0
function testParams()
{
    $result = ChargeBee_Subscription::retrieve('1rifg4iOsZUL4mBhF');
    // print_r($result);
    //print_r($result->subscription()->currentTermEnasdd);
    //print_r($result->customer());
    //print_r($result->customer()->cfDateOfBirth);
    //print_r($result->customer()->cfGender);
    print_r($result->subscription());
}
Esempio n. 2
0
function createTrialSubscription()
{
    /* 
     * Constructing the parameters to be send to the ChargeBee. For demo 
     * purpose a plan with id 'basic' is hard coded which has 15 month trial
     * in ChargeBee app. 
     * 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.
     *               
     */
    $createTrialReqParams = array("plan_id" => "basic", "customer" => $_POST["customer"]);
    /* 
     * Sends request to the ChargeBee server to create trial subscription
     * using the trial plan id set in createTrialReqParams array.
     */
    $result = ChargeBee_Subscription::create($createTrialReqParams);
    return $result;
}
function createSubscription()
{
    /*
     * Constructing a parameter array for create subscription api. 
     * It will have account information, the temporary token got from Stripe and
     * plan details.
     * For demo purpose a plan with id 'annual' is hard coded.
     * Other params are obtained from request object.
     * 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.
     *               
     */
    $createSubscriptionParams = array("planId" => "basic", "customer" => $_POST['customer'], "card" => array("tmp_token" => $_POST['stripeToken']));
    /* 
     * Sending request to the chargebee server to create the subscription from 
     * the parameters received. The result will have customer,subscription and 
     * card attributes.
     */
    $result = ChargeBee_Subscription::create($createSubscriptionParams);
    return $result;
}
 public function reactivateAccount($inData)
 {
     ChargeBee_Environment::configure("rocketmailmerge", "Chargebee api token");
     $data = array();
     $card = array("number" => $inData['number'], "expiryMonth" => $inData['expiryMonth'], "expiryYear" => $inData['expiryYear'], "cvv" => $inData['cvv'], "billingZip" => $inData['billingZip']);
     try {
         $chargebee_result = ChargeBee_Subscription::update($inData['token'], array("planId" => "base_rate", "trialEnd" => 0, "card" => $card));
     } catch (Exception $e) {
         header('Location: https://app.rocketmailmerge.com/account/reactivate.html?id=' . $inData['token'] . "&crd=0");
         die;
     }
     //Reactivate their subscription
     $query = "UPDATE user_subscriptions set subscription_status = 'active'\r\n\t\t\t\t  WHERE chargebee_id = ?";
     $stmt = $this->sql->link->prepare($query);
     if (!$stmt) {
         die('Invalid query: ' . $this->sql->link->error);
     } else {
         $stmt->bind_param('s', $inData['token']);
         $resultFromExec = $stmt->execute();
     }
     //Log them in
     $this->lookupUser(array("id" => $inData['token']));
     $session = new iSession();
     $session->mod_var("logged_in", 1);
     $session->mod_var("user_id", $this->outData['data']['user_id']);
     $session->update_session();
     header('Location: https://app.rocketmailmerge.com/dashboard/?tut=1');
 }
Esempio n. 5
0
    public function createNewSubscribedUser($inData)
    {
        $pass_hasher = new PasswordHash(8, FALSE);
        $time = $this->getCurrentDateTime();
        $affectedRows = 0;
        $userID = "";
        //
        //Begin account creation
        /////////////////////////////////////////
        if (strlen($inData['password']) < 5) {
            $output['success'] = 0;
            $output['text'] = "Sorry, your password must be at least 5 characters.";
            $output['rex'] = "Bark bark woof woof!";
            $output['return'] = 2;
            $this->outData = $output;
            $this->sendTechEmail("*****@*****.**", "Subscriber: Pass too short", "A user tried to register and account but their password was too short -----\n" . print_r($inData, 1));
            header("location:https://" . $_SERVER['SERVER_NAME'] . "/account/register.html?r=0");
            //Pass to short.
            die;
            return $output;
        }
        //
        //Begin account creation
        /////////////////////////////////////////
        $username = $inData['email'];
        $email = $inData['email'];
        $password = @$pass_hasher->HashPassword($inData['password']);
        $new_user_guid = $this->create_guid();
        $file_directory = $this->create_guid();
        ChargeBee_Environment::configure("rocketmailmerge", "Chargebe api token");
        //Build up card data
        $cardNumber = $inData['number'];
        $cardexpiryMonth = $inData['expiryMonth'];
        $cardexpiryYear = $inData['expiryYear'];
        $cardcvv = $inData['cvv'];
        $cardbillingZip = $inData['billingZip'];
        //Check that they supplied a valid email address
        if (filter_var($inData['email'], FILTER_VALIDATE_EMAIL)) {
            //Store the email in the session in case they're redirected back to thje register page.
            session_start();
            $_SESSION['email'] = $inData['email'];
            $customer = array("first_name" => $inData['email']);
            $customer['email'] = $inData['email'];
        } else {
            $this->sendTechEmail("*****@*****.**", "Subscriber: Bogus Email", "A user tried to register and account but their email was bogus -----\n" . print_r($inData, 1));
            header("location:https://" . $_SERVER['SERVER_NAME'] . "/account/register.html?r=2");
            //Bogus email address
            die;
        }
        $card = array("number" => $cardNumber, "expiryMonth" => $cardexpiryMonth, "expiryYear" => $cardexpiryYear, "cvv" => $cardcvv, "billingZip" => $cardbillingZip);
        try {
            $chargebee_result = ChargeBee_Subscription::create(array("planId" => "base_rate", "id" => $new_user_guid, "customer" => $customer, "card" => $card, "list" => 1));
        } catch (Exception $e) {
            $this->sendTechEmail("*****@*****.**", "Subscriber: Bad Credit Card", "A user tried to register and account but their credit card was rejected by Chargebee -----\n" . print_r($inData, 1));
            header("location:https://" . $_SERVER['SERVER_NAME'] . "/account/register.html?r=3");
            //Invalid Credit Card
            die;
        }
        $query = "INSERT INTO users (created_at, updated_at, username, password_hash, file_directory, email)\r\n\t\t\t\t  VALUES (?, NOW(), ?, ?, ?, ?)";
        $stmt = $this->sql->link->prepare($query);
        if (!$stmt) {
            die('Invalid query: ' . $this->sql->link->error);
        } else {
            $stmt->bind_param('sssss', $time, $username, $password, $file_directory, $email);
            $resultFromExec = $stmt->execute();
            //Record the subscription management in the database for this user.
            if ($resultFromExec) {
                $affectedRows += $stmt->affected_rows;
                $userID = $stmt->insert_id;
                ////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Create the user's example files
                //Create the background file link - Invoice mailmerge high.
                $dir1 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/files/png/Invoice_backdrop-mailmerge-high/";
                mkdir($dir1, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/files/png/Invoice_backdrop-mailmerge-high/Invoice_backdrop-mailmerge-high.png", $dir1 . "Invoice_backdrop-mailmerge-high.png");
                $dir2 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/previews/png/Invoice_backdrop-mailmerge-high/";
                mkdir($dir2, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/previews/png/Invoice_backdrop-mailmerge-high/Invoice_backdrop-mailmerge-high.png", $dir2 . "Invoice_backdrop-mailmerge-high.png");
                $dir3 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/templates/png/Invoice_backdrop-mailmerge-high/";
                mkdir($dir3, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/templates/png/Invoice_backdrop-mailmerge-high/Invoice_backdrop-mailmerge-high.png", $dir3 . "Invoice_backdrop-mailmerge-high.png");
                $dir4 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/thumbnails/png/Invoice_backdrop-mailmerge-high/";
                mkdir($dir4, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/thumbnails/png/Invoice_backdrop-mailmerge-high/Invoice_backdrop-mailmerge-high.png", $dir4 . "Invoice_backdrop-mailmerge-high.png");
                //Insert it into the database.
                $query = "INSERT INTO backgrounds (created_at, updated_at, user_id, name, data_path) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, ?, ?)";
                $stmt = $this->sql->link->prepare($query);
                $name = "Invoice_backdrop-mailmerge-high.png";
                $dataPath = "/backgrounds/server/user_files/{$file_directory}/backgrounds/templates/png/Invoice_backdrop-mailmerge-high/";
                $stmt->bind_param('siss', $time, $userID, $name, $dataPath);
                $stmt->execute();
                $backgroundID1 = $stmt->insert_id;
                $query = "INSERT INTO backgrounds_pages (created_at, updated_at, background_id, background_pg_num, file_name) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, '1', ?)";
                $stmt = $this->sql->link->prepare($query);
                $name = "Invoice_backdrop-mailmerge-high.png";
                $stmt->bind_param('sis', $time, $backgroundID1, $name);
                $stmt->execute();
                $backgroundPGID1 = $stmt->insert_id;
                //Create the background file link - Example envelope.
                $dir1 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/files/png/example-envelope/";
                mkdir($dir1, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/files/png/example-envelope/example-envelope.png", $dir1 . "example-envelope.png");
                $dir2 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/previews/png/example-envelope/";
                mkdir($dir2, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/previews/png/example-envelope/example-envelope.png", $dir2 . "example-envelope.png");
                $dir3 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/templates/png/example-envelope/";
                mkdir($dir3, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/templates/png/example-envelope/example-envelope.png", $dir3 . "example-envelope.png");
                $dir4 = __DIR__ . "/../user_files/{$file_directory}/backgrounds/thumbnails/png/example-envelope/";
                mkdir($dir4, 0700, true);
                symlink(__DIR__ . "/../newuser_examples/backgrounds/thumbnails/png/example-envelope/example-envelope.png", $dir4 . "example-envelope.png");
                //Insert it into the database.
                $query = "INSERT INTO backgrounds (created_at, updated_at, user_id, name, data_path) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, ?, ?)";
                $stmt = $this->sql->link->prepare($query);
                $name = "example-envelope.png";
                $dataPath = "/backgrounds/server/user_files/{$file_directory}/backgrounds/templates/png/example-envelope/";
                $stmt->bind_param('siss', $time, $userID, $name, $dataPath);
                $stmt->execute();
                $backgroundID2 = $stmt->insert_id;
                $query = "INSERT INTO backgrounds_pages (created_at, updated_at, background_id, background_pg_num, file_name) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, '1', ?)";
                $stmt = $this->sql->link->prepare($query);
                $name = "example-envelope.png";
                $stmt->bind_param('sis', $time, $backgroundID2, $name);
                $stmt->execute();
                $backgroundPGID2 = $stmt->insert_id;
                //Create the datasource file copy - Example data.
                $dir1 = __DIR__ . "/../user_files/{$file_directory}/datasources/Example - Customer Invoices 2013/";
                mkdir($dir1, 0700, true);
                copy(__DIR__ . "/../newuser_examples/datasources/Example - Customer Invoices 2013/Example - Customer Invoices 2013", $dir1 . "Example - Customer Invoices 2013");
                $query = "INSERT INTO datasources (created_at, updated_at, user_id, name, data_path, file_name, headers, `lines`) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, ?, ?, ?, ?, 2)";
                $stmt = $this->sql->link->prepare($query);
                $path = "/datasources/server/user_files/{$file_directory}/datasources/Example - Customer Invoices 2013/";
                $name1 = "Example - Business Letter 2014";
                $name2 = "Example - Business Letter 2014";
                $headers = '["invoiceNum","name","address","suburb","state","postcode","billingPeriod","invoiceIssuedDate","clientNum","billingDetails","thankyouTxt","invoiceAmt","overdueTxt","overdueAmt","GrandTotal"]';
                $stmt->bind_param('sissss', $time, $userID, $name1, $path, $name2, $headers);
                $stmt->execute();
                $datasourceID = $stmt->insert_id;
                //Create a sample document for the new user.
                $query = "INSERT INTO documents (created_at, updated_at, user_id, name, datasource_id) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, ?, ?)";
                $stmt = $this->sql->link->prepare($query);
                $name = "Example - Business Letter";
                $stmt->bind_param('sisi', $time, $userID, $name, $datasourceID);
                $stmt->execute();
                $documentID = $stmt->insert_id;
                $query = "INSERT INTO documents_pages (created_at, updated_at, document_id, document_pg_num, background_id, background_pg_id, preset, width, height, selected_measurement_unit, variables ) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?), (?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                $stmt = $this->sql->link->prepare($query);
                $variables1 = 'a:1:{i:0;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:5:"127.5";s:1:"y";s:3:"294";s:5:"width";s:3:"381";s:6:"height";s:2:"87";s:4:"text";s:44:"<name>
<address>
<suburb> <state> <postcode>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"16";s:10:"font_style";s:0:"";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}}';
                $variables2 = 'a:13:{i:0;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"700";s:1:"y";s:3:"700";s:5:"width";s:3:"200";s:6:"height";s:4:"39.2";s:4:"text";s:12:"<invoiceAmt>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"16";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:1;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"536";s:1:"y";s:3:"750";s:5:"width";s:3:"161";s:6:"height";s:2:"36";s:4:"text";s:12:"<overdueTxt>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"16";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"R";}i:2;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"700";s:1:"y";s:3:"750";s:5:"width";s:3:"201";s:6:"height";s:2:"36";s:4:"text";s:12:"<overdueAmt>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"16";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:3;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"201";s:1:"y";s:3:"427";s:5:"width";s:3:"229";s:6:"height";s:2:"32";s:4:"text";s:10:"30/11/2012";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:4;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"201";s:1:"y";s:3:"466";s:5:"width";s:3:"229";s:6:"height";s:2:"32";s:4:"text";s:15:"<billingPeriod>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:5;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"201";s:1:"y";s:3:"506";s:5:"width";s:3:"230";s:6:"height";s:2:"32";s:4:"text";s:19:"<invoiceIssuedDate>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:6;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"202";s:1:"y";s:3:"546";s:5:"width";s:3:"228";s:6:"height";s:2:"32";s:4:"text";s:11:"<clientNum>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:7;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"201";s:1:"y";s:3:"586";s:5:"width";s:3:"228";s:6:"height";s:2:"32";s:4:"text";s:12:"<invoiceNum>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:4:"bold";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:8;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"629";s:1:"y";s:3:"901";s:5:"width";s:3:"276";s:6:"height";s:2:"52";s:4:"text";s:12:"<GrandTotal>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"32";s:10:"font_style";s:0:"";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:9;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:2:"46";s:1:"y";s:3:"181";s:5:"width";s:3:"438";s:6:"height";s:2:"49";s:4:"text";s:22:"INVOICE : <invoiceNum>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"26";s:10:"font_style";s:0:"";s:12:"font_padding";s:2:"10";s:10:"font_color";s:14:"rgb(0, 3, 215)";s:10:"font_align";s:1:"L";}i:10;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"128";s:1:"y";s:3:"299";s:5:"width";s:3:"331";s:6:"height";s:18:"63.199999999999996";s:4:"text";s:50:"<name>
<address>
<suburb>    <state>    <postcode>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:0:"";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"L";}i:11;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"496";s:1:"y";s:3:"560";s:5:"width";s:3:"384";s:6:"height";s:4:"34.4";s:4:"text";s:13:"<thankyouTxt>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"12";s:10:"font_style";s:0:"";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"R";}i:12;a:12:{s:4:"name";s:8:"variable";s:1:"x";s:3:"501";s:1:"y";s:3:"296";s:5:"width";s:3:"378";s:6:"height";s:18:"41.599999999999994";s:4:"text";s:16:"<billingDetails>";s:11:"font_family";s:5:"Arial";s:9:"font_size";s:2:"16";s:10:"font_style";s:0:"";s:12:"font_padding";s:2:"10";s:10:"font_color";s:12:"rgb(0, 0, 0)";s:10:"font_align";s:1:"R";}}';
                $pgNum = 1;
                $pgNum2 = 2;
                $empty = '';
                $pgSize = 'a4';
                $zero = 0;
                $size1 = 220;
                $size4 = 110;
                $size2 = 210;
                $size3 = 297;
                $stmt->bind_param('siiiissssssiiiisssss', $time, $documentID, $pgNum, $backgroundID2, $backgroundPGID2, $empty, $size1, $size4, $zero, $variables1, $time, $documentID, $pgNum2, $backgroundID1, $backgroundPGID1, $pgSize, $size2, $size3, $zero, $variables2);
                $stmt->execute();
                ////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Create the user's welcome messages
                $welcomeMessage[0] = "If you need any support simply email our friendly team at <a href=\"mailto:support@rocketmailmerge.com\">support@rocketmailmerge.com</a>";
                $welcomeMessage[1] = "Thanks for signing up to Rocket Mail Merge! This is a help notice, you can click on it to hide it.";
                $query = "INSERT INTO user_notices (created_at, updated_at, user_id, type, message) \n\t\t\t\t\t\t  VALUES (?, NOW(), ?, 'msg_Info', ?), (?, NOW(), ?, 'msg_Info', ?)";
                $stmt = $this->sql->link->prepare($query);
                $stmt->bind_param('sissis', $time, $userID, $welcomeMessage[0], $time, $userID, $welcomeMessage[1]);
                $resultFromExec = $stmt->execute();
                $affectedRows += $stmt->affected_rows;
                ////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Create their statistics data
                $query = "INSERT INTO user_statistics (created_at, updated_at, user_id) \n\t\t\t\t\t\t  VALUES(?, NOW(), ?)";
                $stmt = $this->sql->link->prepare($query);
                $stmt->bind_param('si', $time, $userID);
                $resultFromExec = $stmt->execute();
                $affectedRows += $stmt->affected_rows;
                ////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Create their subscription record.
                $query = "INSERT INTO user_subscriptions (created_at, updated_at, user_id, chargebee_id, subscription_plan_id, subscription_status  ) \r\n\t\t\t\t\t\t  VALUES(?, NOW(), ?, ?, 'base_rate', 'active')";
                $stmt = $this->sql->link->prepare($query);
                $stmt->bind_param('sis', $time, $userID, $new_user_guid);
                $resultFromExec = $stmt->execute();
                $affectedRows += $stmt->affected_rows;
                //We delegate our chargebee account creation as the curl process can take a few seconds to return the data
                //we don't want new user's to be delayed in account creation.
                if ($resultFromExec) {
                }
            }
            /* free result */
            $stmt->free_result();
            $stmt->close();
        }
        if ($affectedRows > 0 && $userID != "") {
            $output['success'] = 1;
            $output['text'] = "Congratulations, your account has been created.";
            $output['return'] = 1;
            $output['data']['user_id'] = $userID;
            $output['parse_curl'] = 1;
            $session = new iSession();
            $session->mod_var("logged_in", 1);
            $session->mod_var("user_id", $userID);
            $session->update_session();
            //Great success - Redirect the user to their dashboard.
            header('Location: https://app.rocketmailmerge.com/dashboard/?tut=1');
            die;
        } else {
            $output['success'] = 0;
            $output['text'] = "Sorry, that email is already registered to an account. Please choose another.";
            $output['rex'] = "Grrr";
            $output['return'] = 1;
            $this->sendTechEmail("*****@*****.**", "Subscriber: Account already registered", "A user tried to register and account but their email was already registered -----\n" . print_r($inData, 1));
            header("location:https://" . $_SERVER['SERVER_NAME'] . "/account/register.html?r=1");
            //Account already taken.
            die;
        }
        $this->outData = $output;
        return $output;
    }
Esempio n. 6
0
<?php

require_once '../partials/header.php';
/*
 * Adding ChargeBee php libraries
 */
require_once dirname(__FILE__) . "/../php_src/Config.php";
$subscriptionId = $_GET["subscription_id"];
$result = ChargeBee_Subscription::retrieve($subscriptionId);
$dob = $result->customer()->cfDateOfBirth;
$comicsType = $result->customer()->cfComicsType;
?>

<div class="jumbotron text-center">
    	<h2><span class="text-muted">Congrats! You've successfully</span> signed up <span class="text-muted">to Honey Comics.</span></h2>
        <h4 class="text-muted"><?php 
echo $comicsType;
?>
 comics will be delivered to your email address.</h4>
        <h3> Expect a surprise on your birthday (<?php 
echo date('M d', strtotime($dob));
?>
) :) </h3>
        <h1>Thank You!</h1>
</div>

<?php 
require_once '../partials/footer.php';
Esempio n. 7
0
<?php

/*
 * Adding ChargeBee php librariesand configuration files.
 */
require_once dirname(__FILE__) . "/Config.php";
require_once dirname(__FILE__) . "/ErrorHandler.php";
require_once dirname(__FILE__) . "/Util.php";
/*
 * Demo on how to create subscription in ChargeBee using Braintree Js.
 */
if ($_POST) {
    validateParameters($_POST);
    $planId = "professional";
    try {
        /* Creating a subscription in ChargeBee by passing the encrypted 
         * card number and card cvv provided by Braintree Js.
         */
        $createSubscriptionParams = array("planId" => $planId, "customer" => $_POST['customer'], "card" => $_POST['card']);
        $result = ChargeBee_Subscription::create($createSubscriptionParams);
        $jsonResp = array("forward" => "/braintree-js/thankyou.html");
        print json_encode($jsonResp);
    } catch (ChargeBee_PaymentException $e) {
        handleTempTokenErrors($e);
    } catch (ChargeBee_InvalidRequestException $e) {
        handleInvalidRequestErrors($e, "plan_id");
    } catch (Exception $e) {
        handleGeneralErrors($e);
    }
}
Esempio n. 8
0
 private function processChargeBeeData($inData)
 {
     //echo "Processing $inData";
     $inData = json_decode($inData, 1);
     $sqlData = array();
     $varData = array();
     if ($inData === null) {
         echo "Invalid Data provided.\n";
         return "Invalid data!";
     }
     echo "Processing : ";
     print_r($inData);
     foreach ($inData['content'] as $key => $value) {
         /*	"subscription": {
         			"id": "HwqE2xeNnwOeYF44",
         			"plan_id": "enterprise",
         			"plan_quantity": 1,
         			"status": "in_trial",
         			"trial_start": 1352158863,
         			"trial_end": 1353454863,
         			"created_at": 1352158863,
         			"due_invoices_count": 0,
         			"object": "subscription"
         		},
         		"customer": {
         			"id": "HwqE2xeNnwOeYF44",
         			"first_name": "Leon",
         			"last_name": "Test",
         			"email": "*****@*****.**",
         			"created_at": 1352158863,
         			"object": "customer",
         			"card_status": "valid"
         		},
         		"card": {
         			"customer_id": "HwqE2xeNnwOeYF44",
         			"status": "valid",
         			"gateway": "chargebee",
         			"first_name": "Leon",
         			"last_name": "Testington",
         			"iin": "411111",
         			"last4": "1111",
         			"card_type": "visa",
         			"expiry_month": 2,
         			"expiry_year": 2020,
         			"billing_addr1": "123 Fake Street",
         			"billing_city": "Fake suburb",
         			"billing_state": "QLD",
         			"billing_country": "AU",
         			"billing_zip": "1234",
         			"object": "card",
         			"masked_number": "411111******1111"
         		},
         		*/
         switch ($key) {
             case "customer":
                 $allowed = array("customer_first_name", "customer_last_name", "customer_email", "customer_created_at");
                 foreach ($value as $customerKey => $customerData) {
                     if (in_array("customer_" . $customerKey, $allowed)) {
                         $sqlData[] = "customer_" . $customerKey . " = ?";
                         $varData[] = $customerData;
                     }
                 }
                 //Flag the curl request as processed/deleted.
                 $query = "UPDATE user_subscriptions \n\t\t\t\t\t\t\t\t  SET " . implode(",", $sqlData) . "\t\n\t\t\t\t\t\t\t\t  WHERE chargebee_id = ?";
                 $stmt = $this->sql->link->prepare($query);
                 for ($c = 0; $c < sizeof($varData); $c++) {
                     $stmt->mbind_param('s', $varData[$c]);
                 }
                 //Bind the document id, document page num and user id.
                 $stmt->mbind_param('s', $value['id']);
                 $stmt->execute();
                 break;
             case "card":
                 $allowed = array("card_status", "card_first_name", "card_last_name", "card_card_type", "card_expiry_month", "card_expiry_year", "card_billing_addr1", "card_billing_addr2", "card_billing_city", "card_billing_state", "card_billing_country", "card_billing_zip", "card_masked_number");
                 foreach ($value as $customerKey => $customerData) {
                     if (in_array("card_" . $customerKey, $allowed)) {
                         $sqlData[] = "card_" . $customerKey . " = ?";
                         $varData[] = $customerData;
                     }
                 }
                 //Flag the curl request as processed/deleted.
                 $query = "UPDATE user_subscriptions \n\t\t\t\t\t\t\t\t  SET " . implode(",", $sqlData) . "\t\n\t\t\t\t\t\t\t\t  WHERE chargebee_id = ?";
                 $stmt = $this->sql->link->prepare($query);
                 for ($c = 0; $c < sizeof($varData); $c++) {
                     $stmt->mbind_param('s', $varData[$c]);
                 }
                 //Bind the document id, document page num and user id.
                 $stmt->mbind_param('s', $value['customer_id']);
                 $stmt->execute();
                 break;
             case "subscription":
                 $allowed = array("subscription_plan_id", "subscription_plan_quantity", "subscription_status", "subscription_trial_start", "subscription_trial_end", "subscription_created_at", "subscription_due_invoices_count", "subscription_activated_at", "subscription_current_term_start", "subscription_current_term_end");
                 foreach ($value as $customerKey => $customerData) {
                     if (in_array("subscription_" . $customerKey, $allowed)) {
                         $sqlData[] = "subscription_" . $customerKey . " = ?";
                         $varData[] = $customerData;
                     }
                 }
                 //Flag the curl request as processed/deleted.
                 $query = "UPDATE user_subscriptions \n\t\t\t\t\t\t\t\t  SET " . implode(",", $sqlData) . "\t\n\t\t\t\t\t\t\t\t  WHERE chargebee_id = ?";
                 $stmt = $this->sql->link->prepare($query);
                 for ($c = 0; $c < sizeof($varData); $c++) {
                     $stmt->mbind_param('s', $varData[$c]);
                 }
                 //Bind the document id, document page num and user id.
                 $stmt->mbind_param('s', $value['id']);
                 $stmt->execute();
                 break;
             default:
                 break;
         }
     }
     require '../php/chargebee/ChargeBee.php';
     ChargeBee_Environment::configure("rocketmailmerge", "1opwNtcdAXu19XWee9cdCFe6E3FfYcCvUF");
     switch ($inData['event_type']) {
         //Reactivate free trial accounts when the free trial runs out and is killed by chargebee
         case "subscription_canceled_no_card":
             $returnResults = array();
             $subscriptionID = $inData['content']['subscription']['id'];
             $subscriptionPlanID = $inData['content']['subscription']['plan_id'];
             $cardStatus = $inData['content']['customer']['card_status'];
             $trialEnd = $inData['content']['subscription']['trial_end'];
             $currentTermStart = $inData['content']['subscription']['current_term_start'];
             //The free trial has expired. Reactivate their account.
             if ($subscriptionPlanID == "free" && $cardStatus == "no_card") {
                 $result = ChargeBee_Subscription::reactivate($subscriptionID);
                 //Locate the user's page usage.
                 $query = "SELECT user_subscriptions.chargebee_id, user_subscriptions.user_id, user_statistics.billing_cycle_pages, subscription_plans.included_pages\n\t\t\t\t\t\t\t\tFROM user_subscriptions\n\t\t\t\t\t\t\t\tLEFT JOIN user_statistics ON user_subscriptions.user_id = user_statistics.user_id\n\t\t\t\t\t\t\t\tLEFT JOIN subscription_plans ON user_subscriptions.subscription_plan_id = subscription_plans.plan_name\n\t\t\t\t\t\t\t\tWHERE user_subscriptions.chargebee_id =  ?";
                 $stmt = $this->sql->link->prepare($query);
                 if (!$stmt) {
                     die('Invalid query: ' . $this->sql->link->error);
                 } else {
                     $stmt->bind_param('s', $subscriptionID);
                     $resultFromExec = $stmt->execute();
                     $stmt->store_result();
                     stmt_bind_assoc($stmt, $returnResults);
                     // loop through all result rows
                     while ($stmt->fetch()) {
                         foreach ($returnResults as $key => $value) {
                             $row_tmb[$key] = $value;
                         }
                         $data = $row_tmb;
                     }
                 }
                 $userID = $data['user_id'];
                 //Reset the user statistics back to 0.
                 $query = "UPDATE user_statistics SET billing_cycle_logins = 0, billing_cycle_documents = 0, billing_cycle_pages = 0\n\t\t\t\t\t\t\t  WHERE user_id = ?";
                 $stmt = $this->sql->link->prepare($query);
                 if (!$stmt) {
                     die('Invalid query: ' . $this->sql->link->error);
                 } else {
                     $stmt->bind_param('i', $userID);
                     $resultFromExec = $stmt->execute();
                 }
             }
             break;
         case "invoice_created":
             echo "Invoice Created!";
             $returnResults = array();
             $invoiceID = $inData['content']['invoice']['id'];
             $subscriptionID = $inData['content']['invoice']['subscription_id'];
             $result = ChargeBee_Subscription::retrieve($subscriptionID);
             $subscription = $result->subscription();
             $addonName = $subscription->__get('planId') . "_extra_pages";
             //build out of the name of their plan + '_extra_pages'
             //Locate the user's page usage.
             $query = "SELECT user_subscriptions.chargebee_id, user_subscriptions.user_id, user_statistics.billing_cycle_pages, subscription_plans.included_pages\n\t\t\t\t\t\t\tFROM user_subscriptions\n\t\t\t\t\t\t\tLEFT JOIN user_statistics ON user_subscriptions.user_id = user_statistics.user_id\n\t\t\t\t\t\t\tLEFT JOIN subscription_plans ON user_subscriptions.subscription_plan_id = subscription_plans.plan_name\n\t\t\t\t\t\t\tWHERE user_subscriptions.chargebee_id =  ?";
             $stmt = $this->sql->link->prepare($query);
             if (!$stmt) {
                 die('Invalid query: ' . $this->sql->link->error);
             } else {
                 $stmt->bind_param('s', $subscriptionID);
                 $resultFromExec = $stmt->execute();
                 $stmt->store_result();
                 stmt_bind_assoc($stmt, $returnResults);
                 // loop through all result rows
                 while ($stmt->fetch()) {
                     foreach ($returnResults as $key => $value) {
                         $row_tmb[$key] = $value;
                     }
                     $data = $row_tmb;
                 }
             }
             $userID = $data['user_id'];
             //Calculate how many pages over their included subscription pages they've used.
             $billingCyclePages = $data['billing_cycle_pages'];
             if (!is_numeric($data['billing_cycle_pages'])) {
                 $billingCyclePages = 0;
             }
             $billingCyclePages = $billingCyclePages - $data['included_pages'];
             //Add the extra pages used by the user to the invoice, if > 0
             if ($billingCyclePages > 0) {
                 $result = ChargeBee_Invoice::addAddonCharge($invoiceID, array("addon_id" => $addonName, "addon_quantity" => $billingCyclePages));
             }
             //Reset the user statistics back to 0.
             $query = "UPDATE user_statistics SET billing_cycle_logins = 0, billing_cycle_documents = 0, billing_cycle_pages = 0\n\t\t\t\t\t\t  WHERE user_id = ?";
             $stmt = $this->sql->link->prepare($query);
             if (!$stmt) {
                 die('Invalid query: ' . $this->sql->link->error);
             } else {
                 $stmt->bind_param('i', $userID);
                 $resultFromExec = $stmt->execute();
             }
             //Close the invoice and charge the customer.
             $result = ChargeBee_Invoice::collect($invoiceID);
             //$invoice = $result->invoice();
             break;
         case "subscription_renewed":
             break;
             //Fired when a user reactivates their subscription. Clear the counters for paid accounts.
         //Fired when a user reactivates their subscription. Clear the counters for paid accounts.
         case "subscription_reactivated":
             $returnResults = array();
             $subscriptionID = $inData['content']['subscription']['id'];
             $subscriptionPlanID = $inData['content']['subscription']['plan_id'];
             //Locate the user's page usage.
             $query = "SELECT user_subscriptions.chargebee_id, user_subscriptions.user_id, user_statistics.billing_cycle_pages, subscription_plans.included_pages\n\t\t\t\t\t\t\tFROM user_subscriptions\n\t\t\t\t\t\t\tLEFT JOIN user_statistics ON user_subscriptions.user_id = user_statistics.user_id\n\t\t\t\t\t\t\tLEFT JOIN subscription_plans ON user_subscriptions.subscription_plan_id = subscription_plans.plan_name\n\t\t\t\t\t\t\tWHERE user_subscriptions.chargebee_id =  ?";
             $stmt = $this->sql->link->prepare($query);
             if (!$stmt) {
                 die('Invalid query: ' . $this->sql->link->error);
             } else {
                 $stmt->bind_param('s', $subscriptionID);
                 $resultFromExec = $stmt->execute();
                 $stmt->store_result();
                 stmt_bind_assoc($stmt, $returnResults);
                 // loop through all result rows
                 while ($stmt->fetch()) {
                     foreach ($returnResults as $key => $value) {
                         $row_tmb[$key] = $value;
                     }
                     $data = $row_tmb;
                 }
             }
             $userID = $data['user_id'];
             //Reset the usage for free accounts.
             if ($subscriptionPlanID != "free") {
                 //Reset the user statistics back to 0.
                 $query = "UPDATE user_statistics SET billing_cycle_logins = 0, billing_cycle_documents = 0, billing_cycle_pages = 0\n\t\t\t\t\t\t\t  WHERE user_id = ?";
                 $stmt = $this->sql->link->prepare($query);
                 if (!$stmt) {
                     die('Invalid query: ' . $this->sql->link->error);
                 } else {
                     $stmt->bind_param('i', $userID);
                     $resultFromExec = $stmt->execute();
                 }
             }
             break;
             //Terminate free trial accounts when the free trial runs out.
         //Terminate free trial accounts when the free trial runs out.
         case "subscription_activated":
             $returnResults = array();
             $subscriptionID = $inData['content']['subscription']['id'];
             $subscriptionPlanID = $inData['content']['subscription']['plan_id'];
             $cardStatus = $inData['content']['customer']['card_status'];
             $trialEnd = $inData['content']['subscription']['trial_end'];
             $currentTermStart = $inData['content']['subscription']['current_term_start'];
             //The free trial has expired. Cancel their account.
             //if($subscriptionPlanID == "free" && $cardStatus == "no_card" && ($trialEnd == $currentTermStart)) {
             //	$result = ChargeBee_Subscription::cancel($subscriptionID);
             //}
             break;
         default:
             break;
     }
 }
function createSubscription($firstName, $lastName, $email)
{
    $plan = createPlan("Basic", "basic", 1000, 15);
    $createSubscriptionParam = array("plan_id" => $plan->id, "id" => $email, "customer[first_name]" => $firstName, "customer[last_name]" => $lastName, "customer[email]" => $email);
    try {
        $result = ChargeBee_Subscription::create($createSubscriptionParam);
        return $result;
    } catch (ChargeBee_InvalidRequestException $e) {
        if ($e->getApiErrorCode() == "duplicate_entry" && $e->getParam() != null && $e->getParam() == "id") {
            $result = ChargeBee_Subscription::retrieve($email);
            return $result;
        } else {
            throw $e;
        }
    }
}
Esempio n. 10
0
 * Adding ChargeBee php libraries
 */
require_once dirname(__FILE__) . "/Config.php";
require_once dirname(__FILE__) . "/Util.php";
require_once dirname(__FILE__) . "/ErrorHandler.php";
/*
 * Demo on how to use Stripe Pop up to get the customer card information
 * and create a subscription in ChargeBee using the same stripe token.
 */
if ($_POST) {
    validateParameters($_POST);
    $planId = "basic";
    try {
        /*
         * Passing StripeToken, customer information, shipping information and plan id
         * to the ChargeBee create Subscription API.
         */
        $result = ChargeBee_Subscription::create(array("planId" => $planId, "customer" => $_POST['customer'], "card" => array("tmpToken" => $_POST['stripeToken']), "shippingAddress" => $_POST['shipping_address']));
        $jsonResp = array("forward" => "thankyou.html");
        print json_encode($jsonResp);
    } catch (ChargeBee_PaymentException $e) {
        handleTempTokenErrors($e);
    } catch (ChargeBee_InvalidRequestException $e) {
        handleInvalidRequestErrors($e, "plan_id");
    } catch (Exception $e) {
        handleGeneralErrors($e);
    }
}
?>

function fetchSubscription()
{
    $subscriptionId = $_POST['subscription_id'];
    if (empty($subscriptionId)) {
        return false;
    }
    try {
        $result = ChargeBee_Subscription::retrieve($subscriptionId);
        session_start();
        $_SESSION['subscription_id'] = $result->subscription()->id;
        $_SESSION['customer_id'] = $result->customer()->id;
        return true;
    } catch (ChargeBee_APIError $e) {
        if ($e->getApiErrorCode() == "resource_not_found") {
            return false;
        }
        throw $e;
    }
}
    /*
     * Calling ChargeBee Create Subscription API to create a new subscription
     * in ChargeBee for the passed plan ID and customer attributes. 
     * Additionally you can send the custom field parameters created for your
     * ChargeBee site.
     * 
     * To create custom field for your site go to Settings-> Request Custom Field
     * and fill the request form.
     * 
     * For demo puropose plan with id 'basic' is hard coded here.
     * 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.
     *               
     */
    $customer = $_POST["customer"];
    $customer["cf_date_of_birth"] = $dob;
    $result = ChargeBee_Subscription::create(array("plan_id" => "basic", "customer" => $customer));
    /*
     * Forwarding to thank you page after subscription created successfully.
     */
    $subscription = $result->subscription();
    $queryParameters = "subscription_id=" . urlencode($subscription->id);
    $jsonResp["forward"] = "thankyou?" . $queryParameters;
    echo json_encode($jsonResp, true);
} catch (ChargeBee_InvalidRequestException $e) {
    handleInvalidRequestErrors($e, "plan_id");
} catch (Exception $e) {
    handleGeneralErrors($e);
}
Esempio n. 13
0
 public function requestPlanChange($inData)
 {
     $userID = $this->session->get_user_var('id');
     $plans = array('free', 'contractor', 'professional', 'small_business', 'office', 'enterprise', 'cancel', 'reactivate', 'card_update');
     if (in_array($inData['plan'], $plans)) {
         /**************
          * Locate user'S SUBSCRIPTION ID
          *****************************/
         $row_tmb = array();
         $data = array();
         $query = "SELECT chargebee_id\n\t\t\t\t\t  FROM user_subscriptions\n\t\t\t\t\t  WHERE user_id = ?";
         $stmt = $this->sql->link->prepare($query);
         if (!$stmt) {
             die('Invalid query: ' . $this->sql->link->error);
         } else {
             $stmt->bind_param('i', $userID);
             $resultFromExec = $stmt->execute();
             $stmt->store_result();
             stmt_bind_assoc($stmt, $returnResults);
             // loop through all result rows
             while ($stmt->fetch()) {
                 foreach ($returnResults as $key => $value) {
                     $row_tmb[$key] = $value;
                 }
                 $data = $row_tmb;
             }
         }
         try {
             ChargeBee_Environment::configure("rocketmailmerge", "1opwNtcdAXu19XWee9cdCFe6E3FfYcCvUF");
             switch ($inData['plan']) {
                 case "card_update":
                     $result = ChargeBee_HostedPage::updateCard(array("customer" => array("id" => $data['chargebee_id'])));
                     $hostedPage = $result->hostedPage();
                     $output['success'] = 1;
                     $output['text'] = "Successfully fetched the card update page.";
                     $output['url'] = $hostedPage->__get('url');
                     $output['return'] = 1;
                     break;
                 case "cancel":
                     $result = ChargeBee_Subscription::cancel($data['chargebee_id'], array("end_of_term" => 'true'));
                     $subscription_status = $result->subscription()->__get('status');
                     $query = "UPDATE user_subscriptions set subscription_status = ?\n\t\t\t\t\t\t\t\t  WHERE user_id = ?";
                     $stmt = $this->sql->link->prepare($query);
                     if (!$stmt) {
                         die('Invalid query: ' . $this->sql->link->error);
                     } else {
                         $stmt->bind_param('si', $subscription_status, $userID);
                         $resultFromExec = $stmt->execute();
                     }
                     $output['success'] = 1;
                     $output['text'] = "Successfully cancelled your subscription.";
                     $output['return'] = 4;
                     break;
                 case "reactivate":
                     $result = ChargeBee_Subscription::reactivate($data['chargebee_id']);
                     $subscription_status = $result->subscription()->__get('status');
                     $query = "UPDATE user_subscriptions set subscription_status = ?\n\t\t\t\t\t\t\t\t  WHERE user_id = ?";
                     $stmt = $this->sql->link->prepare($query);
                     if (!$stmt) {
                         die('Invalid query: ' . $this->sql->link->error);
                     } else {
                         $stmt->bind_param('si', $subscription_status, $userID);
                         $resultFromExec = $stmt->execute();
                     }
                     $output['success'] = 1;
                     $output['text'] = "Successfully reactivated your subscription.";
                     $output['return'] = 5;
                     break;
                 case "free":
                     $this->fetchDashboardData();
                     if ($this->outData['totals']['document_count'] <= 3 && $this->outData['totals']['document_count'] <= 3 && $this->outData['totals']['document_count'] <= 3) {
                         $result = ChargeBee_Subscription::update($data['chargebee_id'], array("planId" => "free"));
                         $output['success'] = 1;
                         $output['text'] = "Successfully updated your account to free.";
                         $output['return'] = 2;
                     } else {
                         $output['success'] = 1;
                         $output['text'] = "Your account does not meet the criteria for the free subscription.";
                         $output['return'] = 6;
                     }
                     break;
                 default:
                     $result = ChargeBee_HostedPage::checkoutExisting(array("subscription" => array("id" => $data['chargebee_id'], "planId" => $inData['plan'])));
                     $hostedPage = $result->hostedPage();
                     $output['success'] = 1;
                     $output['text'] = "Successfully fetched the plan change page.";
                     $output['url'] = $hostedPage->__get('url');
                     $output['return'] = 1;
                     break;
             }
             $this->outData = $output;
             return $output;
         } catch (Exception $e) {
             $output['success'] = 0;
             $output['text'] = "Unable to fetch the plan change page.";
             $output['return'] = 3;
             $this->outData = $output;
             return $output;
         }
     }
 }
Esempio n. 14
0
<?php

require_once dirname(__FILE__) . "/../php_src/Config.php";
require_once dirname(__FILE__) . '/../php_src/Util.php';
require_once '../partials/header.php';
$id = $_GET["customer_id"];
$subscriptionDetail = ChargeBee_Subscription::retrieve($id);
?>
<script type="text/javascript">
    $(document).ready(function(){
        $('.update_msg').show();
        setTimeout(function(){$('.update_msg').slideUp();},2000);
    });       
</script>
<br>
    <div id="cb-demo-ssp">
     <?php 
if (isset($_GET["updated"]) && !is_null($_GET["updated"])) {
    ?>
          <div class="update_msg text-center">
            <p class="alert alert-success">
              <span class="glyphicon glyphicon-ok-sign"></span> Your card details have been saved successfully.
                      </p>
          </div> 
    <?php 
}
?>
        <h2>
            <a align="right" href="/update_payment_method" class="pull-right btn btn-danger">
					<span class="glyphicon glyphicon-off"></span> 
					log out 
Esempio n. 15
0
<?php

require_once '../partials/header.php';
require_once dirname(__FILE__) . '/../php_src/Util.php';
$result = ChargeBee_Subscription::retrieve($_GET['subscription_id']);
?>
<h1 class="text-center" style="font-size: 50px; margin: 40px;"> You have been successfully subscribed. </h1>
<div class="col-sm-8 col-sm-offset-2 cb-spacing-bottom">

             <?php 
if ($result->subscription()->status == "in_trial") {
    ?>
                  <span class="text-muted lead"> Your current subscription trial will end on  </span>
                  <span class="lead">
                  <?php 
    echo date('m/d/y', $result->subscription()->trialEnd);
    ?>
                  </span>
             <?php 
} else {
    if ($result->subscription()->status = "active") {
        ?>
                  <span class="text-muted lead"> Your subscription will be renewed on </span>
                  <span class="lead">
                       <?php 
        echo date('m/d/y', $result->subscription()->currentTermEnd);
        ?>
                  </span>
                   <br>
                  <?php 
        if ($result->subscription->remainingBillingCycles != null) {