<?php

	class wpsg_mod_giropay extends wpsg_mod_basic
	{
		
		var $lizenz = 2;
		var $id = 3050; 
		var $hilfeURL = 'http://wpshopgermany.maennchen1.de/?p=3816';
		var $version = "9.9.9";
		var $free = true;
		
		var $sourceID = '6da0f976433e18641662198d98557955'; // ID des Shop Systems
		
		public function __construct()
		{
		
			parent::__construct();
		
			$this->name = __('GiroCheckout', 'wpsg');
			$this->group = __('Zahlungsarten', 'wpsg');
			$this->desc = wpsg_translate(__('Ermöglicht das Einbinden der Zahlungsarten der <a href="#1">GiroSolution AG</a>.', 'wpsg'), 'http://www.girosolution.de');
		
		} // public function __construct()
		
		public function install()
		{
			
			//$this->shop->checkDefault('wpsg_mod_giropay_currency', 'EUR');
			$this->shop->checkDefault('wpsg_mod_giropay_subject', 'O%order_id% - K%kunde_id%');
			$this->shop->createPage(__('Erfolgreiche Zahlung', 'wpsg'), 'wpsg_mod_giropay_successPage', $_REQUEST['wpsg_mod_giropay_successPage']);
						
			$this->shop->checkDefault('wpsg_mod_giropay_giropay_name', __('GiroCheckout - giropay', 'wpsg'), false, true);
			$this->shop->checkDefault('wpsg_mod_giropay_giropay_hint', __('Die sichere Online-Überweisung über das Online-Banking Ihrer Bank oder Sparkasse. Im nächsten Schritt werden Sie direkt zum Online-Banking Ihrer Hausbank weitergeleitet, wo Sie die Zahlung durch Eingabe von PIN und TAN freigeben.', 'wpsg'), false, true);
			
			$this->shop->checkDefault('wpsg_mod_giropay_creditcard_name', __('GiroCheckout - Kreditkarte', 'wpsg'), false, true);
			$this->shop->checkDefault('wpsg_mod_giropay_creditcard_hint', __('Nach Auswahl des Kreditkartentyps, werden Sie im nächsten Schritt aufgefordert, Ihre Kreditkartennummer und Kartenprüfnummer einzugeben. Wenn Ihre Kreditkarte für 3D-Secure (Verified by Visa bzw. MasterCard SecureCode) freigeschaltet ist, werden Sie während des Bezahlprozesses zur Sicherheitsabfrage Ihrer Hausbank weitergeleitet.', 'wpsg'), false, true);
			
			$this->shop->checkDefault('wpsg_mod_giropay_directdebit_name', __('GiroCheckout - Lastschrift', 'wpsg'), false, true);
			$this->shop->checkDefault('wpsg_mod_giropay_directdebit_hint', __('Hiermit ermächtigen Sie uns, den Betrag von Ihrem Konto einzuziehen. Aus Datenschutzgründen werden Ihre Kontodaten nicht gespeichert. Bei jeder Bestellugn ist deshalb eine Neueingabe erforderlich.', 'wpsg'), false, true);
			
		} // public function install()
		
		public function settings_edit()
		{
			
			$pages = get_pages();
			
			$arPages = array(
					'-1' => __('Neu anlegen und zuordnen', 'wpsg')
			);
			
			foreach ($pages as $k => $v)
			{
				$arPages[$v->ID] = $v->post_title.' (ID:'.$v->ID.')';
			}
			
			$this->shop->view['wpsg_mod_giropay']['arPages'] = $arPages;
			
			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_giropay/settings_edit.phtml');
			
		} // public function settings_edit()
		
		public function settings_save()
		{
			
			$this->shop->update_option('wpsg_mod_giropay_merchantId', $_REQUEST['wpsg_mod_giropay_merchantId']);
			//$this->shop->update_option('wpsg_mod_giropay_currency', $_REQUEST['wpsg_mod_giropay_currency']);
			$this->shop->update_option('wpsg_mod_giropay_paystart', $_REQUEST['wpsg_mod_giropay_paystart']);
			$this->shop->update_option('wpsg_mod_giropay_subject', $_REQUEST['wpsg_mod_giropay_subject']);
			$this->shop->createPage(__('Erfolgreiche Zahlung', 'wpsg'), 'wpsg_mod_giropay_successPage', $_REQUEST['wpsg_mod_giropay_successPage']);
			$this->shop->createPage(__('Fehlerhafte Zahlung', 'wpsg'), 'wpsg_mod_giropay_errorPage', $_REQUEST['wpsg_mod_giropay_errorPage']);
						
			// Direktüberweisung
			$this->shop->update_option('wpsg_mod_giropay_giropay_activ', $_REQUEST['wpsg_mod_giropay_giropay_activ']);
			$this->shop->update_option('wpsg_mod_giropay_giropay_projectid', $_REQUEST['wpsg_mod_giropay_giropay_projectid']);
			$this->shop->update_option('wpsg_mod_giropay_giropay_projectpw', $_REQUEST['wpsg_mod_giropay_giropay_projectpw']);
			
			$this->shop->update_option('wpsg_mod_giropay_giropay_name', $_REQUEST['wpsg_mod_giropay_giropay_name']);
			$this->shop->update_option('wpsg_mod_giropay_giropay_hint', $_REQUEST['wpsg_mod_giropay_giropay_hint']);
			
			$this->shop->addTranslationString('wpsg_mod_giropay_giropay_name', $_REQUEST['wpsg_mod_giropay_giropay_name']);
			$this->shop->addTranslationString('wpsg_mod_giropay_giropay_hint', $_REQUEST['wpsg_mod_giropay_giropay_hint']);
			
			$this->shop->update_option('wpsg_mod_giropay_giropay_logo', $_REQUEST['wpsg_mod_giropay_giropay_logo']);
			$this->shop->update_option('wpsg_mod_giropay_giropay_gebuehr', $_REQUEST['wpsg_mod_giropay_giropay_gebuehr']);
			$this->shop->update_option('wpsg_mod_giropay_giropay_mwst', $_REQUEST['wpsg_mod_giropay_giropay_mwst']);
			$this->shop->update_option('wpsg_mod_giropay_giropay_mwstland', $_REQUEST['wpsg_mod_giropay_giropay_mwstland']);
			
			// Kreditkarte
			$this->shop->update_option('wpsg_mod_giropay_creditcard_activ', $_REQUEST['wpsg_mod_giropay_creditcard_activ']);
			$this->shop->update_option('wpsg_mod_giropay_creditcard_projectid', $_REQUEST['wpsg_mod_giropay_creditcard_projectid']);
			$this->shop->update_option('wpsg_mod_giropay_creditcard_projectpw', $_REQUEST['wpsg_mod_giropay_creditcard_projectpw']);
			
			$this->shop->update_option('wpsg_mod_giropay_creditcard_name', $_REQUEST['wpsg_mod_giropay_creditcard_name']);
			$this->shop->update_option('wpsg_mod_giropay_creditcard_hint', $_REQUEST['wpsg_mod_giropay_creditcard_hint']);
			
			$this->shop->addTranslationString('wpsg_mod_giropay_creditcard_name', $_REQUEST['wpsg_mod_giropay_creditcard_name']);
			$this->shop->addTranslationString('wpsg_mod_giropay_creditcard_hint', $_REQUEST['wpsg_mod_giropay_creditcard_hint']);
			
			$this->shop->update_option('wpsg_mod_giropay_creditcard_logo', $_REQUEST['wpsg_mod_giropay_creditcard_logo']);
			$this->shop->update_option('wpsg_mod_giropay_creditcard_gebuehr', $_REQUEST['wpsg_mod_giropay_creditcard_gebuehr']);
			$this->shop->update_option('wpsg_mod_giropay_creditcard_mwst', $_REQUEST['wpsg_mod_giropay_creditcard_mwst']);
			$this->shop->update_option('wpsg_mod_giropay_creditcard_mwstland', $_REQUEST['wpsg_mod_giropay_creditcard_mwstland']);
			
			// Lastschrift
			$this->shop->update_option('wpsg_mod_giropay_directdebit_activ', $_REQUEST['wpsg_mod_giropay_directdebit_activ']);
			$this->shop->update_option('wpsg_mod_giropay_directdebit_projectid', $_REQUEST['wpsg_mod_giropay_directdebit_projectid']);
			$this->shop->update_option('wpsg_mod_giropay_directdebit_projectpw', $_REQUEST['wpsg_mod_giropay_directdebit_projectpw']);
			
			$this->shop->update_option('wpsg_mod_giropay_directdebit_name', $_REQUEST['wpsg_mod_giropay_directdebit_name']);
			$this->shop->update_option('wpsg_mod_giropay_directdebit_hint', $_REQUEST['wpsg_mod_giropay_directdebit_hint']);
			
			$this->shop->addTranslationString('wpsg_mod_giropay_directdebit_name', $_REQUEST['wpsg_mod_giropay_directdebit_name']);
			$this->shop->addTranslationString('wpsg_mod_giropay_directdebit_hint', $_REQUEST['wpsg_mod_giropay_directdebit_hint']);
			
			$this->shop->update_option('wpsg_mod_giropay_directdebit_logo', $_REQUEST['wpsg_mod_giropay_directdebit_logo']);
			$this->shop->update_option('wpsg_mod_giropay_directdebit_gebuehr', $_REQUEST['wpsg_mod_giropay_directdebit_gebuehr']);
			$this->shop->update_option('wpsg_mod_giropay_directdebit_mwst', $_REQUEST['wpsg_mod_giropay_directdebit_mwst']);
			$this->shop->update_option('wpsg_mod_giropay_directdebit_mwstland', $_REQUEST['wpsg_mod_giropay_directdebit_mwstland']);
			
		} // public function settings_save()
		
		public function addPayment(&$arPayment)
		{
			
			if (is_admin() || $this->shop->get_option('wpsg_mod_giropay_giropay_activ') == '1')
			{
				
				$mwst_value = $this->getTaxValue($this->shop->get_option('wpsg_mod_giropay_giropay_mwst'), $this->shop->getDefaultCountry());
				
				$arPayment[$this->id.'_1'] = array(
						'id' => $this->id.'_1',
						'name' => __($this->shop->get_option('wpsg_mod_giropay_giropay_name'), 'wpsg'),
						'preis' => $this->shop->get_option('wpsg_mod_giropay_giropay_gebuehr'),
						'mwst' => $this->shop->get_option('wpsg_mod_giropay_giropay_mwst'),
						'mwst_value' => $mwst_value,
						'mwst_null' => $this->shop->get_option('wpsg_mod_giropay_giropay_mwstland'),
						'hint' => __($this->shop->get_option('wpsg_mod_giropay_giropay_hint')),
						'logo' => ((wpsg_isSizedString($this->shop->get_option('wpsg_mod_giropay_giropay_logo')))?$this->shop->get_option('wpsg_mod_giropay_giropay_logo'):$this->shop->getRessourceURL('mods/mod_giropay/gfx/gc_giropay.png')),
						'logo_100x25' => $this->shop->getRessourceURL('mods/mod_giropay/gfx/logo_100x25.png')
				);
				
				$this->setPayShipPrice($this->shop->get_option('wpsg_mod_giropay_giropay_gebuehr'), $mwst_value, $arPayment, $this->id.'_1');
								
			}
			 
			if (is_admin() || $this->shop->get_option('wpsg_mod_giropay_creditcard_activ') == '1')
			{
			
				$mwst_value = $this->getTaxValue($this->shop->get_option('wpsg_mod_giropay_giropay_mwst'), $this->shop->getDefaultCountry());
				
				$arPayment[$this->id.'_2'] = array(
						'id' => $this->id.'_2',
						'name' => __($this->shop->get_option('wpsg_mod_giropay_creditcard_name'), 'wpsg'),
						'preis' => $this->shop->get_option('wpsg_mod_giropay_creditcard_gebuehr'),
						'mwst' => $this->shop->get_option('wpsg_mod_giropay_creditcard_mwst'),
						'mwst_value' => $mwst_value,
						'mwst_null' => $this->shop->get_option('wpsg_mod_giropay_creditcard_mwstland'),
						'hint' => __($this->shop->get_option('wpsg_mod_giropay_creditcard_hint')),
						'logo' => ((wpsg_isSizedString($this->shop->get_option('wpsg_mod_giropay_creditcard_logo')))?$this->shop->get_option('wpsg_mod_giropay_creditcard_logo'):$this->shop->getRessourceURL('mods/mod_giropay/gfx/gc_creditcard.png')),
						'logo_100x25' => $this->shop->getRessourceURL('mods/mod_giropay/gfx/logo_100x25.png')
				);
			
				$this->setPayShipPrice($this->shop->get_option('wpsg_mod_giropay_creditcard_gebuehr'), $mwst_value, $arPayment, $this->id.'_2');
			
			}
			
			if (is_admin() || $this->shop->get_option('wpsg_mod_giropay_directdebit_activ') == '1')
			{
			
				$mwst_value = $this->getTaxValue($this->shop->get_option('wpsg_mod_giropay_giropay_mwst'), $this->shop->getDefaultCountry());
				
				$arPayment[$this->id.'_3'] = array(
						'id' => $this->id.'_3',
						'name' => __($this->shop->get_option('wpsg_mod_giropay_directdebit_name'), 'wpsg'),
						'preis' => $this->shop->get_option('wpsg_mod_giropay_directdebit_gebuehr'),
						'mwst' => $this->shop->get_option('wpsg_mod_giropay_directdebit_mwst'),
						'mwst_value' => $mwst_value,
						'mwst_null' => $this->shop->get_option('wpsg_mod_giropay_directdebit_mwstland'),
						'hint' => __($this->shop->get_option('wpsg_mod_giropay_directdebit_hint')),
						'logo' => ((wpsg_isSizedString($this->shop->get_option('wpsg_mod_giropay_directdebit_logo')))?$this->shop->get_option('wpsg_mod_giropay_directdebit_logo'):$this->shop->getRessourceURL('mods/mod_giropay/gfx/gc_directdebit.png')),
						'logo_100x25' => $this->shop->getRessourceURL('mods/mod_giropay/gfx/logo_100x25.png')
				);
			
				$this->setPayShipPrice($this->shop->get_option('wpsg_mod_giropay_directdebit_gebuehr'), $mwst_value, $arPayment, $this->id.'_3');
			
			}
			
		} // public function addPayment(&$arPayment)
		
		public function calcPayment(&$arBasket)
		{
		
			if (preg_match('/^'.$this->id.'_\d+$/', $arBasket['checkout']['payment']))
			{
		
				$subPayTyp = preg_replace('/^\d+_/', '', $arBasket['checkout']['payment']);
		
				switch ($subPayTyp)
				{
		
					case '1': // Giropay
		
						$payment_price = $this->getPreis($this->shop->get_option('wpsg_mod_giropay_giropay_gebuehr'), $arBasket['sum']['preis']);
						$mwstland = $this->shop->get_option('wpsg_mod_giropay_giropay_mwstland');
						$mwst = $this->shop->get_option('wpsg_mod_giropay_giropay_mwst');
		
						break;
		
					case '2': // Kreditkarte
		
						$payment_price = $this->getPreis($this->shop->get_option('wpsg_mod_giropay_creditcard_gebuehr'), $arBasket['sum']['preis']);
						$mwstland = $this->shop->get_option('wpsg_mod_giropay_creditcard_mwstland');
						$mwst = $this->shop->get_option('wpsg_mod_giropay_creditcard_mwst');
		
						break;
		
					case '3': // Lastschrift
		
						$payment_price = $this->getPreis($this->shop->get_option('wpsg_mod_giropay_directdebit_gebuehr'), $arBasket['sum']['preis']);
						$mwstland = $this->shop->get_option('wpsg_mod_giropay_directdebit_mwstland');
						$mwst = $this->shop->get_option('wpsg_mod_giropay_directdebit_mwst');
		
						break; 
		
					default:
		
						$this->shop->throwErrorCode('3050_3');
		
				}
		
				if ($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, $mwst);
		
				}
		
			}
		
		} // public function calcPayment(&$arBasket)
		
		public function order_done(&$order_id, &$done_view)
		{
		
			// Bestellungen mit 0 geben nix aus
			if ($done_view['basket']['sum']['preis_gesamt_brutto'] <= 0) return;
		
			if (preg_match('/^'.$this->id.'_\d+$/', $this->shop->view['basket']['checkout']['payment']))
			{
		
				$payment = $this->shop->view['basket']['checkout']['payment'];
		
				list($project_id, $project_pw) = $this->getpassidfrompayment($payment); 
				
				$this->shop->view['wpsg_mod_giropay']['logo'] = $this->shop->arPayment[$payment]['logo'];
				$this->shop->view['wpsg_mod_giropay']['title'] = __('Mit giropay bezahlen', 'wpsg');
				$this->shop->view['wpsg_mod_giropay']['payLink'] = $this->getPayLink($order_id, $project_id, $project_pw);				
				$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_giropay/order_done.phtml');
				
			}
			
		} // public function order_done(&$order_id, &$done_view)
		
		public function wp_loaded()
		{
		
			if ($_REQUEST['wpsg_plugin'] != 'wpsg_mod_giropay') return;
			
			if ($_REQUEST['confirm'] == 'giropay')
			{
				
				// Bestellung heraussuchen
				$order_id = preg_replace('/(^O)|(T\d+$)/', '', $_REQUEST['order_id']);
				
				if (!wpsg_isSizedInt($order_id)) $this->shop->throwErrorCode('3050_2');
				
				$order = $this->shop->cache->loadOrderObject($order_id);
				
				list($project_id, $project_pw) = $this->getpassidfrompayment($order->getPaymentID());
				
				// Hash prüfen
				$arParam = array(
					'merchantId' => $this->shop->get_option('wpsg_mod_giropay_merchantId'),
					'projectId' => $project_id,
					'transactionId' => $_REQUEST['order_id'],
					'gpCode' => $_REQUEST['gpCode']	
				);
				
				$hash_gen = $this->getHash($arParam, $project_pw);
				
				if ($hash_gen == $_REQUEST['gpHash'])
				{
					 
					if ($_REQUEST['gpCode'] == '4000')
					{
						
						// Zahlung ok 
						$this->db->ImportQuery(WPSG_TBL_OL, array(
							'o_id' => wpsg_q($order_id),
							'cdate' => 'NOW()',
							'title' => __('GiroCheckout: Gültige Rückmeldung mit Zahlungsbestätigung', 'wpsg'),
							'mailtext' => print_r($_REQUEST, 1)
						));
						 
						$this->shop->setOrderStatus($order_id, 100, true);
						
					}
					else
					{
						
						// Zahlung nicht ok, hier Log Meldung
						$this->db->ImportQuery(WPSG_TBL_OL, array(
							'o_id' => wpsg_q($order_id),
							'cdate' => 'NOW()',
							'title' => __('GiroCheckout: Gültige Rückmeldung ohne Zahlungsbestätigung', 'wpsg'),
							'mailtext' => print_r($_REQUEST, 1)	
						));
						
					}
										
				}
				else
				{
					
					$this->db->ImportQuery(WPSG_TBL_OL, array(
						'o_id' => wpsg_q($order_id),
						'cdate' => 'NOW()',
						'title' => __('GiroCheckout: Fehlerhafte Anfrage (Hash stimmt nicht)', 'wpsg'),	
						'mailtext' => print_r($_REQUEST, 1)	
					));
					
				}	
				
			}
			else if ($_REQUEST['confirm'] == 'giropay_return')
			{
				
				// Bestellung heraussuchen
				$order_id = preg_replace('/(^O)|(T\d+$)/', '', $_REQUEST['order_id']);
				
				if (!wpsg_isSizedInt($order_id)) $this->shop->throwErrorCode('3050_2');
				
				$order = $this->shop->cache->loadOrderObject($order_id);
				
				list($project_id, $project_pw) = $this->getpassidfrompayment($order->getPaymentID());
				
				// Hash prüfen
				$arParam = array(
					'merchantId' => $this->shop->get_option('wpsg_mod_giropay_merchantId'),
					'projectId' => $project_id,
					'transactionId' => $_REQUEST['order_id'],
					'gpCode' => $_REQUEST['gpCode']
				);
				
				$hash_gen = $this->getHash($arParam, $project_pw);
				
				if ($hash_gen == $_REQUEST['gpHash'])
				{
					
					// Ich mache hier nur etwas wenn die Hash Werte stimmen
					if ($_REQUEST['gpCode'] == '4000')
					{
						
						// Erfolg
						$this->shop->redirect(get_permalink($this->shop->get_option('wpsg_mod_giropay_successPage')));
						
					}
					else
					{
						
						// Zahlung abgelehnt etc.
						$this->shop->redirect(get_permalink($this->shop->get_option('wpsg_mod_giropay_errorPage')));
						
					}
					
				}
				
			}
			
		} // public function wp_loaded()
		
		public function mail_payment()
		{
		
			if (!preg_match('/^'.$this->id.'_\d+$/', $this->shop->view['basket']['checkout']['payment'])) return;
			
			if ($this->shop->htmlMail === true)
			{
			
				echo '<a href="'.$this->shop->getDoneURL($this->shop->view['o_id']).'">'.__('Zahlungslink', 'wpsg').'</a>'.__(', um die Zahlung durchzuführen', 'wpsg');
				
			}
			else
			{
				
				echo wpsg_pad_right(__('Zahlungslink', 'wpsg').':', 35).$this->shop->getDoneURL($this->shop->view['o_id']);
				
			}
				
		}
				
		/** Modul Funktionen */
		
		/**
		 * Gibt den Zahlungslink für eine neue Zahlung für die Bestellung $order_id zurück
		 * @param Integer $order_id ID der Bestellung
		 */
		public function getPayLink($order_id, $project_id, $project_pw)
		{
			
			$oOrder = $this->shop->cache->loadOrderObject($order_id);
			 
			$notify_url = $this->shop->getURL(wpsg_ShopController::URL_BASKET);
			$return_url = $this->shop->getURL(wpsg_ShopController::URL_BASKET);
			
			if (strpos($notify_url, '?') === false)
			{
			
				$notify_url .= '?wpsg_plugin=wpsg_mod_giropay&confirm=giropay';
				$return_url .= '?wpsg_plugin=wpsg_mod_giropay&confirm=giropay_return';
			
			}
			else
			{
			
				$notify_url .= '&wpsg_plugin=wpsg_mod_giropay&confirm=giropay';
				$return_url .= '&wpsg_plugin=wpsg_mod_giropay&confirm=giropay_return';
			
			}
			
			$arParam = array(
				'sourceId' => $this->sourceID,	
				'merchantId' => $this->shop->get_option('wpsg_mod_giropay_merchantId'),
				'projectId' => $project_id,
				'transactionId' => 'O'.$order_id.'T'.time(),
				'amount' => $oOrder->getAmount(),
				'currency' => 'EUR',
				'vwz' => $this->shop->replaceUniversalPlatzhalter($this->shop->get_option('wpsg_mod_giropay_subject'), $order_id), // Verwendungszweck
				/*'bankcode' => '',
				'bankaccount' => '',
				'bankaccountowner' => '',*/
				//'ccType' => '',
				//'3dSecure' => '',
				//'paymode' => '',
				//'pkn' => '',
				//'recurring' => '',
				/*'info1Label' => '',
				'info1Text' => '',
				'info2Label' => '',
				'info2Text' => '',
				'info3Label' => '',
				'info3Text' => '',
				'info4Label' => '',
				'info4Text' => '',
				'info5Label' => '',
				'info5Text' => '',
				'urlRedirect' => get_permalink($this->shop->get_option('wpsg_mod_giropay_successPage')),
				'urlNotify' => $notify_url*/
			);
			
			if ($oOrder->getPaymentID() == $this->id.'_2')
			{
				
				$arParam['ccType'] = '';
				$arParam['3dSecure'] = '1';
				$arParam['paymode'] = 'payonly';
				
			}
			
			$arParam['urlRedirect'] = $return_url;
			$arParam['urlNotify'] = $notify_url;
			
			$arParam['hash'] = $this->getHash($arParam, $project_pw);
			
			$url = 'https://payment.girosolution.de/payment/start/?'.http_build_query($arParam, null, '&');
			 
			$return = json_decode($this->shop->get_url_content($url));
			
			if ($oOrder->getPaymentID() == $this->id.'_2')
			{
				
				return $return->action;
				
			}
			else
			{
			 
				return $return;
				
			}	
			
		} // public function getPayLink($order_id)
		
		/**
		 * Gibt die ProjektID und das ProjektPasswort für eine Zahlungsart zurück
		 * @param unknown_type $strPayment
		 */
		private function getpassidfrompayment($strPayment)
		{
			
			switch ($strPayment)
			{
			
				case $this->id.'_1': // Giropay
			
					$project_id = $this->shop->get_option('wpsg_mod_giropay_giropay_projectid');
					$project_pw = $this->shop->get_option('wpsg_mod_giropay_giropay_projectpw');
			
					break;
			
				case $this->id.'_2': // Kreditkarte
			
					$project_id = $this->shop->get_option('wpsg_mod_giropay_creditcard_projectid');
					$project_pw = $this->shop->get_option('wpsg_mod_giropay_creditcard_projectpw');
			
					break;
			
				case $this->id.'_3': // Lastschrift
			
					$project_id = $this->shop->get_option('wpsg_mod_giropay_directdebit_projectid');
					$project_pw = $this->shop->get_option('wpsg_mod_giropay_directdebit_projectpw');
			
					break;
			
				default:
			
					$this->shop->throwErrorCode('3050_1');
			
			}
			
			return array($project_id, $project_pw);
			
		} // private function getpassidfrompayment($strPayment)
		
		/**
		 * Gibt den Hash für eine Giropay Zahlungsart zurück
		 * @param Array $arParam über den der Hash gebildet werden soll
		 * @param String $pwd Passwort für den Hash Algorithmus
		 */
		private function getHash($arParam, $pwd)
		{

			$hash = hash_hmac("md5", implode('', $arParam), $pwd);
			
			return $hash;
			
		} // private function getHash($arParam, $pwd)
		
	} // class wpsg_mod_giropay extends wpsg_mod_basic

?>