function authenticate() { if (getSubscriptionId() == null || getCustomerId() == null) { return false; } return true; }
<?php session_start(); ob_start(); if (!isset($_SESSION["user_id"])) { header("Location:/login/"); } require_once "../../inc/config.php"; require_once ROOT_PATH . "inc/database.php"; $mem_levels = array("Individual", "Family", "Steward", "Business Basic", "Business Premium"); $mem_icons = array("fa-user", "fa-users", "fa-user-plus", "fa-briefcase", "fa-briefcase"); $mem_level = $_SESSION["member_level"]; if ($_SERVER["REQUEST_METHOD"] == "POST") { $level = (int) $_POST["level"]; $subscription_id = getSubscriptionId($_SESSION["user_id"]); $cust_id = getStripeCustomerId($_SESSION["user_id"]); $cust = \Stripe\Customer::retrieve($cust_id); $subscription = $cust->subscriptions->retrieve($subscription_id); $subscription->plan = $level; $subscription->save(); $_SESSION["member_level"] = $level; enrollUser($_SESSION["user_id"], $level); $_SESSION["change_mem_level"] = true; header("Location:/user/membership/"); } else { ?> <html> <?php include ROOT_PATH . "inc/head.php"; ?> <body>
//print "Status: $result[r_approved]<br>\n"; //print "Transaction Code: $result[r_code]<br><br>\n"; setRequestInLog($orderId[0], $consumer_id, $subscriptiontype_id, $subscribertype_id, $requestXML_post, 'postauth'); setResponseInLog($orderId[0], $consumer_id, $subscriptiontype_id, $subscribertype_id, $responseStr_post, 'postauth-Response'); echo '<li> <h3>All set. Check your email for a reciept from us. Now you can use all of Techmatcher!</h3> </li>'; } } else { // else of card validation echo "Oops, your credit card was not approved. This is because the address you entered doesn't match the Credit Card issuer's records. </br>Please try again or contact our customer support team for assistance. <br><br>"; // log enteries setRequestInLog($orderId[0], $consumer_id, $subscriptiontype_id, $subscribertype_id, $requestXML, 'preauth'); setResponseInLog($orderId[0], $consumer_id, $subscriptiontype_id, $subscribertype_id, $returnString, 'preauth-Response'); } // checking id address exits if (isset($_SESSION['consumer']['itconsumername'])) { $consumer_subscription_id = getSubscriptionId($_SESSION['consumer']['itconsumer_id']); // adding addresses... if (isset($check_home_billing) && $check_home_billing == 1) { updateHomeAddress($_SESSION['consumer']['itconsumer_id'], $_POST["address1"], $_POST["address2"], $_POST["city"], $_POST["state"], $_POST["zip"], $phone); } else { $billingAddress1 = get_consumer_billing_address($_SESSION['consumer']['itconsumer_id']); if (empty($billingAddress1) || !isset($billingAddress1)) { // if not set the address in DB setBillingAddress($_SESSION['consumer']['itconsumer_id'], $_POST["address1"], $_POST["address2"], $_POST["city"], $_POST["state"], $_POST["zip"], $phone); } else { // else update the previous record updateBillingAddress($_SESSION['consumer']['itconsumer_id'], $_POST["address1"], $_POST["address2"], $_POST["city"], $_POST["state"], $_POST["zip"], $phone); } } } }
<?php require_once dirname(__FILE__) . '/../php_src/Config.php'; require_once dirname(__FILE__) . '/../php_src/Util.php'; $subscriptionId = null; $customerId = null; if (authenticate()) { $subscriptionId = getSubscriptionId(); $customerId = getCustomerId(); } else { header("Location: /ssp-php/"); return; } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <title>Self Service Portal - ChargeBee</title> <link href="/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all"> <link href="/assets/css/ssp-core.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"></script> <script type="text/javascript" src="http://malsup.github.io/jquery.form.js"></script> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js"></script> <!--[if lt IE 9]> <script src="//html5sshiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!--script src="../chargebee/respond.min.js"></script-->
<?php session_start(); ob_start(); if (!isset($_SESSION["user_id"])) { header("Location:/login/"); } require_once "../../../inc/config.php"; require_once ROOT_PATH . "inc/database.php"; $user = getUser($_GET["user_id"]); $user_id = $user["user_id"]; if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["action"] == "cancel") { $subscription_id = getSubscriptionId($user["user_id"]); $cust_id = getStripeCustomerId($user["user_id"]); $cust = \Stripe\Customer::retrieve($cust_id); $subscription = $cust->subscriptions->retrieve($subscription_id); $subscription->cancel(); $_SESSION["member_level"] = 0; enrollUser($_SESSION["user_id"], 0); $_SESSION["cancelled"] = true; header("Location:/user/membership/cancel/"); } if ($_POST["action"] == "return") { header("Location:/admin/users/edit/membership/" . $user["user_id"] . "/"); } } ?> <html> <?php include ROOT_PATH . "inc/head.php";
function subscriptionCancel() { $subscriptionId = getSubscriptionId(); $cancelStatus = $_POST['cancel_status']; $params = array(); if ($cancelStatus == "cancel_on_next_renewal") { $params['end_of_term'] = 'true'; } $result = ChargeBee_Subscription::cancel($subscriptionId, $params); header("Location: subscription"); }