function __construct(Am_Paysystem_Transaction_Interface $transaction) { $this->Amount = $transaction->getAmount(); $this->PaysysId = $transaction->getPaysysId(); $this->ReceiptId = $transaction->getReceiptId(); $this->RecurringType = $transaction->getRecurringType(); $this->Time = $transaction->getTime()->format('Y-m-d H:i:s'); $this->TimeZone = $transaction->getTime()->getTimezone()->getName(); $this->UniqId = $transaction->getUniqId(); }
public function setFromTransaction(Invoice $invoice, Am_Paysystem_Transaction_Interface $transaction, $refundType) { $this->dattm = $transaction->getTime()->format('Y-m-d H:i:s'); $this->invoice_id = $invoice->invoice_id; $this->invoice_public_id = $invoice->public_id; $this->user_id = $invoice->user_id; $this->currency = $invoice->currency; $this->amount = $transaction->getAmount(); $this->paysys_id = $transaction->getPaysysId(); $this->receipt_id = $transaction->getReceiptId(); $this->transaction_id = $transaction->getUniqId(); $this->refund_type = $refundType; return $this; }
public function setFromTransaction(Invoice $invoice, Am_Paysystem_Transaction_Interface $transaction) { $this->dattm = $transaction->getTime()->format('Y-m-d H:i:s'); $this->invoice_id = $invoice->invoice_id; $this->invoice_public_id = $invoice->public_id; $this->user_id = $invoice->user_id; $this->currency = $invoice->currency; $this->paysys_id = $transaction->getPaysysId(); $this->receipt_id = $transaction->getReceiptId(); $this->transaction_id = $transaction->getUniqId(); /// get from invoice $isFirst = !(doubleval($invoice->first_total) === 0.0 || $invoice->getPaymentsCount()); $amount = $transaction->getAmount(); if ($amount <= 0) { $amount = $isFirst ? $invoice->first_total : $invoice->second_total; } $this->amount = (double) $amount; $this->discount = $isFirst ? $invoice->first_discount : $invoice->second_discount; $this->tax = $isFirst ? $invoice->first_tax : $invoice->second_tax; $this->shipping = $isFirst ? $invoice->first_shipping : $invoice->second_shipping; return $this; }
public function stopAccess(Am_Paysystem_Transaction_Interface $transaction) { // if second period has been set to lifetime // check if we've received all expected payments and invoice is not cancelled // if so, do not stop access if ($this->second_period == Am_Period::MAX_SQL_DATE && $this->status != Invoice::RECURRING_CANCELLED && $this->getPaymentsCount() >= $this->getExpectedPaymentsCount()) { return; } // stop access by setting expiration date to yesterday $yesterday = clone $transaction->getTime(); $yesterday->modify('-1 days'); $date = $yesterday->format('Y-m-d'); foreach ($this->getAccessRecords() as $accessRecord) { if ($accessRecord->expire_date > $date) { $accessRecord->updateQuick('expire_date', $date); } if ($accessRecord->begin_date > $date) { $accessRecord->updateQuick('begin_date', $date); } } $this->getUser()->checkSubscriptions(true); $this->updateStatus(); }
public function revokeAccess(Am_Paysystem_Transaction_Interface $transaction) { $yesterday = clone $transaction->getTime(); $yesterday->modify('-1 days'); $date = $yesterday->format('Y-m-d'); foreach ($this->getAccessRecords() as $accessRecord) { if ($accessRecord->expire_date > $date) { $accessRecord->updateQuick('expire_date', $date); } } $this->getUser()->checkSubscriptions(true); $this->updateStatus(); }