Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     if (!$doFirst) {
         throw new Am_Exception_InternalError('Cannot to run rebill from aMember');
     }
     $post = array('approvedPage' => $this->getReturnUrl(), 'declinedPage' => $this->getCancelUrl(), 'errorPage' => $this->getCancelUrl(), 'merchant_id' => $this->getConfig('merchant_id'), 'trnOrderNumber' => $invoice->public_id, 'trnAmount' => $invoice->first_total, 'ordEmailAddress' => $invoice->getUser()->email, 'ordName' => $invoice->getUser()->getName(), 'trnComments' => $invoice->getLineDescription());
     if ($invoice->second_total > 0) {
         if ($invoice->first_total != $invoice->second_total) {
             throw new Am_Exception_InternalError('First price must be the same second price');
         }
         if ($invoice->first_period != $invoice->second_period) {
             throw new Am_Exception_InternalError('First period must be the same second period');
         }
         list($period, $period_unit) = self::parsePeriod($invoice->first_period);
         $post['trnRecurring'] = 1;
         $post['rbBillingPeriod'] = $period_unit;
         $post['rbBillingIncrement'] = $period;
     }
     $post['trnCardOwner'] = $cc->cc_name_f . " " . $cc->cc_name_l;
     $post['trnCardNumber'] = $cc->cc_number;
     $post['trnExpMonth'] = substr($cc->cc_expire, 0, 2);
     $post['trnExpYear'] = substr($cc->cc_expire, 2);
     $post['ordAddress1'] = $cc->cc_street;
     $post['ordCity'] = $cc->cc_city;
     $post['ordCountry'] = $cc->cc_country;
     $post['ordProvince'] = $cc->cc_state;
     $post['ordPostalCode'] = $cc->cc_zip;
     $post['ordPhoneNumber'] = $cc->cc_phone;
     $action = new Am_Paysystem_Action_Form(self::URL_PT);
     foreach ($post as $k => $v) {
         $action->{$k} = $v;
     }
     $result->setAction($action);
 }
Ejemplo n.º 4
0
 public function createForm()
 {
     $form = $this->plugin->createForm($this->_request->getActionName(), $this->invoice);
     $form->setDataSources(array($this->_request, new HTML_QuickForm2_DataSource_Array($form->getDefaultValues($this->invoice->getUser()))));
     $form->addHidden(Am_Controller::ACTION_KEY)->setValue($this->_request->getActionName());
     $form->addHidden('id')->setValue($this->getFiltered('id'));
     return $form;
 }
Ejemplo n.º 5
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $vars = array('amount' => $invoice->first_total, 'currency' => $invoice->currency, 'shop_reference_card' => $this->getConfig('shop_reference'), 'shop_reference_transfer' => $this->getConfig('shop_reference'), 'shop_name' => $this->getConfig('shop_name'), 'transaction_description' => $invoice->getLineDescription(), 'order_id' => $invoice->public_id, 'return_address' => $this->getPluginUrl('status-return-' . $invoice->public_id), 'success_url' => $this->getPluginUrl('status-ok-' . $invoice->public_id), 'failure_url' => $this->getPluginUrl('status-fail-' . $invoice->public_id), 'customer_first_name' => $invoice->getUser()->name_f, 'customer_second_name' => $invoice->getUser()->name_l, 'customer_email' => $invoice->getUser()->email);
     $this->getDi()->errorLogTable->log('paymento-request: [' . print_r($vars, true) . ']');
     $action = new Am_Paysystem_Action_Form($this->getPaymentUrl());
     foreach ($vars as $key => $value) {
         $action->{$key} = $value;
     }
     $result->setAction($action);
 }
Ejemplo n.º 6
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']);
     }
 }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL);
     $result->setAction($a);
     $a->StoreKey = $this->getConfig('storekey');
     $a->CustomerRefNo = $invoice->public_id;
     $a->PaymentType = '';
     $a->CardAction = '0';
     $a->OrderID = $invoice->invoice_id;
     $a->UserID = $invoice->getLogin();
     $a->Email = $invoice->getEmail();
     $a->CustomerIP = $user->remote_addr ? $user->remote_addr : $_SERVER['REMOTE_ADDR'];
     $a->Bname = $invoice->getFirstName() . ' ' . $invoice->getLastName();
     $a->Baddress1 = $user->street;
     $a->Bcity = $user->city;
     $a->Bpostalcode = $user->zip;
     $a->Bcountry = $user->country;
     $a->Sname = $invoice->getFirstName() . ' ' . $invoice->getLastName();
     $a->Saddress1 = $user->street;
     $a->Scity = $user->city;
     $a->Spostalcode = $user->zip;
     $a->Scountry = $user->country;
     $a->SubTotal = $invoice->first_total - $invoice->first_tax;
     $a->Tax1 = $invoice->first_tax;
     $a->ThanksURL = $this->getPluginUrl("thanks");
     $result->setAction($a);
 }
Ejemplo n.º 9
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);
 }
Ejemplo n.º 10
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect($this->getUrl());
     $params = array('PSPID' => $this->getConfig('pspid'), 'ORDERID' => $invoice->public_id, 'AMOUNT' => $invoice->first_total * 100, 'CURRENCY' => $invoice->currency, 'LANGUAGE' => 'en_US', 'CN' => $invoice->getUser()->getName(), 'EMAIL' => $invoice->getUser()->email, 'COM' => $invoice->getLineDescription(), 'ACCEPTURL' => $this->getReturnUrl(), 'DECLINEURL' => $this->getCancelUrl(), 'CANCELURL' => $this->getCancelUrl(), 'EXCEPTIONURL' => $this->getCancelUrl());
     ksort($params, SORT_STRING);
     $s = '';
     foreach ($params as $k => $v) {
         $s .= $k . '=' . $v . $this->getConfig('shain');
     }
     $params['SHASIGN'] = sha1($s);
     foreach ($params as $k => $v) {
         $a->{$k} = $v;
     }
     $this->logRequest($a);
     $result->setAction($a);
 }
Ejemplo n.º 11
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);
 }
Ejemplo n.º 12
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);
     }
 }
Ejemplo n.º 13
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $xml = new SimpleXMLElement('<ewaygateway></ewaygateway>');
     $xml->ewayCustomerID = $this->getConfig('customer_id');
     $xml->ewayTotalAmount = $doFirst ? $invoice->first_total * 100 : $invoice->second_total * 100;
     $xml->ewayCustomerFirstName = $cc->cc_name_f;
     $xml->ewayCustomerLastName = $cc->cc_name_l;
     $xml->ewayCustomerEmail = $invoice->getUser()->email;
     $xml->ewayCustomerAddress = $cc->cc_street;
     $xml->ewayCustomerPostcode = $cc->cc_zip;
     $xml->ewayCustomerInvoiceDescription = $invoice->getLineDescription();
     $xml->ewayCustomerInvoiceRef = $invoice->public_id;
     $xml->ewayCardHoldersName = sprintf('%s %s', $cc->cc_name_f, $cc->cc_name_l);
     $xml->ewayCardNumber = $cc->cc_number;
     $xml->ewayCardExpiryMonth = $cc->getExpire('%1$02d');
     $xml->ewayCardExpiryYear = $cc->getExpire('%2$02d');
     $xml->ewayTrxnNumber = $invoice->public_id;
     $xml->ewayOption1 = '';
     $xml->ewayOption2 = '';
     $xml->ewayOption3 = '';
     $xml->ewayCVN = $cc->getCvv();
     $request = new Am_HttpRequest($this->getGateway(), Am_HttpRequest::METHOD_POST);
     $request->setBody($xml->asXML());
     $request->setHeader('Content-type', 'text/xml');
     $tr = new Am_Paysystem_Transaction_CreditCard_Eway($this, $invoice, $request, $doFirst);
     $tr->run($result);
 }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
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);
 }
Ejemplo 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);
 }
Ejemplo n.º 18
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     if (!$user->data()->get(self::DATA_KEY)) {
         //create user
         $req = new Am_HttpRequest($this->url(), Am_HttpRequest::METHOD_POST);
         $req->addPostParameter(array('fn' => 'eWallet_RegisterUser', 'MerchantGUID' => $this->getConfig('MerchantGUID'), 'MerchantPassword' => $this->getConfig('MerchantPassword'), 'UserName' => $user->login, 'FirstName' => $user->name_f, 'LastName' => $user->name_l, 'EmailAddress' => $user->email, 'DateOfBirth' => '1/1/1900'));
         $this->logRequest($req);
         $resp = $req->send();
         $this->logResponse($resp);
         if ($resp->getStatus() != 200) {
             $result->setFailed('Incorrect HTTP response status: ' . $resp->getStatus());
             return;
         }
         parse_str($resp->getBody(), $tmp);
         parse_str($tmp['response'], $params);
         if ($params['m_Code'] != 'NO_ERROR') {
             $result->setFailed($params['m_Text']);
             return;
         }
         $user->data()->set(self::DATA_KEY, $params['TransactionRefID'])->update();
     }
     //create invoice
     $req = new Am_HttpRequest($this->url(), Am_HttpRequest::METHOD_POST);
     $arrItems = array('Amount' => $invoice->first_total, 'CurrencyCode' => $invoice->currency, 'ItemDescription' => $invoice->getLineDescription(), 'MerchantReferenceID' => $invoice->public_id, 'UserReturnURL' => $this->getReturnUrl(), 'MustComplete' => 'false', 'IsSubscription' => 'false');
     $req->addPostParameter(array('fn' => 'eWallet_AddCheckoutItems', 'MerchantGUID' => $this->getConfig('MerchantGUID'), 'MerchantPassword' => $this->getConfig('MerchantPassword'), 'UserName' => $user->login, 'arrItems' => sprintf('[%s]', http_build_query($arrItems)), 'AutoChargeAccount' => 'false'));
     $this->logRequest($req);
     $resp = $req->send();
     $this->logResponse($resp);
     if ($resp->getStatus() != 200) {
         $result->setFailed('Incorrect HTTP response status: ' . $resp->getStatus());
         return;
     }
     parse_str($resp->getBody(), $tmp);
     parse_str($tmp['response'], $params);
     if ($params['m_Code'] != 'NO_ERROR') {
         $result->setFailed($params['m_Text']);
         return;
     }
     //login and redirect
     $req = new Am_HttpRequest($this->url(), Am_HttpRequest::METHOD_POST);
     $req->addPostParameter(array('fn' => 'eWallet_RequestUserAutoLogin', 'MerchantGUID' => $this->getConfig('MerchantGUID'), 'MerchantPassword' => $this->getConfig('MerchantPassword'), 'UserName' => $user->login));
     $this->logRequest($req);
     $resp = $req->send();
     $this->logResponse($resp);
     if ($resp->getStatus() != 200) {
         $result->setFailed('Incorrect HTTP response status: ' . $resp->getStatus());
         return;
     }
     parse_str($resp->getBody(), $tmp);
     parse_str($tmp['responset'], $params);
     if ($params['m_Code'] != 'NO_ERROR') {
         $result->setFailed($params['m_Text']);
         return;
     }
     $a = new Am_Paysystem_Action_Redirect($this->urlLogin());
     $a->secKey = $params['m_ProcessorTransactionRefNumber'];
     $result->setAction($a);
 }
Ejemplo n.º 19
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     if (!($preapproval_id = $invoice->getUser()->data()->get(self::WEPAY_PREAPPROVAL_ID))) {
         throw new Am_Exception_Paysystem("Stored wepay preapproval id not found");
     }
     $tr = new Am_Paysystem_Transaction_WepayOnsite_Checkout_Charge($this, $invoice, $doFirst, $preapproval_id);
     $tr->run($result);
 }
Ejemplo n.º 20
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL_SUBSCRIPTION);
     $params = array('key' => $this->getConfig('key'), 'uid' => $invoice->getUser()->pk(), 'widget' => $this->getConfig('widget'), 'email' => $invoice->getUser()->email, 'amount' => $invoice->first_total, 'currencyCode' => $invoice->currency, 'ag_name' => $invoice->getLineDescription(), 'ag_external_id' => $invoice->public_id, 'ag_type' => $invoice->first_period == Am_Period::MAX_SQL_DATE ? self::TYPE_FIXED : self::TYPE_SUBSCRIPTION, 'ag_recurring' => $invoice->second_total > 0 ? 1 : 0, 'ag_trial' => $invoice->second_total > 0 && $invoice->first_total != $invoice->second_total ? 1 : 0, 'sign_version' => 2, 'success_url' => $this->getReturnUrl(), 'pingback_url' => $this->getPluginUrl('ipn'));
     if ($params['ag_type'] == self::TYPE_SUBSCRIPTION) {
         $period = new Am_Period($invoice->first_period);
         $params = array_merge($params, array('ag_period_length' => $period->getCount(), 'ag_period_type' => $this->trUnit($period->getUnit())));
     }
     if ($params['ag_trial']) {
         $period = new Am_Period($invoice->second_period);
         $params = array_merge($params, array('ag_post_trial_period_length' => $period->getCount(), 'ag_post_trial_period_type' => $this->trUnit($period->getUnit()), 'ag_post_trial_external_id' => $invoice->public_id, 'post_trial_amount' => $invoice->second_total, 'post_trial_currencyCode' => $invoice->currency, 'ag_post_trial_name' => $invoice->getLineDescription(), 'hide_post_trial_good' => 1));
     }
     $params['sign'] = $this->calculateSignature($params, $this->getConfig('secret'));
     foreach ($params as $k => $v) {
         $a->addParam($k, $v);
     }
     $result->setAction($a);
 }
Ejemplo n.º 21
0
 public function calculate(Invoice $invoiceBill)
 {
     $this->coupon = $invoiceBill->getCoupon();
     $this->user = $invoiceBill->getUser();
     $isFirstPayment = $invoiceBill->isFirstPayment();
     foreach ($invoiceBill->getItems() as $item) {
         $item->first_discount = $item->second_discount = 0;
         $item->_calculateTotal();
     }
     if (!$this->coupon) {
         return;
     }
     if ($this->coupon->getBatch()->discount_type == Coupon::DISCOUNT_PERCENT) {
         foreach ($invoiceBill->getItems() as $item) {
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, $isFirstPayment)) {
                 $item->first_discount = moneyRound($item->first_total * $this->coupon->getBatch()->discount / 100);
             }
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, false)) {
                 $item->second_discount = moneyRound($item->second_total * $this->coupon->getBatch()->discount / 100);
             }
         }
     } else {
         // absolute discount
         $discountFirst = $this->coupon->getBatch()->discount;
         $discountSecond = $this->coupon->getBatch()->discount;
         $first_discountable = $second_discountable = array();
         $first_total = $second_total = 0;
         $second_total = array_reduce($second_discountable, create_function('$s,$item', 'return $s+=$item->second_total;'), 0);
         foreach ($invoiceBill->getItems() as $item) {
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, $isFirstPayment)) {
                 $first_total += $item->first_total;
                 $first_discountable[] = $item;
             }
             if ($this->coupon->isApplicable($item->item_type, $item->item_id, false)) {
                 $second_total += $item->second_total;
                 $second_discountable[] = $item;
             }
         }
         if ($first_total) {
             $k = max(0, min($discountFirst / $first_total, 1));
             // between 0 and 1!
             foreach ($first_discountable as $item) {
                 $item->first_discount = moneyRound($item->first_total * $k);
             }
         }
         if ($second_total) {
             $k = max(0, min($discountSecond / $second_total, 1));
             // between 0 and 1!
             foreach ($second_discountable as $item) {
                 $item->second_discount = moneyRound($item->second_total * $k);
             }
         }
     }
     foreach ($invoiceBill->getItems() as $item) {
         $item->_calculateTotal();
     }
 }
Ejemplo n.º 22
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $subaccount_id = $invoice->getItem(0)->getBillingPlanData("ccbill_subaccount_id") ? $invoice->getItem(0)->getBillingPlanData("ccbill_subaccount_id") : $this->getConfig('subaccount_id');
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->clientAccnum = $this->getConfig('account');
     $a->clientSubacc = $subaccount_id;
     $a->formName = $invoice->getItem(0)->getBillingPlanData("ccbill_form_id");
     $a->username = $user->login;
     $a->email = $invoice->getEmail();
     $a->customer_fname = $invoice->getFirstName();
     $a->customer_lname = $invoice->getLastName();
     $a->address1 = $invoice->getStreet();
     $a->city = $invoice->getCity();
     $a->state = $invoice->getState();
     $a->zipcode = $invoice->getZip();
     $a->country = $invoice->getCountry();
     $a->phone_number = $invoice->getPhone();
     $a->payment_id = $invoice->public_id;
     $a->customVar1 = $invoice->public_id;
     $a->invoice = $invoice->getSecureId("THANKS");
     $a->referer = $invoice->getUser()->aff_id;
     if ($this->getConfig('dynamic_pricing')) {
         $a->formPrice = $invoice->first_total;
         $a->formPeriod = $this->getDays($invoice->first_period);
         $a->currencyCode = $invoice->currency;
         if ($invoice->rebill_times) {
             if ($invoice->rebill_times == IProduct::RECURRING_REBILLS) {
                 $invoice->rebill_times = 99;
             }
             $a->formRecurringPrice = $invoice->second_total;
             $a->formRecurringPeriod = $this->getDays($invoice->second_period);
             $a->formRebills = $invoice->rebill_times;
             $a->formDigest = md5($s = $invoice->first_total . $this->getDays($invoice->first_period) . $invoice->second_total . $this->getDays($invoice->second_period) . $invoice->rebill_times . $invoice->currency . $this->getConfig('salt'));
         } else {
             $a->formDigest = md5($s = $invoice->first_total . $this->getDays($invoice->first_period) . $invoice->currency . $this->getConfig('salt'));
         }
     } else {
         $a->subscriptionTypeId = $invoice->getItem(0)->getBillingPlanData("ccbill_product_id");
         $a->allowedTypes = $invoice->getItem(0)->getBillingPlanData("ccbill_product_id");
         $a->allowedCurrencies = $this->currency_codes[$invoice->currency];
     }
     $result->setAction($a);
 }
Ejemplo n.º 23
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     if (!($trxid = $invoice->getUser()->data()->get(self::INVOICE_TRANSACTION_ID))) {
         throw new Am_Exception_Paysystem("Stored targetpay-wap trxid not found");
     }
     $request = new Am_HttpRequest(self::LIVE_URL_FOLLOWUP, Am_HttpRequest::METHOD_POST);
     $request->addPostParameter(array('trxid' => $trxid, 'service' => $this->getConfig('service'), 'amount' => $invoice->second_total * 100, 'rtlo' => $this->getConfig('rtlo'), 'description' => $invoice->getLineDescription()));
     $tr = new Am_paysystem_Transaction_TargetpayWap_Charge($this, $invoice, $request, $doFirst);
     $tr->run($result);
 }
Ejemplo n.º 24
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Form(self::URL);
     $data = array('ik_co_id' => $this->getConfig('co_id'), 'ik_pm_no' => $invoice->public_id, 'ik_cur' => $invoice->currency, 'ik_am' => $invoice->first_total, 'ik_am_ed' => 0, 'ik_desc' => $invoice->getLineDescription(), 'ik_usr' => $invoice->getUser()->email, 'ik_ia_u' => $this->getPluginUrl('ipn'), 'ik_suc_u' => $this->getReturnUrl(), 'ik_fal_u' => $this->getCancelUrl(), 'ik_x_invoice' => $invoice->public_id);
     $data['ik_sign'] = $this->sign($data);
     foreach ($data as $k => $v) {
         $a->addParam($k, $v);
     }
     $result->setAction($a);
 }
Ejemplo n.º 25
0
 public function calculate(Invoice $invoiceBill)
 {
     $user = $invoiceBill->getUser();
     if (!$user) {
         $user = Am_Di::getInstance()->userRecord;
     }
     $this->tax_rate = $this->getTaxRate($user);
     $invoiceBill->tax_rate = $this->tax_rate;
     parent::calculate($invoiceBill);
 }
Ejemplo n.º 26
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $a = new Am_Paysystem_Action_Redirect($this->host());
     $vars = array('TransactionType' => 'SALE', 'ServiceID' => $this->getConfig('ServiceID'), 'PaymentID' => $invoice->public_id, 'OrderNumber' => $invoice->public_id, 'PaymentDesc' => $invoice->getLineDescription(), 'MerchantReturnURL' => $this->getPluginUrl('thanks'), 'Amount' => $invoice->first_total, 'CurrencyCode' => $invoice->currency, 'CustIP' => $request->getClientIp(), 'CustName' => $user->getName(), 'CustEmail' => $user->email, 'CustPhone' => $user->phone, 'MerchantName' => $this->getDi()->config->get('site_title'), 'PageTimeout' => '3600');
     $a->HashValue = hash('sha256', $this->getConfig('password') . $vars['ServiceID'] . $vars['PaymentID'] . $vars['MerchantReturnURL'] . $vars['Amount'] . $vars['CurrencyCode'] . $vars['CustIP'] . $vars['PageTimeout']);
     foreach ($vars as $k => $v) {
         $a->{$k} = $v;
     }
     $result->setAction($a);
 }
Ejemplo n.º 27
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $vars = array('INAME' => 'purchase', 'Mer' => $this->getConfig('merchant_desc'), 'MerchantID' => $this->getConfig('merchant_id'), 'TransactionID' => $invoice->public_id, 'UserDesc' => strlen($desc = $invoice->getLineDescription()) > 256 ? substr($desc, 0, 253) . "..." : $desc, 'Amount' => $invoice->first_total, 'Currency' => $invoice->currency, 'itemType' => $this->getConfig('is_adult', false) ? 1 : 3, 'SuccessUserPage' => $this->getPluginUrl('thanks'), 'FailureUserPage' => $this->getCancelUrl(), 'MerchantData' => $invoice->getSecureId(self::SECURE_STRING . $invoice->first_total), 'ResultPageMethod' => 'POST', 'settleImmediate' => 1, 'FirstName' => $user->name_f, 'LastName' => $user->name_l, 'email' => $user->email, 'Address' => $user->street, 'City' => $user->city, 'postCode' => $user->zip, 'Country' => $user->country, 'State' => $user->state, 'Telephone' => $user->phone);
     $this->logRequest($vars);
     $action = new Am_Paysystem_Action_Form($this->getConfig('test_mode') ? self::URL_PAY_TEST : self::URL_PAY_LIVE);
     foreach ($vars as $key => $value) {
         $action->{$key} = $value;
     }
     $result->setAction($action);
 }
Ejemplo n.º 28
0
 public function getFileName()
 {
     $filename = $this->getDi()->config->get('invoice_filename', 'amember-invoice-%public_id%.pdf');
     $filename = str_replace('%payment.date%', date('Y-m-d', amstrtotime($this->payment->dattm)), $filename);
     $tmp = new Am_SimpleTemplate();
     $tmp->assign('public_id', $this->invoice->public_id);
     $tmp->assign('receipt_id', $this->payment->receipt_id);
     $tmp->assign('payment', $this->payment);
     $tmp->assign('invoice', $this->invoice);
     $tmp->assign('user', $this->invoice->getUser());
     return $tmp->render($filename);
 }
Ejemplo n.º 29
0
 function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_HtmlTemplate_NetDebits($this->getDir(), 'payment-netdebit-redirect.phtml');
     $a->SID = $this->getConfig('SID');
     $a->PID = $this->getConfig('PID');
     $a->CON = $this->getConfig('CON');
     $a->VAR1 = $invoice->public_id;
     $a->ZAH = 2;
     $item = $invoice->getItem(0);
     $product_id = $item->item_id;
     $product = array_shift($this->getDi()->productTable->findByProductId($product_id));
     $a->POS = $product->data()->get(self::RATES);
     $a->KUN = $invoice->getUser()->data()->get(self::KNR) ? 1 : 0;
     $a->KNR = $invoice->getUser()->data()->get(self::KNR) ? $invoice->getUser()->data()->get(self::KNR) : '';
     if ($this->getConfig('testing')) {
         $a->F = 9090;
     } else {
         $a->F = 1000;
     }
     $result->setAction($a);
 }
Ejemplo n.º 30
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect($this->getConfig('url'));
     $a->customerPaymentPageText = $this->getConfig('tid');
     $a->orderDescription = $invoice->public_id;
     $a->orderdetail = $invoice->getLineDescription();
     $a->currencyText = $invoice->currency;
     $a->purchaseAmount = $invoice->first_total;
     $a->recurring = 0;
     $a->Email = $invoice->getUser()->email;
     $result->setAction($a);
 }