protected function uri() { if (!empty($this->_href)) { return $this->getHref(); } else { return Recurly_Plan::uriForPlan($this->plan_code); } }
function init($plan_code) { $retval = false; $this->plan = Recurly_Plan::get($plan_code); $this->plan->created_at = date(DATE_ATOM, $this->plan->created_at); $retval = $this->plan; return $retval; }
public function testUpdateXml() { $plan = Recurly_Plan::get('silver', $this->client); $plan->plan_code = 'platinum'; $plan->name = 'Platinum Plan'; $plan->unit_amount_in_cents->addCurrency('USD', 1500); $plan->unit_amount_in_cents->addCurrency('EUR', 1200); $plan->setup_fee_in_cents->addCurrency('EUR', 500); $plan->total_billing_cycles = NULL; $this->assertEquals("<?xml version=\"1.0\"?>\n<plan><plan_code>platinum</plan_code><name>Platinum Plan</name><unit_amount_in_cents><USD>1500</USD><EUR>1200</EUR></unit_amount_in_cents><setup_fee_in_cents><USD>500</USD><EUR>500</EUR></setup_fee_in_cents><total_billing_cycles nil=\"nil\"></total_billing_cycles></plan>\n", $plan->xml()); }
public function createRecurlySubscription2(Recurly_Account $account, $planCode, $billingFirstName, $billingLastName, $billingAddr1, $billingAddr2 = "", $billingCity, $billingState, $billingZIP, $billingCountry = "US", $ccNumber, $ccExpMonth, $ccExpYear, $ccVerificationValue) { $billing_info = new Recurly_BillingInfo(); $billing_info->account_code = $account->account_code; $billing_info->first_name = $billingFirstName; $billing_info->last_name = $billingLastName; $billing_info->address1 = $billingAddr1; $billing_info->address2 = $billingAddr2; $billing_info->city = $billingCity; $billing_info->state = $billingState; $billing_info->country = $billingCountry; $billing_info->zip = $billingZIP; $billing_info->year = intval($ccExpYear); $billing_info->month = intval($ccExpMonth); if (trim($ccVerificationValue) != "") { $billing_info->verification_value = $ccVerificationValue; } if (substr($ccNumber, 0, 5) != "*****") { $billing_info->number = $ccNumber; } $billing_info->ip_address = $_SERVER['REMOTE_ADDR']; $account_info = $billing_info->update(); $account_info = null; $currentSubscription = self::getSubscription($account->account_code); $currentPlanCode = ""; $currentPlanCost = 0; $newPlanCost = 0; if ($planCode != "" && $planCode != "daily") { $newPlan = Recurly_Plan::get($planCode); $newPlanCost = $newPlan->unit_amount_in_cents; } if ($currentSubscription) { $currentPlanCode = $currentSubscription->plan_code; $currentPlan = Recurly_Plan::get($currentPlanCode); $currentPlanCost = $currentSubscription->unit_amount_in_cents; } if ($planCode == "" || $planCode == "daily") { // if the plan is being moved from a monthly plan to daily, then we have to cancel subscription. if ($currentSubscription) { $currentSubscription->cancel(); } } else { // if the plan is being moved from one monthly plan to another, then we have to // upgrade or downgrade. if ($currentSubscription) { $currentSubscription->plan_code = $planCode; // get the current plan's amount and compare to the new one if ($newPlanCost > $currentPlanCost) { // upgrade $currentSubscription->updateImmediately(); } elseif ($newPlanCost < $currentPlanCost) { $currentSubscription->updateAtRenewal(); } } else { // no current subscription and we want a monthly, so just add a new one $subscription = new Recurly_Subscription(); $subscription->plan_code = $planCode; $subscription->currency = "USD"; $account->billing_info = $billing_info; $subscription->account = $account; $subscription->create(); } } return $account_info; }
function GetMonthlyPlan() { return Recurly_Plan::get(GetDefaultMonthlyRateCode()); }