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($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL); $a->merchant_id = $this->getConfig('merchant_id'); $a->merchant_site_id = $this->getConfig('merchant_site_id'); $a->currency = $invoice->currency; $a->version = '3.0.0'; $a->merchant_unique_id = $invoice->public_id; $a->first_name = $invoice->getFirstName(); $a->last_name = $invoice->getLastName(); $a->email = $invoice->getEmail(); $a->address1 = $invoice->getStreet(); $a->address2 = $invoice->getStreet1(); $a->city = $invoice->getCity(); $a->country = $invoice->getCountry(); $a->state = $invoice->getState(); $a->zip = $invoice->getZip(); $a->phone1 = $invoice->getPhone(); $a->time_stamp = date("Y-m-d.h:i:s"); if ($invoice->rebill_times && ($gate2shop_id = $invoice->getItem(0)->getBillingPlanData('gate2shop_id')) && ($gate2shop_template_id = $invoice->getItem(0)->getBillingPlanData('gate2shop_template_id'))) { $a->productId = $invoice->getItem(0)->item_id; $a->rebillingProductId = $gate2shop_id; $a->rebillingTemplateId = $gate2shop_template_id; if ($invoice->rebill_times) { $a->isRebilling = 'true'; } $a->checksum = md5($this->getConfig('secret_key') . $this->getConfig('merchant_id') . $gate2shop_id . $gate2shop_template_id . $a->time_stamp); } else { $a->total_amount = $invoice->first_total; $a->discount = $invoice->first_discount; $a->total_tax = $invoice->first_tax; $a->numberofitems = count($invoice->getItems()); for ($i = 0; $i < $a->numberofitems; $i++) { $item = $invoice->getItem($i); $a->addParam('item_name_' . ($i + 1), $item->item_title); $a->addParam('item_number_' . ($i + 1), $i + 1); $a->addParam('item_amount_' . ($i + 1), $item->first_price); $a->addParam('item_discount_' . ($i + 1), $item->first_discount); $a->addParam('item_quantity_' . ($i + 1), $item->qty); } $a->checksum = $this->calculateOutgoingHash($a, $invoice); } $a->filterEmpty(); $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('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) { $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 _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(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) { $u = $invoice->getUser(); $a = new Am_Paysystem_Action_Redirect(self::API_URL); /* */ $params = array('aid' => $this->getConfig('aid'), 'portalid' => $this->getConfig('portalid'), 'mode' => $this->getConfig('testing') ? 'test' : 'live', 'encoding' => 'UTF-8', 'clearingtype' => 'cc', 'reference' => $invoice->public_id, 'customerid' => $invoice->user_id, 'invoiceid' => $invoice->public_id, 'param' => $invoice->public_id, 'successurl' => $this->getReturnUrl(), 'backurl' => $this->getCancelUrl()); //Parameter („createaccess“) $first_period = new Am_Period($invoice->first_period); $params['request'] = 'createaccess'; $params['productid'] = $invoice->getItem(0)->getBillingPlanData('payone_product_id'); // + + N..7 ID for the offer $params['amount_trail'] = $invoice->first_total * 100; // - + N..6 Total price of all items during the initial term. Must equal the sum (quantity * price) of all items for the initial term (in the smallest currency unit, e.g. Cent). $params['period_unit_trail'] = strtoupper($first_period->getUnit()); // - + Default Time unit for initial term, possible values: Y: Value in years M: Value in months D: Value in days $params['period_length_trail'] = $first_period->getCount(); // - + N..4 Duration of the initial term. Can only be used in combination with period_unit_trail. $params['id_trail'] = $invoice->getItem(0)->billing_plan_id; // + + AN..100 Item number (initial term) $params['no_trail'] = 1; // + + N..5 Quantity (initial term) $params['pr_trail'] = $invoice->first_total * 100; // + + N..7 Unit price of the item in smallest currency unit (initial term) $params['de_trail'] = $invoice->getItem(0)->item_description; // + + AN..255 Description (initial term) $params['ti_trail'] = $invoice->getItem(0)->item_title; // + + AN..100 Title (initial term) //$params['va_trail'] = ''; // - + N..4 VAT rate (% or bp) (initial term) value < 100 = percent value > 99 = basis points if ($invoice->second_total > 0) { $second_period = new Am_Period($invoice->second_period); $params['amount_recurring'] = $invoice->second_total * 100; // - + N..6 Total price of all items during the subsequent term. Must equal the sum (quantity * price) of all items for the subsequent term (in the smallest currency unit, e.g. Cent). $params['period_unit_recurring'] = strtoupper($second_period->getUnit()); // - + Default Time unit for subsequent term, possible values: Y: Value in years M: Value in months D: Value in days N: only if no subsequent term $params['period_length_recurring'] = $second_period->getCount(); // - + N..4 Duration of the subsequent term. Can only be used in combination with period_unit_recurring. $params['id_recurring'] = $invoice->getItem(0)->billing_plan_id; // - + AN..100 Item number (subsequent term) $params['no_recurring'] = 1; // - + N..5 Quantity (subsequent term) $params['pr_recurring'] = $invoice->second_total * 100; // - + N..7 Unit price of the item in smallest currency unit (subsequent term) $params['de_recurring'] = $invoice->getItem(0)->item_description; // - + AN..255 Description (subsequent term) $params['ti_recurring'] = $invoice->getItem(0)->item_title; // - + AN..100 Title (subsequent term) //$params['va_recurring'] = ''; // - + N..4 VAT rate (% or bp) (subsequent term) value < 100 = percent value > 99 = basis points ///// } /* //Parameter ( „pre-/authorization“ ) $params['request'] = 'authorization'; $params['amount'] = $invoice->first_total * 100; $params['currency'] = $invoice->currency; $params['it'] = 'goods'; //For BSV: Item type $params['id'] = ''; //Your item no. $params['pr'] = $invoice->first_total * 100; //Price in Cent $params['no'] = 1; //Quantity $params['de'] = ''; //Item description //$params['va'] = ''; //VAT (optional) ///// */ ksort($params); $a->hash = strtolower(md5(implode('', $params) . $this->getConfig('secret_key'))); //Hash value (see chapter 3.1.4) //Parameter ( personal data ) $params['firstname'] = $u->name_f; //AN..50 First name $params['lastname'] = $u->name_l; //AN..50 Surname //$params['company'] = ''; //AN..50 Company $params['street'] = $u->street; //AN..50 Street $params['zip'] = $u->zip; //AN..10 Postcode $params['city'] = $u->city; //AN..50 City $params['country'] = $u->country; //Default Country (ISO 3166) $params['email'] = $u->email; //AN..50 Email address $params['language'] = 'en'; //Language indicator (ISO 639) //If the language is not transferred, the browser //language will be used. For a non-supported //language, English will be used. ///// foreach ($params as $k => $v) { $a->addParam($k, $v); } $result->setAction($a); }