ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPurchaseBMFGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 //include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
14 //include_once './Services/Payment/classes/class.ilShopShoppingCartGUI.php';
15 //include_once './Services/Payment/classes/class.ilPaymentCoupons.php';
16 //include_once 'Services/Payment/classes/class.ilShopVatsList.php';
17 
18 include_once './Services/Payment/classes/class.ilBMFSettings.php';
19 #include_once dirname(__FILE__)."/../bmf/lib/ePayment/cfg_epayment.inc.php";
20 include_once dirname(__FILE__)."/../bmf/lib/SOAP/class.ilBMFClient.php";
21 
22 include_once './Services/Payment/classes/class.ilPayMethods.php';
23 include_once './Services/Payment/classes/class.ilPurchaseBaseGUI.php';
24 
25 
26 
28 {
29  var $ctrl;
30  var $tpl;
31 
32  var $user_obj;
33  var $coupon_obj = null;
34  var $error;
36 
38  var $pay_method = null;
39  private $totalVat = 0;
40  private $pm_id = 0;
41 
43  {
44  $this->pm_id = ilPayMethods::_getIdByTitle('bmf');
45  $this->pay_method = ilPayMethods::_getIdByTitle('bmf');
46  // Get user object
47  $this->user_obj = $user_obj;
48 
49  parent::__construct($this->user_obj, $this->pay_method);
50  }
51 
52  function cancel()
53  {
54  ilUtil::redirect("./payment.php");
55  }
56 
57  function showPersonalData()
58  {
59  // user_id $this->user_obj->getId()
60  // all
61 
62  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
63 
64  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
65  {
66 
67  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
68  $this->tpl->touchBlock("stop_floating");
69  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
70 
71  }
72  else
73  {
74  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step1'));
75  $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_personal_data'));
76  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_personal_data'));
77 
78  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.main_view.html','Services/Payment');
79 
80  $oForm = new ilPropertyFormGUI();
81  $oForm->setFormAction($this->ctrl->getFormAction($this, 'getPersonalData'));
82  $oForm->setTitle($this->lng->txt('pay_bmf_personal_data'));
83 
84  $oFirstname = new ilNonEditableValueGUI($this->lng->txt('firstname'));
85  $oFirstname->setValue($this->user_obj->getFirstname());
86  $oForm->addItem($oFirstname);
87 
88  $oLastname = new ilNonEditableValueGUI($this->lng->txt('lastname'));
89  $oLastname->setValue($this->user_obj->getLastname());
90  $oForm->addItem($oLastname);
91 
92  $oStreet = new ilTextInputGUI($this->lng->txt('street'),'street');
93  $oStreet->setValue($this->error != '' && isset($_POST['street'])
94  ? ilUtil::prepareFormOutput($_POST['street'],true)
95  : ilUtil::prepareFormOutput($_SESSION['bmf']['personal_data']['street'],true));
96  $oForm->addItem($oStreet);
97 
98  $oHouseNumber = new ilTextInputGUI($this->lng->txt('pay_bmf_house_number'), 'house_number');
99  $oHouseNumber->setValue($this->error != '' && isset($_POST['house_number'])
100  ? ilUtil::prepareFormOutput($_POST['house_number'],true)
101  : ilUtil::prepareFormOutput($_SESSION['bmf']['personal_data']['house_number'],true));
102  $oForm->addItem($oHouseNumber);
103 
104  $oPoBox = new ilTextInputGUI($this->lng->txt('pay_bmf_or').' '.$this->lng->txt('pay_bmf_po_box'), 'po_box');
105  $oPoBox->setValue($this->error != '' && isset($_POST['po_box'])
106  ? ilUtil::prepareFormOutput($_POST['po_box'],true)
107  : ilUtil::prepareFormOutput($_SESSION['bmf']['personal_data']['po_box'],true));
108  $oForm->addItem($oPoBox);
109 
110  $oZipCode = new ilTextInputGUI($this->lng->txt('zipcode'), 'zipcode');
111  $oZipCode->setValue($this->error != '' && isset($_POST['zipcode'])
112  ? ilUtil::prepareFormOutput($_POST['zipcode'],true)
113  : ilUtil::prepareFormOutput($_SESSION['bmf']['personal_data']['zipcode'],true));
114  $oForm->addItem($oZipCode);
115 
116  $oCity = new ilTextInputGUI($this->lng->txt('city'), 'city');
117  $oCity->setValue($this->error != '' && isset($_POST['city'])
118  ? ilUtil::prepareFormOutput($_POST['city'],true)
119  : ilUtil::prepareFormOutput($_SESSION['bmf']['personal_data']['city'],true));
120  $oForm->addItem($oCity);
121 
122 
123  $oCountry = new ilSelectInputGUI($this->lng->txt('country'), 'country');
124  $oCountry->setOptions($this->__getCountries());
125  $oCountry->setValue($this->error != '' && isset($_POST['country']) ? $_POST['country']
126  : $_SESSION['bmf']['personal_data']['country']);
127  $oForm->addItem($oCountry);
128 
129  $oEmail = new ilNonEditableValueGUI($this->lng->txt('email'));
130  $oEmail->setValue($this->user_obj->getEmail());
131  $oForm->addItem($oEmail);
132 
133  $oForm->addcommandButton('getPersonalData',ucfirst($this->lng->txt('next')));
134  $this->tpl->setVariable('FORM',$oForm->getHTML());
135 
136  }
137  }
138 
139  function getPersonalData()
140  {
141 
142  if ($_SESSION["bmf"]["personal_data"]["firstname"] == "" ||
143  $_SESSION["bmf"]["personal_data"]["lastname"] == "" ||
144  $_POST["zipcode"] == "" ||
145  $_POST["city"] == "" ||
146  $_POST["country"] == "" ||
147  $_SESSION["bmf"]["personal_data"]["email"] == "")
148  {
149  $this->error = $this->lng->txt('pay_bmf_personal_data_not_valid');
150  ilUtil::sendInfo($this->error);
151  $this->showPersonalData();
152  return;
153  }
154  if (($_POST["street"] == "" && $_POST["house_number"] == "" && $_POST["po_box"] == "") ||
155  (($_POST["street"] != "" || $_POST["house_number"] != "") && $_POST["po_box"] != "") ||
156  ($_POST["street"] != "" && $_POST["house_number"] == "") ||
157  ($_POST["street"] == "" && $_POST["house_number"] != ""))
158  {
159  $this->error = $this->lng->txt('pay_bmf_street_or_pobox');
160  ilUtil::sendInfo($this->error);
161  $this->showPersonalData();
162  return;
163  }
164 
165 
166  $_SESSION["bmf"]["personal_data"]["firstname"] = $this->user_obj->getFirstname();
167  $_SESSION["bmf"]["personal_data"]["lastname"] = $this->user_obj->getLastname();
168  $_SESSION["bmf"]["personal_data"]["street"] = $_POST["street"];
169  $_SESSION["bmf"]["personal_data"]["house_number"] = $_POST["house_number"];
170  $_SESSION["bmf"]["personal_data"]["po_box"] = $_POST["po_box"];
171  $_SESSION["bmf"]["personal_data"]["zipcode"] = $_POST["zipcode"];
172  $_SESSION["bmf"]["personal_data"]["city"] = $_POST["city"];
173  $_SESSION["bmf"]["personal_data"]["country"] = $_POST["country"];
174  $_SESSION["bmf"]["personal_data"]["email"] = $this->user_obj->getEmail();
175  $_SESSION["bmf"]["personal_data"]["language"] = $this->user_obj->getLanguage();
176 
177  if ($_SESSION["bmf"]["personal_data"]["country"] != "DE")
178  {
179  if ($_SESSION["bmf"]["payment_type"] == "debit_entry")
180  {
181  $_SESSION["bmf"]["payment_type"] = "";
182  }
183  }
184 
185  $this->error = "";
186  $this->showPaymentType();
187  }
188 
189  function showPaymentType()
190  {
191  // user_id $this->user_obj->getId()
192  // all
193 
194  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
195 
196  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
197  {
198 
199  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
200  $this->tpl->touchBlock("stop_floating");
201  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
202 
203  }
204  else
205  {
206 
207  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_payment_type.html','Services/Payment');
208 
209  $this->tpl->setVariable("PAYMENT_TYPE_FORMACTION",$this->ctrl->getFormAction($this));
210 
211  // set table header
212  $this->tpl->setVariable("TYPE_IMG", ilObject::_getIcon('', '', 'pays'));
213  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
214  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step2'));
215  $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_payment_type'));
216  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_payment_type'));
217  $this->tpl->touchBlock("stop_floating");
218  $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
219 
220  // set plain text variables
221  if ($_SESSION["bmf"]["personal_data"]["country"] == "DE")
222  {
223  $this->tpl->setVariable("TXT_DEBIT_ENTRY",$this->lng->txt('pay_bmf_debit_entry'));
224  }
225  $this->tpl->setVariable("TXT_CREDIT_CARD",$this->lng->txt('pay_bmf_credit_card'));
226 
227  $this->tpl->setVariable("INPUT_VALUE",ucfirst($this->lng->txt('next')));
228  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
229 
230  // fill defaults
231 
232  if ($this->error != "" &&
233  isset($_POST["payment_type"]))
234  {
235  $this->tpl->setVariable("PAYMENT_TYPE_" . strtoupper($_POST["payment_type"]), " checked") ;
236  }
237  else
238  {
239  if (($_SESSION["bmf"]["personal_data"]["country"] != "DE" && $_POST["payment_type"] != "debit_entry") ||
240  $_SESSION["bmf"]["personal_data"]["country"] == "DE")
241  {
242  $this->tpl->setVariable("PAYMENT_TYPE_" . strtoupper($_SESSION["bmf"]["payment_type"]), " checked") ;
243  }
244  }
245 
246  // Button
247  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
248  $this->tpl->setCurrentBlock("btn_cell");
249  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPersonalData"));
250  $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
251  $this->tpl->parseCurrentBlock("btn_cell");
252 
253  }
254  }
255 
256  function getPaymentType()
257  {
258  if (($_POST["payment_type"] != "credit_card" && $_POST["payment_type"] != "debit_entry") ||
259  ($_SESSION["bmf"]["personal_data"]["country"] != "DE" && $_POST["payment_type"] == "debit_entry"))
260  {
261  $this->error = $this->lng->txt('pay_bmf_payment_type_not_valid');
262  ilUtil::sendInfo($this->error);
263  $this->showPaymentType();
264  return;
265  }
266 
267  $_SESSION["bmf"]["payment_type"] = $_POST["payment_type"];
268 
269  $this->error = "";
270  if ($_SESSION["bmf"]["payment_type"] == "credit_card")
271  {
272  $this->showCreditCard();
273  }
274  else
275  {
276  $this->showDebitEntry();
277  }
278  }
279 
280  function showDebitEntry()
281  {
282  // user_id $this->user_obj->getId()
283  // all
284 
285 /* if ($_SESSION["bmf"]["debit_entry"]["kontoinhaber"] == "" &&
286  $this->error == "" &&
287  $_POST["account_holder"] == "")
288  {
289  $_SESSION["bmf"]["debit_entry"]["kontoinhaber"] = $_SESSION["bmf"]["personal_data"]["vorname"] . " " . $_SESSION["bmf"]["personal_data"]["nachname"];
290  }*/
291 
292  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
293 
294  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
295  {
296 
297  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
298  $this->tpl->touchBlock("stop_floating");
299  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
300 
301  }
302  else
303  {
304 
305  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_debit_entry.html','Services/Payment');
306 
307  $this->__showShoppingCart();
308 
309  $this->tpl->setVariable("DEBIT_ENTRY_FORMACTION",$this->ctrl->getFormAction($this));
310 
311  // set table header
312  $this->tpl->setVariable("TYPE_IMG",ilObject::_getIcon('', '', 'pays'));
313  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
314  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step3_debit_entry'));
315  $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_debit_entry_data'));
316  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_debit_entry'));
317  $this->tpl->touchBlock("stop_floating");
318  $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
319 
320  // set plain text variables
321  $this->tpl->setVariable("TXT_ACCOUNT_HOLDER",$this->lng->txt('pay_bmf_account_holder'));
322  $this->tpl->setVariable("TXT_OPTIONAL",$this->lng->txt('pay_bmf_optional'));
323  $this->tpl->setVariable("TXT_BANK_CODE",$this->lng->txt('pay_bmf_bank_code'));
324  $this->tpl->setVariable("TXT_ACCOUNT_NUMBER",$this->lng->txt('pay_bmf_account_number'));
325  $this->tpl->setVariable("TXT_TERMS_CONDITIONS",$this->lng->txt('pay_bmf_terms_conditions'));
326  $this->tpl->setVariable("TXT_TERMS_CONDITIONS_READ",$this->lng->txt('pay_bmf_terms_conditions_read'));
327  $this->tpl->setVariable("TXT_TERMS_CONDITIONS_SHOW",$this->lng->txt('pay_bmf_terms_conditions_show'));
328  $this->tpl->setVariable("LINK_TERMS_CONDITIONS","./payment.php?view=conditions");
329  $this->tpl->setVariable("TXT_PASSWORD",$this->lng->txt('password'));
330  $this->tpl->setVariable("TXT_CONFIRM_ORDER",$this->lng->txt('pay_confirm_order'));
331 
332  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_send_order'));
333  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
334 
335  // fill defaults
336 
337  $this->tpl->setVariable("ACCOUNT_HOLDER",
338  $this->error != "" && isset($_POST['account_holder'])
339  ? ilUtil::prepareFormOutput($_POST['account_holder'],true)
340  : ilUtil::prepareFormOutput($_SESSION['bmf']["debit_entry"]['kontoinhaber'],true));
341  $this->tpl->setVariable("BANK_CODE",
342  $this->error != "" && isset($_POST['bank_code'])
343  ? ilUtil::prepareFormOutput($_POST['bank_code'],true)
344  : ilUtil::prepareFormOutput($_SESSION['bmf']["debit_entry"]['BLZ'],true));
345  $this->tpl->setVariable("ACCOUNT_NUMBER",
346  $this->error != "" && isset($_POST['account_number'])
347  ? ilUtil::prepareFormOutput($_POST['account_number'],true)
348  : ilUtil::prepareFormOutput($_SESSION['bmf']["debit_entry"]['kontoNr'],true));
349 /* if ($this->error != "" &&
350  isset($_POST["terms_conditions"]))
351  {
352  $this->tpl->setVariable("TERMS_CONDITIONS_" . strtoupper($_POST["terms_conditions"]), " checked") ;
353  }*/
354 /* if ($this->error != "" &&
355  isset($_POST["password"]))
356  {
357  $this->tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST['password'],true));
358  }*/
359 
360  // Button
361  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
362  $this->tpl->setCurrentBlock("btn_cell");
363  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPaymentType"));
364  $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
365  $this->tpl->parseCurrentBlock("btn_cell");
366 
367  }
368  }
369 
370  function getDebitEntry()
371  {
372  if ($_POST["account_holder"] == "" ||
373  $_POST["bank_code"] == "" ||
374  $_POST["account_number"] == "")
375  {
376  $this->error = $this->lng->txt('pay_bmf_debit_entry_not_valid');
377  ilUtil::sendInfo($this->error);
378  $this->showDebitEntry();
379  return;
380  }
381  if ($_POST["terms_conditions"] != 1)
382  {
383  $this->error = $this->lng->txt('pay_bmf_check_terms_conditions');
384  ilUtil::sendInfo($this->error);
385  $this->showDebitEntry();
386  return;
387  }
388  require_once 'Services/User/classes/class.ilUserPasswordManager.php';
389  $verified_passwd = ilUserPasswordManager::getInstance()->verifyPassword($this->user_obj, ilUtil::stripSlashes($_POST["password"]));
390  if ($_POST["password"] == "" || $verified_passwd == false)
391  {
392  $this->error = $this->lng->txt('pay_bmf_password_not_valid');
393  ilUtil::sendInfo($this->error);
394  $this->showDebitEntry();
395  return;
396  }
397 
398  $_SESSION["bmf"]["debit_entry"]["BLZ"] = $_POST["bank_code"];
399  $_SESSION["bmf"]["debit_entry"]["kontoinhaber"] = $_POST["account_holder"];
400  $_SESSION["bmf"]["debit_entry"]["kontoNr"] = $_POST["account_number"];
401 
402  $this->error = "";
403  $this->sendDebitEntry();
404  }
405 
406  function sendDebitEntry()
407  {
408  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
409 
410  $this->psc_obj->clearCouponItemsSession();
411 
412  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
413  {
414 
415  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
416  $this->tpl->touchBlock("stop_floating");
417  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
418 
419  }
420  else
421  {
422  $customer = new KundenstammdatenPflegeWS();
423 
424  $newCustomer = new Kunde($this->user_obj->getId());
425 
426  $resultCustomerObj = $customer->anlegenKunde($newCustomer);
427 
428  $resultCustomer = $resultCustomerObj->ergebnis;
429 
430  if (is_object($resultCustomer))
431  {
432  if ($resultCustomer->code < 0)
433  {
434  $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $resultCustomer->code . ": " . $resultCustomer->kurzText . "<br>\n" . $resultCustomer->langText;
435  if ($resultCustomer->code == -103 ||
436  $resultCustomer->code == -104 ||
437  $resultCustomer->code == -107 ||
438  ($resultCustomer->code <= -202 && $resultCustomer->code >= -208) ||
439  $resultCustomer->code == -213)
440  {
442  $this->showPersonalData();
443  }
444  else
445  {
446  $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
448  $this->showPersonalData();
449  }
450  }
451  else
452  {
453  $payment = new LastschriftWS();
454 
455  $debitEntry = new Lastschrift();
456 
457  $address = new LieferAdresse();
458 
459  $bank = new Bankverbindung();
460 
461  $sc_obj = new ilPaymentShoppingCart($this->user_obj);
462 
463  $tmp_bookEntries = $sc_obj->getShoppingCart();
464 
465  if (!is_array($tmp_bookEntries))
466  {
467  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
468  }
469  else
470  {
471  $totalAmount = 0;
472  for ($i = 0; $i < count($tmp_bookEntries); $i++)
473  {
474  $booking = true;
475 
476  if (!empty($_SESSION["coupons"]["bmf"]))
477  {
478  $price = $tmp_bookEntries[$i]["price"];
479  $tmp_bookEntries[$i]["math_price"] = $price;
480 
481  foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
482  {
483  $this->coupon_obj->setId($coupon["pc_pk"]);
484  $this->coupon_obj->setCurrentCoupon($coupon);
485 
486  $tmp_pobject = new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']);
487 
488  if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
489  {
490  $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += $price;
491  $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i];
492  $booking = false;
493  }
494 
495  unset($tmp_pobject);
496  }
497  }
498 
499  if ($booking)
500  {
501  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ".", "");
502  $bookEntries[] = new Buchung($tmp_bookEntries[$i]);
503  $totalAmount += $tmp_bookEntries[$i]["price"];
504  }
505  else
506  {
507  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ",", ".");
508  }
509  }
510 
511  $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
512 
513  if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
514  {
515  foreach ($coupon_discount_items as $item)
516  {
517  $item["price"]= number_format( (float) $item["discount_price"], 2, ".", "");
518  $bookEntries[] = new Buchung($item);
519  $totalAmount += $item["price"];
520  }
521  }
522 
523  $totalAmount = number_format( (float) $totalAmount , 2, ".", "");
524  $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries);
525  $bookingList = new BuchungsListe($this->user_obj->getId(), $values);
526  }
527 
528 
529 
530  $resultObj = $payment->abbuchenOhneEinzugsermaechtigung($resultCustomerObj->kunde->EShopKundenNr, $address, $bank, $bookingList);
531  $result = $resultObj->ergebnis;
532 
533  if (is_object($result))
534  {
535  if ($result->code < 0)
536  {
537  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
538  $this->tpl->touchBlock("stop_floating");
539  $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText;
540  if ($result->code == -103 ||
541  $result->code == -104 ||
542  $result->code == -107 ||
543  ($result->code <= -202 && $result->code >= -208) ||
544  $result->code == -213)
545  {
547  $this->showPersonalData();
548  }
549  else if ($result->code == -507 ||
550  $result->code == -510 ||
551  $result->code == -511)
552  {
554  $this->showPaymentType();
555  }
556  else if ($result->code == -402 ||
557  $result->code == -402 ||
558  $result->code == -403 ||
559  $result->code == -406 ||
560  $result->code == -410 ||
561  $result->code == -413 ||
562  $result->code == -701 ||
563  $result->code == -702 ||
564  $result->code == -703)
565  {
567  $this->showDebitEntry();
568  }
569  else
570  {
571  $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
573  $this->showPersonalData();
574  }
575 
576  }
577  else
578  {
579  $resultCustomerObj->kunde->vorname = utf8_decode($resultCustomerObj->kunde->vorname);
580  $resultCustomerObj->kunde->nachname = utf8_decode($resultCustomerObj->kunde->nachname);
581  $resultCustomerObj->kunde->rechnungsAdresse->strasse = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse);
582  $resultCustomerObj->kunde->rechnungsAdresse->hausNr = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
583  $resultCustomerObj->kunde->rechnungsAdresse->postfach = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
584  $resultCustomerObj->kunde->rechnungsAdresse->PLZ = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
585  $resultCustomerObj->kunde->rechnungsAdresse->ort = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
586  $resultCustomerObj->kunde->rechnungsAdresse->land = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
587 
588  // everything ok => send confirmation, fill statistik, delete session, delete shopping cart.
589  $external_data = array();
590  $external_data['voucher'] = $resultObj->buchungsListe->buchungen[$b++]->belegNr;
591  $external_data['transaction_extern'] = $resultObj->buchungsListe->kassenzeichen;
592  $external_data['street'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse).' '.utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
593  $external_data['po_box'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
594  $external_data['zipcode'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
595  $external_data['city'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
596  $external_data['country'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
597 
598  parent::__addbookings($external_data);
599 
600  $this->__emptyShoppingCart();
601  $this->__clearSession();
602 
603  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
604  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_thanks'));
605  $this->tpl->touchBlock("stop_floating");
606 
607  ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'));
608 
609  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_bmf_debit_entry.html','Services/Payment');
610 
611  if ($this->ilias->getSetting("https") != 1)
612  {
613  $this->tpl->setCurrentBlock("buyed_objects");
614  $link = $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui');
615  $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link);
616  $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects'));
617  $this->tpl->parseCurrentBlock("buyed_objects");
618  }
619  $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window'));
620  }
621  }
622  else
623  {
624  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
625  $this->tpl->touchBlock("stop_floating");
626  ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
627  }
628  }
629  }
630  else
631  {
632  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
633  $this->tpl->touchBlock("stop_floating");
634  ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
635  }
636  }
637  }
638 
639  function showCreditCard()
640  {
641  // user_id $this->user_obj->getId()
642  // all
643 
644 /* if ($_SESSION["bmf"]["credit_card"]["karteninhaber"] == "" &&
645  $this->error == "" &&
646  $_POST["card_holder"] == "")
647  {
648  $_SESSION["bmf"]["credit_card"]["karteninhaber"] = $_SESSION["bmf"]["personal_data"]["vorname"] . " " . $_SESSION["bmf"]["personal_data"]["nachname"];
649  }*/
650 
651  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
652 
653  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
654  {
655 
656  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
657  $this->tpl->touchBlock("stop_floating");
658  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
659 
660  }
661  else
662  {
663 
664  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_credit_card.html','Services/Payment');
665  $this->__showShoppingCart();
666 
667  $this->tpl->setVariable("CREDIT_CARD_FORMACTION",$this->ctrl->getFormAction($this));
668 
669  // set table header
670  $this->tpl->setVariable("TYPE_IMG",ilObject::_getIcon('', '', 'pays'));
671  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
672  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step3_credit_card'));
673  $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_credit_card_data'));
674  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_credit_card'));
675  $this->tpl->touchBlock("stop_floating");
676  $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
677 
678  // set plain text variables
679  $this->tpl->setVariable("TXT_CARD_HOLDER",$this->lng->txt('pay_bmf_card_holder'));
680  $this->tpl->setVariable("TXT_CHECK_NUMBER",$this->lng->txt('pay_bmf_check_number'));
681  $this->tpl->setVariable("TXT_OPTIONAL",$this->lng->txt('pay_bmf_optional'));
682  $this->tpl->setVariable("TXT_CARD_NUMBER",$this->lng->txt('pay_bmf_card_number'));
683  $this->tpl->setVariable("TXT_VALIDITY",$this->lng->txt('pay_bmf_validity'));
684  $this->tpl->setVariable("TXT_TERMS_CONDITIONS",$this->lng->txt('pay_bmf_terms_conditions'));
685  $this->tpl->setVariable("TXT_TERMS_CONDITIONS_READ",$this->lng->txt('pay_bmf_terms_conditions_read'));
686  $this->tpl->setVariable("TXT_TERMS_CONDITIONS_SHOW",$this->lng->txt('pay_bmf_terms_conditions_show'));
687  $this->tpl->setVariable("LINK_TERMS_CONDITIONS","./payment.php?view=conditions");
688  $this->tpl->setVariable("TXT_PASSWORD",$this->lng->txt('password'));
689  $this->tpl->setVariable("TXT_CONFIRM_ORDER",$this->lng->txt('pay_confirm_order'));
690 
691  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_send_order'));
692  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
693 
694  // fill defaults
695 
696  $this->tpl->setVariable("CARD_HOLDER",
697  $this->error != "" && isset($_POST['card_holder'])
698  ? ilUtil::prepareFormOutput($_POST['card_holder'],true)
699  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['karteninhaber'],true));
700  $this->tpl->setVariable("CARD_NUMBER_BLOCK_1",
701  $this->error != "" && isset($_POST['card_number']['block_1'])
702  ? ilUtil::prepareFormOutput($_POST['card_number']['block_1'],true)
703  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_1'],true));
704  $this->tpl->setVariable("CARD_NUMBER_BLOCK_2",
705  $this->error != "" && isset($_POST['card_number']['block_2'])
706  ? ilUtil::prepareFormOutput($_POST['card_number']['block_2'],true)
707  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_2'],true));
708  $this->tpl->setVariable("CARD_NUMBER_BLOCK_3",
709  $this->error != "" && isset($_POST['card_number']['block_3'])
710  ? ilUtil::prepareFormOutput($_POST['card_number']['block_3'],true)
711  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_3'],true));
712  $this->tpl->setVariable("CARD_NUMBER_BLOCK_4",
713  $this->error != "" && isset($_POST['card_number']['block_4'])
714  ? ilUtil::prepareFormOutput($_POST['card_number']['block_4'],true)
715  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_4'],true));
716  $this->tpl->setVariable("CHECK_NUMBER",
717  $this->error != "" && isset($_POST['check_number'])
718  ? ilUtil::prepareFormOutput($_POST['check_number'],true)
719  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kartenpruefnummer'],true));
720  for ($i = 1; $i <= 12; $i++)
721  {
722  $this->tpl->setCurrentBlock("loop_validity_months");
723  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS", $i < 10 ? "0" . $i : $i);
724  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_TXT", $i < 10 ? "0" . $i : $i);
725  if ($this->error != "" &&
726  isset($_POST['validity']['month']))
727  {
728  if ($_POST['validity']['month'] == $i)
729  {
730  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_SELECTED", " selected");
731  }
732  }
733  else
734  {
735  if ($_SESSION["bmf"]["credit_card"]["gueltigkeit"]["monat"] == $i)
736  {
737  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_SELECTED", " selected");
738  }
739  }
740  $this->tpl->parseCurrentBlock("loop_validity_months");
741  }
742  for ($i = date("Y"); $i <= (date("Y")+6); $i++)
743  {
744  $this->tpl->setCurrentBlock("loop_validity_years");
745  $this->tpl->setVariable("LOOP_VALIDITY_YEARS", $i);
746  $this->tpl->setVariable("LOOP_VALIDITY_YEARS_TXT", $i);
747  if ($this->error != "" &&
748  isset($_POST['validity']['year']))
749  {
750  if ($_POST['validity']['year'] == $i)
751  {
752  $this->tpl->setVariable("LOOP_VALIDITY_YEARS_SELECTED", " selected");
753  }
754  }
755  else
756  {
757  if ($_SESSION["bmf"]["credit_card"]["gueltigkeit"]["jahr"] == $i)
758  {
759  $this->tpl->setVariable("LOOP_VALIDITY_YEARS_SELECTED", " selected");
760  }
761  }
762  $this->tpl->parseCurrentBlock("loop_validity_years");
763  }
764 /* if ($this->error != "" &&
765  isset($_POST["terms_conditions"]))
766  {
767  $this->tpl->setVariable("TERMS_CONDITIONS_" . $_POST["terms_conditions"], " checked") ;
768  }*/
769 /* if ($this->error != "" &&
770  isset($_POST["password"]))
771  {
772  $this->tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST['password'],true));
773  }*/
774 
775  // Button
776  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
777  $this->tpl->setCurrentBlock("btn_cell");
778  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPaymentType"));
779  $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
780  $this->tpl->parseCurrentBlock("btn_cell");
781 
782  }
783  }
784 
785  function getCreditCard()
786  {
787  if ($_POST["card_holder"] == "" ||
788  $_POST["card_number"]["block_1"] == "" ||
789  $_POST["card_number"]["block_2"] == "" ||
790  $_POST["card_number"]["block_3"] == "" ||
791  $_POST["card_number"]["block_4"] == "" ||
792  $_POST["validity"]["month"] == "" ||
793  $_POST["validity"]["year"] == "" ||
794  $_POST["validity"]["year"]."-".$_POST["validity"]["month"] < date("Y-m"))
795  {
796  $this->error = $this->lng->txt('pay_bmf_credit_card_not_valid');
797  ilUtil::sendInfo($this->error);
798  $this->showCreditCard();
799  return;
800  }
801  if ($_POST["terms_conditions"] != 1)
802  {
803  $this->error = $this->lng->txt('pay_bmf_check_terms_conditions');
804  ilUtil::sendInfo($this->error);
805  $this->showCreditCard();
806  return;
807  }
808 
809  require_once 'Services/User/classes/class.ilUserPasswordManager.php';
810  $verified_passwd = ilUserPasswordManager::getInstance()->verifyPassword($this->user_obj, ilUtil::stripSlashes($_POST["password"]));
811  if ($_POST["password"] == "" || $verified_passwd == false)
812  {
813  $this->error = $this->lng->txt('pay_bmf_password_not_valid');
814  ilUtil::sendInfo($this->error);
815  $this->showCreditCard();
816  return;
817  }
818 
819  $_SESSION["bmf"]["credit_card"]["gueltigkeit"]["monat"] = $_POST["validity"]["month"];
820  $_SESSION["bmf"]["credit_card"]["gueltigkeit"]["jahr"] = $_POST["validity"]["year"];
821  $_SESSION["bmf"]["credit_card"]["karteninhaber"] = $_POST["card_holder"];
822  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_1"] = $_POST["card_number"]["block_1"];
823  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_2"] = $_POST["card_number"]["block_2"];
824  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_3"] = $_POST["card_number"]["block_3"];
825  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_4"] = $_POST["card_number"]["block_4"];
826  $_SESSION["bmf"]["credit_card"]["kartenpruefnummer"] = $_POST["check_number"];
827  # zum testen
828  $this->error = "";
829  $this->sendCreditCard();
830  }
831 
832  function sendCreditCard()
833  {
834  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
835 
836  $this->psc_obj->clearCouponItemsSession();
837 
838  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
839  {
840 
841  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
842  $this->tpl->touchBlock("stop_floating");
843  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
844 
845  }
846  else
847  {
848  $payment = new KreditkartenzahlungWS();
849 
850  $customer = new Kunde($this->user_obj->getId());
851 
852  $creditCard = new Kreditkarte();
853 
854  $sc_obj = new ilPaymentShoppingCart($this->user_obj);
855 
856  $tmp_bookEntries = $sc_obj->getShoppingCart();
857  if (!is_array($tmp_bookEntries))
858  {
859  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
860  }
861  else
862  {
863  $totalAmount = 0;
864  for ($i = 0; $i < count($tmp_bookEntries); $i++)
865  {
866  $booking = true;
867 
868  if (!empty($_SESSION["coupons"]["bmf"]))
869  {
870  $price = $tmp_bookEntries[$i]["price"];
871  $tmp_bookEntries[$i]["math_price"] = $price;
872 
873  foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
874  {
875  $this->coupon_obj->setId($coupon["pc_pk"]);
876  $this->coupon_obj->setCurrentCoupon($coupon);
877 
878  $tmp_pobject = new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']);
879 
880  if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
881  {
882  $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += $price;
883  $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i];
884 
885  $booking = false;
886  }
887 
888  unset($tmp_pobject);
889  }
890  }
891 
892  if ($booking)
893  {
894  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ",", ".");
895 
896  $bookEntries[] = new Buchung($tmp_bookEntries[$i]);
897  $totalAmount += $tmp_bookEntries[$i]["price"];
898  }
899  else
900  {
901  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ",", ".");
902  }
903  }
904 
905  $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
906 
907  if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
908  {
909  foreach ($coupon_discount_items as $item)
910  {
911  $item["price"] = number_format((float)$item["discount_price"] , 2, ".", "");
912  $bookEntries[] = new Buchung($item);
913  $totalAmount += $item["discount_price"];
914  }
915  }
916 
917  $totalAmount = number_format((float)$totalAmount , 2, ".", "");
918  $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries);
919  $bookingList = new BuchungsListe($this->user_obj->getId(), $values);
920  }
921 
922  $resultObj = $payment->zahlenUndAnlegenKunde($customer, $creditCard, $bookingList);
923  $result = $resultObj->ergebnis;
924 
925  if (is_object($result))
926  {
927  if ($result->code < 0)
928  {
929  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
930  $this->tpl->touchBlock("stop_floating");
931  $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText;
932  if ($result->code == -103 ||
933  $result->code == -104 ||
934  $result->code == -107 ||
935  ($result->code <= -202 && $result->code >= -208) ||
936  $result->code == -213)
937  {
939  $this->showPersonalData();
940  }
941  else if ($result->code == -507 ||
942  $result->code == -510 ||
943  $result->code == -511)
944  {
946  $this->showPaymentType();
947  }
948  else if ($result->code == -701 ||
949  $result->code == -1701 ||
950  $result->code == -1706 ||
951  $result->code == -1707 ||
952  $result->code == -1710 ||
953  $result->code == -1711)
954  {
956  $this->showCreditCard();
957  }
958  else
959  {
960  $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
962  $this->showPersonalData();
963  }
964  }
965  else
966  {
967  // everything ok => send confirmation, fill statistik, delete session, delete shopping cart.
968  $external_data = array();
969  $external_data['voucher'] = $resultObj->buchungsListe->buchungen[$b++]->belegNr;
970  $external_data['transaction_extern'] = $resultObj->buchungsListe->kassenzeichen;
971  $external_data['street'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse).' '.utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
972  $external_data['po_box'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
973  $external_data['zipcode'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
974  $external_data['city'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
975  $external_data['country'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
976 
977  parent::__addbookings($external_data);
978 
979  $this->__emptyShoppingCart();
980  $this->__clearSession();
981 
982  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
983  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_thanks'));
984  $this->tpl->touchBlock("stop_floating");
985 
986  ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'));
987 
988  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_bmf_credit_card.html','Services/Payment');
989 
990  if ($this->ilias->getSetting("https") != 1)
991  {
992  $this->tpl->setCurrentBlock("buyed_objects");
993  $link = $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui');
994  $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link);
995  $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects'));
996  $this->tpl->parseCurrentBlock("buyed_objects");
997  }
998  $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window'));
999  }
1000  }
1001  else
1002  {
1003  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
1004  $this->tpl->touchBlock("stop_floating");
1005  ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
1006  }
1007  #zum testen
1008  }
1009 
1010  }
1011 
1015  function &executeCommand()
1016  {
1017  global $tree;
1018 
1019  $cmd = $this->ctrl->getCmd();
1020 
1021  switch ($this->ctrl->getNextClass($this))
1022  {
1023 
1024  default:
1025  if(!$cmd = $this->ctrl->getCmd())
1026  {
1027  $cmd = 'showPersonalData';
1028  }
1029  $this->$cmd();
1030  break;
1031  }
1032  }
1033 }
1034 
1035 
1037 {
1038 
1039  var $_soapClient = NULL;
1040 
1042  {
1043  $bmfSetObj = ilBMFSettings::getInstance();
1044  $bmfConfig = $bmfSetObj->getAll();
1045 
1046  $this->_soapClient = new ilBMFClient($bmfConfig["ePaymentServer"], false, false, array('curl' => array(CURLOPT_SSLCERT => $bmfConfig["clientCertificate"], CURLE_SSL_PEER_CERTIFICATE => $bmfConfig["caCertificate"], CURLOPT_TIMEOUT => (int)$bmfConfig["timeOut"])));
1047  }
1048 
1049  function anlegenKunde ($customer)
1050  {
1051  $bmfSetObj = ilBMFSettings::getInstance();
1052  $bmfConfig = $bmfSetObj->getAll();
1053 
1054  $tmp = array(
1055  'mandantNr' => $bmfConfig["mandantNr"],
1056  'kunde' => $customer
1057  );
1058 
1059  $result = $this->_soapClient->call("anlegenKunde", $tmp, "KundenstammdatenPflegeWS");
1060  return $result;
1061  }
1062 
1063 };
1064 
1066 {
1067  var $_soapClient = NULL;
1068 
1070  {
1071  $bmfSetObj = ilBMFSettings::getInstance();
1072  $bmfConfig = $bmfSetObj->getAll();
1073 
1074  $this->_soapClient = new ilBMFClient($bmfConfig["ePaymentServer"], false, false, array('curl' => array(CURLOPT_SSLCERT => $bmfConfig["clientCertificate"], CURLE_SSL_PEER_CERTIFICATE => $bmfConfig["caCertificate"], CURLOPT_TIMEOUT => (int)$bmfConfig["timeOut"])));
1075  }
1076 
1077  function validierenKreditkarte($creditCard)
1078  {
1079  $bmfSetObj = ilBMFSettings::getInstance();
1080  $bmfConfig = $bmfSetObj->getAll();
1081 
1082  $tmp = array(
1083  'mandantNr' => $bmfConfig["mandantNr"],
1084  'kreditkarte' => $creditCard,
1085  'waehrungskennzeichen' => $bmfConfig["waehrungskennzeichen"]
1086  );
1087 
1088  $result = $this->_soapClient->call("validierenKreditkarte", $tmp, "KreditkartenzahlungWS");
1089  return $result;
1090  }
1091 
1092  function zahlenUndAnlegenKunde($customer, $creditCard, $bookingList)
1093  {
1094  $bmfSetObj = ilBMFSettings::getInstance();
1095  $bmfConfig = $bmfSetObj->getAll();
1096 
1097  $lieferadresse = new LieferAdresse();
1098 
1099  $tmp = array(
1100  'mandantNr' => $bmfConfig["mandantNr"],
1101  'Kunde' => $customer,
1102  'Kreditkarte' => $creditCard,
1103  'buchungsListe' => $bookingList,
1104  'lieferadresse' => $lieferadresse
1105  );
1106 
1107  $result = $this->_soapClient->call("zahlenUndAnlegenKunde", $tmp, "KreditkartenzahlungWS");
1108  return $result;
1109  }
1110 }
1111 
1113 {
1114 
1115  var $_soapClient = NULL;
1116 
1117  function LastschriftWS ()
1118  {
1119  $bmfSetObj = ilBMFSettings::getInstance();
1120  $bmfConfig = $bmfSetObj->getAll();
1121 
1122  $this->_soapClient = new ilBMFClient($bmfConfig["ePaymentServer"], false, false, array('curl' => array(CURLOPT_SSLCERT => $bmfConfig["clientCertificate"], CURLE_SSL_PEER_CERTIFICATE => $bmfConfig["caCertificate"], CURLOPT_TIMEOUT => (int)$bmfConfig["timeOut"])));
1123  }
1124 
1125  function abbuchenOhneEinzugsermaechtigung($eShopCustomerNumber, $address, $bank, $bookingList)
1126  {
1127  $bmfSetObj = ilBMFSettings::getInstance();
1128  $bmfConfig = $bmfSetObj->getAll();
1129 
1130  $tmp = array(
1131  'mandantNr' => $bmfConfig["mandantNr"],
1132  'eShopKundenNr' => $eShopCustomerNumber,
1133  'lieferAdresse' => $address,
1134  'bankverbindung' => $bank,
1135  'buchungsListe' => $bookingList
1136  );
1137 
1138  $result = $this->_soapClient->call("abbuchenOhneEinzugsermaechtigung", $tmp, "LastschriftWS");
1139  return $result;
1140  }
1141 
1142 };
1143 
1144 class Kunde
1145 {
1146  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Kunde');
1147 
1148  function Kunde ($customerNumber = "", $values = "")
1149  {
1150 /* if ($customerNumber != "")
1151  {
1152  $this->EShopKundenNr = $customerNumber;
1153  }
1154  else
1155  {*/
1156  $this->EShopKundenNr = time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1157  if ($customerNumber != "")
1158  {
1159  $this->EShopKundenNr = $customerNumber . "_" . time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1160  }
1161 /* }*/
1162 
1163  if ($values == "")
1164  {
1165  $values = $_SESSION["bmf"]["personal_data"];
1166  }
1167 
1168  if ($values["language"] != NULL)
1169  {
1170  $this->sprache = $values["language"];
1171  }
1172  if ($values["firstname"] != NULL)
1173  {
1174  $this->vorname = utf8_decode($values["firstname"]);
1175  }
1176  if ($values["lastname"] != NULL)
1177  {
1178  $this->nachname = utf8_decode($values["lastname"]);
1179  }
1180  if ($values["email"] != NULL)
1181  {
1182  $this->EMailAdresse = utf8_decode($values["email"]);
1183  }
1184 
1185  $address = new Adresse();
1186 
1187  $this->rechnungsAdresse = $address;
1188  }
1189 
1191  {
1192  return $this->EShopKundenNr;
1193  }
1194 
1195 }
1196 
1197 class Adresse
1198 {
1199  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Adresse');
1200 
1201  function Adresse ($values = "")
1202  {
1203  if ($values == "")
1204  {
1205  $values = $_SESSION["bmf"]["personal_data"];
1206  }
1207 
1208  if (is_array($values))
1209  {
1210  if ($values["street"] != NULL)
1211  {
1212  $this->strasse = utf8_decode($values["street"]);
1213  }
1214  if ($values["house_number"] != NULL)
1215  {
1216  $this->hausNr = utf8_decode($values["house_number"]);
1217  }
1218  if ($values["po_box"] != NULL)
1219  {
1220  $this->postfach = utf8_decode($values["po_box"]);
1221  }
1222  if ($values["country"] != NULL)
1223  {
1224  $this->land = utf8_decode($values["country"]);
1225  }
1226  if ($values["zipcode"] != NULL)
1227  {
1228  $this->PLZ = utf8_decode($values["zipcode"]);
1229  }
1230  if ($values["city"] != NULL)
1231  {
1232  $this->ort = utf8_decode($values["city"]);
1233  }
1234  }
1235  }
1236 
1237 }
1238 
1240 {
1241  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Kreditkarte');
1242 
1243  function Kreditkarte ($values = "")
1244  {
1245  if ($values == "")
1246  {
1247  $values = $_SESSION["bmf"]["credit_card"];
1248  }
1249 
1250  if (is_array($values))
1251  {
1252  if ($values["karteninhaber"] != NULL)
1253  {
1254  $this->karteninhaber = utf8_decode($values["karteninhaber"]);
1255  }
1256  if ($values["kartenpruefnummer"] != NULL)
1257  {
1258  $this->kartenpruefnummer = utf8_decode($values["kartenpruefnummer"]);
1259  }
1260  if (is_array ($values["kreditkartenNr"]) &&
1261  count($values["kreditkartenNr"]) == 4)
1262  {
1263  for ($i = 1; $i <= count($values["kreditkartenNr"]); $i++)
1264  {
1265  $this->kreditkartenNr .= utf8_decode($values["kreditkartenNr"]["block_".$i]);# . "-";
1266  }
1267 # $this->kreditkartenNr = substr($this->kreditkartenNr, 0, strlen($this->kreditkartenNr)-1);
1268  }
1269  if (is_array($values["gueltigkeit"]) &&
1270  $values["gueltigkeit"]["monat"] != "" &&
1271  $values["gueltigkeit"]["jahr"] != "")
1272  {
1273  $this->gueltigkeit = utf8_decode($values["gueltigkeit"]["monat"]);
1274  $this->gueltigkeit .= utf8_decode($values["gueltigkeit"]["jahr"]);
1275  }
1276  }
1277  }
1278 
1279 }
1280 
1282 {
1283  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Lastschrift');
1284 
1285  function Lastschrift ($customerNumber = "", $values = "")
1286  {
1287  $this->EShopKundenNr = time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1288  if ($customerNumber != "")
1289  {
1290  $this->EShopKundenNr = $customerNumber . "_" . time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1291  }
1292  }
1293 
1294 }
1295 
1297 {
1298  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Bankverbindung');
1299 
1300  function Bankverbindung ($values = "")
1301  {
1302  if ($values == "")
1303  {
1304  $values = $_SESSION["bmf"]["debit_entry"];
1305  }
1306 
1307  if (is_array($values))
1308  {
1309  if ($values["kontoinhaber"] != NULL)
1310  {
1311  $this->kontoinhaber = utf8_decode($values["kontoinhaber"]);
1312  }
1313  if ($values["kontoNr"] != NULL)
1314  {
1315  $this->kontoNr = utf8_decode($values["kontoNr"]);
1316  }
1317  if ($values["BLZ"] != NULL)
1318  {
1319  $this->BLZ = utf8_decode($values["BLZ"]);
1320  }
1321  }
1322  }
1323 
1324 }
1325 
1326 class Buchung
1327 {
1328  var $OBJTypeNS = array ('namespace' => 'http://schemas.xmlsoap.org/soap/encoding/', 'nsPrefix' => 'ns3', 'type' => 'Buchung', 'pnamespace' => 'http://www.bff.bund.de/ePayment', 'pnsPrefix' => 'ns2', 'item' => 'ns2:Buchung');
1329 
1330  function Buchung($values = "")
1331  {
1332  $bmfSetObj = ilBMFSettings::getInstance();
1333  $bmfConfig = $bmfSetObj->getAll();
1334 
1335  if ($bmfConfig["haushaltsstelle"] != NULL)
1336  {
1337  $this->haushaltsstelle = $bmfConfig["haushaltsstelle"];
1338  }
1339  if ($bmfConfig["objektNr"] != NULL)
1340  {
1341  $this->objektnummer = $bmfConfig["objektNr"];
1342  }
1343 
1344  if (is_array($values))
1345  {
1346  if ($values["object_title"] != NULL)
1347  {
1348  $buchungstext = utf8_decode($values["object_title"]);
1349  if(strlen($buchungstext) > 16)
1350  {
1351  $buchungstext = substr($buchungstext,0,15).'...';
1352  }
1353 
1354  $this->buchungstext = $buchungstext;
1355  }
1356  if ($values["price"] != "")
1357  {
1358  $this->betrag = (float)$values["price"];
1359  }
1360  }
1361  }
1362 
1363  /* Die BelegNr wird vom BMF zur�ck geliefert */
1364  function setVoucherNumber($voucherNumber)
1365  {
1366  if ($voucherNumber != NULL)
1367  {
1368  $this->belegNr = $voucherNumber;
1369  }
1370  }
1371 
1372  function getVoucherNumber()
1373  {
1374  return $this->belegNr;
1375  }
1376 }
1377 
1379 {
1380  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment', 'nsPrefix' => 'ns2', 'type' => 'BuchungsListe');
1381 
1382  function BuchungsListe($userId, $values = "")
1383  {
1384  global $ilias;
1385 
1386  $bmfSetObj = ilBMFSettings::getInstance();
1387  $bmfConfig = $bmfSetObj->getAll();
1388 
1389  if ($bmfConfig["bewirtschafterNr"] != NULL)
1390  {
1391  $this->bewirtschafterNr = $bmfConfig["bewirtschafterNr"];
1392  }
1393  if ($bmfConfig["waehrungskennzeichen"] != NULL)
1394  {
1395  $this->waehrungskennzeichen = $bmfConfig["waehrungskennzeichen"];
1396  }
1397  $this->faelligkeitsdatum = date("Y-m-d") . "T" . date("H:i:s") . "Z";
1398  if ($bmfConfig["kennzeichenMahnverfahren"] != NULL)
1399  {
1400  $this->kennzeichenMahnverfahren = $bmfConfig["kennzeichenMahnverfahren"];
1401  }
1402 
1403  $inst_id_time = $ilias->getSetting('inst_id').'_'.$userId.'_'.substr((string) time(),-3);
1404  $this->EShopTransaktionsNr = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
1405 
1406  if (is_array($values))
1407  {
1408  if ($values["betrag"] != NULL)
1409  {
1410  $this->betrag = (float)$values["betrag"];
1411  }
1412  if ($values["buchungen"] != NULL)
1413  {
1414  $this->buchungen = $values["buchungen"];
1415  }
1416  }
1417  }
1418  function getTransaction()
1419  {
1420  return $this->EShopTransaktionsNr;
1421  }
1422 
1423  /* Das Kassenzeichen wird vom BMF zur�ck geliefert */
1424  function setKassenzeichen($kassenzeichen)
1425  {
1426  if ($kassenzeichen != NULL)
1427  {
1428  $this->kassenzeichen = $kassenzeichen;
1429  }
1430  }
1431 
1432  function getKassenzeichen()
1433  {
1434  return $this->kassenzeichen;
1435  }
1436 
1437 }
1438 
1440 {
1441  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'LieferAdresse');
1442 
1443  function LieferAdresse ($values = "")
1444  {
1445  if ($values == "")
1446  {
1447  $values = $_SESSION["bmf"]["personal_data"];
1448  }
1449 
1450  if (is_array($values))
1451  {
1452  if ($values["firstname"] != NULL)
1453  {
1454  $this->vorname = utf8_decode($values["firstname"]);
1455  }
1456  if ($values["lastname"] != NULL)
1457  {
1458  $this->nachname = utf8_decode($values["lastname"]);
1459  }
1460  if ($values["street"] != NULL)
1461  {
1462  $this->strasse = utf8_decode($values["street"]);
1463  }
1464  if ($values["house_number"] != NULL)
1465  {
1466  $this->hausNr = utf8_decode($values["house_number"]);
1467  }
1468  if ($values["po_box"] != NULL)
1469  {
1470  $this->postfach = utf8_decode($values["po_box"]);
1471  }
1472  if ($values["country"] != NULL)
1473  {
1474  $this->land = utf8_decode($values["country"]);
1475  }
1476  if ($values["zipcode"] != NULL)
1477  {
1478  $this->PLZ = utf8_decode($values["zipcode"]);
1479  }
1480  if ($values["city"] != NULL)
1481  {
1482  $this->ort = utf8_decode($values["city"]);
1483  }
1484  }
1485  }
1486 }
1487 ?>