public function xChangePlanAction()
{
if (!$this->getParam('package')) {
$this->response->failure("z");
}
if ($this->billing->package == $this->getParam('package')) {
$this->response->success();
}
if ($this->getParam('package') == 'cancel') {
if ($this->billing->subscriptionId) {
$this->billing->cancelSubscription();
}
$this->response->success("Subscription cancelled: Scalr has STOPPED managing your instances. You can reactivate your account at any time.");
return;
}
if ($this->billing->subscriptionId) {
$this->billing->changePackage($this->getParam('package'));
$this->response->success("Subscription successfully updated");
} else {
if (!$this->getParam('postalCode')) {
$this->response->failure("Billing postal code is required");
exit;
}
$this->billing->createSubscription($this->getParam('package'), $this->getParam('ccNumber'), $this->getParam('ccExpMonth'), $this->getParam('ccExpYear'), $this->getParam('ccCvv'), $this->getParam('firstName'), $this->getParam('lastName'), $this->getParam('postalCode'));
$this->response->success("Subscription successfully created");
}
}