Example #1
0
 public function get_error_url()
 {
     // @see /shopp/core/functions.php#L1873
     // @see /shopp/core/flow/Storefront.php#L1364
     return shoppurl(array('messagetype' => 'error'), 'thanks');
 }
Example #2
0
 function isPermitted()
 {
     if (!$this->isConfigured()) {
         new ShoppError(__('Billmate Invoice is not cofigured', 'shopp-billmate-invoice'), 2);
         echo '<script type="text/javascript">window.location.href="' . shoppurl(false, 'checkout') . '";</script>';
     }
 }
Example #3
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];
     }
 }