public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $m = $this->getConfig('methods'); if (@count($m) == 1) { $a = new Am_Paysystem_Action_Form(self::URL . $m[0] . '/event/'); } else { $a = new Am_Paysystem_Action_HtmlTemplate_Micropayment($this->getDir(), 'micropayment-confirm.phtml'); $methods = array(); if (@count($m)) { $a->url = self::URL . $m[0] . '/event/'; foreach ($m as $title) { $methods[self::URL . $title . '/event/'] = $this->getConfig($title . '.title'); } } else { foreach ($this->getConfig() as $k => $v) { if (is_array($v) && !empty($v['title'])) { $methods[self::URL . $k . '/event/'] = $v['title']; } } $a->url = array_shift(array_keys($methods)); } $a->methods = $methods; } $a->project = $this->getConfig('project'); $a->amount = $invoice->first_total * 100; $a->freepaymentid = $invoice->public_id; $a->seal = md5("project={$a->project}&amount={$a->amount}&freepaymentid={$a->freepaymentid}" . $this->getConfig('key')); $result->setAction($a); }
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); }
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); } }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Redirect(self::URL); $result->setAction($a); $a->MerchantID = $this->config['merchant_id']; $a->ProductID = $invoice->getItem(0)->getBillingPlanData('1shoppingcart_id'); $a->AMemberID = $invoice->invoice_id; $a->PostBackURL = $this->getDi()->config->get('root_url') . "/payment/1shoppingcart/ipn"; $a->filterEmpty(); $result->setAction($a); }
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); }
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); }
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); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Form(self::URL); $vars = array('MERCHANT' => $this->getConfig('email'), 'COUNTRY_ID' => $this->getConfig('country'), 'PAYMENT_METHOD_AVAILABLE' => 'all', 'TRANSACTION_ID' => $invoice->public_id); $i = '1'; foreach ($invoice->getItems() as $item) { //Creating new format without dot for $item->first_price $price = str_replace('.', '', $item->first_total); $vars['ITEM_NAME_' . $i] = $item->item_title; $vars['ITEM_CODE_' . $i] = $item->item_id; $vars['ITEM_AMMOUNT_' . $i] = $price; $vars['ITEM_QUANTITY_' . $i] = $item->qty; $vars['ITEM_CURRENCY_' . $i] = $item->currency; $i++; } $vars['CURRENCY'] = strtoupper($invoice->currency); foreach ($vars as $k => $v) { $a->__set($k, $v); } $a->__set('BUYER_FNAME', $invoice->getFirstName()); $a->__set('BUYER_LNAME', $invoice->getLastName()); $a->__set('BUYER_EMAIL', $invoice->getEmail()); $a->__set('BUYER_PHONE', $invoice->getPhone()); $a->__set('BUYER_STREET', $invoice->getStreet()); $a->__set('BUYER_STATE', $invoice->getState()); $a->__set('BUYER_CITY', $invoice->getCity()); $a->__set('BUYER_COUNTRY', $invoice->getCountry()); $a->__set('BUYER_ZIP_CODE', $invoice->getZip()); $a->__set('BUYER_CITY', $invoice->getCity()); $a->__set('BUYER_STATE', $invoice->getState()); $a->__set('LANGUAGE', $this->getConfig('language', 'es')); $result->setAction($a); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Redirect(self::URL); $a->products = current(array_filter(array($invoice->getItem(0)->getBillingPlanData('paypro_product_id'), $this->getConfig('product_id')))); $id = $this->invoice->getSecureId("THANKS"); $desc = array(); foreach ($invoice->getItems() as $it) { if ($it->first_total > 0) { $desc[] = $it->item_title; } } $desc = implode(',', $desc); $desc .= ". (invoice: {$id})"; $name = $invoice->getLineDescription(); $hash = "price={$invoice->first_total}-{$invoice->currency}^^^name={$name}^^^desc={$desc}"; $a->hash = base64_encode($this->getHash($hash)); $a->CustomField1 = $invoice->public_id; $a->firstname = $invoice->getFirstName(); $a->Lastname = $invoice->getLastName(); $a->Email = $invoice->getEmail(); $a->Address = $invoice->getStreet(); $a->City = $invoice->getCity(); $a->Country = $invoice->getCountry() == 'GB' ? 'united kingdom' : $invoice->getCountry(); $a->State = $invoice->getState(); $a->Zipcode = $invoice->getZip(); $a->Phone = $invoice->getPhone(); //$a->lnk = $this->getCancelUrl(); $result->setAction($a); }
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']); } }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Form(self::URL); $vars = array('MERCHANT' => $this->getConfig('merchant'), 'ORDER_REF' => $invoice->public_id, 'ORDER_DATE' => $invoice->tm_added); foreach ($invoice->getItems() as $item) { $vars['ORDER_PNAME[]'] = $item->item_title; $vars['ORDER_PCODE[]'] = $item->item_id; $vars['ORDER_PRICE[]'] = $item->first_price; $vars['ORDER_QTY[]'] = $item->qty; $vars['ORDER_VAT[]'] = $item->first_tax; } $vars['ORDER_SHIPPING'] = 0; $vars['PRICES_CURRENCY'] = strtoupper($invoice->currency); $vars['DISCOUNT'] = $invoice->first_discount; foreach ($vars as $k => $v) { $a->__set($k, $v); } $a->__set('ORDER_HASH', $this->calculateHash($vars)); $a->__set('BILL_FNAME', $invoice->getFirstName()); $a->__set('BILL_LNAME', $invoice->getLastName()); $a->__set('BILL_EMAIL', $invoice->getEmail()); $a->__set('BILL_PHONE', $invoice->getPhone()); $a->__set('BILL_ADDRESS', $invoice->getStreet()); $a->__set('BILL_ZIPCODE', $invoice->getZip()); $a->__set('BILL_CITY', $invoice->getCity()); $a->__set('BILL_STATE', $invoice->getState()); $a->__set('BILL_COUNTRYCODE', $invoice->getCountry()); $a->__set('LANGUAGE', $this->getConfig('language', 'ro')); if ($this->getConfig('testing')) { $a->__set('TESTORDER', 'TRUE'); } $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Redirect(self::URL); $result->setAction($a); $a->ok_receiver = $this->getConfig('wallet_id'); $a->ok_invoice = $invoice->public_id; $a->ok_currency = strtoupper($invoice->currency); if (!(double) $invoice->second_total) { $a->ok_kind = 'payment'; $a->ok_item_1_name = $invoice->getLineDescription(); $a->ok_item_1_price = $invoice->first_total; } else { $a->ok_kind = 'subscription'; $a->ok_s_title = $invoice->getLineDescription(); if ($invoice->first_total != $invoice->second_total || $invoice->first_period != $invoice->second_period) { $p = new Am_Period($invoice->first_period); $a->ok_s_trial_price = $invoice->first_total; $a->ok_s_trial_cycle = sprintf('%d %s', $p->getCount(), strtoupper($p->getUnit())); } $p = new Am_Period($invoice->second_period); $a->ok_s_regular_price = $invoice->second_total; $a->ok_s_regular_cycle = sprintf('%d %s', $p->getCount(), strtoupper($p->getUnit())); $a->ok_s_regular_count = $invoice->rebill_times == IProduct::RECURRING_REBILLS ? 0 : $invoice->rebill_times; } $a->ok_payer_first_name = $invoice->getFirstName(); $a->ok_payer_last_name = $invoice->getLastName(); $a->ok_payer_street = $invoice->getStreet(); $a->ok_payer_city = $invoice->getCity(); $a->ok_payer_state = $invoice->getState(); $a->ok_payer_zip = $invoice->getZip(); $a->ok_payer_country = $invoice->getCountry(); $a->ok_ipn = $this->getPluginUrl('ipn'); $a->ok_return_success = $this->getReturnUrl(); $a->ok_return_fail = $this->getCancelUrl(); }
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); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { //recurring if (!is_null($invoice->second_period)) { if ($invoice->first_total != $invoice->second_total) { throw new Am_Exception_InputError(___('Wepay does not support trial periods!')); } list($period, $end_time) = $this->getPeriod($invoice); $mode = 'preapproval'; $params = array('account_id' => $this->getConfig('account_id'), 'amount' => $invoice->second_total, 'short_description' => $invoice->getLineDescription(), 'redirect_uri' => $this->getReturnUrl(), 'callback_uri' => $this->getPluginUrl('ipn'), 'reference_id' => $invoice->public_id, 'frequency' => 1, 'end_time' => $end_time, 'auto_recur' => 'true', 'period' => $period, 'fee_payer' => $this->getConfig('fee_payer')); } else { $mode = 'checkout'; $params = array('account_id' => $this->getConfig('account_id'), 'amount' => $invoice->first_total, 'short_description' => $invoice->getLineDescription(), 'type' => 'GOODS', 'redirect_uri' => $this->getPluginUrl('thanks'), 'reference_id' => $invoice->public_id, 'fee_payer' => $this->getConfig('fee_payer')); } $params = array_filter($params); $req = new Am_HttpRequest($this->getUrl() . "/{$mode}/create", Am_HttpRequest::METHOD_POST); $req->setBody(json_encode($params)); $req->setHeader("Content-Type", "application/json"); $req->setHeader("Authorization", "Bearer " . $this->getConfig('token')); $res = $req->send(); $arr = json_decode($res->getBody(), true); if ($res->getStatus() != 200) { $this->getDi()->errorLogTable->log("WEPAY API ERROR : {$arr['error_code']} - {$arr['error_description']}"); throw new Am_Exception_InputError(___('Error happened during payment process. ')); } if (!empty($arr['error_description'])) { throw new Am_Exception_InputError($arr['error_description']); } $a = new Am_Paysystem_Action_Redirect(!empty($arr['checkout_uri']) ? $arr['checkout_uri'] : $arr['preapproval_uri']); $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::TEST_URL : self::URL); $a->instId = $this->getConfig('installation_id'); $a->cartId = $invoice->public_id; $a->currency = $invoice->currency; $a->desc = $invoice->getLineDescription(); $a->email = $invoice->getEmail(); $a->name = $invoice->getName(); $a->address = $invoice->getStreet(); $a->city = $invoice->getCity(); $a->state = $invoice->getState(); $a->postcode = $invoice->getZip(); //$a->MC_callback = preg_replace('|^https?://|', '', $this->getPluginUrl('ipn')); $a->amount = $invoice->first_total; if ($this->getConfig('testing')) { $a->testMode = 100; $a->name = 'CAPTURE'; } if ($invoice->rebill_times) { if ($invoice->rebill_times != IProduct::RECURRING_REBILLS) { $a->noOfPayments = $invoice->rebill_times; } $a->futurePayType = 'regular'; list($c, $u) = $this->period2Wp($invoice->second_period); $a->intervalUnit = $u; $a->intervalMult = $c; $a->normalAmount = $invoice->second_total; $a->option = 0; list($c, $u) = $this->period2Wp($invoice->first_period); $a->startDelayMult = $c; $a->startDelayUnit = $u; } $result->setAction($a); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Form(self::URL); $a->co_code = $this->getConfig('co_code'); $a->pi_code = $invoice->getItem(0)->getBillingPlanData('epoch_product_id'); if ($site_subcat = $invoice->getItem(0)->getBillingPlanData('epoch_site_subcat')) { $a->site_subcat = $site_subcat; } $a->reseller = 'a'; $a->zip = $invoice->getZip(); $a->email = $invoice->getEmail(); $a->country = $invoice->getCountry(); $a->no_userpass = self::YES; $a->name = $invoice->getName(); $a->street = $invoice->getStreet(); $a->phone = $invoice->getPhone(); $a->city = $invoice->getCity(); $a->state = $invoice->getState(); $a->pi_returnurl = $this->getPluginUrl("thanks"); $a->response_post = self::YES; $a->x_payment_id = $invoice->public_id; if ($this->getConfig('ach_form') == self::YES) { $a->ach_form = self::YES; } $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Form(self::WINDOW_URL); $currency = $this->getCurrencyCode($invoice); /* Mandatory input parameters: */ $formKeyValues = array(); $formKeyValues['merchant'] = $this->getConfig('merchant'); $formKeyValues['amount'] = intval($invoice->first_total * 100); $formKeyValues['currency'] = $currency; $formKeyValues['orderid'] = $invoice->public_id; $formKeyValues['acceptReturnUrl'] = $this->getReturnUrl($request); /* Optional input parameters: */ $formKeyValues['cancelreturnurl'] = $this->getCancelUrl($request); $formKeyValues['callbackurl'] = $this->getPluginUrl('ipn'); $formKeyValues['language'] = $this->getConfig('lang'); $formKeyValues['addFee'] = 1; $formKeyValues['capturenow'] = 1; /* Invoice's parameters: */ $formKeyValues['oiTypes'] = 'QUANTITY;DESCRIPTION;AMOUNT;ITEMID'; $formKeyValues['oiNames'] = 'Items;Description;Amount;ItemId'; $i = 0; foreach ($invoice->getItems() as $item) { $row_name = "oiRow" . ++$i; $formKeyValues[$row_name] = $item->qty . ";" . $item->item_title . ";" . intval($item->first_total * 100) . ";" . $item->item_id; } if ($this->getConfig('test')) { $formKeyValues['test'] = 1; } foreach ($formKeyValues as $k => $v) { $a->addParam($k, $v); } $a->addParam('MAC', $this->calculateMac($formKeyValues, $this->getConfig('hmackey'))); $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { if ($this->getConfig('instant') == 1) { $a = new Am_Paysystem_Action_Redirect($this->getActionUrl($invoice)); } else { $a = new Am_Paysystem_Action_Form("http://sites.fastspring.com/" . $this->getConfig('company') . "/api/order"); $a->operation = 'create'; $a->destination = 'checkout'; $i = 1; foreach ($invoice->getItems() as $item) { $path = "product_{$i}_path"; $quantity = "product_{$i}_quantity"; $a->{$path} = '/' . $item->getBillingPlanData('fastspring_product_id'); $a->{$quantity} = $item->qty; $i++; } } $a->contact_fname = $invoice->getFirstName(); $a->contact_lname = $invoice->getLastName(); //$a->contact_company = ''; $a->contact_email = $invoice->getEmail(); $a->contact_phone = $invoice->getPhone(); $a->referrer = $invoice->public_id; if ($this->getConfig('testing')) { $a->mode = 'test'; $a->member = 'new'; $a->sessionOption = 'new'; } $coupon = $invoice->getCoupon()->code; if ($coupon) { $a->coupon = $coupon; } $result->setAction($a); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { if (!$this->getConfig('wallet_id')) { throw new Am_Exception_Configuration("There is a configuration error in [okpay] plugin - no [wallet_id] Wallet ID or e-mail"); } $a = new Am_Paysystem_Action_Redirect(self::URL); $result->setAction($a); # Payment config $a->ok_receiver = $this->getConfig('wallet_id'); $a->ok_invoice = $invoice->getRandomizedId(); $a->ok_currency = strtoupper($invoice->currency); $a->ok_item_1_name = $invoice->getLineDescription(); $a->ok_item_1_price = $invoice->first_total; # Payer data $a->ok_payer_first_name = $invoice->getFirstName(); $a->ok_payer_last_name = $invoice->getLastName(); $a->ok_payer_street = $invoice->getStreet(); $a->ok_payer_city = $invoice->getCity(); $a->ok_payer_state = $invoice->getState(); $a->ok_payer_zip = $invoice->getZip(); $a->ok_payer_country = $invoice->getCountry(); # IPN and Return URLs $a->ok_ipn = $this->getPluginUrl('ipn'); $a->ok_return_success = $this->getReturnUrl(); $a->ok_return_fail = $this->getCancelUrl(); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Form($this->getConfig('testing') ? self::TEST_URL : self::LIVE_URL); $a->vendor_name = $this->getConfig('vendor_name'); $a->payment_alert = $this->getDi()->config->get('admin_email'); $a->__set($invoice->getLineDescription(), $invoice->first_total); $a->payment_reference = $invoice->public_id; $a->receipt_address = $invoice->getEmail(); if (floatval($invoice->first_tax) > 0) { $a->gst_rate = $invoice->tax_rate; $a->gst_added = 'true'; } $if = array(); $a->__set($if[] = 'E-Mail', $invoice->getEmail()); $a->__set($if[] = 'Country', $this->getCountry($invoice)); $a->__set($if[] = 'Name', $invoice->getName()); $a->__set($if[] = 'Street/PO Box', $invoice->getStreet()); $a->__set($if[] = 'City', $invoice->getCity()); $a->__set($if[] = 'State', $this->getState($invoice)); $a->__set($if[] = 'Post Code', $invoice->getZip()); $a->__set($if[] = 'Telephone Number', $invoice->getPhone()); $a->information_fields = implode(',', $if); $a->return_link_url = $this->getReturnUrl(); $a->reply_url = $this->getPluginUrl('ipn') . '?invoice=' . $invoice->public_id; $a->reply_link_url = $this->getPluginUrl('ipn') . '?invoice=' . $invoice->public_id; $result->setAction($a); }
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) { $a = new Am_Paysystem_Action_Form(self::URL_LIVE); $result->setAction($a); $sequence = rand(1, 1000); $vars = array('x_version' => '1.0', 'x_login' => $this->getConfig('login'), 'x_invoice_num' => $invoice->public_id, 'x_method' => $this->getConfig('testmode') ? 'TEST' : 'NONE', 'x_name' => $invoice->getName(), 'x_address' => $invoice->getStreet(), 'x_address2' => $invoice->getStreet2(), 'x_city' => $invoice->getCity(), 'x_country' => $invoice->getCountry(), 'x_state' => $invoice->getState(), 'x_zip' => $invoice->getZip(), 'x_email' => $invoice->getEmail(), 'x_currency_code' => $invoice->currency, 'x_amount' => $price = sprintf('%.2f', $invoice->first_total), 'x_tax_amount' => $tprice = sprintf('%.2f', $invoice->first_tax), 'x_fp_sequence' => $sequence, 'x_fp_arg_list' => 'x_login^x_fp_arg_list^x_fp_sequence^x_amount^x_currency_code', 'x_fp_hash' => '', 'x_fp_hash' => md5($q = $this->getConfig('login') . "^x_login^x_fp_arg_list^x_fp_sequence^x_amount^x_currency_code^" . $sequence . "^" . $price . "^" . $invoice->currency . "^" . $this->getConfig('key'))); foreach ($invoice->getItems() as $kk => $item) { $k = $kk + 1; $vars['x_product_sku_' . $k] = $item->item_id; $vars['x_product_title_' . $k] = $item->item_title; $vars['x_product_quantity_' . $k] = $item->qty; $vars['x_product_unitprice_' . $k] = $item->first_total; $vars['x_product_url_' . $k] = ROOT_URL; } foreach ($vars as $k => $v) { $a->addParam($k, $v); } $result->setAction($a); }
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); }