SAAS-976: September 1st: Undo the billing page changes for the August promotion
This commit is contained in:
parent
17074e5f70
commit
fa340c3e30
|
@ -329,150 +329,4 @@ class Billing
|
||||||
$result = Billing::makeRequest($credentials["url"], $query_string);
|
$result = Billing::makeRequest($credentials["url"], $query_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of the current Airtime Pro plan IDs.
|
|
||||||
* This excludes any old, free, promotional, or custom plans.
|
|
||||||
*/
|
|
||||||
public static function getCurrentPaidProductIds()
|
|
||||||
{
|
|
||||||
$products = self::getProducts();
|
|
||||||
$productIds = array();
|
|
||||||
foreach ($products as $k => $p) {
|
|
||||||
array_push($productIds, $p["pid"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $productIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of the Awesome August 2015 Promotional plans
|
|
||||||
*/
|
|
||||||
public static function getAwesomeAugustPromoProducts()
|
|
||||||
{
|
|
||||||
$credentials = self::getAPICredentials();
|
|
||||||
|
|
||||||
$postfields = array();
|
|
||||||
$postfields["username"] = $credentials["username"];
|
|
||||||
$postfields["password"] = md5($credentials["password"]);
|
|
||||||
$postfields["action"] = "getproducts";
|
|
||||||
$postfields["responsetype"] = "json";
|
|
||||||
//gid is the Airtime product group id on whmcs
|
|
||||||
$postfields["gid"] = WHMCS_AIRTIME_GROUP_ID;
|
|
||||||
|
|
||||||
$query_string = "";
|
|
||||||
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";
|
|
||||||
|
|
||||||
$result = self::makeRequest($credentials["url"], $query_string);
|
|
||||||
$promoProducts = $result["products"]["product"];
|
|
||||||
|
|
||||||
foreach ($promoProducts as $k => $p) {
|
|
||||||
if (strpos($p["name"], "Awesome August 2015") === false) {
|
|
||||||
unset($promoProducts[$k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $promoProducts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the eligible promo plan ID that corresponds to the regular paid plan.
|
|
||||||
*
|
|
||||||
* i.e. if the client wants to upgrade to the Plus plan this function returns the
|
|
||||||
* plan id of the Awesome August 2015 Plus plan.
|
|
||||||
*/
|
|
||||||
public static function getEligibleAwesomeAugustPromoPlanId($productName)
|
|
||||||
{
|
|
||||||
$promoPlans = self::getAwesomeAugustPromoProducts();
|
|
||||||
$promoPlanId = "";
|
|
||||||
|
|
||||||
foreach($promoPlans as $k => $p) {
|
|
||||||
if (strpos($p["name"], $productName) !== false) {
|
|
||||||
$promoPlanId = $p["pid"];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $promoPlanId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getProductName($productId)
|
|
||||||
{
|
|
||||||
$products = self::getProducts();
|
|
||||||
$productName = "";
|
|
||||||
|
|
||||||
foreach($products as $k => $p) {
|
|
||||||
if ($p["pid"] == $productId) {
|
|
||||||
$productName = $p["name"];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $productName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isClientEligibleForPromo($newProductId, $newProductBillingCycle)
|
|
||||||
{
|
|
||||||
// use this to check if client is upgrading from an old plan
|
|
||||||
$currentPaidPlanProductIds = self::getCurrentPaidProductIds();
|
|
||||||
|
|
||||||
$currentPlanProduct = self::getClientCurrentAirtimeProduct();
|
|
||||||
$currentPlanProductId = $currentPlanProduct["pid"];
|
|
||||||
$currentPlanBillingCycle = strtolower($currentPlanProduct["billingcycle"]);
|
|
||||||
|
|
||||||
if (self::isClientOnAwesomeAugustPromoPlan($currentPlanProductId)) {
|
|
||||||
|
|
||||||
$newEligiblePromoId = self::getEligibleAwesomeAugustPromoPlanId(
|
|
||||||
self::getProductName($newProductId)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($newProductBillingCycle == "annually" || $newEligiblePromoId > $currentPlanProductId) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if client is on trial plan, YES
|
|
||||||
if ($currentPlanProductId == AIRTIME_PRO_FREE_TRIAL_PLAN_ID) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if client is currently on monthly or annually or old/free plan AND (upgrading OR upgrading/downgrading to annual plan), YES
|
|
||||||
if ($currentPlanBillingCycle == "monthly" || $currentPlanBillingCycle == "free account"
|
|
||||||
|| $currentPlanBillingCycle == "annually") {
|
|
||||||
// is the client changing billing cycle to annual?
|
|
||||||
if ($newProductBillingCycle == "annually") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is the client staying on monthly and upgrading?
|
|
||||||
// This won't hold true if the client is on an old/free plan because the
|
|
||||||
// old/free plan ids are higher than the current paid plan ids.
|
|
||||||
if ($newProductBillingCycle == "monthly" && $newProductId > $currentPlanProductId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is the client staying on monthly and upgrading from an old plan?
|
|
||||||
if ($newProductBillingCycle == "monthly" && !in_array($currentPlanProductId, $currentPaidPlanProductIds)
|
|
||||||
&& in_array($newProductId, $currentPaidPlanProductIds)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isClientOnAwesomeAugustPromoPlan($currentPlanId)
|
|
||||||
{
|
|
||||||
$promoPlans = self::getAwesomeAugustPromoProducts();
|
|
||||||
|
|
||||||
foreach ($promoPlans as $k => $p) {
|
|
||||||
if ($p["pid"] == $currentPlanId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ class BillingController extends Zend_Controller_Action {
|
||||||
//Two of the actions in this controller return JSON because they're used for AJAX:
|
//Two of the actions in this controller return JSON because they're used for AJAX:
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext->addActionContext('vat-validator', 'json')
|
$ajaxContext->addActionContext('vat-validator', 'json')
|
||||||
->addActionContext('promo-eligibility-check', 'json')
|
|
||||||
->addActionContext('is-country-in-eu', 'json')
|
->addActionContext('is-country-in-eu', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
@ -20,33 +19,6 @@ class BillingController extends Zend_Controller_Action {
|
||||||
$this->_redirect('billing/upgrade');
|
$this->_redirect('billing/upgrade');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function promoEligibilityCheckAction()
|
|
||||||
{
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$request = $this->getRequest();
|
|
||||||
if (!$request->isPost()) {
|
|
||||||
throw new Exception("Must POST data to promoEligibilityCheckAction.");
|
|
||||||
}
|
|
||||||
$data = $request->getPost();
|
|
||||||
|
|
||||||
$current_namespace = new Zend_Session_Namespace('csrf_namespace');
|
|
||||||
$observed_csrf_token = $this->_getParam('csrf_token');
|
|
||||||
$expected_csrf_token = $current_namespace->authtoken;
|
|
||||||
|
|
||||||
if($observed_csrf_token == $expected_csrf_token) {
|
|
||||||
$eligible = Billing::isClientEligibleForPromo(
|
|
||||||
$data["newproductid"], $data["newproductbillingcycle"]);
|
|
||||||
|
|
||||||
//Set the return JSON value
|
|
||||||
$this->_helper->json(array("result"=>$eligible));
|
|
||||||
} else {
|
|
||||||
$this->getResponse()->setHttpResponseCode(403);
|
|
||||||
$this->_helper->json(array("result"=>false, "error"=>"CSRF token did not match."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function upgradeAction()
|
public function upgradeAction()
|
||||||
{
|
{
|
||||||
$CC_CONFIG = Config::getConfig();
|
$CC_CONFIG = Config::getConfig();
|
||||||
|
@ -63,14 +35,6 @@ class BillingController extends Zend_Controller_Action {
|
||||||
|
|
||||||
if ($form->isValid($formData)) {
|
if ($form->isValid($formData)) {
|
||||||
|
|
||||||
// Check if client is eligible for promo and update the new product id if so
|
|
||||||
$eligibleForPromo = Billing::isClientEligibleForPromo(
|
|
||||||
$formData["newproductid"], $formData["newproductbillingcycle"]);
|
|
||||||
if ($eligibleForPromo) {
|
|
||||||
$newProductName = Billing::getProductName($formData["newproductid"]);
|
|
||||||
$formData["newproductid"] = Billing::getEligibleAwesomeAugustPromoPlanId($newProductName);
|
|
||||||
}
|
|
||||||
|
|
||||||
$credentials = Billing::getAPICredentials();
|
$credentials = Billing::getAPICredentials();
|
||||||
|
|
||||||
//Check if VAT should be applied or not to this invoice.
|
//Check if VAT should be applied or not to this invoice.
|
||||||
|
|
|
@ -120,30 +120,6 @@ function configureByCountry(countryCode)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function promoEligibilityCheck()
|
|
||||||
{
|
|
||||||
var newproductid = $("input[type='radio'][name='newproductid']:checked").val();
|
|
||||||
|
|
||||||
// newproductid can be undefined if the client is currently on an old plan
|
|
||||||
// and they just change the billing cycle value without selecting a new plan type.
|
|
||||||
// In this case, let's not check if they are eligible for the promo because
|
|
||||||
// they won't be able to upgrade without selecting a new plan first.
|
|
||||||
if (newproductid === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var newproductbillingcycle = $("input[type='radio'][name='newproductbillingcycle']:checked").val();
|
|
||||||
|
|
||||||
$.post("/billing/promo-eligibility-check", {"newproductid": newproductid,
|
|
||||||
"newproductbillingcycle": newproductbillingcycle, "csrf_token": $("#csrf").attr('value')})
|
|
||||||
.success(function(data) {
|
|
||||||
if (data.result == true) {
|
|
||||||
$("#promo-plan-eligible").show();
|
|
||||||
} else if ($("#promo-plan-eligible").is(":visible")) {
|
|
||||||
$("#promo-plan-eligible").hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
configureByCountry($("#country").val());
|
configureByCountry($("#country").val());
|
||||||
|
@ -152,11 +128,9 @@ $(document).ready(function() {
|
||||||
$("input[name='newproductid']").change(function() {
|
$("input[name='newproductid']").change(function() {
|
||||||
validatePlan();
|
validatePlan();
|
||||||
recalculateTotals();
|
recalculateTotals();
|
||||||
promoEligibilityCheck();
|
|
||||||
});
|
});
|
||||||
$("input[name='newproductbillingcycle']").change(function() {
|
$("input[name='newproductbillingcycle']").change(function() {
|
||||||
recalculateTotals();
|
recalculateTotals();
|
||||||
promoEligibilityCheck();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#country").change(function() {
|
$("#country").change(function() {
|
||||||
|
@ -196,17 +170,13 @@ $(document).ready(function() {
|
||||||
<div class="ui-widget ui-widget-content block-shadow clearfix padded-strong billing-panel">
|
<div class="ui-widget ui-widget-content block-shadow clearfix padded-strong billing-panel">
|
||||||
<H2><?=_("Account Plans")?></H2>
|
<H2><?=_("Account Plans")?></H2>
|
||||||
<H4><?=_("Upgrade today to get more listeners and storage space!")?></H4>
|
<H4><?=_("Upgrade today to get more listeners and storage space!")?></H4>
|
||||||
<div>
|
|
||||||
<a href="https://www.airtime.pro/pricing#promo-details" target="_blank">
|
|
||||||
<img width="400px" height="133px" class="promo-banner" /></a>
|
|
||||||
</div>
|
|
||||||
<div class="pricing-grid">
|
<div class="pricing-grid">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Awesome Hobbyist</th>
|
<th>Hobbyist</th>
|
||||||
<th>Awesome Starter</th>
|
<th>Starter</th>
|
||||||
<th>Awesome Plus</th>
|
<th>Plus</th>
|
||||||
<th>Awesome Premium</th>
|
<th>Premium</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>1 Stream
|
<td>1 Stream
|
||||||
|
@ -228,40 +198,24 @@ $(document).ready(function() {
|
||||||
<td>64kbps, 128kbps, and 196kbps Stream Quality
|
<td>64kbps, 128kbps, and 196kbps Stream Quality
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="august-promo">
|
<tr>
|
||||||
<td>
|
<td>5 Listeners
|
||||||
<span>5 Listeners</span><br>
|
|
||||||
<div>10 Listeners</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>40 Listeners per stream
|
||||||
<span>40 Listeners per stream</span><br>
|
|
||||||
<div>80 Listeners per stream</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>100 Listeners per stream
|
||||||
<span>100 Listeners per stream</span><br>
|
|
||||||
<div>200 Listeners per stream</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>500 Listeners per stream
|
||||||
<span>500 Listeners per stream</span><br>
|
|
||||||
<div>1000 Listeners per stream</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="august-promo">
|
<tr>
|
||||||
<td>
|
<td>2GB Storage
|
||||||
<span>2GB Storage</span><br>
|
|
||||||
<div>4GB Storage</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>5GB Storage
|
||||||
<span>5GB Storage</span><br>
|
|
||||||
<div>10GB Storage</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>30GB Storage
|
||||||
<span>30GB Storage</span><br>
|
|
||||||
<div>60GB Storage</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>150GB Storage
|
||||||
<span>150GB Storage</span><br>
|
|
||||||
<div>300GB Storage</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -322,10 +276,6 @@ echo($currentProduct["name"]);
|
||||||
<div id="billingcycle_disclaimer">
|
<div id="billingcycle_disclaimer">
|
||||||
Save 15% on annual plans (Hobbyist plan excluded).
|
Save 15% on annual plans (Hobbyist plan excluded).
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
|
||||||
<div id="promo-plan-eligible" style="display:none;">
|
|
||||||
Congratulations, you are eligible for an Awesome Promotional Plan!
|
|
||||||
</div>
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
<div id="subtotal_box">
|
<div id="subtotal_box">
|
||||||
<b>Subtotal:</b><br>
|
<b>Subtotal:</b><br>
|
||||||
|
|
|
@ -56,8 +56,8 @@
|
||||||
border-spacing: 0px;
|
border-spacing: 0px;
|
||||||
border-collapse: separate;
|
border-collapse: separate;
|
||||||
border: 1px solid #777;
|
border: 1px solid #777;
|
||||||
width: 680px;
|
width: 600px;
|
||||||
margin-left: -140px;
|
margin-left: -100px;
|
||||||
/*background-color: #555;*/
|
/*background-color: #555;*/
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
|
@ -65,19 +65,6 @@
|
||||||
box-shadow: 0px 5px 5px rgba(0,0,0,0.5);
|
box-shadow: 0px 5px 5px rgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pricing-grid .august-promo div {
|
|
||||||
display: inline-block;
|
|
||||||
background-color: #ff611f;
|
|
||||||
padding: 3px 5px;
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-left: -5px;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pricing-grid .august-promo span {
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pricing-grid td, .pricing-grid th
|
.pricing-grid td, .pricing-grid th
|
||||||
{
|
{
|
||||||
border-bottom: 1px solid #999;
|
border-bottom: 1px solid #999;
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 49 KiB |
Loading…
Reference in New Issue