Esempio n. 1
0
 public function Action()
 {
     $return = '';
     if (!empty($_POST['invoices'])) {
         $notfound = array();
         $updated = array();
         $db = JFactory::getDBO();
         $list = explode("\n", $_POST['invoices']);
         foreach ($list as $li) {
             $invoice = new Invoice();
             $invoice->loadInvoiceNumber(trim($li));
             if (empty($invoice->id)) {
                 $notfound[] = trim($li);
                 continue;
             }
             if (!is_numeric($invoice->usage)) {
                 $notfound[] = trim($li);
                 continue;
             }
             $metaUser = new metaUser($invoice->userid);
             $cfid = $metaUser->focusSubscription->id;
             if ($cfid != $invoice->subscr_id) {
                 if (!$metaUser->moveFocus($invoice->subscr_id)) {
                     $notfound[] = trim($li);
                     continue;
                 }
             }
             if ($metaUser->focusSubscription->status == 'Active') {
                 $metaUser->focusSubscription->expiration = date('Y-m-d H:i:s', (int) gmdate('U') - 60);
                 $metaUser->focusSubscription->plan = $invoice->usage;
                 $metaUser->focusSubscription->type = $invoice->method;
                 $metaUser->focusSubscription->recurring = 1;
                 $metaUser->focusSubscription->check();
                 $metaUser->focusSubscription->store();
                 $updated[] = $invoice->invoice_number;
             } else {
                 $metaUser->focusSubscription->status = 'Active';
                 $metaUser->focusSubscription->expiration = date('Y-m-d H:i:s', (int) gmdate('U') - 60);
                 $metaUser->focusSubscription->plan = $invoice->usage;
                 $metaUser->focusSubscription->type = $invoice->method;
                 $metaUser->focusSubscription->recurring = 1;
                 $metaUser->focusSubscription->check();
                 $metaUser->focusSubscription->store();
                 $updated[] = $invoice->invoice_number;
             }
         }
         $return = '<p>Provided ' . count($list) . ' Invoice Numbers.</p>';
         if (count($updated)) {
             $return .= '<p>Updated ' . count($updated) . ' Invoices:</p>';
             $return .= '<p>' . implode(', ', $updated) . '</p>';
         }
         if (count($notfound)) {
             $return .= '<p>Failed to process the following ' . count($notfound) . ' Invoices:</p>';
             $return .= '<p>' . implode(', ', $notfound) . '</p>';
         }
     } elseif (isset($_POST['invoices'])) {
         $return = '<p>Please enter invoice numbers.</p>';
     }
     return $return;
 }
 /**
  * This function is likely never returns
  * but anyway handle result and exceptions
  * @return Am_Paysystem_Result
  */
 function process()
 {
     $err = $this->invoice->validate();
     if ($err) {
         throw new Am_Exception_InputError($err[0]);
     }
     $this->invoice->save();
     $plugin = Am_Di::getInstance()->plugins_payment->loadGet($this->invoice->paysys_id);
     $this->result = new Am_Paysystem_Result();
     $plugin->processInvoice($this->invoice, $this->controller->getRequest(), $this->result);
     if ($this->result->isSuccess() || $this->result->isFailure()) {
         if ($transaction = $this->result->getTransaction()) {
             $transaction->setInvoice($this->invoice);
             $transaction->process();
         }
     }
     if ($this->result->isSuccess()) {
         $url = REL_ROOT_URL . "/thanks?id=" . $this->invoice->getSecureId('THANKS');
         $this->callback($this->onSuccess);
         $this->controller->redirectLocation($url, ___("Invoice processed"), ___("Invoice processed successfully"));
         // no return Am_Exception_Redirect
     } elseif ($this->result->isAction()) {
         $this->callback($this->onAction);
         $this->result->getAction()->process($this->controller);
         // no return Am_Exception_Redirect
     } else {
         //  ($result->isFailure()) {
         $this->callback($this->onFailure);
     }
     return $this->result;
 }
Esempio n. 3
0
 function indexAction()
 {
     $this->getDi()->plugins_payment->loadEnabled()->getAllEnabled();
     $id = $this->_request->getFiltered('id');
     if (empty($id)) {
         $id = filterId(@$_GET['id']);
     }
     $this->invoice = null;
     if ($id) {
         $this->invoice = $this->getDi()->invoiceTable->findBySecureId($id, 'THANKS');
         if (!$this->invoice) {
             throw new Am_Exception_InputError("Invoice #{$id} not found");
         }
         $tm = max($this->invoice->tm_started, $this->invoice->tm_added);
         if ($this->getDi()->time - strtotime($tm) > 48 * 3600) {
             throw new Am_Exception_InputError("Link expired");
         }
         // Clean signup_member_login and signup_member_id to avoid duplicate signups with the same email address.
         $this->getSession()->signup_member_id = null;
         $this->getSession()->signup_member_login = null;
         $this->view->invoice = $this->invoice;
         foreach ($this->invoice->getPaymentRecords() as $p) {
             $this->view->payment = $p;
         }
         if (!$this->invoice->tm_started) {
             $this->view->show_waiting = true;
             $this->view->refreshTime = "<span id='am-countdown'>00:10</span> " . ___("seconds");
         }
         $this->view->script = $this->getJs(10);
     }
     $this->getDi()->hook->call(Am_Event::THANKS_PAGE, array('controller' => $this, 'invoice' => $this->invoice));
     $this->view->layoutNoMenu = true;
     $this->view->display('thanks.phtml');
 }
Esempio n. 4
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $a = new Am_Paysystem_Action_Redirect(self::LIVE_URL);
     $a->sitereference = $this->getConfig('sitereference');
     $a->currencyiso3a = $invoice->currency;
     $a->mainamount = $invoice->first_total;
     $a->version = 1;
     $a->billingstreet = $user->street;
     $a->billingtown = $user->city;
     $a->billingcounty = $user->country;
     $a->billingpostcode = $user->zip;
     $a->billingfirstname = $user->name_f;
     $a->billinglastname = $user->name_l;
     $a->billingemail = $user->email;
     $a->billingtelephone = $user->phone;
     $a->customerstreet = $user->street;
     $a->customertown = $user->city;
     $a->customercounty = $user->country;
     $a->customerpostcode = $user->zip;
     $a->customerfirstname = $user->name_f;
     $a->customerlastname = $user->name_l;
     $a->customeremail = $user->email;
     $a->customertelephone = $user->phone;
     $a->orderreference = $invoice->public_id;
     $a->filterEmpty();
     $result->setAction($a);
 }
Esempio n. 5
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $req = $this->createHttpRequest();
     $req->setUrl(self::POST_URL);
     $req->addPostParameter('Key', $this->getConfig('app_key'));
     $req->addPostParameter('Secret', $this->getConfig('app_secret'));
     $req->addPostParameter('DestinationId', $this->getConfig('destination_id'));
     $req->addPostParameter('OrderId', $invoice->public_id);
     $req->addPostParameter('Amount', $invoice->first_total);
     $req->addPostParameter('Test', $this->getConfig('testing') ? 'true' : 'false');
     $req->addPostParameter('Redirect', $this->getPluginUrl('thanks') . '?id=' . $invoice->getSecureId('THANKS'));
     $req->addPostParameter('Name', $this->getDi()->config->get('site_title'));
     $req->addPostParameter('Description', $invoice->getLineDescription());
     $req->addPostParameter('Callback', $this->getPluginUrl('ipn'));
     $this->logRequest($req);
     $req->setMethod(Am_HttpRequest::METHOD_POST);
     $response = $req->send();
     $this->logResponse($response);
     $resp = $response->getBody();
     if (strstr($resp, "Invalid+application+credentials")) {
         $result->setFailed("Invalid Application Credentials.");
         return;
     } elseif (strstr($resp, "error")) {
         $result->setFailed("Invalid Response From Dwolla's server.");
         return;
     }
     $i = strpos($resp, "checkout/");
     $checkout_id = substr($resp, $i + 9, 36);
     $a = new Am_Paysystem_Action_Redirect(self::REDIRECT_URL . $checkout_id);
     $result->setAction($a);
 }
Esempio n. 6
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL);
     $result->setAction($a);
     $u = $invoice->getUser();
     $vars = array();
     $vars['PSPID'] = $this->config['pspid'];
     $vars['ORDERID'] = $invoice->public_id;
     $vars['AMOUNT'] = $invoice->first_total * 100;
     $vars['CURRENCY'] = $invoice->currency;
     $vars['LANGUAGE'] = 'en_US';
     $vars['CN'] = $u->getName();
     $vars['EMAIL'] = $u->email;
     $vars['OWNERZIP'] = $u->zip;
     $vars['OWNERADDRESS'] = $u->street;
     $vars['OWNERCTY'] = $u->city;
     $vars['COM'] = $invoice->getLineDescription();
     $vars['HOMEURL'] = $this->getReturnUrl();
     $vars['ACCEPTURL'] = $this->getPluginUrl('thanks');
     $vars['DECLINEURL'] = $this->getCancelUrl();
     $vars['CANCELURL'] = $this->getCancelUrl();
     $vars = array_filter($vars);
     ksort($vars);
     foreach ($vars as $k => $v) {
         $sha .= "{$k}={$v}" . $this->config['sha_in'];
         $a->addParam($k, $v);
     }
     $a->SHASIGN = sha1($sha);
     $result->setAction($a);
 }
Esempio n. 7
0
 /**
  * Store a newly created resource in storage.
  * POST /invoice
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::to('invoice')->withErrors($validator)->withInput(Input::all());
     } else {
         $invoice = new Invoice();
         $invoice->no_inv = Input::get('no_inv');
         $invoice->tgl_inv = Input::get('tgl_inv');
         $invoice->no_PO = Input::get('no_PO');
         $invoice->ship_by = Input::get('ship_by');
         $invoice->pay_method = Input::get('pay_method');
         $invoice->no_rek = Input::get('no_rek');
         $invoice->pelabuhan = Input::get('pelabuhan');
         $invoice->carrier = Input::get('carrier');
         $invoice->save();
         $SPPB = Barang::join('detil_SPPB', 'barang.kode_barang', '=', 'detil_SPPB.kode_barang')->join('SPPB', 'detil_SPPB.no_SPPB', '=', 'SPPB.no_SPPB')->join('PO', 'SPPB.no_SPPB', '=', 'PO.no_SPPB')->where('no_PO', Input::get('no_PO'))->selectRaw('barang.kode_barang as barang, jml_pesan as pesan')->get();
         foreach ($SPPB as $key => $value) {
             $barang = Barang::find($value->barang);
             $barang->jml_barang = $barang->jml_barang - $value->pesan;
             $barang->save();
         }
         Session::flash('message', 'Successfully created invoice!');
         return Redirect::to('invoice');
     }
 }
Esempio n. 8
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Form(self::LIVE_URL);
     $u = $invoice->getUser();
     $a->intInstID = $this->config['installation_id'];
     $a->strCartID = $invoice->public_id;
     $a->strCurrency = $invoice->currency;
     $a->strDesc = $invoice->getLineDescription();
     $a->strEmail = $u->email;
     $a->strCardHolder = $u->getName();
     $a->strAddress = $u->street;
     $a->strCity = $u->city;
     $a->strState = $u->state;
     $a->strCountry = $u->country;
     $a->strPostcode = $u->zip;
     $a->intTestMode = $this->getConfig('testing') ? '1' : '';
     $a->fltAmount = sprintf('%.3f', $invoice->first_total);
     //recurring
     if (!is_null($invoice->second_period)) {
         $a->intRecurs = '1';
         $a->intCancelAfter = substr($invoice->rebill_times, 3);
         $a->fltSchAmount1 = sprintf('%.3f', $invoice->second_total);
         $a->strSchPeriod1 = $this->metacharge_get_period($invoice->first_period);
         $a->fltSchAmount = sprintf('%.3f', $invoice->first_total);
         $a->strSchPeriod = $this->metacharge_get_period($invoice->second_period);
     }
     $a->filterEmpty();
     $result->setAction($a);
 }
Esempio n. 9
0
 /**
  * This function is likely never returns
  * but anyway handle result and exceptions
  * @return Am_Paysystem_Result
  */
 function process()
 {
     Am_Di::getInstance()->hook->call(Am_Event::INVOICE_BEFORE_PAYMENT, array('invoice' => $this->invoice, 'controller' => $this->controller));
     $plugin = Am_Di::getInstance()->plugins_payment->loadGet($this->invoice->paysys_id);
     $this->result = new Am_Paysystem_Result();
     $plugin->processInvoice($this->invoice, $this->controller->getRequest(), $this->result);
     if ($this->result->isSuccess() || $this->result->isFailure()) {
         if ($transaction = $this->result->getTransaction()) {
             $transaction->setInvoice($this->invoice);
             $transaction->process();
         }
     }
     if ($this->result->isSuccess()) {
         if (method_exists($this->controller, 'getForm')) {
             $this->controller->getForm()->getSessionContainer()->destroy();
         }
         $url = REL_ROOT_URL . "/thanks?id=" . $this->invoice->getSecureId('THANKS');
         $this->callback($this->onSuccess);
         $this->controller->redirectLocation($url);
         // no return
         // Am_Exception_Redirect only for APPLICATION_ENV = 'testing'
     } elseif ($this->result->isAction()) {
         if (method_exists($this->controller, 'getForm')) {
             $this->controller->getForm()->getSessionContainer()->destroy();
         }
         $this->callback($this->onAction);
         $this->result->getAction()->process($this->controller);
         // no return
         // Am_Exception_Redirect only for APPLICATION_ENV = 'testing'
     } else {
         //  ($result->isFailure()) {
         $this->callback($this->onFailure);
     }
     return $this->result;
 }
 /**
  * Constructor
  */
 public function __construct(Invoice $invoice, array $wallets)
 {
     $this->invoice = $invoice;
     $this->wallets = $wallets;
     $defaults = array('LMI_SIM_MODE' => sfConfig::get('app_webmoney_sim_mode'), 'LMI_PAYMENT_NO' => $invoice->getId(), 'LMI_PAYMENT_DESC_BASE64' => base64_encode($invoice->getDescription()));
     parent::__construct($defaults);
 }
Esempio n. 11
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $req = new Am_HttpRequest(sprintf('https://gateway-japa.americanexpress.com/api/rest/version/23/merchant/%s/session', $this->getConfig('merchant')), Am_HttpRequest::METHOD_POST);
     $req->setAuth('merchant.' . $this->getConfig('merchant'), $this->getConfig('password'));
     $req->setBody(Am_Controller::getJson(array('apiOperation' => 'CREATE_PAYMENT_PAGE_SESSION', 'order' => array('id' => $invoice->public_id, 'amount' => $invoice->first_total, 'currency' => $invoice->currency), 'paymentPage' => array('cancelUrl' => $this->getCancelUrl(), 'returnUrl' => $this->getPluginUrl('thanks')))));
     $this->logRequest($req);
     $res = $req->send();
     $this->logResponse($res);
     if ($res->getStatus() != 201) {
         $result->setFailed(sprintf('Incorrect Responce Status From Paysystem [%s]', $res->getStatus()));
         return;
     }
     $msg = Am_Controller::decodeJson($res->getBody());
     if ($msg['result'] == 'ERROR') {
         $result->setFailed($msg['error']['explanation']);
         return;
     }
     $invoice->data()->set(self::DATA_KEY, $msg['successIndicator'])->update();
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->{'merchant'} = $this->getConfig('merchant');
     $a->{'order.description'} = $invoice->getLineDescription();
     $a->{'paymentPage.merchant.name'} = $this->getDi()->config->get('site_title');
     $a->{'session.id'} = $msg['session']['id'];
     $this->logRequest($a);
     $result->setAction($a);
 }
Esempio n. 12
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $items = $invoice->getItems();
     if (count($items) > 1) {
         $exc = new Am_Exception_InternalError("It's impossible purchase " . count($items) . " products at one invoice with Selz-plugin");
         $this->getDi()->errorLogTable->logException($exc);
         throw $exc;
     }
     $item = $items[0];
     $bp = $this->getDi()->billingPlanTable->load($item->billing_plan_id);
     $sharedLink = $bp->data()->get(self::SHARED_LINK_FIELD);
     if (!$sharedLink) {
         $exc = new Am_Exception_InternalError("Product #{$item->item_id} has no shared link");
         $this->getDi()->errorLogTable->logException($exc);
         throw $exc;
     }
     if ($this->getConfig('payment_way', 'redirect') == 'redirect') {
         $a = new Am_Paysystem_Action_Redirect($sharedLink);
     } else {
         $a = new Am_Paysystem_Action_HtmlTemplate_Selz($this->getDir(), 'selz.phtml');
         $a->link = $sharedLink;
         $a->inv = $invoice->public_id;
         $a->thanks = $this->getReturnUrl();
         $a->ipn = $this->getPluginUrl('ipn');
         $a->way = $this->getConfig('payment_way');
     }
     $result->setAction($a);
 }
 /**
  * Constructor
  */
 public function __construct(Invoice $invoice)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'Date'));
     $resultUrl = 'https://' . sfContext::getInstance()->getRequest()->getHost() . url_for('payment_liqpay_result');
     $defaults = array('version' => '1.1', 'merchant_id' => sfConfig::get('app_liqpay_merchant'), 'amount' => $invoice->getAmount(), 'currency' => 'UAH', 'order_id' => $invoice->getId(), 'description' => $invoice->getDescription(), 'result_url' => $resultUrl, 'server_url' => $resultUrl);
     parent::__construct($defaults);
 }
Esempio n. 14
0
 public function calculate(Invoice $invoiceBill)
 {
     $this->invoiceBill = $invoiceBill;
     foreach ($invoiceBill->getItems() as $item) {
         $this->item = $item;
         foreach (self::$_prefixes as $prefix) {
             $this->currentPrefix = $prefix;
             $fields = new stdClass();
             foreach (self::$_noPrefixFields as $k) {
                 $fields->{$k} = @$item->{$k};
             }
             foreach (self::$_prefixFields as $k) {
                 $kk = $prefix ? $prefix . $k : $k;
                 if (isset($fields->{$kk})) {
                     throw new Am_Exception_InternalError("Field is already defined [{$k}]");
                 }
                 $fields->{$k} = @$item->{$kk};
             }
             $this->calculatePiece($fields);
             foreach (self::$_noPrefixFields as $k) {
                 $item->{$k} = $fields->{$k};
             }
             foreach (self::$_prefixFields as $k) {
                 $kk = $prefix ? $prefix . $k : $k;
                 $item->{$kk} = $fields->{$k};
             }
         }
         unset($this->item);
     }
 }
Esempio n. 15
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     if ($cc->user_id != $user->pk()) {
         throw new Am_Exception_Paysystem("Assertion failed: cc.user_id != user.user_id");
     }
     // will be stored only if cc# or expiration changed
     $this->storeCreditCard($cc, $result);
     if (!$result->isSuccess()) {
         return;
     }
     $user->refresh();
     // we have both profile id and payment id, run the necessary transaction now if amount > 0
     $result->reset();
     if ($doFirst && !$invoice->first_total) {
         // free trial
         $tr = new Am_Paysystem_Transaction_Free($this);
         $tr->setInvoice($invoice);
         $tr->process();
         $result->setSuccess($tr);
     } else {
         $tr = new Am_Paysystem_Transaction_Securepaycomau_Payment($this, $invoice, $doFirst);
         $tr->run($result);
     }
 }
Esempio n. 16
0
 public function refundStore()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rentD' => 'required', 'waterD' => 'required', 'electricityD' => 'required', 'grepairs' => 'required', 'Obills' => 'required', 'Tcost' => 'required', 'Sfees' => 'required', 'duedate' => 'required'));
     if ($v->passes()) {
         $balance = Input::get('rentD') + Input::get('waterD') + Input::get('grepairs') + Input::get('Obills') + Input::get('Tcost') + Input::get('Sfees') + Input::get('electricityD');
         $invoice = new Invoice();
         $invoice->type = Input::get('type');
         $invoice->houseID = Input::get('houseID');
         $invoice->recipient = Input::get('tenant');
         $invoice->balance = $balance;
         $invoice->duedate = Input::get('duedate');
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rentD = Input::get('rentD');
         $invoicedetail->waterD = Input::get('waterD');
         $invoicedetail->g_repairs = Input::get('grepairs');
         $invoicedetail->o_bills = Input::get('Obills');
         $invoicedetail->transport_cost = Input::get('Tcost');
         $invoicedetail->storage_fees = Input::get('Sfees');
         $invoicedetail->electricityD = Input::get('electricityD');
         $invoice->invoicedetail()->save($invoicedetail);
         return Redirect::intended('admin/invoice');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Esempio n. 17
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $a = new Am_Paysystem_Action_Form(self::LIVE_URL);
     $a->Merchant = $this->getConfig('merchant_id');
     $a->Site = $this->getConfig('site_id');
     $a->DirectTransfer = 'true';
     $a->Amount = $invoice->first_total;
     $a->Currency = $invoice->currency;
     $a->TransRef = $invoice->public_id;
     $a->Product = $invoice->getLineDescription();
     $a->PaymentType = 'cup';
     $a->AttemptMode = '1';
     $a->TestTrans = $this->getConfig('testing') ? '1' : '0';
     $a->__set("customer[email]", $user->email);
     $a->__set("customer[first_name]", $user->name_f);
     $a->__set("customer[last_name]", $user->name_l);
     $a->__set("customer[address1]", $user->street);
     $a->__set("customer[address2]", $user->street2);
     $a->__set("customer[city]", $user->city);
     $a->__set("customer[state]", $user->state);
     $a->__set("customer[postcode]", $user->postcode);
     $a->__set("customer[country]", $user->country);
     $a->__set("customer[phone]", $user->phone);
     $a->ReturnUrlFailure = $this->getCancelUrl();
     $a->ReturnUrlSuccess = $this->getPluginUrl('thanks');
     $result->setAction($a);
 }
Esempio n. 18
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $houses = House::where('status', '=', 'booked')->where('frequency', '=', 4)->get();
     foreach ($houses as $house) {
         $hid = $house->id;
         $rent = $house->rent;
         $water = $house->water;
         $garbage = $house->garbage;
         $frequency = $house->frequency;
         $tenant_id = $house->tenant;
         $tenant = Tenant::find($tenant_id);
         $t_name = $tenant->name;
         $t_agent = $tenant->agent_id;
         $balance = $rent + $water + $garbage;
         $invoice = new Invoice();
         $invoice->type = 'to tenant';
         $invoice->houseID = $hid;
         $invoice->recipient = $t_name;
         $invoice->agent_id = $t_agent;
         $invoice->balance = $balance;
         $invoice->duedate = '2015/03/21';
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = $rent;
         $invoicedetail->water = $water;
         $invoicedetail->garbage = $garbage;
         $invoice->invoicedetail()->save($invoicedetail);
     }
 }
Esempio n. 19
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $vars = $this->getConfig();
     $vars['Amount'] = $invoice->first_total;
     $vars['Currency'] = $invoice->currency;
     $vars['ReturnUrl'] = $this->getPluginUrl('thanks');
     $vars['CancelUrl'] = $this->getCancelUrl();
     $vars['MerchantInvoice'] = $invoice->public_id;
     $vars['MerchantReference'] = $invoice->public_id;
     $vars['CustomerFirstName'] = $invoice->getFirstName();
     $vars['CustomerLastName'] = $invoice->getLastName();
     $vars['CustomerAddress'] = $invoice->getStreet();
     $vars['CustomerCity'] = $invoice->getCity();
     $vars['CustomerState'] = $invoice->getState();
     $vars['InvoiceDescription'] = $invoice->getLineDescription();
     $vars['CustomerCountry'] = $invoice->getCountry();
     $vars['CustomerPhone'] = $invoice->getPhone();
     $vars['CustomerEmail'] = $invoice->getEmail();
     $r = new Am_HttpRequest($this->getUrl() . '?' . http_build_query($vars, '', '&'));
     $response = $r->send()->getBody();
     if (!$response) {
         $this->getDi()->errorLogTable->log('Plugin eWAY: Got empty response from API server');
         $result->setErrorMessages(array(___("An error occurred while handling your payment.")));
         return;
     }
     $xml = simplexml_load_string($response);
     if (!empty($xml->Error)) {
         $this->getDi()->errorLogTable->log('Plugin eWAY: Got error from API: ' . (string) $xml->Error);
         $result->setErrorMessages(array(___("An error occurred while handling your payment.")));
         return;
     }
     $action = new Am_Paysystem_Action_Redirect($xml->URI);
     $result->setAction($action);
 }
Esempio n. 20
0
 function repeatAction()
 {
     if (!$this->invoice) {
         throw new Am_Exception_InputError('No invoice found, cannot repeat');
     }
     if ($this->invoice->isPaid()) {
         throw new Am_Exception_InputError("Invoice #{$id} is already paid");
     }
     $found = false;
     foreach ($this->view->paysystems as $ps) {
         if ($ps['paysys_id'] == $this->getFiltered('paysys_id')) {
             $found = true;
             break;
         }
     }
     if (!$found) {
         return $this->indexAction();
     }
     $this->invoice->updateQuick('paysys_id', $this->getFiltered('paysys_id'));
     if ($err = $this->invoice->validate()) {
         throw new Am_Exception_InputError($err[0]);
     }
     $payProcess = new Am_Paysystem_PayProcessMediator($this, $this->invoice);
     $result = $payProcess->process();
     if ($result->isFailure()) {
         $this->view->error = $result->getErrorMessages();
         return $this->indexAction();
     }
 }
Esempio n. 21
0
 public function More($id)
 {
     $variable = array();
     $inv = new Invoice();
     $variable['Invoices'] = $inv->More($id);
     $this->RenderPartioal('report/more', $variable);
 }
Esempio n. 22
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $u = $invoice->getUser();
     $domain = $this->getConfig('testing') ? Am_Paysystem_Xfers::SANDBOX_DOMAIN : Am_Paysystem_Xfers::LIVE_DOMAIN;
     $a = new Am_Paysystem_Action_Form('https://' . $domain . '/api/v2/payments');
     $a->api_key = $this->getConfig('api_key');
     $a->order_id = $invoice->public_id;
     $a->cancel_url = $this->getCancelUrl();
     $a->return_url = $this->getReturnUrl();
     $a->notify_url = $this->getPluginUrl('ipn');
     if ($invoice->first_tax) {
         $a->tax = $invoice->first_tax;
     }
     /* @var $item InvoiceItem */
     $i = 1;
     foreach ($invoice->getItems() as $item) {
         $a->{'item_name_' . $i} = $item->item_title;
         $a->{'item_description_' . $i} = $item->item_description;
         $a->{'item_quantity_' . $i} = $item->qty;
         $a->{'item_price_' . $i} = $item->first_price;
         $i++;
     }
     $a->total_amount = $invoice->first_total;
     $a->currency = $invoice->currency;
     $a->user_email = $invoice->getUser()->email;
     $a->signature = sha1($a->api_key . $this->getConfig('api_secret') . $a->order_id . $a->total_amount . $a->currency);
     $result->setAction($a);
 }
Esempio n. 23
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $product = $this->getDi()->productTable->load($invoice->getItem(0)->item_id);
     $billers = json_decode($product->data()->getBlob('sliiing_billers'), true);
     if (!@count($billers['options'])) {
         $this->getDi()->errorLogTable->log("SLIING ERROR : please add billers for product #" . $product->pk());
         throw new Am_Exception_InputError('An error occurred while payment request');
     } elseif (count($billers['options']) == 1) {
         //redirect
         $aff = '0';
         $lin = '0';
         $refe_url = '0';
         $ip = '0';
         $keyword = '0';
         if (isset($_COOKIE['MID'])) {
             $mid = base64_decode($_COOKIE['MID']);
             list($aff, $lin, $refe_url, $ip, $keyword) = explode('|', $mid);
         }
         $datas = base64_encode("{$aff}|{$lin}|{$refe_url}|{$ip}|{$keyword}");
         $url = $billers['options'][0];
         $url = str_replace('$datas', $datas, $url);
         $a = new Am_Paysystem_Action_Redirect($url);
         $a->x_invoice_id = $invoice->public_id;
         $a->username = $invoice->getUser()->login;
         $a->email = urlencode($invoice->getUser()->email);
         $result->setAction($a);
     } else {
         //show form
         $a = new Am_Paysystem_Action_HtmlTemplate_Sliiing($this->getDir(), 'sliiing-confirm.phtml');
         $a->action = $this->getPluginUrl('confirm');
         $a->billers = $billers;
         $a->invoice = $invoice;
         $result->setAction($a);
     }
 }
Esempio n. 24
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     if ($cc->user_id != $user->pk()) {
         throw new Am_Exception_Paysystem("Assertion failed: cc.user_id != user.user_id");
     }
     // will be stored only if cc# or expiration changed
     $this->storeCreditCard($cc, $result);
     if (!$result->isSuccess()) {
         return;
     }
     $user->refresh();
     // we have both profile id and payment id, run the necessary transaction now if amount > 0
     $result->reset();
     if ($doFirst && doubleval($invoice->first_total) <= 0) {
         // free trial
         $tr = new Am_Paysystem_Transaction_Free($this);
         $tr->setInvoice($invoice);
         $tr->process();
         $result->setSuccess($tr);
     } else {
         $request = array($this->getConfig('key'), $this->getConfig('testing'), $user->data()->get(self::CUSTOMER_VAULT_ID), null, $this->getConfig('project'), '', '', '', $doFirst ? intval($invoice->first_total * 100) : intval($invoice->second_total * 100), $invoice->currency, $invoice->getLineDescription(), $invoice->getLineDescription(), $user->remote_addr ? $user->remote_addr : $_SERVER['REMOTE_ADDR']);
         $tr = new Am_Paysystem_Transaction_MicropaymentDbtSale($this, $invoice, $request, $doFirst);
         $tr->run($result);
     }
 }
Esempio n. 25
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     include_once dirname(__FILE__) . '/SOPGClassicMerchantClient.php';
     $client = new SOPGClassicMerchantClient($this->getConfig('testing') ? self::TEST_API_URL : self::LIVE_API_URL);
     $mtid = $invoice->public_id;
     //$this->generateMtid();
     // SEE par.2
     if ($invoice->first_total > 1000) {
         throw new InvalidArgumentException('The maximum amount value of dispositions is 1000.00');
     }
     // see par.2
     $request = array($this->getConfig('login'), $this->getConfig('password'), $mtid, null, sprintf('%.2f', $invoice->first_total), $invoice->currency, urlencode($this->getReturnUrl()), urlencode($this->getPluginUrl('cancelpaysafecart') . "?id=" . $invoice->getSecureId('CANCEL')), $invoice->getUserId(), urlencode($this->getPluginUrl()), null);
     $this->logRequest($request);
     $response = call_user_func_array(array($client, 'createDisposition'), $request);
     $this->logResponse(get_object_vars($response));
     if ($response->resultCode != 0 || $response->errorCode != 0) {
         // SEE par.4
         $result->setErrorMessages(array('Transaction could not be initiated due to connection problems.'));
         //$result->setErrorMessages(array('Error during request to paysafecard server'));
         // see par.4
         return;
     }
     $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::TEST_REDIRECT_URL : self::LIVE_REDIRECT_URL);
     $a->mid = $response->mid;
     $a->mtid = $mtid;
     $a->amount = sprintf('%.2f', $invoice->first_total);
     $a->currency = $invoice->currency;
     $result->setAction($a);
 }
Esempio n. 26
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $u = $invoice->getUser();
     $request = $this->createHttpRequest();
     $vars = array('VPSProtocol' => '2.23', 'TxType' => 'PAYMENT', 'Vendor' => $this->getConfig('login'), 'VendorTxCode' => $invoice->public_id . '-AMEMBER', 'Amount' => number_format($invoice->first_total, 2, '.', ''), 'Currency' => $invoice->currency ? $invoice->currency : 'USD', 'Description' => $invoice->getLineDescription(), 'NotificationURL' => $this->getPluginUrl('ipn'), 'SuccessURL' => $this->getReturnUrl(), 'RedirectionURL' => $this->getReturnUrl(), 'BillingFirstnames' => $u->name_f, 'BillingSurname' => $u->name_l, 'BillingAddress1' => $u->street, 'BillingCity' => $u->city, 'BillingPostCode' => $u->zip, 'BillingCountry' => $u->country, 'DeliveryFirstnames' => $u->name_f, 'DeliverySurname' => $u->name_l, 'DeliveryAddress1' => $u->street, 'DeliveryCity' => $u->city, 'DeliveryPostCode' => $u->zip, 'DeliveryCountry' => $u->country, 'CustomerEMail' => $u->email, 'Profile' => 'NORMAL');
     if ($u->country == 'US') {
         $vars['BillingState'] = $u->state;
         $vars['DeliveryState'] = $u->state;
     }
     $request->addPostParameter($vars);
     $request->setUrl($this->getConfig('testing') ? self::TEST_URL : self::LIVE_URL);
     $request->setMethod(Am_HttpRequest::METHOD_POST);
     $this->logRequest($request);
     $response = $request->send();
     $this->logResponse($response);
     if (!$response->getBody()) {
         throw new Am_Exception_InputError("An error occurred while payment request");
     }
     $res = array();
     foreach (split(PHP_EOL, $response->getBody()) as $line) {
         list($l, $r) = explode('=', $line, 2);
         $res[trim($l)] = trim($r);
     }
     if ($res['Status'] == 'OK') {
         $invoice->data()->set('sagepay_securitykey', $res['SecurityKey']);
         $invoice->update();
         $a = new Am_Paysystem_Action_Form($res['NextURL']);
         $result->setAction($a);
     } else {
         throw new Am_Exception_InputError($res['StatusDetail']);
     }
 }
 /**
  * Constructor
  */
 public function __construct(Invoice $invoice)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     $defaults = array('WMI_MERCHANT_ID' => sfConfig::get('app_w1_merchant'), 'WMI_PAYMENT_AMOUNT' => sprintf('%01.2f', $invoice->getAmount()), 'WMI_CURRENCY_ID' => 980, 'WMI_PAYMENT_NO' => $invoice->getId(), 'WMI_DESCRIPTION' => $invoice->geDescription(), 'WMI_SUCCESS_URL' => url_for('payment_w1_success', array(), true), 'WMI_FAIL_URL' => url_for('payment_w1_fail', array(), true), 'WMI_PTENABLED' => 'CashTerminalUAH');
     $defaults['WMI_SIGNATURE'] = $this->createSign($defaults);
     parent::__construct($defaults);
 }
 /**
  * A custom method within the Plugin to generate the content
  * 
  */
 function generateContactInvoiceContent()
 {
     $output = '';
     if (!is_object($_SESSION['do_invoice_list'])) {
         $do_invoice_list = new Invoice();
         $do_invoice_list->sessionPersistent("do_invoice_list", "index.php", OFUZ_TTL);
     }
     if ($_SESSION['do_invoice_list']->hasInvoicesForEntity($_SESSION['do_cont']->idcontact, 'Contact')) {
         $user_settings = $_SESSION['do_User']->getChildUserSettings();
         if ($user_settings->getNumRows()) {
             while ($user_settings->next()) {
                 if ($user_settings->setting_name == 'currency' && $user_settings->setting_value != '') {
                     $currency = explode("-", $user_settings->setting_value);
                     $_SESSION['do_invoice_list']->currency_iso_code = $currency[0];
                     $_SESSION['do_invoice_list']->currency_sign = $currency[1];
                     //$_SESSION['do_invoice_list']->currency = $_SESSION['do_invoice_list']->currecy_sign ;
                     $_SESSION['do_invoice_list']->setCurrencyDisplay();
                     $_SESSION['do_invoice_list']->getCurrencyPostion();
                 }
             }
         }
         $e_filter_inv = new Event("do_invoice_list->eventFilterInvoice");
         $e_filter_inv->addParam("type", "Contact");
         $e_filter_inv->addParam("idcontact", $_SESSION['do_cont']->idcontact);
         $e_filter_inv->addParam("goto", "invoices.php");
         $e_filter_inv->setLevel(10);
         $output .= '<table width="100%">';
         $output .= $_SESSION['do_invoice_list']->getInvoiceTotals($e_filter_inv, $_SESSION['do_cont']->idcontact);
         $output .= '</table>';
     } else {
         $this->setIsActive(false);
     }
     return $output;
 }
Esempio n. 29
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $u = $invoice->getUser();
     $a = new Am_Paysystem_Action_Redirect(self::LIVE_URL);
     $a->pay_to_email = $this->getConfig('business');
     $a->pay_from_email = $u->email;
     $a->transaction_id = $invoice->public_id;
     $a->amount = $invoice->first_total;
     $a->currency = $invoice->currency;
     $a->language = $u->lang;
     $a->return_url = $this->getReturnUrl();
     $a->cancel_url = $this->getCancelUrl();
     $a->status_url = $this->getPluginUrl('ipn');
     $a->detail1_text = $invoice->getLineDescription();
     $a->firstname = $u->name_f;
     $a->lastname = $u->name_l;
     $a->address = $u->street;
     $a->postal_code = $u->zip;
     $a->city = $u->city;
     $a->state = $u->state;
     $a->country = $u->country;
     if ($invoice->second_total > 0) {
         $a->rec_amount = $invoice->second_total;
         $periods = array('m' => 'month', 'y' => 'year', 'd' => 'day');
         $second_period = new Am_Period($invoice->second_period);
         $a->rec_cycle = $periods[$second_period->getUnit()];
         $a->rec_period = $second_period->getCount();
         $a->rec_start_date = date('Y/m/d', strtotime($invoice->calculateRebillDate(1)));
         $a->rec_status_url = $this->getPluginUrl('ipn');
     }
     $result->setAction($a);
 }
Esempio n. 30
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     if ($this->getConfig('dynamic_pricing')) {
         $req = new Am_HttpRequest('http://srs.segpay.com/PricingHash/PricingHash.svc/GetDynamicTrans?value=' . $invoice->first_total, Am_HttpRequest::METHOD_GET);
         $res = $req->send();
         $action = new Am_Paysystem_Action_Redirect($this->getActionURL($invoice) . '&dynamictrans=' . strip_tags($res->getBody()));
         $action->amount = $invoice->first_total;
         $action->addParam('publicid', $invoice->public_id);
         $action->publicid = $invoice->public_id;
         $action->addParam('x-billname', $user->getName());
         $action->addParam('x-billemail', $user->email);
         $action->addParam('x-billaddr', $user->street);
         $action->addParam('x-billcity', $user->city);
         $action->addParam('x-billzip', $user->zip);
         $action->addParam('x-billcntry', $user->country);
         $action->addParam('x-billstate', $user->state);
         $action->addParam('x-auth-link', $this->getReturnUrl($request));
         $action->addParam('x-decl-link', $this->getCancelUrl($request));
     } else {
         $action = new Am_Paysystem_Action_Form($this->getActionURL($invoice));
         $action->addParam('x-billname', $user->getName());
         $action->addParam('x-billemail', $user->email);
         $action->addParam('x-billaddr', $user->street);
         $action->addParam('x-billcity', $user->city);
         $action->addParam('x-billzip', $user->zip);
         $action->addParam('x-billcntry', $user->country);
         $action->addParam('x-billstate', $user->state);
         $action->addParam('x-auth-link', $this->getReturnUrl($request));
         $action->addParam('x-decl-link', $this->getCancelUrl($request));
         $action->addParam('username', $invoice->getLogin());
         $action->addParam('publicid', $invoice->public_id);
     }
     $result->setAction($action);
 }