SAAS-973: Airtime Billing page - Add support for August promotion plans

created promo-eligibility-check endpoint
This commit is contained in:
drigato 2015-07-29 08:10:05 -04:00
parent bda6a4585c
commit 4d9fb27554
2 changed files with 37 additions and 1 deletions

View File

@ -10,6 +10,7 @@ class BillingController extends Zend_Controller_Action {
//Two of the actions in this controller return JSON because they're used for AJAX:
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('vat-validator', 'json')
->addActionContext('promo-eligibility-check', 'json')
->addActionContext('is-country-in-eu', 'json')
->initContext();
}
@ -19,6 +20,22 @@ class BillingController extends Zend_Controller_Action {
$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();
Logging::info($data);
//Set the return JSON value
$this->_helper->json(array("result"=>"ok"));
}
public function upgradeAction()
{
$CC_CONFIG = Config::getConfig();
@ -29,9 +46,13 @@ class BillingController extends Zend_Controller_Action {
$request = $this->getRequest();
$form = new Application_Form_BillingUpgradeDowngrade();
if ($request->isPost()) {
$doUpgrade = false;
$formData = $request->getPost();
if ($form->isValid($formData)) {
Logging::info($formData);
if ($doUpgrade && $form->isValid($formData)) {
Logging::info("---upgrading----");
$credentials = Billing::getAPICredentials();
//Check if VAT should be applied or not to this invoice.

View File

@ -120,6 +120,19 @@ function configureByCountry(countryCode)
});
}
function promoEligibilityCheck()
{
var newproductid = $("input[type='radio'][name='newproductid']:checked");
var newproductbillingcycle = $("input[type='radio'][name='newproductbillingcycle']:checked");
console.log(newproductid.val());
console.log(newproductbillingcycle.val());
$.post("/billing/promo-eligibility-check", {"newproductid": newproductid,
"newproductbillingcycle": newproductbillingcycle})
.success(function(data) {
console.log(data);
});
}
$(document).ready(function() {
configureByCountry($("#country").val());
@ -128,9 +141,11 @@ $(document).ready(function() {
$("input[name='newproductid']").change(function() {
validatePlan();
recalculateTotals();
promoEligibilityCheck();
});
$("input[name='newproductbillingcycle']").change(function() {
recalculateTotals();
promoEligibilityCheck();
});
$("#country").change(function() {