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; }
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; }