Example #1
0
 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);
 }
Example #2
0
 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();
 }
Example #3
0
 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();
 }
Example #4
0
 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);
 }
Example #5
0
 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);
 }
Example #6
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->merchant = $this->getConfig('merchant');
     $a->trans_id = $invoice->public_id;
     $a->amount = $invoice->first_total;
     $a->callback = $this->getPluginUrl('thanks');
     $a->digest = $this->calculateDigest($a);
     $a->bill_addr_1 = $invoice->getStreet();
     $a->bill_city = $invoice->getCity();
     $a->bill_country = $invoice->getCountry();
     $a->bill_email = $invoice->getEmail();
     $a->bill_name = $invoice->getName();
     $a->bill_post_code = $invoice->getZip();
     $a->bill_state = $invoice->getState();
     $a->bill_tel = $invoice->getPhone();
     $a->currency = $invoice->currency;
     $a->options = "cb_post=true,md_flds=trans_id:amount:callback";
     if ($invoice->rebill_times) {
         // Recurring payment;
         $a->repeat = sprintf("%s/%s/%s:%s", gmdate('Ymd', strtotime($invoice->calculateRebillDate(1))), $this->getPeriod($invoice->second_period), $invoice->rebill_times == IProduct::RECURRING_REBILLS ? '-1' : $invoice->rebill_times, $invoice->second_total);
         $a->repeat_callback = $a->callback;
     }
     if ($this->getConfig('testing')) {
         $a->test_status = 'true';
     }
     $result->setAction($a);
 }
Example #7
0
 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);
 }
Example #8
0
 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);
 }
Example #9
0
 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);
 }
Example #10
0
 function setShippingAddress(Invoice $invoice)
 {
     $this->addPostParameter('SHIPTONAME', $invoice->getName());
     $this->addPostParameter('SHIPTOSTREET', $invoice->getStreet());
     $this->addPostParameter('SHIPTOCITY', $invoice->getCity());
     $this->addPostParameter('SHIPTOSTATE', $invoice->getState());
     $this->addPostParameter('SHIPTOZIP', $invoice->getZip());
     $this->addPostParameter('SHIPTOCOUNTRY', $invoice->getCountry());
     $this->addPostParameter('SHIPTOPHONENUM', $invoice->getPhone());
 }
Example #11
0
 function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect('https://clickbetter.com/pay/' . $invoice->getItem(0)->getBillingPlanData('clickbetter_prod_item'));
     $result->setAction($a);
     $a->api = 'yes';
     $a->custom1 = $invoice->public_id;
     $a->first_name = $invoice->getFirstName();
     $a->last_name = $invoice->getLastName();
     $a->email = $invoice->getEmail();
     $a->city = $invoice->getCity();
     $a->address = $invoice->getStreet();
     $a->phone_no = $invoice->getPhone();
     $a->country = $invoice->getCountry();
     $a->zip = $invoice->getZip();
 }
Example #12
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL);
     $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);
 }
Example #13
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $action = new Am_Paysystem_Action_Form(self::ACTION_URL);
     $action->pos_id = $this->getConfig('pos_id');
     $action->pos_auth_key = $this->getConfig('pos_auth_key');
     $action->session_id = $invoice->public_id;
     $action->amount = round($invoice->first_total * 100);
     $action->desc = $invoice->getLineDescription();
     $action->first_name = $invoice->getFirstName();
     $action->last_name = $invoice->getLastName();
     $action->street = $invoice->getStreet();
     $action->city = $invoice->getCity();
     $action->postcode = $invoice->getZip();
     $action->email = $invoice->getEmail();
     $action->city = $this->getConfig('lang');
     $action->client_ip = $_SERVER['REMOTE_ADDR'];
     $result->setAction($action);
 }
Example #14
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $subaccount_id = $invoice->getItem(0)->getBillingPlanData("ccbill_subaccount_id") ? $invoice->getItem(0)->getBillingPlanData("ccbill_subaccount_id") : $this->getConfig('subaccount_id');
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->clientAccnum = $this->getConfig('account');
     $a->clientSubacc = $subaccount_id;
     $a->formName = $invoice->getItem(0)->getBillingPlanData("ccbill_form_id");
     $a->username = $user->login;
     $a->email = $invoice->getEmail();
     $a->customer_fname = $invoice->getFirstName();
     $a->customer_lname = $invoice->getLastName();
     $a->address1 = $invoice->getStreet();
     $a->city = $invoice->getCity();
     $a->state = $invoice->getState();
     $a->zipcode = $invoice->getZip();
     $a->country = $invoice->getCountry();
     $a->phone_number = $invoice->getPhone();
     $a->payment_id = $invoice->public_id;
     $a->customVar1 = $invoice->public_id;
     $a->invoice = $invoice->getSecureId("THANKS");
     $a->referer = $invoice->getUser()->aff_id;
     if ($this->getConfig('dynamic_pricing')) {
         $a->formPrice = $invoice->first_total;
         $a->formPeriod = $this->getDays($invoice->first_period);
         $a->currencyCode = $invoice->currency;
         if ($invoice->rebill_times) {
             if ($invoice->rebill_times == IProduct::RECURRING_REBILLS) {
                 $invoice->rebill_times = 99;
             }
             $a->formRecurringPrice = $invoice->second_total;
             $a->formRecurringPeriod = $this->getDays($invoice->second_period);
             $a->formRebills = $invoice->rebill_times;
             $a->formDigest = md5($s = $invoice->first_total . $this->getDays($invoice->first_period) . $invoice->second_total . $this->getDays($invoice->second_period) . $invoice->rebill_times . $invoice->currency . $this->getConfig('salt'));
         } else {
             $a->formDigest = md5($s = $invoice->first_total . $this->getDays($invoice->first_period) . $invoice->currency . $this->getConfig('salt'));
         }
     } else {
         $a->subscriptionTypeId = $invoice->getItem(0)->getBillingPlanData("ccbill_product_id");
         $a->allowedTypes = $invoice->getItem(0)->getBillingPlanData("ccbill_product_id");
         $a->allowedCurrencies = $this->currency_codes[$invoice->currency];
     }
     $result->setAction($a);
 }
Example #15
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->MerchantNumber = $this->getConfig('merchant_id');
     $a->Products = sprintf("%s::1::999::%s::", $invoice->first_total, $invoice->getLineDescription());
     $a->ReturnCGI = $this->getPluginUrl('thanks');
     $a->xxxName = $invoice->getName();
     $a->xxxAddress = $invoice->getStreet();
     $a->xxxCity = $invoice->getCity();
     $a->xxxProvince = $invoice->getState();
     $a->xxxCountry = $invoice->getCountry();
     $a->xxxPostal = $invoice->getZip();
     $a->xxxEmail = $invoice->getEmail();
     $a->xxxVar1 = $invoice->public_id;
     if ($this->getConfig('testing')) {
         $a->Products .= '{TEST}';
     }
     $result->setAction($a);
 }
Example #16
0
 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);
 }
Example #17
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->LOGIN = $this->getConfig('login');
     $a->PARTNER = $this->getConfig('partner');
     $a->AMOUNT = sprintf('%.2f', $invoice->first_total);
     $a->TYPE = 'S';
     $a->INVOICE = $invoice->public_id;
     $a->DESCRIPTION = $invoice->getLineDescription();
     $a->NAME = $invoice->getName();
     $a->ADDRESS = $invoice->getStreet();
     $a->CITY = $invoice->getCity();
     $a->STATE = $invoice->getState();
     $a->COUNTRY = $invoice->getCountry();
     $a->ZIP = $invoice->getZip();
     $a->EMAIL = $invoice->getEmail();
     $a->PHONE = $invoice->getPhone();
     $result->setAction($a);
 }
Example #18
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->con = 'my_cart';
     $a->met = 'addToCart';
     $a->pid = $invoice->getItem(0)->getBillingPlanData('premiumwebcart_id');
     $a->pquantity = 1;
     $a->clearcart = 1;
     $a->action = 2;
     $a->fname = $invoice->getFirstName();
     $a->lname = $invoice->getLastName();
     $a->email = $invoice->getEmail();
     $a->baddress1 = $invoice->getStreet();
     $a->bcity = $invoice->getCity();
     $a->bzip = $invoice->getZip();
     $a->bstate = $invoice->getState();
     $a->bcountry = $invoice->getCountry();
     $a->custom1 = $invoice->public_id;
     $result->setAction($a);
 }
Example #19
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Form(self::URL);
     $a->deferred_entry = 1;
     $a->mer_id = $this->getConfig('mer_id');
     $a->num_items = 1;
     $a->mer_url_idx = $this->getConfig('page_id');
     $a->item1_desc = $invoice->getLineDescription();
     $a->item1_price = $invoice->first_total;
     $a->item1_qty = 1;
     $a->user1 = $invoice->public_id;
     $a->user2 = $invoice->user_id;
     $a->cust_name = $invoice->getName();
     $a->cust_email = $invoice->getEmail();
     $a->card_name = $invoice->getName();
     $a->cust_address1 = $invoice->getStreet();
     $a->cust_city = $invoice->getCity();
     $a->cust_country = $invoice->getCountry();
     $a->cust_state = $invoice->getState();
     $a->cust_zip = $invoice->getZip();
     $result->setAction($a);
 }
Example #20
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->sid = $this->getConfig('seller_id');
     $a->mode = '2CO';
     $i = 0;
     foreach ($invoice->getItems() as $item) {
         $a->{"li_{$i}_type"} = 'product';
         $a->{"li_{$i}_name"} = $item->item_title;
         $a->{"li_{$i}_quantity"} = $item->qty;
         $a->{"li_{$i}_price"} = $item->rebill_times ? $item->second_total : $item->first_total;
         $a->{"li_{$i}_tangible"} = $item->is_tangible ? 'Y' : 'N';
         $a->{"li_{$i}_product_id"} = $item->item_id;
         if ($item->rebill_times) {
             $a->{"li_{$i}_recurrence"} = $this->period2Co($item->first_period);
             if ($item->rebill_times != IProduct::RECURRING_REBILLS) {
                 $a->{"li_{$i}_duration"} = $this->period2Co($item->first_period, $item->rebill_times);
             } else {
                 $a->{"li_{$i}_duration"} = 'Forever';
             }
             $a->{"li_{$i}_startup_fee"} = $item->first_total - $item->second_total;
         }
         $i++;
     }
     $a->skip_landing = 1;
     $a->x_Receipt_Link_URL = $this->getReturnUrl();
     $a->lang = $this->getConfig('lang', 'en');
     $a->merchant_order_id = $invoice->public_id;
     $a->first_name = $invoice->getFirstName();
     $a->last_name = $invoice->getLastName();
     $a->city = $invoice->getCity();
     $a->state = $invoice->getState();
     $a->zip = $invoice->getZip();
     $a->country = $invoice->getCountry();
     $a->email = $invoice->getEmail();
     $a->phone = $invoice->getPhone();
     $result->setAction($a);
 }
Example #21
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $xml = new SimpleXMLElement('<request/>');
     $transactiondetails = $xml->addChild('transactiondetails');
     $transactiondetails->addChild('merchantcode', $this->getConfig('merchantid'));
     $transactiondetails->addChild('merchantpwd', $this->getConfig('merchantpwd'));
     $transactiondetails->addChild('trackid', $invoice->public_id);
     $transactiondetails->addChild('customerip', $request->getClientIp());
     $transactiondetails->addChild('udf1', $invoice->public_id);
     $transactiondetails->addChild('customerid', $invoice->getLogin());
     $paymentdetails = $xml->addChild('paymentdetails');
     $paymentdetails->addChild('paysource', 'enets');
     $paymentdetails->addChild('amount', $invoice->first_total);
     $paymentdetails->addChild('currency', $invoice->currency);
     $paymentdetails->addChild('actioncode', 1);
     $notificationurls = $xml->addChild('notificationurls');
     $notificationurls->addChild('successurl', $this->getReturnUrl());
     $notificationurls->addChild('failurl', $this->getCancelUrl());
     $shippingdetails = $xml->addChild('shippingdetails');
     foreach (array('ship_address' => $invoice->getStreet(), 'ship_email' => $invoice->getEmail(), 'ship_postal' => $invoice->getZip(), 'ship_address2' => $invoice->getStreet1(), 'ship_city' => $invoice->getCity(), 'ship_state' => $invoice->getState(), 'ship_phone' => $invoice->getPhone(), 'ship_country' => $invoice->getCountry()) as $k => $v) {
         $shippingdetails->addChild($k, $v);
     }
     $req = new Am_HttpRequest($this->getConfig('gatewayurl'), Am_HttpRequest::METHOD_POST);
     $req->setHeader('Content-type: text/xml; charset=utf-8')->setHeader('Connection:close')->setBody($xml->asXML());
     $response = $req->send();
     $resxml = @simplexml_load_string($response->getBody());
     if (!$resxml instanceof SimpleXMLElement) {
         throw new Am_Exception_InputError('Incorrect Gateway response received!');
     }
     if ($paymenturl = (string) $resxml->transactionresponse->paymenturl) {
         $a = new Am_Paysystem_Action_Redirect($paymenturl);
         $result->setAction($a);
     } else {
         throw new Am_Exception_InputError('Incorrect Gateway response received! Got: ' . (string) $resxml->responsedesc);
     }
 }
Example #22
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $subaccount_id = $invoice->getItem(0)->getBillingPlanData("ecsuite_subaccount_id") ? $invoice->getItem(0)->getBillingPlanData("ecsuite_subaccount_id") : $this->getConfig('subaccount_id');
     $a = new Am_Paysystem_Action_Redirect(self::URL);
     $a->clientAccnum = $this->getConfig('account');
     $a->clientSubacc = $subaccount_id;
     $a->subscriptionTypeId = $invoice->getItem(0)->getBillingPlanData("ecsuite_product_id");
     $a->allowedTypes = $invoice->getItem(0)->getBillingPlanData("ecsuite_product_id");
     $a->username = $user->login;
     $a->email = $invoice->getEmail();
     $a->customer_fname = $invoice->getFirstName();
     $a->customer_lname = $invoice->getLastName();
     $a->address1 = $invoice->getStreet();
     $a->city = $invoice->getCity();
     $a->state = $invoice->getState();
     $a->zipcode = $invoice->getZip();
     $a->country = $invoice->getCountry();
     $a->phone_number = $invoice->getPhone();
     $a->payment_id = $invoice->public_id;
     $a->formName = $invoice->getItem(0)->getBillingPlanData("ecsuite_form_id");
     $a->customVar1 = $invoice->public_id;
     $result->setAction($a);
 }
    function getSaleCode(Invoice $invoice, InvoicePayment $payment)
    {
        $out = <<<CUT

<script type="text/javascript">
  var _gaq = _gaq || [];

if (typeof(_gaq)=='object') { // sometimes google-analytics can be blocked and we will avoid error
    _gaq.push(['_setAccount', '{$this->id}']);
    _gaq.push(['_trackPageview']);
}
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
CUT;
        if (empty($payment->amount)) {
            return $out;
        }
        $a = array($payment->transaction_id, "", $payment->amount, $payment->tax, $payment->shipping, $invoice->getCity(), $invoice->getState(), $invoice->getCountry());
        $a = implode(",\n", array_map('json_encode', $a));
        $items = "";
        // uncomment to enable items tracking
        //        foreach ($invoice->getItems() as $item)
        //        {
        //            $items .= "['_addItem', '$payment->transaction_id', '$item->item_id', '$item->item_title','', $item->first_total, $item->qty],";
        //        }
        return $out . <<<CUT
<script type="text/javascript">

if (typeof(_gaq)=='object') { // sometimes google-analytics can be blocked and we will avoid error
    _gaq.push(
        ['_addTrans', {$a}],
        {$items}
        ['_trackTrans']
    );
}
</script>
<!-- end of GA code -->
CUT;
    }
Example #24
0
 function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     if (!$this->getConfig('business')) {
         throw new Am_Exception_Configuration("There is a configuration error in [paypal] plugin - no [business] e-mail configured");
     }
     $a = new Am_Paysystem_Action_Redirect('https://' . $this->domain . '/cgi-bin/webscr');
     $result->setAction($a);
     $a->business = $this->getConfig('business');
     $a->return = $this->getReturnUrl();
     $a->notify_url = $this->getPluginUrl('ipn');
     $a->cancel_return = $this->getCancelUrl();
     $a->item_name = html_entity_decode($invoice->getLineDescription(), null, 'UTF-8');
     $a->no_shipping = $invoice->hasShipping() ? 0 : 1;
     $a->shipping = $invoice->first_shipping;
     $a->currency_code = strtoupper($invoice->currency);
     $a->no_note = 1;
     $a->invoice = $invoice->getRandomizedId();
     $a->bn = 'CgiCentral.aMemberPro';
     $a->first_name = $invoice->getFirstName();
     $a->last_name = $invoice->getLastName();
     $a->address1 = $invoice->getStreet();
     $a->city = $invoice->getCity();
     $a->state = $invoice->getState();
     $a->zip = $invoice->getZip();
     $a->country = $invoice->getCountry();
     $a->charset = 'utf-8';
     if ($lc = $this->getConfig('lc')) {
         $a->lc = $lc;
     }
     $a->rm = 2;
     if ($invoice->rebill_times) {
         $a->cmd = '_xclick-subscriptions';
         $a->sra = 1;
         if ($invoice->rebill_times == 1) {
             $a->src = 0;
         } else {
             $a->src = 1;
             //Ticket #HPU-80211-470: paypal_r plugin not passing the price properly (or at all)?
             if ($invoice->rebill_times != IProduct::RECURRING_REBILLS) {
                 $a->srt = $invoice->rebill_times;
             }
         }
         /** @todo check with rebill times = 1 */
         $a->a1 = $invoice->first_total;
         $p = new Am_Period($invoice->first_period);
         $a->p1 = $p->getCount();
         $a->t1 = $this->getPeriodUnit($p->getUnit());
         $a->tax1 = $invoice->first_tax;
         $a->a3 = $invoice->second_total;
         $p = new Am_Period($invoice->second_period);
         $a->p3 = $p->getCount();
         $a->t3 = $this->getPeriodUnit($p->getUnit());
         $a->tax3 = $invoice->second_tax;
     } else {
         $a->cmd = '_xclick';
         $a->amount = $invoice->first_total - $invoice->first_tax - $invoice->first_shipping;
         $a->tax = $invoice->first_tax;
     }
 }
Example #25
0
    function getSaleCode(Invoice $invoice, InvoicePayment $payment)
    {
        if ($this->getDi()->config->get('analytics_version', 'google') == 'universal') {
            $out = <<<CUT
<script type="text/javascript">
    ga('create', '{$this->id}', 'auto');
    ga('send', 'pageview');
</script>
CUT;
        } else {
            $out = <<<CUT

<script type="text/javascript">
if (typeof(_gaq)=='object') { // sometimes google-analytics can be blocked and we will avoid error
    _gaq.push(['_setAccount', '{$this->id}']);
    _gaq.push(['_trackPageview']);
}
</script>
CUT;
        }
        if (empty($payment->amount) && !$this->getDi()->config->get('google_analytics_track_free_signups')) {
            return $out;
        } elseif (empty($payment->amount)) {
            $a = array($invoice->public_id, $this->getDi()->config->get('site_title'), 0, 0, 0, $invoice->getCity(), $invoice->getState(), $invoice->getCountry());
        } else {
            $a = array($payment->transaction_id, $this->getDi()->config->get('site_title'), $payment->amount - $payment->tax - $payment->shipping, (double) $payment->tax, (double) $payment->shipping, $invoice->getCity(), $invoice->getState(), $invoice->getCountry());
        }
        $a = implode(",\n", array_map('json_encode', $a));
        $items = "";
        foreach ($invoice->getItems() as $item) {
            if ($this->getDi()->config->get('analytics_version', 'google') == 'universal') {
                $it = json_encode(array('id' => $payment->transaction_id, 'name' => $item->item_title, 'sku' => $item->item_id, 'price' => moneyRound($item->first_total / $item->qty), 'quantity' => $item->qty));
                $items .= "ga('ecommerce:addItem', {$it});\n";
            } else {
                $items .= "['_addItem', '{$payment->transaction_id}', '{$item->item_id}', '{$item->item_title}','', {$item->first_total}, {$item->qty}],";
            }
        }
        if ($this->getDi()->config->get('analytics_version', 'google') == 'universal') {
            $tr = json_encode(array('id' => $payment->transaction_id, 'affiliation' => $this->getDi()->config->get("site_title"), 'revenue' => empty($payment->amount) ? 0 : $payment->amount - $payment->tax - $payment->shipping, 'shipping' => empty($payment->amount) ? 0 : $payment->shipping, 'tax' => empty($payment->amount) ? 0 : $payment->tax));
            return $out . <<<CUT
<script type="text/javascript">
    ga('require', 'ecommerce');
    ga('ecommerce:addTransaction', {$tr});
    {$items}
    ga('ecommerce:send');
</script>
<!-- end of GA code -->
CUT;
        }
        return $out . <<<CUT
<script type="text/javascript">
if (typeof(_gaq)=='object') { // sometimes google-analytics can be blocked and we will avoid error
    _gaq.push(
        ['_addTrans', {$a}],
        {$items}
        ['_trackTrans']
    );
}
</script>
<!-- end of GA code -->
CUT;
    }
Example #26
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $vars = array('x_version' => '3.1', 'x_login' => $this->getConfig('login'), 'x_test_request' => $this->getTestRequestStatus(), 'x_show_form' => 'PAYMENT_FORM', 'x_amount' => $price = sprintf('%.2f', $invoice->first_total), 'x_receipt_link_url' => $this->getPluginUrl('thanks'), 'x_relay_url' => $this->getPluginUrl('thanks'), 'x_relay_response' => 'TRUE', 'x_cancel_url' => $this->getCancelUrl(), 'x_invoice_num' => $invoice->public_id, 'x_cust_id' => $invoice->getUserId(), 'x_description' => $invoice->getLineDescription(), 'x_fp_sequence' => $invoice->public_id, 'x_fp_timestamp' => $tstamp = time(), 'x_address' => $invoice->getStreet(), 'x_city' => $invoice->getCity(), 'x_country' => $invoice->getCountry(), 'x_state' => $invoice->getState(), 'x_zip' => $invoice->getZip(), 'x_email' => $invoice->getEmail(), 'x_first_name' => $invoice->getFirstName(), 'x_last_name' => $invoice->getLastName(), 'x_fp_hash' => hash_hmac('md5', $this->getConfig('login') . "^" . $invoice->public_id . "^" . $tstamp . "^" . $price . "^", $this->getConfig('tkey')));
     $action = new Am_Paysystem_Action_Redirect($this->getRedirectUrl() . "?" . http_build_query($vars, '', '&'));
     $result->setAction($action);
 }