function createPlan($name, $id, $price, $trialPeriod = null)
{
    $createPlanArray = array("name" => $name, "id" => $id, "invoice_name" => $name, "price" => $price);
    if ($trialPeriod != null) {
        $createPlanArray['trial_period'] = $trialPeriod;
        $createPlanArray['trial_period_unit'] = "day";
    }
    try {
        $result = ChargeBee_Plan::create($createPlanArray);
        return $result->plan();
    } catch (ChargeBee_InvalidRequestException $e) {
        if ($e->getApiErrorCode() == "duplicate_entry" && $e->getParam() != null && $e->getParam() == "id") {
            $result = ChargeBee_Plan::retrieve($id);
            return $result->plan();
        } else {
            throw $e;
        }
    }
}
Example #2
0
                </div>
                <div class="row">
                  <label class="col-xs-5 control-label">Phone</label>
                  <div class="col-xs-7">
                    <p class="form-control-static"> 
						<?php 
echo esc($subscriptionDetail->customer()->phone);
?>
					</p>
                  </div>
                </div> 
            </div>
        </div>
        <h3 class="page-header">Subscription Information</h3>                                                        
        <?php 
$planDetail = ChargeBee_Plan::retrieve($subscriptionDetail->subscription()->planId);
$plan = $planDetail->plan();
?>
        <div class="row form-horizontal">
            <div class="col-sm-6">
                 <div class="row">
                  <label class="col-xs-5 control-label"> Plan Status</label>
                  <div class="col-xs-7">
                    <p class="form-control-static"> 
                        <span class="label-<?php 
echo $subscriptionDetail->subscription()->status;
?>
">
                            <?php 
echo esc($subscriptionDetail->subscription()->status);
?>