Example #1
0
 /**
  *
  * @param Am_Paysystem_Abstract $plugin
  * @param Invoice $invoice
  * @param HTTP_Request2 $request
  * @param bool $doFirst 
  */
 public function __construct(Am_Paysystem_Abstract $plugin, Invoice $invoice, $request, $doFirst)
 {
     parent::__construct($plugin, array());
     $this->setInvoice($invoice);
     $this->request = $request;
     $this->doFirst = $doFirst;
 }
 public function setFromTransaction(Invoice $invoice, Am_Paysystem_Transaction_Abstract $transaction, $refundType)
 {
     $this->dattm = $transaction->getTime()->format('Y-m-d H:i:s');
     $this->invoice_id = $invoice->invoice_id;
     $this->user_id = $invoice->user_id;
     $this->currency = $invoice->currency;
     $this->amount = $transaction->getAmount();
     $this->paysys_id = $transaction->getPlugin()->getId();
     $this->receipt_id = $transaction->getReceiptId();
     $this->transaction_id = $transaction->getUniqId();
     $this->refund_type = $refundType;
     return $this;
 }
 public function setFromTransaction(Invoice $invoice, Am_Paysystem_Transaction_Abstract $transaction)
 {
     $this->dattm = $transaction->getTime()->format('Y-m-d H:i:s');
     $this->invoice_id = $invoice->invoice_id;
     $this->user_id = $invoice->user_id;
     $this->currency = $invoice->currency;
     $this->paysys_id = $transaction->getPlugin()->getId();
     $this->receipt_id = $transaction->getReceiptId();
     $this->transaction_id = $transaction->getUniqId();
     /// get from invoice
     $isFirst = !$invoice->getPaymentsCount();
     $amount = $transaction->getAmount();
     if ($amount <= 0) {
         $amount = $isFirst && $invoice->first_total ? $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;
 }
Example #4
0
 public function __construct(Am_Paysystem_Abstract $plugin, array $vars)
 {
     $this->vars = $vars;
     parent::__construct($plugin);
 }
Example #5
0
 public function __construct($plugin)
 {
     parent::__construct($plugin, Am_Request::createEmpty());
 }
Example #6
0
 function __construct(Am_Paysystem_Abstract $plugin, $vars)
 {
     parent::__construct($plugin);
     $this->vars = $vars;
 }
Example #7
0
 function process()
 {
     // resend postback first as exception may be raised below
     $this->resendPostback();
     parent::process();
     // all went OK, with no exceptions, lets try to update customer info
     if (!empty($this->invoice->_autoCreated) && ($user = $this->invoice->getUser())) {
         $this->fillInUserFields($user);
     }
 }
Example #8
0
 public function revokeAccess(Am_Paysystem_Transaction_Abstract $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();
 }
 /**
  * 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_Abstract $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;
     $recurringType = $transaction->getPlugin()->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->insert();
 }