Scalr_Billing::changePackage PHP Method

changePackage() public method

public changePackage ( $newPackage )
    public function changePackage($newPackage)
    {
        $info = $this->getInfo();
        $includeTrial = false;
        if ($info['realState'] == 'Trialing') {
            $includeTrial = true;
        }
        $this->chargify->upgradeSubscription($this->subscriptionId, $newPackage, $includeTrial);
        $this->setPackage($newPackage);
        return true;
    }

Usage Example

Example #1
0
 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");
     }
 }
All Usage Examples Of Scalr_Billing::changePackage