Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 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;
 }
Esempio n. 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;
 }
Esempio n. 4
0
 /** @return Invoice_Payment */
 protected function addPaymentWithoutAccessPeriod(Am_Paysystem_Transaction_Interface $transaction)
 {
     $c = $this->getPaymentsCount();
     if ($c >= $this->getExpectedPaymentsCount()) {
         $rt = (int) $this->rebill_times;
         if ($this->rebill_times) {
             throw new Am_Exception_Paysystem("Existing payments count [{$c}] exceeds number of allowed rebills [{$rt}]+1, could not add new payment");
         } else {
             // if that is not a recurring transaction, it is already handled for sure
             $paysys_id = $transaction->getPaysysId();
             $transaction_id = $transaction->getUniqId();
             throw new Am_Exception_Paysystem_TransactionAlreadyHandled("Transaction {$paysys_id}-{$transaction_id} is already handled");
         }
     }
     $p = $this->getDi()->invoicePaymentRecord;
     $p->setFromTransaction($this, $transaction);
     $p->_setInvoice($this);
     // caching
     try {
         $p->insert();
     } catch (Am_Exception_Db_NotUnique $e) {
         if ($e->getTable() == '?_invoice_payment') {
             throw new Am_Exception_Paysystem_TransactionAlreadyHandled("Transaction {$p->paysys_id}-{$p->transaction_id} is already handled");
         } else {
             throw $e;
         }
     }
     $records = $this->getAccessRecords();
     $isFirstPeriod = !$records;
     $this->addToRebillDate($isFirstPeriod);
     $this->updateStatus();
     return $p;
 }