protected function buildSubscriptionParams(Am_Paysystem_Action_Redirect $a, Invoice $invoice) { $a->ap_purchasetype = 'subscription'; $a->ap_trialamount = $invoice->first_total; $period = new Am_Period(); $period->fromString($invoice->first_period); $a->ap_trialtimeunit = $this->translatePeriodUnit($period->getUnit()); $a->ap_trialperiodlength = $period->getCount(); $a->ap_amount = $invoice->second_total; $period = new Am_Period(); $period->fromString($invoice->second_period); $a->ap_timeunit = $this->translatePeriodUnit($period->getUnit()); $a->ap_periodlength = $period->getCount(); $a->ap_periodcount = $invoice->rebill_times == IProduct::RECURRING_REBILLS ? 0 : $invoice->rebill_times; }
public function getCycle(Invoice $invoice) { $p = new Am_Period(); $p->fromString($invoice->second_period); switch ($p->getUnit()) { case Am_Period::DAY: return $p->getCount(); case Am_Period::MONTH: return $p->getCount() * 30; case Am_Period::YEAR: return $p->getCount() * 356; default: throw new Am_Exception_InputError('Incorrect product second period: ' . $p->getUnit()); } }
public function isNotAcceptableForInvoice(Invoice $invoice) { if ($invoice->rebill_times && $invoice->rebill_times != IProduct::RECURRING_REBILLS) { return 'Incorrect Rebill Times setting!'; } if ($invoice->second_total > 0 && $invoice->second_total != $invoice->first_total) { return 'First & Second price must be the same in invoice!'; } if ($invoice->second_period > 0 && $invoice->second_period != $invoice->first_period) { return 'First & Second period must be the same in invoice!'; } if ($invoice->rebill_times) { $p = new Am_Period(); $p->fromString($invoice->first_period); if ($p->getUnit() == Am_Period::MONTH && $p->getCount() == 1) { return; } if ($p->getUnit() == Am_Period::DAY && $p->getCount() == 7) { return; } return "Incorrect billing terms. Only monthly and weekly payments are supported"; } }