public function createSubscription($package, $ccNumber, $ccExpMonth, $ccExpYear, $ccCvv, $fName = "", $lName = "", $postalCode = "")
{
if (!$this->subscriptionId) {
if (!$this->customerId) {
if ($fName == "" && $lName == "") {
$c = explode(" ", $this->account->getOwner()->fullname);
$fName = array_shift($c);
$lName = implode(" ", $c);
}
$clientInfo = array('email' => $this->account->getOwner()->getEmail(), 'org' => $this->account->name, 'first_name' => $fName, 'last_name' => $lName);
} else {
$clientInfo = false;
}
$subscription = $this->chargify->createSubscription($this->account->id, $package, $ccNumber, $ccExpMonth, $ccExpYear, $ccCvv, $clientInfo, $postalCode);
$this->account->setSetting(self::SETTING_CGF_SID, $subscription['subscription']['id']);
$this->account->setSetting(self::SETTING_CGF_CID, $subscription['subscription']['customer']['id']);
$this->account->setSetting(self::SETTING_PACKAGE, $package);
$this->account->status = Scalr_Account::STATUS_ACTIVE;
$this->account->save();
$this->setLimits($package);
return true;
} else {
throw new Exception("Account already have subscription");
}
}