Ejemplo n.º 1
0
Archivo: Data.php Proyecto: ext/magento
 public function verifyCredentials($eid, $secret)
 {
     $billmate = new BillMate($eid, $secret, true, false, false);
     $additionalinfo['PaymentData'] = array("currency" => 'SEK', "country" => 'se', "language" => 'sv');
     $result = $billmate->GetPaymentPlans($additionalinfo);
     if (isset($result['code']) && $result['code'] == '9013') {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 function process()
 {
     global $Shopp;
     $Shopping =& $Shopp->Shopping;
     $Order =& $Shopp->Order;
     require_once SHOPP_ADDONS . '/BillmateCore/BillMate.php';
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpc.inc";
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpcs.inc";
     $pno = $this->Order->pno;
     $phone = $this->Order->billmatephone;
     $eid = (int) $this->settings['eid'];
     $key = $this->settings['secretkey'];
     $ssl = true;
     $debug = false;
     $k = new BillMate($eid, $key, $ssl, $debug, $this->settings['testmode'] == 'on');
     $Customer = $this->Order->Customer;
     $Billing = $this->Order->Billing;
     $Shipping = $this->Order->Shipping;
     $country = $zone = $locale = $global = false;
     $country = $Billing->country;
     $country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
     $ship_address = $bill_address = array();
     $countryData = BillmateCountry::getCountryData($Shipping->country);
     $ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countryData['country']);
     $bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countryData['country']);
     foreach ($ship_address as $key => $col) {
         $ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     foreach ($bill_address as $key => $col) {
         $bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     extract($countryData);
     $goods_list = array();
     $taxrate = 0;
     if (sizeof($this->Order->Cart) <= 1 && !empty($this->settings['invoice_fee'])) {
         $Shopp->Order->Cart = array();
         new ShoppError(__('Cart is empty', 'shopp-billmate-invoice'), 2);
         $this->Order->feeadded = false;
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'cart') . '";</script>';
         die;
     }
     foreach ($this->Order->Cart as $item) {
         // echo links for the items
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $taxrate = $taxrate == 0 ? $item->taxrate : $taxrate;
         $goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
     }
     if ($this->Order->Cart->Totals->discount > 0) {
         $rate = (100 + $taxrate * 100) / 100;
         $totalAmt = $this->Order->Cart->Totals->discount;
         $price = $totalAmt - $totalAmt / $rate;
         $discount = $totalAmt - $price;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-invoice'), 'title' => __('Discount', 'shopp-billmate-invoice'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => $taxrate * 100, 'discount' => 0, 'flags' => $flag));
     }
     if (!empty($this->Order->Cart->Totals->shipping)) {
         $totalAmt = $this->Order->Cart->Totals->shipping;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-invoice'), 'title' => __('Shipping', 'shopp-billmate-invoice'), 'price' => round($totalAmt * 100, 0), 'vat' => $taxrate * 100, 'discount' => 0, 'flags' => 8));
     }
     $pclass = -1;
     $transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $currency, "country" => $country, "language" => $language, "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $order_info['customer_id'])));
     $result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
     //shopp_rmv_cart_item($this->settings['invoice_fee']);
     if (!is_array($result1)) {
         $this->remove_fee();
         /*
         if( !empty($this->settings['invoice_fee'])){
         	$Shopp->Order->Cart->remove(sizeof( $this->Order->Cart )-1);
         	$Shopp->Order->Cart->totals();
         	$this->Order->feeadded = false;
         	unset($this->Order->feeadded);
         }
         */
         new ShoppError(__('Unable to process billmate try again <br/>Error:', 'shopp-billmate-invoice') . utf8_encode($result1), 2);
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'checkout') . '";</script>';
         die;
     } else {
         $this->Order->billmateId = $result1[0];
     }
     $this->Order->pno = '';
     $this->Order->billmatephone = '';
     $this->Order->feeadded = false;
     $this->Order->transaction($this->txnid());
     return true;
 }
Ejemplo n.º 3
0
 function process()
 {
     global $Shopp;
     $Shopping =& $Shopp->Shopping;
     $Order =& $Shopp->Order;
     require_once SHOPP_ADDONS . '/BillmateCore/BillMate.php';
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpc.inc";
     include_once SHOPP_ADDONS . "/BillmateCore/lib/xmlrpcs.inc";
     $pno = $this->Order->partpaymentpno;
     $phone = $this->Order->partpaymentphone;
     $eid = (int) $this->settings['eid'];
     $key = $this->settings['secretkey'];
     $ssl = true;
     $debug = false;
     $k = new BillMate($eid, $key, $ssl, $debug, $this->settings['testmode'] == 'on');
     $Customer = $this->Order->Customer;
     $Billing = $this->Order->Billing;
     $Shipping = $this->Order->Shipping;
     $country = $zone = $locale = $global = false;
     $country = $Billing->country;
     $country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
     $ship_address = $bill_address = array();
     $countryData = BillmateCountry::getCountryData($Shipping->country);
     $ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countryData['country']);
     $bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countryData['country']);
     foreach ($ship_address as $key => $col) {
         $ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     foreach ($bill_address as $key => $col) {
         $bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     extract($countryData);
     //new ShoppError(var_export($Shipping->country,1), 'invalid_personal_number');
     //shopp_safe_redirect(shoppurl(false,'checkout'));
     $goods_list = array();
     foreach ($this->Order->Cart->contents as $item) {
         // echo links for the items
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
         $taxrate = $item->taxrate;
     }
     if ($this->Order->Cart->Totals->discount > 0) {
         $rate = (100 + $taxrate * 100) / 100;
         $totalAmt = $this->Order->Cart->Totals->discount;
         $price = $totalAmt - $totalAmt / $rate;
         $discount = $totalAmt - $price;
         $goods_list[] = array('qty' => 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-partpayment'), 'title' => __('Discount', 'shopp-billmate-partpayment'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => $taxrate * 100, 'discount' => 0, 'flags' => $flag));
     }
     if (!empty($this->Order->Cart->Totals->shipping)) {
         $taxrate = $taxrate * 100;
         //$rate = (100+$taxrate)/100;
         $totalAmt = $this->Order->Cart->Totals->shipping;
         //$price = $totalAmt-($totalAmt/$rate);
         // $shipping = $totalAmt - $price;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-partpayment'), 'title' => __('Shipping', 'shopp-billmate-partpayment'), 'price' => round($totalAmt * 100, 0), 'vat' => $taxrate, 'discount' => 0, 'flags' => 8));
     }
     $pclass = (int) $this->Order->pclass;
     $transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $currency, "country" => $country, "language" => $language, "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $order_info['customer_id'])));
     try {
         $result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
     } catch (Exception $ex) {
     }
     $this->Order->partpaymentpno = '';
     $this->Order->partpaymentphone = '';
     $this->Order->pclass = false;
     if (!is_array($result1)) {
         new ShoppError(__('It is not possible to pay with that method and to choose a different payment method or use a different personal number', 'shopp-billmate-partpayment'), 'billmate_error', SHOPP_TRXN_ERR);
         shopp_redirect(shoppurl(false, 'checkout'));
         die;
     } else {
         $this->Order->billmateId = $result1[0];
     }
     $this->Order->transaction($this->txnid());
     return true;
 }
Ejemplo n.º 4
0
 function billmate_transaction($add_order = false)
 {
     global $Shopp;
     $Shopping =& $Shopp->Shopping;
     $Order =& $Shopp->Order;
     if (empty($_POST)) {
         $_POST = $_GET;
     }
     $pno = '';
     $eid = (int) $this->settings['merchantid'];
     $key = $this->settings['cardpaysecret'];
     $ssl = true;
     $debug = false;
     $k = new BillMate($eid, $key, $ssl, $debug);
     $Customer = $this->Order->Customer;
     $Billing = $this->Order->Billing;
     $Shipping = $this->Order->Shipping;
     $country = $zone = $locale = $global = false;
     $country = $Billing->country;
     $country_to_currency = array('NO' => 'NOK', 'SE' => 'SEK', 'FI' => 'EUR', 'DK' => 'DKK', 'DE' => 'EUR', 'NL' => 'EUR');
     $ship_address = $bill_address = array();
     $countries = Lookup::countries();
     //$countryData = BillmateCountry::getCountryData($Shipping->country);
     $countryData = BillmateCountry::getSwedenData();
     $ship_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Shipping->address, 'house_number' => isset($house_no) ? $house_no : '', 'house_extension' => isset($house_ext) ? $house_ext : '', 'zip' => $Shipping->postcode, 'city' => $Shipping->city, 'country' => $countries[$Shipping->country]['name']);
     $bill_address = array('email' => $Customer->email, 'telno' => $Customer->phone, 'cellno' => '', 'fname' => $Customer->firstname, 'lname' => $Customer->lastname, 'company' => $Customer->company, 'careof' => '', 'street' => $Billing->address, 'house_number' => '', 'house_extension' => '', 'zip' => $Billing->postcode, 'city' => $Billing->city, 'country' => $countries[$Billing->country]['name']);
     foreach ($ship_address as $key => $col) {
         $ship_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     foreach ($bill_address as $key => $col) {
         $bill_address[$key] = utf8_decode(Encoding::fixUTF8($col));
     }
     extract($countryData);
     $goods_list = array();
     $taxrate = 0;
     foreach ($this->Order->Cart as $item) {
         // echo links for the items
         $flag = stripos($item->name, 'billmate fee') === false ? stripos($item->name, 'billmate invoice fee') === false ? 0 : 16 : 0;
         $taxrate = $taxrate == 0 ? $item->taxrate : $taxrate;
         $goods_list[] = array('qty' => (int) $item->quantity, 'goods' => array('artno' => $item->product, 'title' => $item->name, 'price' => round($item->unitprice * 100, 0), 'vat' => (double) round($item->taxrate * 100, 0), 'discount' => 0.0, 'flags' => $flag));
     }
     if ($this->Order->Cart->Totals->discount > 0) {
         $rate = (100 + $taxrate * 100) / 100;
         $totalAmt = $this->Order->Cart->Totals->discount;
         $price = $totalAmt - $totalAmt / $rate;
         $discount = $totalAmt - $price;
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('discount', 'shopp-billmate-cardpay'), 'title' => __('Discount', 'shopp-billmate-cardpay'), 'price' => -1 * abs(round($this->Order->Cart->Totals->discount * 100, 0)), 'vat' => (double) $taxrate * 100, 'discount' => (double) 0, 'flags' => $flag));
     }
     if (!empty($this->Order->Cart->Totals->shipping)) {
         /* $taxrate = $taxrate * 100;
            $rate = (100+$taxrate)/100;
            $totalAmt = $this->Order->Cart->Totals->shipping;
            $price = $totalAmt-($totalAmt/$rate);
            $shipping = $totalAmt - $price;*/
         $goods_list[] = array('qty' => (int) 1, 'goods' => array('artno' => __('Shipping', 'shopp-billmate-cardpay'), 'title' => __('Shipping', 'shopp-billmate-cardpay'), 'price' => round($this->Order->Cart->Totals->shipping * 100, 0), 'vat' => (double) $taxrate * 100, 'discount' => 0, 'flags' => 8));
     }
     $pclass = -1;
     $lang = explode("_", strtoupper(WPLANG));
     $base = $Shopp->Settings->get('base_operations');
     $_ = array();
     $transaction = array("order1" => (string) $this->txnid(), "comment" => (string) "", "flags" => 0, "reference" => "", "reference_code" => "", "currency" => $base['currency']['code'], "country" => 209, "language" => $lang[0], "pclass" => $pclass, "shipInfo" => array("delay_adjust" => "1"), "travelInfo" => array(), "incomeInfo" => array(), "bankInfo" => array(), "sid" => array("time" => microtime(true)), "extraInfo" => array(array("cust_no" => (string) $Customer->id, "creditcard_data" => $_POST)));
     if (!empty($this->Order->capture) && $this->Order->capture == 'YES') {
         $transaction["extraInfo"][0]["status"] = 'Paid';
     }
     if ($add_order) {
         return $k->AddOrder($pno, $bill_address, $ship_address, $goods_list, $transaction);
     }
     if (!isset($_SESSION['card_invoice_called']) || $_SESSION['card_invoice_called'] == false) {
         $result1 = $k->AddInvoice($pno, $bill_address, $ship_address, $goods_list, $transaction);
     } else {
         $result1[0] = $_SESSION['card_invoice_called_inv'];
     }
     if (!is_array($result1)) {
         new ShoppError(__('Unable to process billmate try again <br/>Error:', 'shopp-billmate-cardpay') . utf8_encode($result1), 2);
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'checkout') . '";</script>';
         die;
     } else {
         $this->Order->billmateId = $result1[0];
     }
 }