Index: ds/wpsg_mod_cab.class.php
===================================================================
--- /mods/wpsg_mod_cab.class.php	(revision 5988)
+++ 	(revision )
@@ -1,803 +1,0 @@
-<?php
-
-	/**
-	 * Klasse die die Zahlungsart Click&Buy ermÃ¶glicht
-	 * @author daniel
-	 */
-	class wpsg_mod_cab extends wpsg_mod_basic 
-	{
-		
-		var $lizenz = 2;
-		var $id = 810; 
-		
-		var $version = "9.9.9";
-		var $hilfeURL = 'http://wpshopgermany.de/?p=969';		 
-		var $free = true;
-		
-		/**
-		 * Costructor
-		 */
-		public function __construct()
-		{
-			
-			parent::__construct();
-			
-			$this->name = __('Click & Buy', 'wpsg');
-			$this->group = __('Zahlungsarten', 'wpsg');
-			$this->desc = __('ErmÃ¶glicht die Zahlungsart ClickandBuy.', 'wpsg');
-						
-		} // public function __construct()
-		
-		public function install()
-		{
-			
-			$this->shop->checkDefault('wpsg_mod_cab_bezeichnung', $this->name, false, true);
-			$this->shop->checkDefault('wpsg_mod_cab_bezeichnung', '', false, true);
-			$this->shop->checkDefault('wpsg_mod_cab_aktiv', '1');
-			$this->shop->checkDefault('wpsg_mod_cab_sandbox', '1');
-			$this->shop->checkDefault('wpsg_mod_cab_hint', __('Wickeln Sie ihre Bestellung ÃŒber Click&Buy ab.', 'wpsg'), false, true);
-			
-			$this->shop->checkDefault('wpsg_mod_cab_merchantID', '<!-- Erhalten Sie von Click&Buy --!>');
-			$this->shop->checkDefault('wpsg_mod_cab_projectID', '<!-- Erhalten Sie von Click&Buy --!>');
-			$this->shop->checkDefault('wpsg_mod_cab_kryptkey', '<!-- Erhalten Sie von Click&Buy --!>');
-			
-			$this->shop->checkDefault('wpsg_mod_cab_mmskryptkey', '<!-- Erhalten Sie von Click&Buy --!>');
-			$this->shop->checkDefault('wpsg_mod_cab_mmsstatusmail', '');
-			
-			$this->shop->checkDefault('wpsg_mod_cab_mmskryptkey', '');
-			$this->shop->checkDefault('wpsg_mod_cab_mmsstatusmail', '');
-			
-			$this->shop->checkDefault('wpsg_mod_cab_gebuehr', '0');
-			$this->shop->checkDefault('wpsg_mod_cab_mwst', '0');
-			$this->shop->checkDefault('wpsg_mod_cab_mwstland', '0');
-			
-			$this->shop->checkDefault('wpsg_mod_cab_currency', 'EUR');
-			$this->shop->checkDefault('wpsg_mod_cab_autorun', '0');
-			
-			// Bestelltabelle erweitern
-		  	require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
-			
-			$sql = "CREATE TABLE ".WPSG_TBL_ORDER." (
-		   		cab_externalid varchar(255) NOT NULL,
-   				cab_requestTrackingID varchar(255) NOT NULL,
-   				cab_transactionID varchar(255) NOT NULL,
-			   	cab_transactionStatus varchar(255) NOT NULL,
-		   		cab_started datetime NOT NULL,
-   				cab_lastupdate datetime NOT NULL,
-		   		cab_paylink varchar(5000) NOT NULL,
-   				cab_repayed double(10,2) NOT NULL
-		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-			 
-			dbDelta($sql);
-			 
-			// Tabelle fÃŒr Click&Buy Log 			
-			$sql = "CREATE TABLE ".WPSG_TBL_CABLOG." (
-		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
-			  	cdate datetime NOT NULL,
-			  	extID varchar(255) NOT NULL,
-			  	transID varchar(255) NOT NULL,
-			  	eventID int(11) NOT NULL,
-			  	oldState varchar(255) NOT NULL,
-			  	newState varchar(255) NOT NULL,
-			  	PRIMARY KEY  (id)	  
-		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-			
-			dbDelta($sql);
-			
-		} // public function install()
-		
-		public function delOrder(&$order_id) { } // public function delOrder(&$order_id)
-		
-		public function settings_edit()
-		{
-						
-			$pages = get_pages();
-			 
-			foreach ($pages as $k => $v)
-			{
-				
-				$this->shop->view['pages'][$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
-				$this->shop->view['pageURLs'][$v->ID] = get_permalink($v->ID);
-				
-			}
-			
-			$basket_link = get_permalink(get_option('wpsg_page_basket'));
-			
-			if (strpos($basket_link, "?") > 0)
-			{
-				$mmsURL = $basket_link."&wpsg_plugin=wpsg_mod_cab&confirm=mms&no_head=1";
-			}
-			else
-			{
-				$mmsURL = $basket_link."?wpsg_plugin=wpsg_mod_cab&confirm=mms&no_head=1";
-			}
-			
-			$this->shop->view['wpsg_mod_cab_mmspushurl'] = preg_replace("/^http:/", "https:", $mmsURL);
-						
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/settings_edit.phtml');
-			
-		} // public function settings_edit()
-		
-		public function settings_save()
-		{
-			
-			$this->shop->update_option('wpsg_mod_cab_bezeichnung', $_REQUEST['wpsg_mod_cab_bezeichnung']);
-			$this->shop->update_option('wpsg_mod_cab_auftragsbezeichnung', $_REQUEST['wpsg_mod_cab_auftragsbezeichnung']);
-			$this->shop->update_option('wpsg_mod_cab_aktiv', $_REQUEST['wpsg_mod_cab_aktiv']);
-			$this->shop->update_option('wpsg_mod_cab_sandbox', $_REQUEST['wpsg_mod_cab_sandbox']);
-			$this->shop->update_option('wpsg_mod_cab_hint', $_REQUEST['wpsg_mod_cab_hint']);
-			
-			$this->shop->update_option('wpsg_mod_cab_merchantID', $_REQUEST['wpsg_mod_cab_merchantID']);
-			$this->shop->update_option('wpsg_mod_cab_projectID', $_REQUEST['wpsg_mod_cab_projectID']);
-			$this->shop->update_option('wpsg_mod_cab_kryptkey', $_REQUEST['wpsg_mod_cab_kryptkey']);
-			
-			$this->shop->update_option('wpsg_mod_cab_mmskryptkey', $_REQUEST['wpsg_mod_cab_mmskryptkey']);
-			$this->shop->update_option('wpsg_mod_cab_mmsstatusmail', $_REQUEST['wpsg_mod_cab_mmsstatusmail']);
-			
-			$this->shop->update_option('wpsg_mod_cab_success', $_REQUEST['wpsg_mod_cab_success']);
-			$this->shop->update_option('wpsg_mod_cab_error', $_REQUEST['wpsg_mod_cab_error']);
-			
-			$this->shop->update_option('wpsg_mod_cab_gebuehr', $_REQUEST['wpsg_mod_cab_gebuehr']);
-			$this->shop->update_option('wpsg_mod_cab_mwst', $_REQUEST['wpsg_mod_cab_mwst']);
-			$this->shop->update_option('wpsg_mod_cab_mwstland', $_REQUEST['wpsg_mod_cab_mwstland']);
-			
-			$this->shop->update_option('wpsg_mod_cab_currency', $_REQUEST['wpsg_mod_cab_currency']);
-			$this->shop->update_option('wpsg_mod_cab_autorun', $_REQUEST['wpsg_mod_cab_autorun']);
-			
-			$this->shop->addTranslationString('wpsg_mod_cab_bezeichnung', $_REQUEST['wpsg_mod_cab_bezeichnung']);
-			$this->shop->addTranslationString('wpsg_mod_cab_auftragsbezeichnung', $_REQUEST['wpsg_mod_cab_auftragsbezeichnung']);
-			$this->shop->addTranslationString('wpsg_mod_cab_hint', $_REQUEST['wpsg_mod_cab_hint']);
-			
-		} // public function settings_save()
-		
-		public function addPayment(&$arPayment) 
-		{
-		
-			if (!is_admin() && $this->shop->get_option('wpsg_mod_cab_aktiv') != '1') return;
-			
-			$mwst_value = $this->getTaxValue($this->shop->get_option('wpsg_mod_cab_mwst'), $this->shop->getDefaultCountry());
-			
-			$arPayment[$this->id] = array(
-				'id' => $this->id,
-				'name' => __($this->shop->get_option('wpsg_mod_cab_bezeichnung'), 'wpsg'),
-				'preis' => $this->shop->get_option('wpsg_mod_cab_gebuehr'),
-				'mwst' => $this->shop->get_option('wpsg_mod_cabmwst'),
-				'mwst_value' => $mwst_value,
-				'mwst_null' => $this->shop->get_option('wpsg_mod_cab_mwstland'),
-				'hint' => __($this->shop->get_option('wpsg_mod_cab_hint')),
-				'logo' => WPSG_URL_CONTENT.'plugins/'.WPSG_FOLDERNAME.'/views/gfx/cab.png' 
-			);
-			
-			if (isset($_REQUEST['wpsg_checkout2']) || ($this->shop->hasMod('wpsg_mod_onepagecheckout') && isset($_REQUEST['wpsg_checkout'])))
-			{
-
-				$arBasket = $this->shop->basket->toArray();
-				 
-				if ($this->shop->get_option('wpsg_preisangaben') == WPSG_NETTO || $arBasket['noMwSt'])
-				{
-						
-					$payment_netto = $this->getPreis($this->shop->get_option('wpsg_mod_cab_gebuehr'), $arBasket['sum']['preis']);
-					$payment_brutto = wpsg_calculatePreis($payment_netto, WPSG_BRUTTO, $mwst_value);
-						
-				}
-				else
-				{
-												
-					$payment_brutto = $this->getPreis($this->shop->get_option('wpsg_mod_cab_gebuehr'), $arBasket['sum']['preis']);																								
-					$payment_netto = wpsg_calculatePreis($payment_brutto, WPSG_NETTO, $mwst_value);						
-						
-				}
-				
-				// Entsprechenden Preis anzeigen
-				if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
-				{
-					
-					$arPayment[$this->id]['price'] = $payment_netto;
-					
-				}
-				else 
-				{
-					
-					$arPayment[$this->id]['price'] = $payment_brutto;
-					
-				}
-				
-			}
-			
-		} // public function addPayment(&$arPayment)
-
-		public function order_view($order_id, &$arSidebarArray)
-		{
-			
-			$order_data = $this->shop->cache->LoadOrder($order_id);
-			
-			if ($order_data['type_payment'] != $this->id) return false;
-			
-			$this->shop->view['wpsg_mod_cab']['order'] = $order_data;
-			$this->shop->view['wpsg_mod_cab']['content'] = $this->order_view_content_inner($order_id); 
-
-			$arSidebarArray[$this->id] = array(
-				'title' => $this->name,
-				'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/order_view_content.phtml', false)
-			);
-			
-		} // public function order_view_content($order_id)
-
-		public function order_ajax()
-		{
-			
-			 if ($_REQUEST['cmd'] == 'refresh')
-			 {
-			 	 
-				$this->getPaymentStatus($_REQUEST['edit_id']);
-				$this->shop->cache->clearOrderCache($_REQUEST['edit_id']);
-				
-				die($this->order_view_content_inner($_REQUEST['edit_id']));
-			 	
-			 }
-			 else if ($_REQUEST['cmd'] == 'rebuild')
-			 {
-			 	
-			 	$order_data = $this->shop->cache->loadOrder($_REQUEST['edit_id']);			 	
-			 	$customer_data = $this->shop->cache->loadKunden($order_data['k_id']);
-			 	
-			 	$arBasket = $this->shop->cache->loadBasketArray($_REQUEST['edit_id']);
-			 	
-			 	$this->shop->view['wpsg_mod_cab']['payLink'] = $this->startPayment($arBasket, $order_data['id'], $order_data['k_id']);
-				 
-			 	$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
-			 		'cab_paylink' => $this->shop->view['wpsg_mod_cab']['payLink']
-			 	), "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
-			 	
-			 	$this->shop->cache->clearOrderCache($_REQUEST['edit_id']);
-			 	
-			 	$this->shop->view['wpsg_mod_cab']['order'] = $order_data;
-			 	$this->shop->view['wpsg_mod_cab']['customer'] = $customer_data;
-			 	
-				$tpl = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/mail_resend.phtml', false);
-				
-				$empfaenger = $customer_data['email'];
-				$betreff = __("Neuer ClickandBuy Bezahl Link", "wpsg");
-				
-				mail($empfaenger, $betreff, $tpl);
-				
-				$this->db->ImportQuery(WPSG_TBL_OL, array(
-					"cdate" => "NOW()",
-					"o_id" => wpsg_q($_REQUEST['edit_id']),
-					"title" => $betreff,				
-					"mailtext" => $tpl
-				));
-				
-				die($this->order_view_content_inner($_REQUEST['edit_id']));
-			 	
-			 }
-			 else if ($_REQUEST['cmd'] == 'repay')
-			 {
-			 	
-			 	$repay = wpsg_tf($_REQUEST['value']);
-				
-			 	$order_data = $this->shop->cache->loadOrder($_REQUEST['edit_id']);
-			 	
-				// Value checken
-				if ($repay > ($order_data['price_gesamt'] - $order_data['cab_repayed']))
-				{				
-					$this->strError = __("Der angefragte RÃŒckzahlungsbetrag ist grÃ¶Ãer als der noch nicht zurÃŒckgezahlte Betrag!", "wpsg");
-				}
-				else if ($repay <= 0 || $repay == "")
-				{
-					$this->strError = __("Der angefragte RÃŒckzahlungsbetrag muss grÃ¶Ãer als 0 sein!", "wpsg");
-				}
-				else 
-				{
-					
-					$bReturn = $this->refundPayment($_REQUEST['edit_id'], $repay);
-					
-					if (!$bReturn)
-					{
-						$this->strError = __("Es gab technische Probleme, die RÃŒckzahlung konnte nicht ausgefÃŒhrt werden.", "wpsg");
-					}
-					else
-					{
-						
-						$this->db->UpdateQuery(WPSG_TBL_OL, array(
-							"cab_repayed" => ($order_data['cab_repayed'] + $repay)
-						), "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
-						
-					}
-					
-				}
-				
-				die($this->order_view_content_inner($_REQUEST['edit_id']));
-			 	
-			 }
-			
-		} // public function order_ajax()
-		
-		public function template_redirect() 
-		{ 
-				   
-			if ($_REQUEST['wpsg_plugin'] == 'wpsg_mod_cab' && $_REQUEST['cab'] == 'success')
-			{
-
-				$this->shop->redirect(get_permalink($this->shop->get_option('wpsg_mod_cab_success')));
-				
-			}
-			else if ($_REQUEST['wpsg_plugin'] == 'wpsg_mod_cab' && $_REQUEST['cab'] == 'error')
-			{
-				
-				$this->shop->redirect(get_permalink($this->shop->get_option('wpsg_mod_cab_error')));
-				
-			}
-			else if ($_REQUEST['wpsg_plugin'] == 'wpsg_mod_cab' && $_REQUEST['confirm'] == 'mms')			
-			{
-				
-				$_REQUEST['xml'] = stripslashes($_REQUEST['xml']);
-				$xml = simplexml_load_string($_REQUEST['xml']);
-				
-				$signature = $xml->signature;
-				$npayEvents = sizeof($xml->{payEvent});
-
-				// Hash ÃŒberprÃŒfen
-				$bOK = $this->makeMMSHash($_REQUEST['xml'], get_option('wpsg_mod_cab_mmskryptkey'));
-				
-				if ($bOK && isset($_REQUEST['xml']))
-				{
-				
-					$nUpdated = 0;
-					foreach ($xml->{payEvent} as $payEvent)
-					{
-				
-						$creationDateTime = strtotime($payEvent->{"creationDateTime"});
-						 
-						$order = $this->db->fetchRow("
-							SELECT 
-								*,
-								UNIX_TIMESTAMP(`cab_lastupdate`)
-							FROM
-								`".WPSG_TBL_ORDER."`
-							WHERE
-								`cab_externalid` = '".wpsg_q($payEvent->{"externalID"})."' AND
-								`cab_transactionID` = '".wpsg_q($payEvent->{"transactionID"})."' AND
-								UNIX_TIMESTAMP(`cab_lastupdate`) < '".wpsg_q($creationDateTime)."' 
-						"); 
-						
-						if (is_array($order) && $order['id'] > 0)
-						{
-								
-							// Ins Protokoll eintragen wenn noch nicht drin
-							$bExists = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_OL."` WHERE `extID` = '".wpsg_q_($order['cab_externalid'])."' AND `eventID` = '".wpsg_q($payEvent->{"eventID"})."'");
-							
-							if ($bExists <= 0)
-							{
-								
-								$this->db->updateQuery(
-									WPSG_TBL_OL,
-									array(
-										"cab_lastupdate" => "NOW()",
-										"cab_transactionStatus" => wpsg_q($payEvent->{"newState"})
-									)
-								);
-								
-								$this->db->ImportQuery(
-									WPSG_TBL_CABLOG,
-									array(
-										"cdate" => "NOW()",
-										"extID" => wpsg_q($payEvent->{"externalID"}),
-										"transID" => wpsg_q($payEvent->{"transactionID"}),
-										"eventID" => wpsg_q($payEvent->{"eventID"}),
-										"oldState" => wpsg_q($payEvent->{"oldState"}),
-										"newState" => wpsg_q($payEvent->{"newState"})
-									)
-								);							
-								
-							}
-							
-							$nUpdated ++;
-							
-						}
-						
-					}
-					
-					if (get_option("wpsg_mod_cab_mmsstatusmail") != "")
-					{
-						
-						// Hinweismail an angegebene Mail Adresse senden 
-						$this->view['wpsg_mod_cab']['nUpdated'] = $nUpdated;
-						$this->view['wpsg_mod_cab']['xml'] = $_REQUEST['xml'];
-						
-						$tpl = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/mail_mms.phtml', false);
-						  
-						mail(get_option("wpsg_mod_cab_mmsstatusmail"), __("Neue MMS StatusÃ€nderungen ERFOLG", "wpsg"), $tpl, $header);
-												
-					}
-					
-					die("OK");
-					
-				}
-				else
-				{
-
-					if (get_option("wpsg_mod_cab_mmsstatusmail") != "")
-					{
-						
-						$this->view['wpsg_mod_cab']['hash'] = $hash;
-						$this->view['wpsg_mod_cab']['xml'] = $_REQUEST['xml'];
-						
-						$tpl = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/mail_mms_error.phtml', false);
-						  
-						mail(get_option("wpsg_mod_cab_mmsstatusmail"), __("Neue MMS StatusÃ€nderungen FEHLER", "wpsg"), $tpl, $header);
-						
-					}
-					
-				}
-				
-			}
-			
-		} // public function template_redirect() 
-		
-		public function calcPayment(&$arBasket) 
-		{ 
-			
-			if ($arBasket['checkout']['payment'] == $this->id)
-			{
-			 
-				$payment_price = $this->getPreis($this->shop->get_option('wpsg_mod_cab_gebuehr'), $arBasket['sum']['preis']);
-				
-				if ($this->shop->get_option('wpsg_mod_cab_mwstland') == '1' && $arBasket['noMwSt'])
-				{
-					
-					// Keine MwSt. berechnen !
-					$arBasket['sum']['preis_payment'] = $payment_price;
-					$arBasket['sum']['preis_payment_brutto'] = $payment_price;
-					$arBasket['sum']['preis_payment_netto'] = $payment_price;
-					
-					$arBasket['payment']['mwst'] = 0;
-					$this->shop->arPayment[$arBasket['checkout']['payment']]['mwst_value'] = 0;
-						
-					$arBasket['payment']['tax_rata'] = false;
-					
-				}
-				else
-				{
-					
-					// MwSt berechnen (Angaben im Backend sind immer Brutto)
-					$this->setPaymentKosten($arBasket, $payment_price, $this->shop->get_option('wpsg_mod_cab_mwst'));
-
-				}
-								
-			}
-			
-		} // public function calcPayment(&$arBasket) 
- 		
-		public function basket_save_done_array(&$order_id, &$kunde_id, &$arBasket) 
-		{ 
-			 	 
-			if ($arBasket['checkout']['payment'] == $this->id)
-			{
-			
-				$this->startPayment($arBasket, $order_id, $kunde_id);
-				
-			}
-			 
-		} // public function basket_save_done(&$order_id, &$kunde_id, &$oBasket)
-				
-		public function order_done(&$order_id, &$done_view) 
-		{
-			
-			// Bestellungen mit 0 geben nix aus
-			if ($done_view['basket']['sum']['preis_gesamt_brutto'] <= 0) return;
-			
-			$order_data = $this->shop->cache->loadOrder($order_id);
-			 			
-			if ($order_data['type_payment'] != $this->id) return;
-			
-			$this->shop->view['wpsg_mod_cab']['url'] = $order_data['cab_paylink'];
-			
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/order_done.phtml');
-			
-		}  // public function order_done($order_id)
-		 		
-		/** Modufunctionen */
-		
-		/**
-		 * Zeichnet den inneren Teil, der mit Ajax nachgeladen wird
-		 */
-		public function order_view_content_inner($order_id)
-		{
-
-			$order_data = $this->shop->cache->LoadOrder($order_id);
-			
-			if ($order_data['type_payment'] != $this->id) return false;
-			
-			$this->shop->view['wpsg_mod_cab']['order'] = $order_data;
-			
-			if (isset($this->strError)) $this->shop->view['wpsg_mod_cab']['strError'] = $this->strError;
-			 
-			return $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/order_view_content_inner.phtml', false);
-			
-		} // public function order_view_content_inner($order_id)
-				
-		/**
-		 * Startet einen Bezahlvorgang und gibt den Link zum bezahlen zurÃŒck
-		 * @param unknown_type $order
-		 */
-		private function startPayment($arBasket, $order_id, $kunde_id)
-		{
- 
-			$basket_link = get_permalink($this->shop->get_option('wpsg_page_basket'));
-			
-			if (strpos($basket_link, "?") > 0)
-			{
-				$successURL = $basket_link."&wpsg_plugin=wpsg_mod_cab&cab=success&order_id=".$order_id;
-			}
-			else
-			{
-				$successURL = $basket_link."?wpsg_plugin=wpsg_mod_cab&cab=success&order_id=".$order_id;
-			}
-			
-			if (strpos($basket_link, "?") > 0)
-			{
-				$failureURL = $basket_link."&wpsg_plugin=wpsg_mod_cab&cab=error&order_id=".$order_id;
-			}
-			else
-			{
-				$failureURL = $basket_link."?wpsg_plugin=wpsg_mod_cab&cab=error&order_id=".$order_id;
-			}
-			
-			//wpsg_debug("SUCCESSLINK:".$successURL);
-			//wpsg_debug("FAILURELINK:".$failureURL);
-			
-			$externalID = time().":".$order_id;
-					
-			// ClickandBuy Authentifizierung
-			$authentication = array();
-			$authentication['merchantID'] = $this->shop->get_option("wpsg_mod_cab_merchantID");
-			$authentication['projectID'] = $this->shop->get_option("wpsg_mod_cab_projectID");
-			$authentication['secretKey'] = $this->shop->get_option("wpsg_mod_cab_kryptkey");
-			$authentication['token'] = $this->generateToken($authentication['projectID'], $authentication['secretKey']);
-			
-			foreach ($arBasket['produkte'] as $p)
-			{
-				
-				if (preg_match('/^vp_(.*)/', $p['id']))
-				{
-					
-					$produkt_id = preg_replace('/(^vp_)|(\/(.*)$)/', '', $op['id']);
-					
-				}
-				else
-				{
-					
-					$produkt_id = $p['id'];
-					
-				}
-				
-				$produkt_db = $this->shop->cache->loadProduct($produkt_id);
-				
-				$product_name = $produkt_db['name']; 
-				
-				// Ãbersetzung checken
-				if ($this->shop->isOtherLang())
-				{
-					
-					$produkt_trans = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($produkt_id)."' AND `lang_code` = '".wpsg_q($this->shop->getCurrentLanguageCode())."'");
-					
-					if ($produkt_trans['id'] > 0)
-					{
-						
-						$product_name = $produkt_trans['name']; 
-						
-					}
-					
-				}
-				
-				$item = array();
-				$item['description'] = $product_name;	
-				$item['itemType'] = "ITEM";		
-				$item['quantity'] = $p['menge'];
-				$item['unitPrice']['amount'] = number_format($p['preis_brutto'], 2, '.', '');
-				$item['unitPrice']['currency'] = $this->shop->get_option("wpsg_mod_cab_currency");
-				$item['totalPrice']['amount'] = number_format($p['menge'] * $p['preis_brutto'], 2, '.', '');
-				$item['totalPrice']['currency'] = $this->shop->get_option("wpsg_mod_cab_currency");
- 
-				$arItems[] = $item; 
-
-				$itemPrice += $p['menge'] * $p['preis_brutto'];
-				
-			}
-			
-			$plus = $arBasket['sum']['preis_gesamt_brutto'] - $itemPrice;
-			
-			if ($plus > 0)
-			{
-				
-				$item = array();				
-				$item['description'] = __("Versandkosten und AufschlÃ€ge", "wpsg");
-				$item['itemType'] = "ITEM";
-				$item['quantity'] = "1";
-				$item['unitPrice']['amount'] = number_format($plus, 2, '.', '');
-				$item['unitPrice']['currency'] = get_option("wpsg_mod_cab_currency");
-				$item['totalPrice']['amount'] = number_format($plus, 2, '.', '');
-				$item['totalPrice']['currency'] = get_option("wpsg_mod_cab_currency");
-				 
-				$arItems[] = $item;
-				
-			}
-			
-			$details = array();
-			$details['consumerLanguage'] = "de";
-						
-			$details['amount'] = array();
-			$details['amount']['amount'] = number_format($arBasket['sum']['preis_gesamt_brutto'], 2, '.', '');
-			$details['amount']['currency'] = get_option("wpsg_mod_cab_currency");	
-			
-			$details['successURL'] = $successURL;
-			$details['failureURL'] = $failureURL;
-			
-			$details['externalID'] = $externalID;
-			
-			$details['orderDetails'] = array();
-			$details['orderDetails']['itemList'] = $arItems;
-			$details['orderDetails']['text'] = $this->shop->replaceUniversalPlatzhalter($this->shop->get_option("wpsg_mod_cab_auftragsbezeichnung"), $order_id);
- 			
-			$kunde = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_KU."` WHERE `id` = '".wpsg_q($kunde_id)."'");
-			
-			$details['shipping']['consumer'] = array(
-				'firstName' => $kunde['shipping_vname'],
-				'lastName' => $kunde['shipping_name'],
-				'address' => array(
-					'street' => $kunde['shipping_strasse'],
-					'zip' => $kunde['shipping_plz'],
-					'city' => $kunde['shipping_ort'],
-					'country' => $this->db->fetchOne("SELECT `kuerzel` FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($kunde['shipping_land'])."'")				
-				)			
-			);
-			
-			$details['billing']['consumer'] = array(
-				'firstName' => $kunde['vname'],
-				'lastName' => $kunde['name'],
-				'address' => array(
-					'street' => $kunde['strasse'],
-					'zip' => $kunde['plz'],
-					'city' => $kunde['ort'],
-					'country' => $this->db->fetchOne("SELECT `kuerzel` FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($kunde['land'])."'")			
-				)
-			);
-			
-			// Wenn kein Name und Vorname bei der Lieferanschrift gesetzt gehe ich davon aus, das die Lieferanschrift gleich der Rechnugsanschrift ist
-			if ($kunde['shipping_vname'] == "" && $kunde['shipping_name'] == "")
-			{
-				
-				$details['shipping']['consumer'] = array(
-					'firstName' => $kunde['vname'],
-					'lastName' => $kunde['name'],
-					'address' => array(
-						'street' => $kunde['strasse'],
-						'zip' => $kunde['plz'],
-						'city' => $kunde['ort'],
-						'country' => $this->db->fetchOne("SELECT `kuerzel` FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($kunde['land'])."'")			
-					)
-				);
-				
-			}
-			
-			$soap_data = array(
-				"authentication" => $authentication,
-				"details" => $details
-			); 
-		
-			$client = $this->getClient(); 
-			$result = $client->payRequest($soap_data);
-						
-			// Daten in Bestellung eintragen
-			$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
-				"cab_externalid" => $result->transaction->externalID,
-				"cab_requestTrackingID" => $result->requestTrackingID,
-				"cab_transactionID" => $result->transaction->transactionID,
-				"cab_transactionStatus" => $result->transaction->transactionStatus,
-				"cab_started" => "NOW()",
-				"cab_lastupdate" => "NOW()",
-				"cab_paylink" => $result->transaction->redirectURL
-			), "`id` = '".wpsg_q($order_id)."'");
-			 
-			return $result->transaction->redirectURL;
-						
-		} // private function startPayment($order)
-		
-		/**
-		 * Fragt den PaymentStatus einer Bestellung ab und aktualisiert ihn in der Bestellung
-		 * Enter description here ...
-		 * @param unknown_type $order_id
-		 */
-		private function getPaymentStatus($order_id)
-		{
-			
-			$order = $this->shop->cache->LoadOrder($order_id);
-			
-			// ClickandBuy Authentifizierung
-			$authentication = array();
-			$authentication['merchantID'] = get_option("wpsg_mod_cab_merchantID");
-			$authentication['projectID'] = get_option("wpsg_mod_cab_projectID");
-			$authentication['secretKey'] = get_option("wpsg_mod_cab_kryptkey");
-			$authentication['token'] = $this->generateToken($authentication['projectID'], $authentication['secretKey']);			
-			
-			$details = array();
-			$details['transactionIDList'] = array();
-			$details['transactionIDList']['transactionID'] = $order['cab_transactionID'];
-			
-			$soap_data = array(
-				"authentication" => $authentication,
-				"details" => $details
-			);  
-			 
-			$client = $this->getClient();				
-			$result = $client->statusRequest($soap_data);		
-			
-			if ($result->transactionList->transaction->transactionID != $order['cab_transactionID'] || $result->transactionList->transaction->externalID != $order['cab_externalid'])
-			{
-				
-				return false;
-				
-			}
-			
-			$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
-				"cab_transactionStatus" => $result->transactionList->transaction->transactionStatus,
-				"cab_lastupdate" => "NOW()"
-			), "`id` = '".wpsg_q($order['id'])."'");
-			
-			return $result->transactionList->transaction->transactionStatus;
-			
-		} // private function getPaymentStatus($order_id)
-		
-		/**
-		 * Gibt das Clientobjekt fÃŒr die SOAP Anfragen zurÃŒck
-		 */
-		private function getClient()
-		{
-			
-			if (get_option("wpsg_mod_cab_sandbox") == "1")
-			{
-				
-				$client = new SoapClient('https://api.clickandbuy.com/webservices/soap/pay_1_0_0.wsdl');
-				$client->__setLocation('https://api.clickandbuy-s1.com/webservices/soap/pay_1_0_0');
-				
-			}
-			else
-			{
-				
-				$client = new SoapClient('https://api.clickandbuy.com/webservices/pay_1_0_0.wsdl');
-				
-			} 
-			
-			return $client;
-			
-		} // private function getClient()
-		
-		function generateToken($projectID, $secretKey) 
-		{
-			
-			$timestamp = gmdate("YmdHis");	
-			$hashStr = $projectID."::".$secretKey."::".$timestamp;
-			$toBeHashed = strtoupper(sha1($hashStr));	
-			$token = $timestamp.'::'.$toBeHashed; 	
-			
-			return $token;	
-			
-		} // function generateToken($projectID, $secretKey)
-
-		/**
-		 * Generiert den Hash (Signatur) fÃŒr die MMS Verfikation
-		 * @param $xml
-		 */
-		private function makeMMSHash($xml)
-		{
-			
-			$xml = preg_replace("/\<signature\>(.*)\<\/signature\>/", "<signature />", $xml);
-			 
-			return sha1(get_option("wpsg_cab_mmskey").$xml);
-			
-		} // private function makeMMSHash($xml)
-				
-	} // class wpsg_mod_cab extends wpsg_mod_basic
-
-?>
Index: /system/intern/mods/mod_cab/changelog
===================================================================
--- /system/intern/mods/mod_cab/changelog	(revision 5989)
+++ /system/intern/mods/mod_cab/changelog	(revision 5989)
@@ -0,0 +1,8 @@
+#3.0.6
+ - Erste Version
+ 
+#3.1.0
+ - KompatibilitÃ€t zu 3.1.0
+ 
+#3.2.0
+ - KompatibilitÃ€t mit Shop 3.2.0
Index: /system/intern/mods/wpsg_mod_cab.class.php
===================================================================
--- /system/intern/mods/wpsg_mod_cab.class.php	(revision 5989)
+++ /system/intern/mods/wpsg_mod_cab.class.php	(revision 5989)
@@ -0,0 +1,803 @@
+<?php
+
+	/**
+	 * Klasse die die Zahlungsart Click&Buy ermÃ¶glicht
+	 * @author daniel
+	 */
+	class wpsg_mod_cab extends wpsg_mod_basic 
+	{
+		
+		var $lizenz = 2;
+		var $id = 810; 
+		
+		var $version = "9.9.9";
+		var $hilfeURL = 'http://wpshopgermany.de/?p=969';		 
+		var $free = true;
+		
+		/**
+		 * Costructor
+		 */
+		public function __construct()
+		{
+			
+			parent::__construct();
+			
+			$this->name = __('Click & Buy', 'wpsg');
+			$this->group = __('Zahlungsarten', 'wpsg');
+			$this->desc = __('ErmÃ¶glicht die Zahlungsart ClickandBuy.', 'wpsg');
+						
+		} // public function __construct()
+		
+		public function install()
+		{
+			
+			$this->shop->checkDefault('wpsg_mod_cab_bezeichnung', $this->name, false, true);
+			$this->shop->checkDefault('wpsg_mod_cab_bezeichnung', '', false, true);
+			$this->shop->checkDefault('wpsg_mod_cab_aktiv', '1');
+			$this->shop->checkDefault('wpsg_mod_cab_sandbox', '1');
+			$this->shop->checkDefault('wpsg_mod_cab_hint', __('Wickeln Sie ihre Bestellung ÃŒber Click&Buy ab.', 'wpsg'), false, true);
+			
+			$this->shop->checkDefault('wpsg_mod_cab_merchantID', '<!-- Erhalten Sie von Click&Buy --!>');
+			$this->shop->checkDefault('wpsg_mod_cab_projectID', '<!-- Erhalten Sie von Click&Buy --!>');
+			$this->shop->checkDefault('wpsg_mod_cab_kryptkey', '<!-- Erhalten Sie von Click&Buy --!>');
+			
+			$this->shop->checkDefault('wpsg_mod_cab_mmskryptkey', '<!-- Erhalten Sie von Click&Buy --!>');
+			$this->shop->checkDefault('wpsg_mod_cab_mmsstatusmail', '');
+			
+			$this->shop->checkDefault('wpsg_mod_cab_mmskryptkey', '');
+			$this->shop->checkDefault('wpsg_mod_cab_mmsstatusmail', '');
+			
+			$this->shop->checkDefault('wpsg_mod_cab_gebuehr', '0');
+			$this->shop->checkDefault('wpsg_mod_cab_mwst', '0');
+			$this->shop->checkDefault('wpsg_mod_cab_mwstland', '0');
+			
+			$this->shop->checkDefault('wpsg_mod_cab_currency', 'EUR');
+			$this->shop->checkDefault('wpsg_mod_cab_autorun', '0');
+			
+			// Bestelltabelle erweitern
+		  	require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
+			
+			$sql = "CREATE TABLE ".WPSG_TBL_ORDER." (
+		   		cab_externalid varchar(255) NOT NULL,
+   				cab_requestTrackingID varchar(255) NOT NULL,
+   				cab_transactionID varchar(255) NOT NULL,
+			   	cab_transactionStatus varchar(255) NOT NULL,
+		   		cab_started datetime NOT NULL,
+   				cab_lastupdate datetime NOT NULL,
+		   		cab_paylink varchar(5000) NOT NULL,
+   				cab_repayed double(10,2) NOT NULL
+		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+			 
+			dbDelta($sql);
+			 
+			// Tabelle fÃŒr Click&Buy Log 			
+			$sql = "CREATE TABLE ".WPSG_TBL_CABLOG." (
+		   		id mediumint(9) NOT NULL AUTO_INCREMENT,
+			  	cdate datetime NOT NULL,
+			  	extID varchar(255) NOT NULL,
+			  	transID varchar(255) NOT NULL,
+			  	eventID int(11) NOT NULL,
+			  	oldState varchar(255) NOT NULL,
+			  	newState varchar(255) NOT NULL,
+			  	PRIMARY KEY  (id)	  
+		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+			
+			dbDelta($sql);
+			
+		} // public function install()
+		
+		public function delOrder(&$order_id) { } // public function delOrder(&$order_id)
+		
+		public function settings_edit()
+		{
+						
+			$pages = get_pages();
+			 
+			foreach ($pages as $k => $v)
+			{
+				
+				$this->shop->view['pages'][$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
+				$this->shop->view['pageURLs'][$v->ID] = get_permalink($v->ID);
+				
+			}
+			
+			$basket_link = get_permalink(get_option('wpsg_page_basket'));
+			
+			if (strpos($basket_link, "?") > 0)
+			{
+				$mmsURL = $basket_link."&wpsg_plugin=wpsg_mod_cab&confirm=mms&no_head=1";
+			}
+			else
+			{
+				$mmsURL = $basket_link."?wpsg_plugin=wpsg_mod_cab&confirm=mms&no_head=1";
+			}
+			
+			$this->shop->view['wpsg_mod_cab_mmspushurl'] = preg_replace("/^http:/", "https:", $mmsURL);
+						
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/settings_edit.phtml');
+			
+		} // public function settings_edit()
+		
+		public function settings_save()
+		{
+			
+			$this->shop->update_option('wpsg_mod_cab_bezeichnung', $_REQUEST['wpsg_mod_cab_bezeichnung']);
+			$this->shop->update_option('wpsg_mod_cab_auftragsbezeichnung', $_REQUEST['wpsg_mod_cab_auftragsbezeichnung']);
+			$this->shop->update_option('wpsg_mod_cab_aktiv', $_REQUEST['wpsg_mod_cab_aktiv']);
+			$this->shop->update_option('wpsg_mod_cab_sandbox', $_REQUEST['wpsg_mod_cab_sandbox']);
+			$this->shop->update_option('wpsg_mod_cab_hint', $_REQUEST['wpsg_mod_cab_hint']);
+			
+			$this->shop->update_option('wpsg_mod_cab_merchantID', $_REQUEST['wpsg_mod_cab_merchantID']);
+			$this->shop->update_option('wpsg_mod_cab_projectID', $_REQUEST['wpsg_mod_cab_projectID']);
+			$this->shop->update_option('wpsg_mod_cab_kryptkey', $_REQUEST['wpsg_mod_cab_kryptkey']);
+			
+			$this->shop->update_option('wpsg_mod_cab_mmskryptkey', $_REQUEST['wpsg_mod_cab_mmskryptkey']);
+			$this->shop->update_option('wpsg_mod_cab_mmsstatusmail', $_REQUEST['wpsg_mod_cab_mmsstatusmail']);
+			
+			$this->shop->update_option('wpsg_mod_cab_success', $_REQUEST['wpsg_mod_cab_success']);
+			$this->shop->update_option('wpsg_mod_cab_error', $_REQUEST['wpsg_mod_cab_error']);
+			
+			$this->shop->update_option('wpsg_mod_cab_gebuehr', $_REQUEST['wpsg_mod_cab_gebuehr']);
+			$this->shop->update_option('wpsg_mod_cab_mwst', $_REQUEST['wpsg_mod_cab_mwst']);
+			$this->shop->update_option('wpsg_mod_cab_mwstland', $_REQUEST['wpsg_mod_cab_mwstland']);
+			
+			$this->shop->update_option('wpsg_mod_cab_currency', $_REQUEST['wpsg_mod_cab_currency']);
+			$this->shop->update_option('wpsg_mod_cab_autorun', $_REQUEST['wpsg_mod_cab_autorun']);
+			
+			$this->shop->addTranslationString('wpsg_mod_cab_bezeichnung', $_REQUEST['wpsg_mod_cab_bezeichnung']);
+			$this->shop->addTranslationString('wpsg_mod_cab_auftragsbezeichnung', $_REQUEST['wpsg_mod_cab_auftragsbezeichnung']);
+			$this->shop->addTranslationString('wpsg_mod_cab_hint', $_REQUEST['wpsg_mod_cab_hint']);
+			
+		} // public function settings_save()
+		
+		public function addPayment(&$arPayment) 
+		{
+		
+			if (!is_admin() && $this->shop->get_option('wpsg_mod_cab_aktiv') != '1') return;
+			
+			$mwst_value = $this->getTaxValue($this->shop->get_option('wpsg_mod_cab_mwst'), $this->shop->getDefaultCountry());
+			
+			$arPayment[$this->id] = array(
+				'id' => $this->id,
+				'name' => __($this->shop->get_option('wpsg_mod_cab_bezeichnung'), 'wpsg'),
+				'preis' => $this->shop->get_option('wpsg_mod_cab_gebuehr'),
+				'mwst' => $this->shop->get_option('wpsg_mod_cabmwst'),
+				'mwst_value' => $mwst_value,
+				'mwst_null' => $this->shop->get_option('wpsg_mod_cab_mwstland'),
+				'hint' => __($this->shop->get_option('wpsg_mod_cab_hint')),
+				'logo' => WPSG_URL_CONTENT.'plugins/'.WPSG_FOLDERNAME.'/views/gfx/cab.png' 
+			);
+			
+			if (isset($_REQUEST['wpsg_checkout2']) || ($this->shop->hasMod('wpsg_mod_onepagecheckout') && isset($_REQUEST['wpsg_checkout'])))
+			{
+
+				$arBasket = $this->shop->basket->toArray();
+				 
+				if ($this->shop->get_option('wpsg_preisangaben') == WPSG_NETTO || $arBasket['noMwSt'])
+				{
+						
+					$payment_netto = $this->getPreis($this->shop->get_option('wpsg_mod_cab_gebuehr'), $arBasket['sum']['preis']);
+					$payment_brutto = wpsg_calculatePreis($payment_netto, WPSG_BRUTTO, $mwst_value);
+						
+				}
+				else
+				{
+												
+					$payment_brutto = $this->getPreis($this->shop->get_option('wpsg_mod_cab_gebuehr'), $arBasket['sum']['preis']);																								
+					$payment_netto = wpsg_calculatePreis($payment_brutto, WPSG_NETTO, $mwst_value);						
+						
+				}
+				
+				// Entsprechenden Preis anzeigen
+				if ($this->shop->getFrontendTaxview() == WPSG_NETTO)
+				{
+					
+					$arPayment[$this->id]['price'] = $payment_netto;
+					
+				}
+				else 
+				{
+					
+					$arPayment[$this->id]['price'] = $payment_brutto;
+					
+				}
+				
+			}
+			
+		} // public function addPayment(&$arPayment)
+
+		public function order_view($order_id, &$arSidebarArray)
+		{
+			
+			$order_data = $this->shop->cache->LoadOrder($order_id);
+			
+			if ($order_data['type_payment'] != $this->id) return false;
+			
+			$this->shop->view['wpsg_mod_cab']['order'] = $order_data;
+			$this->shop->view['wpsg_mod_cab']['content'] = $this->order_view_content_inner($order_id); 
+
+			$arSidebarArray[$this->id] = array(
+				'title' => $this->name,
+				'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/order_view_content.phtml', false)
+			);
+			
+		} // public function order_view_content($order_id)
+
+		public function order_ajax()
+		{
+			
+			 if ($_REQUEST['cmd'] == 'refresh')
+			 {
+			 	 
+				$this->getPaymentStatus($_REQUEST['edit_id']);
+				$this->shop->cache->clearOrderCache($_REQUEST['edit_id']);
+				
+				die($this->order_view_content_inner($_REQUEST['edit_id']));
+			 	
+			 }
+			 else if ($_REQUEST['cmd'] == 'rebuild')
+			 {
+			 	
+			 	$order_data = $this->shop->cache->loadOrder($_REQUEST['edit_id']);			 	
+			 	$customer_data = $this->shop->cache->loadKunden($order_data['k_id']);
+			 	
+			 	$arBasket = $this->shop->cache->loadBasketArray($_REQUEST['edit_id']);
+			 	
+			 	$this->shop->view['wpsg_mod_cab']['payLink'] = $this->startPayment($arBasket, $order_data['id'], $order_data['k_id']);
+				 
+			 	$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
+			 		'cab_paylink' => $this->shop->view['wpsg_mod_cab']['payLink']
+			 	), "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
+			 	
+			 	$this->shop->cache->clearOrderCache($_REQUEST['edit_id']);
+			 	
+			 	$this->shop->view['wpsg_mod_cab']['order'] = $order_data;
+			 	$this->shop->view['wpsg_mod_cab']['customer'] = $customer_data;
+			 	
+				$tpl = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/mail_resend.phtml', false);
+				
+				$empfaenger = $customer_data['email'];
+				$betreff = __("Neuer ClickandBuy Bezahl Link", "wpsg");
+				
+				mail($empfaenger, $betreff, $tpl);
+				
+				$this->db->ImportQuery(WPSG_TBL_OL, array(
+					"cdate" => "NOW()",
+					"o_id" => wpsg_q($_REQUEST['edit_id']),
+					"title" => $betreff,				
+					"mailtext" => $tpl
+				));
+				
+				die($this->order_view_content_inner($_REQUEST['edit_id']));
+			 	
+			 }
+			 else if ($_REQUEST['cmd'] == 'repay')
+			 {
+			 	
+			 	$repay = wpsg_tf($_REQUEST['value']);
+				
+			 	$order_data = $this->shop->cache->loadOrder($_REQUEST['edit_id']);
+			 	
+				// Value checken
+				if ($repay > ($order_data['price_gesamt'] - $order_data['cab_repayed']))
+				{				
+					$this->strError = __("Der angefragte RÃŒckzahlungsbetrag ist grÃ¶Ãer als der noch nicht zurÃŒckgezahlte Betrag!", "wpsg");
+				}
+				else if ($repay <= 0 || $repay == "")
+				{
+					$this->strError = __("Der angefragte RÃŒckzahlungsbetrag muss grÃ¶Ãer als 0 sein!", "wpsg");
+				}
+				else 
+				{
+					
+					$bReturn = $this->refundPayment($_REQUEST['edit_id'], $repay);
+					
+					if (!$bReturn)
+					{
+						$this->strError = __("Es gab technische Probleme, die RÃŒckzahlung konnte nicht ausgefÃŒhrt werden.", "wpsg");
+					}
+					else
+					{
+						
+						$this->db->UpdateQuery(WPSG_TBL_OL, array(
+							"cab_repayed" => ($order_data['cab_repayed'] + $repay)
+						), "`id` = '".wpsg_q($_REQUEST['edit_id'])."'");
+						
+					}
+					
+				}
+				
+				die($this->order_view_content_inner($_REQUEST['edit_id']));
+			 	
+			 }
+			
+		} // public function order_ajax()
+		
+		public function template_redirect() 
+		{ 
+				   
+			if ($_REQUEST['wpsg_plugin'] == 'wpsg_mod_cab' && $_REQUEST['cab'] == 'success')
+			{
+
+				$this->shop->redirect(get_permalink($this->shop->get_option('wpsg_mod_cab_success')));
+				
+			}
+			else if ($_REQUEST['wpsg_plugin'] == 'wpsg_mod_cab' && $_REQUEST['cab'] == 'error')
+			{
+				
+				$this->shop->redirect(get_permalink($this->shop->get_option('wpsg_mod_cab_error')));
+				
+			}
+			else if ($_REQUEST['wpsg_plugin'] == 'wpsg_mod_cab' && $_REQUEST['confirm'] == 'mms')			
+			{
+				
+				$_REQUEST['xml'] = stripslashes($_REQUEST['xml']);
+				$xml = simplexml_load_string($_REQUEST['xml']);
+				
+				$signature = $xml->signature;
+				$npayEvents = sizeof($xml->{payEvent});
+
+				// Hash ÃŒberprÃŒfen
+				$bOK = $this->makeMMSHash($_REQUEST['xml'], get_option('wpsg_mod_cab_mmskryptkey'));
+				
+				if ($bOK && isset($_REQUEST['xml']))
+				{
+				
+					$nUpdated = 0;
+					foreach ($xml->{payEvent} as $payEvent)
+					{
+				
+						$creationDateTime = strtotime($payEvent->{"creationDateTime"});
+						 
+						$order = $this->db->fetchRow("
+							SELECT 
+								*,
+								UNIX_TIMESTAMP(`cab_lastupdate`)
+							FROM
+								`".WPSG_TBL_ORDER."`
+							WHERE
+								`cab_externalid` = '".wpsg_q($payEvent->{"externalID"})."' AND
+								`cab_transactionID` = '".wpsg_q($payEvent->{"transactionID"})."' AND
+								UNIX_TIMESTAMP(`cab_lastupdate`) < '".wpsg_q($creationDateTime)."' 
+						"); 
+						
+						if (is_array($order) && $order['id'] > 0)
+						{
+								
+							// Ins Protokoll eintragen wenn noch nicht drin
+							$bExists = $this->db->fetchOne("SELECT COUNT(*) FROM `".WPSG_TBL_OL."` WHERE `extID` = '".wpsg_q_($order['cab_externalid'])."' AND `eventID` = '".wpsg_q($payEvent->{"eventID"})."'");
+							
+							if ($bExists <= 0)
+							{
+								
+								$this->db->updateQuery(
+									WPSG_TBL_OL,
+									array(
+										"cab_lastupdate" => "NOW()",
+										"cab_transactionStatus" => wpsg_q($payEvent->{"newState"})
+									)
+								);
+								
+								$this->db->ImportQuery(
+									WPSG_TBL_CABLOG,
+									array(
+										"cdate" => "NOW()",
+										"extID" => wpsg_q($payEvent->{"externalID"}),
+										"transID" => wpsg_q($payEvent->{"transactionID"}),
+										"eventID" => wpsg_q($payEvent->{"eventID"}),
+										"oldState" => wpsg_q($payEvent->{"oldState"}),
+										"newState" => wpsg_q($payEvent->{"newState"})
+									)
+								);							
+								
+							}
+							
+							$nUpdated ++;
+							
+						}
+						
+					}
+					
+					if (get_option("wpsg_mod_cab_mmsstatusmail") != "")
+					{
+						
+						// Hinweismail an angegebene Mail Adresse senden 
+						$this->view['wpsg_mod_cab']['nUpdated'] = $nUpdated;
+						$this->view['wpsg_mod_cab']['xml'] = $_REQUEST['xml'];
+						
+						$tpl = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/mail_mms.phtml', false);
+						  
+						mail(get_option("wpsg_mod_cab_mmsstatusmail"), __("Neue MMS StatusÃ€nderungen ERFOLG", "wpsg"), $tpl, $header);
+												
+					}
+					
+					die("OK");
+					
+				}
+				else
+				{
+
+					if (get_option("wpsg_mod_cab_mmsstatusmail") != "")
+					{
+						
+						$this->view['wpsg_mod_cab']['hash'] = $hash;
+						$this->view['wpsg_mod_cab']['xml'] = $_REQUEST['xml'];
+						
+						$tpl = $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/mail_mms_error.phtml', false);
+						  
+						mail(get_option("wpsg_mod_cab_mmsstatusmail"), __("Neue MMS StatusÃ€nderungen FEHLER", "wpsg"), $tpl, $header);
+						
+					}
+					
+				}
+				
+			}
+			
+		} // public function template_redirect() 
+		
+		public function calcPayment(&$arBasket) 
+		{ 
+			
+			if ($arBasket['checkout']['payment'] == $this->id)
+			{
+			 
+				$payment_price = $this->getPreis($this->shop->get_option('wpsg_mod_cab_gebuehr'), $arBasket['sum']['preis']);
+				
+				if ($this->shop->get_option('wpsg_mod_cab_mwstland') == '1' && $arBasket['noMwSt'])
+				{
+					
+					// Keine MwSt. berechnen !
+					$arBasket['sum']['preis_payment'] = $payment_price;
+					$arBasket['sum']['preis_payment_brutto'] = $payment_price;
+					$arBasket['sum']['preis_payment_netto'] = $payment_price;
+					
+					$arBasket['payment']['mwst'] = 0;
+					$this->shop->arPayment[$arBasket['checkout']['payment']]['mwst_value'] = 0;
+						
+					$arBasket['payment']['tax_rata'] = false;
+					
+				}
+				else
+				{
+					
+					// MwSt berechnen (Angaben im Backend sind immer Brutto)
+					$this->setPaymentKosten($arBasket, $payment_price, $this->shop->get_option('wpsg_mod_cab_mwst'));
+
+				}
+								
+			}
+			
+		} // public function calcPayment(&$arBasket) 
+ 		
+		public function basket_save_done_array(&$order_id, &$kunde_id, &$arBasket) 
+		{ 
+			 	 
+			if ($arBasket['checkout']['payment'] == $this->id)
+			{
+			
+				$this->startPayment($arBasket, $order_id, $kunde_id);
+				
+			}
+			 
+		} // public function basket_save_done(&$order_id, &$kunde_id, &$oBasket)
+				
+		public function order_done(&$order_id, &$done_view) 
+		{
+			
+			// Bestellungen mit 0 geben nix aus
+			if ($done_view['basket']['sum']['preis_gesamt_brutto'] <= 0) return;
+			
+			$order_data = $this->shop->cache->loadOrder($order_id);
+			 			
+			if ($order_data['type_payment'] != $this->id) return;
+			
+			$this->shop->view['wpsg_mod_cab']['url'] = $order_data['cab_paylink'];
+			
+			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/order_done.phtml');
+			
+		}  // public function order_done($order_id)
+		 		
+		/** Modufunctionen */
+		
+		/**
+		 * Zeichnet den inneren Teil, der mit Ajax nachgeladen wird
+		 */
+		public function order_view_content_inner($order_id)
+		{
+
+			$order_data = $this->shop->cache->LoadOrder($order_id);
+			
+			if ($order_data['type_payment'] != $this->id) return false;
+			
+			$this->shop->view['wpsg_mod_cab']['order'] = $order_data;
+			
+			if (isset($this->strError)) $this->shop->view['wpsg_mod_cab']['strError'] = $this->strError;
+			 
+			return $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_cab/order_view_content_inner.phtml', false);
+			
+		} // public function order_view_content_inner($order_id)
+				
+		/**
+		 * Startet einen Bezahlvorgang und gibt den Link zum bezahlen zurÃŒck
+		 * @param unknown_type $order
+		 */
+		private function startPayment($arBasket, $order_id, $kunde_id)
+		{
+ 
+			$basket_link = get_permalink($this->shop->get_option('wpsg_page_basket'));
+			
+			if (strpos($basket_link, "?") > 0)
+			{
+				$successURL = $basket_link."&wpsg_plugin=wpsg_mod_cab&cab=success&order_id=".$order_id;
+			}
+			else
+			{
+				$successURL = $basket_link."?wpsg_plugin=wpsg_mod_cab&cab=success&order_id=".$order_id;
+			}
+			
+			if (strpos($basket_link, "?") > 0)
+			{
+				$failureURL = $basket_link."&wpsg_plugin=wpsg_mod_cab&cab=error&order_id=".$order_id;
+			}
+			else
+			{
+				$failureURL = $basket_link."?wpsg_plugin=wpsg_mod_cab&cab=error&order_id=".$order_id;
+			}
+			
+			//wpsg_debug("SUCCESSLINK:".$successURL);
+			//wpsg_debug("FAILURELINK:".$failureURL);
+			
+			$externalID = time().":".$order_id;
+					
+			// ClickandBuy Authentifizierung
+			$authentication = array();
+			$authentication['merchantID'] = $this->shop->get_option("wpsg_mod_cab_merchantID");
+			$authentication['projectID'] = $this->shop->get_option("wpsg_mod_cab_projectID");
+			$authentication['secretKey'] = $this->shop->get_option("wpsg_mod_cab_kryptkey");
+			$authentication['token'] = $this->generateToken($authentication['projectID'], $authentication['secretKey']);
+			
+			foreach ($arBasket['produkte'] as $p)
+			{
+				
+				if (preg_match('/^vp_(.*)/', $p['id']))
+				{
+					
+					$produkt_id = preg_replace('/(^vp_)|(\/(.*)$)/', '', $op['id']);
+					
+				}
+				else
+				{
+					
+					$produkt_id = $p['id'];
+					
+				}
+				
+				$produkt_db = $this->shop->cache->loadProduct($produkt_id);
+				
+				$product_name = $produkt_db['name']; 
+				
+				// Ãbersetzung checken
+				if ($this->shop->isOtherLang())
+				{
+					
+					$produkt_trans = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($produkt_id)."' AND `lang_code` = '".wpsg_q($this->shop->getCurrentLanguageCode())."'");
+					
+					if ($produkt_trans['id'] > 0)
+					{
+						
+						$product_name = $produkt_trans['name']; 
+						
+					}
+					
+				}
+				
+				$item = array();
+				$item['description'] = $product_name;	
+				$item['itemType'] = "ITEM";		
+				$item['quantity'] = $p['menge'];
+				$item['unitPrice']['amount'] = number_format($p['preis_brutto'], 2, '.', '');
+				$item['unitPrice']['currency'] = $this->shop->get_option("wpsg_mod_cab_currency");
+				$item['totalPrice']['amount'] = number_format($p['menge'] * $p['preis_brutto'], 2, '.', '');
+				$item['totalPrice']['currency'] = $this->shop->get_option("wpsg_mod_cab_currency");
+ 
+				$arItems[] = $item; 
+
+				$itemPrice += $p['menge'] * $p['preis_brutto'];
+				
+			}
+			
+			$plus = $arBasket['sum']['preis_gesamt_brutto'] - $itemPrice;
+			
+			if ($plus > 0)
+			{
+				
+				$item = array();				
+				$item['description'] = __("Versandkosten und AufschlÃ€ge", "wpsg");
+				$item['itemType'] = "ITEM";
+				$item['quantity'] = "1";
+				$item['unitPrice']['amount'] = number_format($plus, 2, '.', '');
+				$item['unitPrice']['currency'] = get_option("wpsg_mod_cab_currency");
+				$item['totalPrice']['amount'] = number_format($plus, 2, '.', '');
+				$item['totalPrice']['currency'] = get_option("wpsg_mod_cab_currency");
+				 
+				$arItems[] = $item;
+				
+			}
+			
+			$details = array();
+			$details['consumerLanguage'] = "de";
+						
+			$details['amount'] = array();
+			$details['amount']['amount'] = number_format($arBasket['sum']['preis_gesamt_brutto'], 2, '.', '');
+			$details['amount']['currency'] = get_option("wpsg_mod_cab_currency");	
+			
+			$details['successURL'] = $successURL;
+			$details['failureURL'] = $failureURL;
+			
+			$details['externalID'] = $externalID;
+			
+			$details['orderDetails'] = array();
+			$details['orderDetails']['itemList'] = $arItems;
+			$details['orderDetails']['text'] = $this->shop->replaceUniversalPlatzhalter($this->shop->get_option("wpsg_mod_cab_auftragsbezeichnung"), $order_id);
+ 			
+			$kunde = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_KU."` WHERE `id` = '".wpsg_q($kunde_id)."'");
+			
+			$details['shipping']['consumer'] = array(
+				'firstName' => $kunde['shipping_vname'],
+				'lastName' => $kunde['shipping_name'],
+				'address' => array(
+					'street' => $kunde['shipping_strasse'],
+					'zip' => $kunde['shipping_plz'],
+					'city' => $kunde['shipping_ort'],
+					'country' => $this->db->fetchOne("SELECT `kuerzel` FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($kunde['shipping_land'])."'")				
+				)			
+			);
+			
+			$details['billing']['consumer'] = array(
+				'firstName' => $kunde['vname'],
+				'lastName' => $kunde['name'],
+				'address' => array(
+					'street' => $kunde['strasse'],
+					'zip' => $kunde['plz'],
+					'city' => $kunde['ort'],
+					'country' => $this->db->fetchOne("SELECT `kuerzel` FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($kunde['land'])."'")			
+				)
+			);
+			
+			// Wenn kein Name und Vorname bei der Lieferanschrift gesetzt gehe ich davon aus, das die Lieferanschrift gleich der Rechnugsanschrift ist
+			if ($kunde['shipping_vname'] == "" && $kunde['shipping_name'] == "")
+			{
+				
+				$details['shipping']['consumer'] = array(
+					'firstName' => $kunde['vname'],
+					'lastName' => $kunde['name'],
+					'address' => array(
+						'street' => $kunde['strasse'],
+						'zip' => $kunde['plz'],
+						'city' => $kunde['ort'],
+						'country' => $this->db->fetchOne("SELECT `kuerzel` FROM `".WPSG_TBL_LAND."` WHERE `id` = '".wpsg_q($kunde['land'])."'")			
+					)
+				);
+				
+			}
+			
+			$soap_data = array(
+				"authentication" => $authentication,
+				"details" => $details
+			); 
+		
+			$client = $this->getClient(); 
+			$result = $client->payRequest($soap_data);
+						
+			// Daten in Bestellung eintragen
+			$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
+				"cab_externalid" => $result->transaction->externalID,
+				"cab_requestTrackingID" => $result->requestTrackingID,
+				"cab_transactionID" => $result->transaction->transactionID,
+				"cab_transactionStatus" => $result->transaction->transactionStatus,
+				"cab_started" => "NOW()",
+				"cab_lastupdate" => "NOW()",
+				"cab_paylink" => $result->transaction->redirectURL
+			), "`id` = '".wpsg_q($order_id)."'");
+			 
+			return $result->transaction->redirectURL;
+						
+		} // private function startPayment($order)
+		
+		/**
+		 * Fragt den PaymentStatus einer Bestellung ab und aktualisiert ihn in der Bestellung
+		 * Enter description here ...
+		 * @param unknown_type $order_id
+		 */
+		private function getPaymentStatus($order_id)
+		{
+			
+			$order = $this->shop->cache->LoadOrder($order_id);
+			
+			// ClickandBuy Authentifizierung
+			$authentication = array();
+			$authentication['merchantID'] = get_option("wpsg_mod_cab_merchantID");
+			$authentication['projectID'] = get_option("wpsg_mod_cab_projectID");
+			$authentication['secretKey'] = get_option("wpsg_mod_cab_kryptkey");
+			$authentication['token'] = $this->generateToken($authentication['projectID'], $authentication['secretKey']);			
+			
+			$details = array();
+			$details['transactionIDList'] = array();
+			$details['transactionIDList']['transactionID'] = $order['cab_transactionID'];
+			
+			$soap_data = array(
+				"authentication" => $authentication,
+				"details" => $details
+			);  
+			 
+			$client = $this->getClient();				
+			$result = $client->statusRequest($soap_data);		
+			
+			if ($result->transactionList->transaction->transactionID != $order['cab_transactionID'] || $result->transactionList->transaction->externalID != $order['cab_externalid'])
+			{
+				
+				return false;
+				
+			}
+			
+			$this->db->UpdateQuery(WPSG_TBL_ORDER, array(
+				"cab_transactionStatus" => $result->transactionList->transaction->transactionStatus,
+				"cab_lastupdate" => "NOW()"
+			), "`id` = '".wpsg_q($order['id'])."'");
+			
+			return $result->transactionList->transaction->transactionStatus;
+			
+		} // private function getPaymentStatus($order_id)
+		
+		/**
+		 * Gibt das Clientobjekt fÃŒr die SOAP Anfragen zurÃŒck
+		 */
+		private function getClient()
+		{
+			
+			if (get_option("wpsg_mod_cab_sandbox") == "1")
+			{
+				
+				$client = new SoapClient('https://api.clickandbuy.com/webservices/soap/pay_1_0_0.wsdl');
+				$client->__setLocation('https://api.clickandbuy-s1.com/webservices/soap/pay_1_0_0');
+				
+			}
+			else
+			{
+				
+				$client = new SoapClient('https://api.clickandbuy.com/webservices/pay_1_0_0.wsdl');
+				
+			} 
+			
+			return $client;
+			
+		} // private function getClient()
+		
+		function generateToken($projectID, $secretKey) 
+		{
+			
+			$timestamp = gmdate("YmdHis");	
+			$hashStr = $projectID."::".$secretKey."::".$timestamp;
+			$toBeHashed = strtoupper(sha1($hashStr));	
+			$token = $timestamp.'::'.$toBeHashed; 	
+			
+			return $token;	
+			
+		} // function generateToken($projectID, $secretKey)
+
+		/**
+		 * Generiert den Hash (Signatur) fÃŒr die MMS Verfikation
+		 * @param $xml
+		 */
+		private function makeMMSHash($xml)
+		{
+			
+			$xml = preg_replace("/\<signature\>(.*)\<\/signature\>/", "<signature />", $xml);
+			 
+			return sha1(get_option("wpsg_cab_mmskey").$xml);
+			
+		} // private function makeMMSHash($xml)
+				
+	} // class wpsg_mod_cab extends wpsg_mod_basic
+
+?>
Index: /system/intern/views/mod_cab/mail_mms.phtml
===================================================================
--- /system/intern/views/mod_cab/mail_mms.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/mail_mms.phtml	(revision 5989)
@@ -0,0 +1,12 @@
+Hallo Administrator,
+
+Eine neue MMS ClickandBuy Benachrichtigung ist eingetroffen
+
+Datum: <?php echo date("d.m.Y H:i:s"); ?>
+
+Aktualisierte Bestellungen: <?php echo $this->view['wpsg_mod_cab']['nUpdated']; ?>
+
+Es folgt der Inhalt der XML Daten:
+
+-----------------------------------------------------------
+<?php echo $this->view['wpsg_mod_cab']['xml']; ?>
Index: /system/intern/views/mod_cab/mail_mms_error.phtml
===================================================================
--- /system/intern/views/mod_cab/mail_mms_error.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/mail_mms_error.phtml	(revision 5989)
@@ -0,0 +1,12 @@
+Hallo Administrator,
+
+Eine neue MMS ClickandBuy Benachrichtigung ist eingetroffen, aber der Hash konnte nicht verifiziert werden!
+
+Datum: <?php echo date("d.m.Y H:i:s"); ?>
+
+Ermittelter Hash: <?php echo $this->view['wpsg_mod_cab']['hash']; ?>
+
+Es folgt der Inhalt der XML Daten:
+
+-----------------------------------------------------------
+<?php echo $this->view['wpsg_mod_cab']['xml']; ?>
Index: /system/intern/views/mod_cab/mail_resend.phtml
===================================================================
--- /system/intern/views/mod_cab/mail_resend.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/mail_resend.phtml	(revision 5989)
@@ -0,0 +1,10 @@
+<?php wpsg_translate(__('Hallo #1# #2#,', 'wpsg'), $this->view['wpsg_mod_cab']['customer']['vname'], $this->view['wpsg_mod_cab']['customer']['name']); ?>,
+ 
+<?php echo __('Es wurde vom Administrator ein neuer ClickandBuy Bezahllink erstellt:', 'wpsg'); ?>
+ 
+<?php echo $this->view['wpsg_mod_cab']['payLink']; ?>
+ 
+ 
+<?php echo __('Mit freundlichen GrÃŒÃen', 'wpsg'); ?>
+
+<?php echo __($this->get_option('wpsg_shopdata_name'), 'wpsg'); ?> - <?php echo __('Team', 'wpsg'); ?>
Index: /system/intern/views/mod_cab/order_done.phtml
===================================================================
--- /system/intern/views/mod_cab/order_done.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/order_done.phtml	(revision 5989)
@@ -0,0 +1,24 @@
+<?php
+
+	/**
+	 * Dieses Template wird bei der Bezahlart "ClickandBuy" nach der Bestellung eingebunden 
+	 */
+
+?>
+<p><?php echo __('Um den Betrag mit ClickandBuy zu bezahlen klicken Sie bitte auf folgendes Logo.', 'wpsg'); ?></p>
+<p>
+	<a href="<?php echo $this->view['wpsg_mod_cab']['url']; ?>">
+		<img src="<?php echo $this->arPayment[810]['logo']; ?>" alt="<?php echo __('Mit ClickandBuy bezahlen', 'wpsg'); ?>" />
+	</a>
+</p>
+<?php if ($this->get_option('wpsg_mod_cab_autostart') == '1') { ?>
+<script type="text/javascript">
+ 
+	jQuery(document).ready(function() { 
+		window.setTimeout(function() {
+    	location.href = "<?php echo $this->view['wpsg_mod_cab']['url']; ?>";
+		}, 1000);
+	} );
+	
+</script>
+<?php } ?>
Index: /system/intern/views/mod_cab/order_view_content.phtml
===================================================================
--- /system/intern/views/mod_cab/order_view_content.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/order_view_content.phtml	(revision 5989)
@@ -0,0 +1,83 @@
+<?php
+
+	/**
+	 * Template fÃŒr die Integration der Zahlungsart Click&Buy in die Bestellverwaltung
+	 */
+
+?>
+<script type="text/javascript">/* <![CDATA[ */
+
+	function wpsg_mod_cab_reload()
+	{
+
+		jQuery('#wpsg_mod_cab_inner').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+		
+		jQuery.ajax( {
+			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_cab&cmd=refresh&noheader=1&edit_id=<?php echo $this->view['wpsg_mod_cab']['order']['id']; ?>',
+			data: {
+			},
+			success: function(data) {
+				
+				jQuery('#wpsg_mod_cab_inner').html(data);
+				
+			}
+		} );
+
+		return false;
+		
+	} // function wpsg_mod_cab_reload()
+
+	function wpsg_mod_cab_rebuild()
+	{
+
+		jQuery('#wpsg_mod_cab_inner').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+		
+		jQuery.ajax( {
+			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_cab&cmd=rebuild&noheader=1&edit_id=<?php echo $this->view['wpsg_mod_cab']['order']['id']; ?>',
+			data: {
+			},
+			success: function(data) {
+				
+				jQuery('#wpsg_mod_cab_inner').html(data);
+				
+			}
+		} );
+		 
+		return false;
+		
+	} // function wpsg_mod_cab_rebuild()
+
+	function wpsg_mod_cab_repay()
+	{
+
+		jQuery('#wpsg_mod_cab_inner').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
+		
+		jQuery.ajax( {
+			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_cab&cmd=repay&noheader=1&edit_id=<?php echo $this->view['wpsg_mod_cab']['order']['id']; ?>',
+			data: {
+				value: jQuery('#wpsg_cab_repayvalue').val()				
+			},
+			success: function(data) {
+				
+				jQuery('#wpsg_mod_cab_inner').html(data);
+				
+			}
+		} );
+		 
+		return false;
+		
+	} // function wpsg_mod_cab_repay()
+	
+/* ]]> */</script> 
+		
+<div id="wpsg_cab" class="postbox">
+	<h3 class="wpsg_handlediv">
+		<span class="handlediv" title="<?php echo __('Zum Ein/Ausklappen hier klicken', 'wpsg'); ?>"><br></span>
+		<span><?php echo __('Click & Buy', 'wpsg'); ?></span>
+	</h3>
+	<div class="inside" id="wpsg_mod_cab_inner">
+
+		<?php echo $this->view['wpsg_mod_cab']['content']; ?>
+ 		
+	</div>
+</div>
Index: /system/intern/views/mod_cab/order_view_content_inner.phtml
===================================================================
--- /system/intern/views/mod_cab/order_view_content_inner.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/order_view_content_inner.phtml	(revision 5989)
@@ -0,0 +1,67 @@
+<?php
+
+	/**
+	 * Template fÃŒr die Integration von Click&Buy in die Bestellverwaltung
+	 */
+
+?>
+<?php if (wpsg_isSizedString($this->view['wpsg_mod_cab']['strError'])) { ?>
+<div class="wpsg_error"><?php echo $this->view['wpsg_mod_cab']['strError']; ?></div><br />
+<?php } ?>
+
+<div style="width:30%; float:left;"><?php echo __("Derzeitiger Status", "wpsg"); ?></div>
+
+<div style="width:70%; float:right;">
+	<?php echo $this->view['wpsg_mod_cab']['order']['cab_transactionStatus'].' ('.wpsg_formatTimestamp(strtotime($this->view['wpsg_mod_cab']['order']['cab_lastupdate'])).')'; ?>
+	<a href="#" onclick="return wpsg_mod_cab_reload();"><?php echo __("Neu abfragen", "wpsg"); ?></a>
+</div><div style="clear:both; height:3px; width:100%;"></div>			
+
+<div style="width:100%;">
+	<div style="width:30%; float:left;"><?php echo __("transactionID", "wpsg"); ?>:</div>
+	<div style="width:70%; float:right;"><?php echo $this->view['wpsg_mod_cab']['order']['cab_transactionID']; ?></div>
+</div><div style="clear:both; height:3px; width:100%;"></div>
+		
+<div style="width:100%;">
+	<div style="width:30%; float:left;"><?php echo __("externalID", "wpsg"); ?>:</div>
+	<div style="width:70%; float:right;"><?php echo $this->view['wpsg_mod_cab']['order']['cab_externalid']; ?></div>
+</div><div style="clear:both; height:3px; width:100%;"></div>
+
+<?php if (wpsg_isSizedArray($this->view['wpsg_mod_cab']['log'])) { ?>
+<table style="width:100%;">
+	<tr>
+		<th><?php echo __("Datum", "wpsg"); ?></th>
+		<th><?php echo __("Event ID", "wpsg"); ?></th>
+		<th><?php echo __("Alter Status", "wpsg"); ?></th>
+		<th><?php echo __("Neuer Status", "wpsg"); ?></th>
+	</tr>
+	<?php foreach ($log as $l) { ?>
+	<tr>
+		<td><?php echo date("d.m.Y H:i:s", strtotime($l['cdate'])); ?></td>
+		<td><?php echo $l['eventID']; ?></td>
+		<td><?php echo $l['oldState']; ?></td>
+		<td><?php echo $l['newState']; ?></td>
+	</tr>
+	<?php } ?>
+</table><div style="clear:both; height:3px; width:100%;"></div>
+<?php } ?>
+
+<div style="width:100%;">
+<div style="width:30%; float:left;"><?php echo __("Link zum Bezahlen", "wpsg"); ?>:</div>
+<div style="width:70%; float:right;">
+	<a href="<?php echo $this->view['wpsg_mod_cab']['order']['cab_paylink']; ?>"><?php echo __("Link", "wpsg"); ?></a>&nbsp;|&nbsp;
+	<a href="#" onclick="return wpsg_mod_cab_rebuild();"><?php echo __("Neu generieren und versenden", "wpsg"); ?></a>
+</div>
+</div><div style="clear:both; height:3px; width:100%;"></div>
+		
+<br />
+
+<div style="width:30%; float:left; line-height:20px;"><?php echo __("RÃŒckzahlung", "wpsg"); ?>:</div>
+	
+<?php if (($this->view['wpsg_mod_cab']['order']['price_gesamt'] - $this->view['wpsg_mod_cab']['order']['cab_repayed']) > 0) { ?>
+<div style="width:70%; float:left;">
+	<input type="text" id="wpsg_cab_repayvalue" name="wpsg_cab_repayvalue" value="" />&nbsp;&nbsp;(<?php echo __('Max', 'wpsg'); ?>: <?php echo wpsg_ff($this->view['wpsg_mod_cab']['order']['price_gesamt'] - $this->view['wpsg_mod_cab']['order']['cab_repayed'], $this->get_option('wpsg_currency')).')'; ?>
+	<input onclick="return wpsg_mod_cab_repay();" type="submit" value="<?php echo __("ZurÃŒckzahlen", "wpsg"); ?>" style="float:right;" />
+</div>
+<?php } ?>
+	
+<div style="clear:both; height:3px; width:100%;"></div>
Index: /system/intern/views/mod_cab/settings_edit.phtml
===================================================================
--- /system/intern/views/mod_cab/settings_edit.phtml	(revision 5989)
+++ /system/intern/views/mod_cab/settings_edit.phtml	(revision 5989)
@@ -0,0 +1,49 @@
+<?php
+
+	/**
+	 * Template fÃŒr die Einstellungen des Click&Buy Moduls
+	 */
+
+?>
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_bezeichnung', __('Bezeichnung', 'wpsg'), $this->get_option('wpsg_mod_cab_bezeichnung'), array('help' => 'wpsg_mod_cab_bezeichnung')); ?>
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_auftragsbezeichnung', __('Auftragsbezeichnung', 'wpsg'), $this->get_option('wpsg_mod_cab_auftragsbezeichnung'), array('help' => 'wpsg_mod_cab_auftragsbezeichnung')); ?>
+<?php echo wpsg_drawForm_Checkbox('wpsg_mod_cab_aktiv', __('Aktiv', 'wpsg'), $this->get_option('wpsg_mod_cab_aktiv'), array('help' => 'wpsg_mod_cab_aktiv')); ?>
+<?php echo wpsg_drawForm_Checkbox('wpsg_mod_cab_sandbox', __('Sandbox', 'wpsg'), $this->get_option('wpsg_mod_cab_sandbox'), array('help' => 'wpsg_mod_cab_sandbox')); ?>
+<?php echo wpsg_drawForm_Textarea('wpsg_mod_cab_hint', __('Hinweistext', 'wpsg'), $this->get_option('wpsg_mod_cab_hint'), array('help' => 'wpsg_mod_cab_hint')); ?>
+<br />
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_merchantID', __('MerchantID', 'wpsg'), $this->get_option('wpsg_mod_cab_merchantID'), array('help' => 'wpsg_mod_cab_merchantID')); ?>
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_projectID', __('ProjektID', 'wpsg'), $this->get_option('wpsg_mod_cab_projectID'), array('help' => 'wpsg_mod_cab_projectID')); ?>
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_kryptkey', __('Kryptographischer SchlÃŒssel', 'wpsg'), $this->get_option('wpsg_mod_cab_kryptkey'), array('help' => 'wpsg_mod_cab_kryptkey')); ?>
+<br />
+<?php echo wpsg_drawForm_Input('', __('MMS Push URL', 'wpsg'), $this->view['wpsg_mod_cab_mmspushurl'], array('help' => 'wpsg_mod_cab_mmspushurl','readonly' => true, 'disabled' => false)); ?>
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_mmskryptkey', __('Kryptographischer SchlÃŒssel (MMS)', 'wpsg'), $this->get_option('wpsg_mod_cab_mmskryptkey'), array('help' => 'wpsg_mod_cab_mmskryptkey')); ?>
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_mmsstatusmail', __('MMS Statusmail', 'wpsg'), $this->get_option('wpsg_mod_cab_mmsstatusmail'), array('help' => 'wpsg_mod_cab_mmsstatusmail')); ?>
+<br />
+<?php echo wpsg_drawForm_Select('wpsg_mod_cab_success', __('Erfolgslink', 'wpsg'), $this->view['pages'], $this->get_option('wpsg_mod_cab_success'), array('help' => 'wpsg_mod_cab_success')); ?>
+<?php echo wpsg_drawForm_Select('wpsg_mod_cab_error', __('Abbruchlink', 'wpsg'), $this->view['pages'], $this->get_option('wpsg_mod_cab_error'), array('help' => 'wpsg_mod_cab_error')); ?>
+<br />
+<?php echo wpsg_drawForm_Input('wpsg_mod_cab_gebuehr', __('GebÃŒhr/Rabatt', 'wpsg'), wpsg_ff($this->get_option('wpsg_mod_cab_gebuehr'), true), array('help' => 'wpsg_mod_cab_gebuehr','unit' => $this->get_option('wpsg_currency').' / %')); ?>
+<?php echo wpsg_drawForm_Select('wpsg_mod_cab_mwst', __('Mehrwertsteuersatz', 'wpsg'), wpsg_tax_groups(), $this->get_option('wpsg_mod_cab_mwst'), array('help' => 'wpsg_mod_cab_mwst')); ?>
+<?php echo wpsg_drawForm_Checkbox('wpsg_mod_cab_mwstland', __('Keine MwSt. wenn Land steuerfrei', 'wpsg'), $this->get_option('wpsg_mod_cab_mwstland'), array('help' => 'wpsg_mod_cab_mwstland')); ?>
+<br />
+<?php echo wpsg_drawForm_Select('wpsg_mod_cab_currency', __('WÃ€hrung', 'wpsg'), array('EUR' => __('EUR', 'wpsg'), 'GBP' => __('GBP', 'wpsg'), 'USD' => __('USD', 'wpsg'), 'CHR' => __('CHR', 'wpsg')), $this->get_option('wpsg_mod_cab_currency'), array('help' => 'wpsg_mod_cab_currency')); ?>
+<?php echo wpsg_drawForm_Checkbox('wpsg_mod_cab_autorun', __('Zahlung sofort starten', 'wpsg'), $this->get_option('wpsg_mod_cab_autorun'), array('help' => 'wpsg_mod_cab_autorun')); ?>
+
+<script type="text/javascript">/* <![CDATA[ */
+
+	var wpsg_pageURLs = new Object();
+
+	<?php if (wpsg_isSizedArray($this->view['pageURLs'])) { ?>
+	<?php foreach ($this->view['pageURLs'] as $page_id => $page_url) { ?>
+	wpsg_pageURLs['<?php echo $page_id; ?>'] = '<?php echo $page_url; ?>';
+	<?php } ?>	
+	<?php } ?>
+ 
+	jQuery(document).ready(function() {
+
+		wpsg_switchPage(jQuery('#wpsg_mod_cab_success'));
+		wpsg_switchPage(jQuery('#wpsg_mod_cab_error'));
+		
+	} );
+	
+/* ]]> */</script>
