public static function planUpgradeDowngrade($subId, $addRatePlanId, $chargeAndQty, $removeRatePlanId, $invoice, $previewOpt) { $removedRatePlan = Amender::removeRatePlan($subId, $removeRatePlanId, $invoice, $previewOpt); $addedRatePlan = Amender::addRatePlan($subId, $addRatePlanId, $chargeAndQty, $previewOpt); $amendResult = array("addedPlanResult" => $addedRatePlan, "removedPlanResult" => $removedRatePlan); return $amendResult; }
function removeRatePlan() { global $messages; $rpId = $_REQUEST['rpId']; $subId = $_REQUEST['subId']; $invoice = true; $preview = false; $amRes = Amender::removeRatePlan($subId, $rpId, $invoice, $preview); if (!$amRes->results->Success) { addErrors(null, "Unable to remove Rate Plan"); return; } $messages = $amRes; }
function test_Amender_removeRatePlan() { global $EXISTING_CUSTOMER_ACCOUNT_NAME; printResultStart(__FUNCTION__); $messages = array(); try { //Get the Rateplan ID of one of the active plans on this user's subscription $sub = SubscriptionManager::getCurrentSubscriptions($EXISTING_CUSTOMER_ACCOUNT_NAME); $rpId = $sub->active_plans[0]->Id; echo "Removing '" . $sub->active_plans[0]->ProductName . " : " . $sub->active_plans[0]->Name . "' from subscription on account '" . $EXISTING_CUSTOMER_ACCOUNT_NAME . "'<br>"; //Test $amRes = Amender::removeRatePlan($EXISTING_CUSTOMER_ACCOUNT_NAME, $rpId, false); print_r_html($amRes); if ($amRes->results->Success) { echo "<br>RemoveProduct amendment successfully created.<br>"; $zapi = new zApi(); echo "Deleting created amendment.<br>"; $deleteResult = $zapi->zDelete(array($amRes->results->AmendmentIds), 'Amendment'); print_r_html($deleteResult); } } catch (Exception $e) { array_push($messages, $e->getMessage()); } printResultEnd($messages); }