Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
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);
 }