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 _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) { $u = $invoice->getUser(); $a = new Am_Paysystem_Action_Form($this->getConfig('testing') ? self::TEST_URL : self::LIVE_URL); $a->VPSProtocol = '3.00'; $a->TxType = 'PAYMENT'; $a->Vendor = $this->getConfig('login'); $vars = array('VendorTxCode=' . $invoice->public_id, 'Amount=' . $invoice->first_total, 'Currency=' . $invoice->currency, 'Description=' . $invoice->getLineDescription(), 'SuccessURL=' . $this->getPluginUrl('thanks'), 'FailureURL=' . $this->getCancelUrl(), 'CustomerEmail=' . $u->email, 'VendorEmail=' . $this->getDi()->config->get('admin_email'), 'CustomerName=' . $u->name_f . ' ' . $u->name_l); // New mandatory fields for 3.00 protocol // All mandatory fields must contain a value, apart from the BillingPostcode/DeliveryPostCode. $surname = $u->name_l != '' ? $u->name_l : 'Surname'; $firstname = $u->name_f != '' ? $u->name_f : 'Firstname'; $address = $u->street != '' ? $u->street : 'Address'; $city = $u->city != '' ? $u->city : 'City'; $country = $u->country != '' ? $u->country : 'US'; $state = $u->state != '' ? $u->state : 'AL'; $zip = $u->zip != '' ? $u->zip : '12345'; $vars[] = 'BillingSurname=' . $surname; $vars[] = 'BillingFirstnames=' . $firstname; $vars[] = 'BillingAddress1=' . $address; $vars[] = 'BillingCity=' . $city; $vars[] = 'BillingPostCode=' . $zip; $vars[] = 'BillingCountry=' . $country; $vars[] = 'DeliverySurname=' . $surname; $vars[] = 'DeliveryFirstnames=' . $firstname; $vars[] = 'DeliveryAddress1=' . $address; $vars[] = 'DeliveryCity=' . $city; $vars[] = 'DeliveryPostCode=' . $zip; $vars[] = 'DeliveryCountry=' . $country; if ($country == 'US') { //becomes mandatory when the BillingCountry/DeliveryCountry is set to US $vars[] = 'BillingState=' . $state; $vars[] = 'DeliveryState=' . $state; } /* * Important – if your business is classed as Financial Institution (Merchant code – 6012) * there are 4 additional fields that will need to be included with the transaction post from your system. * FIRecipientAcctNumber * FIRecipientSurname * FIRecipientPostcode * FIRecipientDoB */ //$a->Crypt = base64_encode($this->sagepay_simple_xor(implode('&',$vars), $this->getConfig('pass'))); $a->Crypt = self::encryptAes(implode('&', $vars), $this->getConfig('pass')); $a->filterEmpty(); $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::MODE_SANDBOX ? self::TESTING_URL : self::URL); $a->contractId = $invoice->getItem(0)->getBillingPlanData("plimus_contract_id"); $a->custom1 = $invoice->public_id; $a->member_id = $invoice->user_id; $a->currency = strtoupper($invoice->currency); $a->firstName = $invoice->getFirstName(); $a->lastName = $invoice->getLastName(); $a->email = $invoice->getEmail(); $a->overridePrice = sprintf("%.2f", $invoice->first_total); $a->overrideRecurringPrice = sprintf("%.2f", $invoice->second_total); if ($this->getConfig('testing') == self::MODE_TEST) { $a->testMode = Y; } $a->filterEmpty(); $result->setAction($a); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $u = $invoice->getUser(); $a = new Am_Paysystem_Action_Form(self::LIVE_URL); $a->account_id = $this->getConfig('account_id'); $a->return_url = $this->getPluginUrl('thanks') . '?DR={DR}'; $a->mode = $this->getConfig('mode'); $a->reference_no = $invoice->public_id; $a->amount = $invoice->first_total; $a->description = $invoice->getLineDescription(); $a->name = $u->name_f . ' ' . $u->name_l; $a->address = $u->street; $a->city = $u->city; $a->state = $u->state; $a->postal_code = $u->zip; $a->country = $u->country; $a->phone = $u->phone; $a->email = $u->email; $a->secure_hash = md5($this->getConfig('secret', "ebskey") . "|" . $a->account_id . "|" . $a->amount . "|" . $a->reference_no . "|" . $a->return_url . "|" . $a->mode); $a->filterEmpty(); $result->setAction($a); }