コード例 #1
0
ファイル: Saved.php プロジェクト: grlf/eyedock
 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();
 }
コード例 #2
0
ファイル: InvoiceRefund.php プロジェクト: grlf/eyedock
 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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: InvoiceItem.php プロジェクト: grlf/eyedock
 /**
  * Add access period for current product based on information from incoming paysystem transaction
  * @throws Am_Exception_Db_NotUnique
  */
 public function addAccessPeriod($isFirstPayment, Invoice $invoice, Am_Paysystem_Transaction_Interface $transaction, $beginDate, $invoicePaymentId)
 {
     if ($this->item_type != 'product') {
         return;
     }
     // if that is not a product then no access
     $a = $this->getDi()->accessRecord;
     $a->setDisableHooks(true);
     $a->begin_date = $beginDate;
     $p = new Am_Period($isFirstPayment ? $this->first_period : $this->second_period);
     $a->invoice_id = $this->invoice_id;
     $a->invoice_public_id = $this->invoice_public_id;
     $recurringType = $transaction->getRecurringType();
     if (in_array($recurringType, array(Am_Paysystem_Abstract::REPORTS_EOT, Am_Paysystem_Abstract::REPORTS_NOTHING))) {
         $a->expire_date = Am_Period::RECURRING_SQL_DATE;
     } else {
         $a->expire_date = $p->addTo($a->begin_date);
     }
     $a->product_id = $this->item_id;
     $a->user_id = $invoice->user_id;
     $a->transaction_id = $transaction->getUniqId();
     $a->invoice_payment_id = $invoicePaymentId;
     $a->invoice_item_id = $this->pk();
     $a->qty = $this->qty;
     $a->insert();
 }
コード例 #5
0
ファイル: Invoice.php プロジェクト: grlf/eyedock
 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();
 }
コード例 #6
0
ファイル: Invoice.php プロジェクト: alexanderTsig/arabic
 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();
 }