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) { $action = new Am_Paysystem_Action_Form(); $action->setUrl('https://www.cashu.com/cgi-bin/pcashu.cgi'); $action->merchant_id = $this->getConfig('merchant_id'); $action->amount = $invoice->first_total; $action->currency = $invoice->currency; $action->language = 'en'; $action->display_text = $invoice->getLineDescription(); $action->token = md5(strtolower($action->merchant_id . ":" . sprintf("%.2f", $action->amount) . ":" . $action->currency . ":") . $this->getConfig('secret')); $action->txt1 = $invoice->getLineDescription(); $action->txt2 = $invoice->public_id; $action->test_mode = $this->getConfig('testing'); $result->setAction($action); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $periods = array('y' => 'years', 'm' => 'months', 'd' => 'days', 'fixed' => 'years'); $u = $invoice->getUser(); $a = new Am_Paysystem_Action_Form(self::LIVE_URL); $a->language = $this->getDi()->app->getDefaultLocale(); $order = array(); $a->__set('order[shop_id]', $this->getConfig('shop_id')); $a->__set('order[currency]', $invoice->currency); $a->__set('order[email]', $u->email); $a->__set('order[success_url]', $this->getReturnUrl($request)); $a->__set('order[cancel_url]', $this->getCancelUrl($request)); $a->__set('order[fail_url]', $this->getCancelUrl($request)); $a->__set('order[notification_url]', $this->getPluginUrl('ipn')); $a->__set('order[billing_address_attributes][first_name]', $u->name_f); $a->__set('order[billing_address_attributes][last_name]', $u->name_l); $a->__set('order[billing_address_attributes][address]', $u->street); $a->__set('order[billing_address_attributes][country]', $u->country); $a->__set('order[billing_address_attributes][city]', $u->city); $a->__set('order[billing_address_attributes][zip]', $u->zip); $a->__set('order[billing_address_attributes][state]', $u->state); $a->__set('order[billing_address_attributes][zip]', $u->zip); //recurring if (!is_null($invoice->second_period)) { $a->__set('order[subscription_attributes][description]', $invoice->getLineDescription()); $a->__set('order[subscription_attributes][trial_amount]', $invoice->first_total * 100); $first_period = new Am_Period($invoice->first_period); $a->__set('order[subscription_attributes][trial_interval_unit]', $periods[$first_period->getUnit()]); $a->__set('order[subscription_attributes][trial_interval]', $first_period->getCount() == Am_Period::MAX_SQL_DATE ? '25' : $first_period->getCount()); $a->__set('order[subscription_attributes][amount]', $invoice->second_total * 100); $second_period = new Am_Period($invoice->second_period); $a->__set('order[subscription_attributes][interval_unit]', $periods[$second_period->getUnit()]); $a->__set('order[subscription_attributes][interval]', $second_period->getCount() == Am_Period::MAX_SQL_DATE ? '25' : $second_period->getCount()); if ($invoice->rebill_times) { $a->__set('order[subscription_attributes][rebill_limit]', $invoice->rebill_times); } } else { $a->__set('order[line_items_attributes][][name]', $invoice->getLineDescription()); $a->__set('order[line_items_attributes][][amount]', $invoice->first_total * 100); $a->__set('order[line_items_attributes][][quantity]', 1); $a->__set('order[tax_amount]', $invoice->first_tax * 100); } $a->__set('order[tracking_params_attributes][][name]', 'invoice_id'); $a->__set('order[tracking_params_attributes][][value]', $invoice->public_id); $a->filterEmpty(); $a->__set('order[signature]', hash('sha256', $sha = $a->__get('order[subscription_attributes][trial_amount]') . $a->__get('order[line_items_attributes][][amount]') . $a->__get('order[cancel_url]') . $a->__get('order[currency]') . $a->__get('order[email]') . $a->__get('order[fail_url]') . $a->__get('order[success_url]') . $invoice->public_id . $a->__get('order[subscription_attributes][amount]') . $a->__get('order[subscription_attributes][description]') . $a->__get('order[subscription_attributes][interval]') . $a->__get('order[subscription_attributes][interval_unit]') . $a->__get('order[subscription_attributes][rebill_limit]') . $a->__get('order[subscription_attributes][trial_amount]') . $a->__get('order[subscription_attributes][trial_interval]') . $a->__get('order[subscription_attributes][trial_interval_unit]') . $this->getConfig('secret_key'))); $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 _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); }
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) { $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) { $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_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) { $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) { $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) { $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); }
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_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) { $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(); 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); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $vars = array('fp_acc' => $this->getConfig('fp_account'), 'fp_store' => $this->getConfig('fp_store'), 'fp_item' => $invoice->getLineDescription(), 'fp_amnt' => $invoice->first_total, 'fp_currency' => $invoice->currency, 'fp_merchant_ref' => $invoice->public_id, 'fp_success_url' => $this->getReturnUrl(), 'fp_fail_url' => $this->getCancelUrl(), 'fp_status_url' => $this->getPluginUrl('ipn')); $this->logRequest($vars); $action = new Am_Paysystem_Action_Form($this->getConfig('is_sandbox') ? self::URL_TEST : self::URL_LIVE); foreach ($vars as $key => $value) { $action->{$key} = $value; } $result->setAction($action); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Redirect(self::URL); $params = array('MERCHANT_ID' => $this->getConfig('merchant'), 'AMOUNT' => $invoice->first_total, 'ORDER_NUMBER' => $invoice->public_id, 'REFERENCE_NUMBER' => '', 'ORDER_DESCRIPTION' => $invoice->getLineDescription(), 'CURRENCY' => $invoice->currency, 'RETURN_ADDRESS' => $this->getReturnUrl(), 'CANCEL_ADDRESS' => $this->getCancelUrl(), 'PENDING_ADDRESS' => '', 'NOTIFY_ADDRESS' => $this->getPluginUrl('ipn'), 'TYPE' => 'S1', 'CULTURE' => '', 'PRESELECTED_METHOD' => '', 'MODE' => '1', 'VISIBLE_METHODS' => '', 'GROUP' => ''); $params['AUTHCODE'] = strtoupper(md5($this->getConfig('hash') . '|' . implode('|', $params))); foreach ($params as $k => $v) { $a->addParam($k, $v); } $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $response = $this->_sendRequest('/redirect_flows', array('redirect_flows' => array('description' => $invoice->getLineDescription(), 'session_token' => Zend_Session::getId(), 'success_redirect_url' => $this->getDi()->config->get('root_url') . '/payment/gocardlesspro/thanks', 'links' => array('creditor' => $this->getConfig('merchant_id'))))); $response = json_decode($response->getBody(), true); if (!isset($response['redirect_flows']) || !isset($response['redirect_flows']['redirect_url'])) { return false; } $this->invoice->data()->set('gocardlesspro_id', $response['redirect_flows']['id'])->update(); $result->setAction(new Am_Paysystem_Action_Redirect($response['redirect_flows']['redirect_url'])); }
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::LIVE_URL); $vars = array('MrchLogin' => $this->getConfig('merchant_login'), 'OutSum' => $invoice->first_total, 'InvId' => $invoice->invoice_id, 'Desc' => $invoice->getLineDescription(), 'Culture' => $this->getConfig('language', 'en')); $vars['SignatureValue'] = $this->getSignature($vars, $this->getConfig('merchant_pass1')); foreach ($vars as $k => $v) { $a->addParam($k, $v); } $result->setAction($a); }
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); }
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); }
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); }
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); }
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); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $a = new Am_Paysystem_Action_Redirect(self::URL); $params = array('m_shop' => $this->getConfig('id'), 'm_orderid' => $invoice->public_id, 'm_amount' => $invoice->first_total, 'm_curr' => $invoice->currency, 'm_desc' => base64_encode($invoice->getLineDescription())); $params['m_sign'] = $this->calculateSignature($params); $params['m_process'] = 'send'; foreach ($params as $k => $v) { $a->addParam($k, $v); } $result->setAction($a); }
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); }