public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $products = $invoice->getProducts(); $data = $this->getPaymentData($products[0]->data()->get('fortumo_service_xml')); $a = new Am_Paysystem_Action_HtmlTemplate_Fortumo($this->getDir(), 'fortumo-payment.phtml'); $a->data = $data; $a->invoice = $invoice; $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $prSpeeds = array(); foreach ($invoice->getProducts() as $product) { $prSpeeds[] = ($o = $product->data()->get('bitpay_speed_risk')) ? $o : $this->getConfig('bitpay_speed_risk'); } $user = $invoice->getUser(); $post = array('price' => $invoice->first_total, 'currency' => $invoice->currency, 'posData' => array(), 'notificationURL' => $this->getPluginUrl('ipn'), 'transactionSpeed' => $this->transactionSpeed[min($prSpeeds)], 'redirectURL' => $this->getConfig('use_http', false) ? str_replace('https://', 'http://', $this->getReturnUrl()) : $this->getReturnUrl(), 'orderID' => $invoice->public_id, 'itemDesc' => $invoice->getLineDescription(), 'buyerName' => $user->getName(), 'buyerAddress1' => $user->street, 'buyerAddress2' => $user->street2, 'buyerState' => Am_Di::getInstance()->stateTable->getTitleByCode($user->country, $user->state), 'buyerZip' => $user->zip, 'buyerCountry' => Am_Di::getInstance()->countryTable->getTitleByCode($user->country), 'buyerEmail' => $user->email, 'buyerPhone' => $user->phone); $post = array_filter($post); $req = new Am_Request_Bitpay($this, Am_HttpRequest::METHOD_POST, json_encode($post), 'createInvoice'); $res = $req->getResult(); if (!isset($res['status']) || $res['status'] != 'new') { Am_Di::getInstance()->errorLogTable->log("BitPay API Error. Invoice status is not NEW: " . @$res['status'] . "."); throw new Am_Exception_InternalError(); } $invoice->data()->set(self::BITPAY_INVOICE_ID, $res['id'])->update(); $action = new Am_Paysystem_Action_Redirect($res['url']); $result->setAction($action); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $products = $invoice->getProducts(); $a = new Am_Paysystem_Action_Form(self::LIVE_URL); $web_id = $products[0]->data()->get('web_id'); if (empty($web_id)) { $this->getConfig('web_id'); } $a->id = $web_id; $a->pricepoint = $products[0]->data()->get(self::PRICEPOINT); $a->paymentoption = $this->getPaymentOption($invoice); $a->firstname = $invoice->getFirstName(); $a->lastname = $invoice->getLastName(); $a->address = $invoice->getStreet(); $a->city = $invoice->getCity(); $a->state = $invoice->getState(); $a->zip = $invoice->getZip(); $a->country = $invoice->getCountry(); $a->phone = $invoice->getPhone(); $a->email = $invoice->getEmail(); $a->username = $invoice->getLogin(); $a->password = '******'; $a->purchaseamt = $invoice->first_total; $a->currencyid = $invoice->currency; $a->purchasedesc = $invoice->getLineDescription(); if ($invoice->rebill_times) { $a->recurflag = 'Y'; $a->recuramt = $invoice->second_total; $a->recurdatevalue = $this->getDays(new Am_Period($this->invoice->first_period)); } else { $a->recurflag = 'N'; } $a->xfield = $invoice->public_id; $a->postbackurl = $this->getPluginUrl('ipn'); $a->country = $invoice->getCountry(); $result->setAction($a); }
protected function isNotificationRuleMatch(EmailTemplate $tmpl, Invoice $invoice) { if (!$tmpl->conditions) { return true; } $conds = array(); foreach (explode(',', $tmpl->conditions) as $item) { preg_match('/([A-Z]*)-(.*)/', $item, $match); $conds[$match[1]][] = $match[2]; } //check product conditions $product_ids = array(); if (isset($conds['CATEGORY'])) { $catProducts = $this->getDi()->productCategoryTable->getCategoryProducts(); foreach ($conds['CATEGORY'] as $cat_id) { if (isset($catProducts[$cat_id])) { $product_ids = array_merge($product_ids, $catProducts[$cat_id]); } } } if (isset($conds['PRODUCT'])) { $product_ids = array_merge($product_ids, $conds['PRODUCT']); } if (!count($product_ids) && isset($conds['CATEGORY'])) { //user set up categories without products return false; } if (count($product_ids)) { $invoice_product_id = array_map(create_function('$a', 'return $a->pk();'), $invoice->getProducts()); if (!array_intersect($product_ids, $invoice_product_id)) { return false; } } //check paysystem conditions if (isset($conds['PAYSYSTEM']) && !in_array($invoice->paysys_id, $conds['PAYSYSTEM'])) { return false; } return true; }
function hasDigitalProducts(Invoice $invoice) { if ($this->getConfig('tax_digital')) { return true; } foreach ($invoice->getProducts() as $p) { if ($p->tax_group && $p->tax_digital) { return true; } } }