ILIAS  release_4-3 Revision
 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",ilUtil::getImagePath('icon_pays_b.png'));
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",ilUtil::getImagePath('icon_pays_b.png'));
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  if ($_POST["password"] == "" ||
389  md5($_POST["password"]) != $this->user_obj->getPasswd())
390  {
391  $this->error = $this->lng->txt('pay_bmf_password_not_valid');
392  ilUtil::sendInfo($this->error);
393  $this->showDebitEntry();
394  return;
395  }
396 
397  $_SESSION["bmf"]["debit_entry"]["BLZ"] = $_POST["bank_code"];
398  $_SESSION["bmf"]["debit_entry"]["kontoinhaber"] = $_POST["account_holder"];
399  $_SESSION["bmf"]["debit_entry"]["kontoNr"] = $_POST["account_number"];
400 
401  $this->error = "";
402  $this->sendDebitEntry();
403  }
404 
405  function sendDebitEntry()
406  {
407  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
408 
409  $this->psc_obj->clearCouponItemsSession();
410 
411  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
412  {
413 
414  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
415  $this->tpl->touchBlock("stop_floating");
416  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
417 
418  }
419  else
420  {
421  $customer = new KundenstammdatenPflegeWS();
422 
423  $newCustomer = new Kunde($this->user_obj->getId());
424 
425  $resultCustomerObj = $customer->anlegenKunde($newCustomer);
426 
427  $resultCustomer = $resultCustomerObj->ergebnis;
428 
429  if (is_object($resultCustomer))
430  {
431  if ($resultCustomer->code < 0)
432  {
433  $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $resultCustomer->code . ": " . $resultCustomer->kurzText . "<br>\n" . $resultCustomer->langText;
434  if ($resultCustomer->code == -103 ||
435  $resultCustomer->code == -104 ||
436  $resultCustomer->code == -107 ||
437  ($resultCustomer->code <= -202 && $resultCustomer->code >= -208) ||
438  $resultCustomer->code == -213)
439  {
441  $this->showPersonalData();
442  }
443  else
444  {
445  $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
447  $this->showPersonalData();
448  }
449  }
450  else
451  {
452  $payment = new LastschriftWS();
453 
454  $debitEntry = new Lastschrift();
455 
456  $address = new LieferAdresse();
457 
458  $bank = new Bankverbindung();
459 
460  $sc_obj = new ilPaymentShoppingCart($this->user_obj);
461 
462  $tmp_bookEntries = $sc_obj->getShoppingCart();
463 
464  if (!is_array($tmp_bookEntries))
465  {
466  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
467  }
468  else
469  {
470  $totalAmount = 0;
471  for ($i = 0; $i < count($tmp_bookEntries); $i++)
472  {
473  $booking = true;
474 
475  if (!empty($_SESSION["coupons"]["bmf"]))
476  {
477  $price = $tmp_bookEntries[$i]["price"];
478  $tmp_bookEntries[$i]["math_price"] = $price;
479 
480  foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
481  {
482  $this->coupon_obj->setId($coupon["pc_pk"]);
483  $this->coupon_obj->setCurrentCoupon($coupon);
484 
485  $tmp_pobject = new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']);
486 
487  if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
488  {
489  $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += $price;
490  $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i];
491  $booking = false;
492  }
493 
494  unset($tmp_pobject);
495  }
496  }
497 
498  if ($booking)
499  {
500  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ".", "");
501  $bookEntries[] = new Buchung($tmp_bookEntries[$i]);
502  $totalAmount += $tmp_bookEntries[$i]["price"];
503  }
504  else
505  {
506  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ",", ".");
507  }
508  }
509 
510  $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
511 
512  if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
513  {
514  foreach ($coupon_discount_items as $item)
515  {
516  $item["price"]= number_format( (float) $item["discount_price"], 2, ".", "");
517  $bookEntries[] = new Buchung($item);
518  $totalAmount += $item["price"];
519  }
520  }
521 
522  $totalAmount = number_format( (float) $totalAmount , 2, ".", "");
523  $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries);
524  $bookingList = new BuchungsListe($this->user_obj->getId(), $values);
525  }
526 
527 
528 
529  $resultObj = $payment->abbuchenOhneEinzugsermaechtigung($resultCustomerObj->kunde->EShopKundenNr, $address, $bank, $bookingList);
530  $result = $resultObj->ergebnis;
531 
532  if (is_object($result))
533  {
534  if ($result->code < 0)
535  {
536  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
537  $this->tpl->touchBlock("stop_floating");
538  $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText;
539  if ($result->code == -103 ||
540  $result->code == -104 ||
541  $result->code == -107 ||
542  ($result->code <= -202 && $result->code >= -208) ||
543  $result->code == -213)
544  {
546  $this->showPersonalData();
547  }
548  else if ($result->code == -507 ||
549  $result->code == -510 ||
550  $result->code == -511)
551  {
553  $this->showPaymentType();
554  }
555  else if ($result->code == -402 ||
556  $result->code == -402 ||
557  $result->code == -403 ||
558  $result->code == -406 ||
559  $result->code == -410 ||
560  $result->code == -413 ||
561  $result->code == -701 ||
562  $result->code == -702 ||
563  $result->code == -703)
564  {
566  $this->showDebitEntry();
567  }
568  else
569  {
570  $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
572  $this->showPersonalData();
573  }
574 
575  }
576  else
577  {
578  $resultCustomerObj->kunde->vorname = utf8_decode($resultCustomerObj->kunde->vorname);
579  $resultCustomerObj->kunde->nachname = utf8_decode($resultCustomerObj->kunde->nachname);
580  $resultCustomerObj->kunde->rechnungsAdresse->strasse = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse);
581  $resultCustomerObj->kunde->rechnungsAdresse->hausNr = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
582  $resultCustomerObj->kunde->rechnungsAdresse->postfach = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
583  $resultCustomerObj->kunde->rechnungsAdresse->PLZ = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
584  $resultCustomerObj->kunde->rechnungsAdresse->ort = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
585  $resultCustomerObj->kunde->rechnungsAdresse->land = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
586 
587  // everything ok => send confirmation, fill statistik, delete session, delete shopping cart.
588  $external_data = array();
589  $external_data['voucher'] = $resultObj->buchungsListe->buchungen[$b++]->belegNr;
590  $external_data['transaction_extern'] = $resultObj->buchungsListe->kassenzeichen;
591  $external_data['street'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse).' '.utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
592  $external_data['po_box'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
593  $external_data['zipcode'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
594  $external_data['city'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
595  $external_data['country'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
596 
597  parent::__addbookings($external_data);
598 
599  $this->__emptyShoppingCart();
600  $this->__clearSession();
601 
602  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
603  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_thanks'));
604  $this->tpl->touchBlock("stop_floating");
605 
606  ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'));
607 
608  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_bmf_debit_entry.html','Services/Payment');
609 
610  if ($this->ilias->getSetting("https") != 1)
611  {
612  $this->tpl->setCurrentBlock("buyed_objects");
613  $link = $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui');
614  $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link);
615  $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects'));
616  $this->tpl->parseCurrentBlock("buyed_objects");
617  }
618  $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window'));
619  }
620  }
621  else
622  {
623  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
624  $this->tpl->touchBlock("stop_floating");
625  ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
626  }
627  }
628  }
629  else
630  {
631  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
632  $this->tpl->touchBlock("stop_floating");
633  ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
634  }
635  }
636  }
637 
638  function showCreditCard()
639  {
640  // user_id $this->user_obj->getId()
641  // all
642 
643 /* if ($_SESSION["bmf"]["credit_card"]["karteninhaber"] == "" &&
644  $this->error == "" &&
645  $_POST["card_holder"] == "")
646  {
647  $_SESSION["bmf"]["credit_card"]["karteninhaber"] = $_SESSION["bmf"]["personal_data"]["vorname"] . " " . $_SESSION["bmf"]["personal_data"]["nachname"];
648  }*/
649 
650  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
651 
652  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
653  {
654 
655  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
656  $this->tpl->touchBlock("stop_floating");
657  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
658 
659  }
660  else
661  {
662 
663  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_credit_card.html','Services/Payment');
664  $this->__showShoppingCart();
665 
666  $this->tpl->setVariable("CREDIT_CARD_FORMACTION",$this->ctrl->getFormAction($this));
667 
668  // set table header
669  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays_b.png'));
670  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
671  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step3_credit_card'));
672  $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_credit_card_data'));
673  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_credit_card'));
674  $this->tpl->touchBlock("stop_floating");
675  $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
676 
677  // set plain text variables
678  $this->tpl->setVariable("TXT_CARD_HOLDER",$this->lng->txt('pay_bmf_card_holder'));
679  $this->tpl->setVariable("TXT_CHECK_NUMBER",$this->lng->txt('pay_bmf_check_number'));
680  $this->tpl->setVariable("TXT_OPTIONAL",$this->lng->txt('pay_bmf_optional'));
681  $this->tpl->setVariable("TXT_CARD_NUMBER",$this->lng->txt('pay_bmf_card_number'));
682  $this->tpl->setVariable("TXT_VALIDITY",$this->lng->txt('pay_bmf_validity'));
683  $this->tpl->setVariable("TXT_TERMS_CONDITIONS",$this->lng->txt('pay_bmf_terms_conditions'));
684  $this->tpl->setVariable("TXT_TERMS_CONDITIONS_READ",$this->lng->txt('pay_bmf_terms_conditions_read'));
685  $this->tpl->setVariable("TXT_TERMS_CONDITIONS_SHOW",$this->lng->txt('pay_bmf_terms_conditions_show'));
686  $this->tpl->setVariable("LINK_TERMS_CONDITIONS","./payment.php?view=conditions");
687  $this->tpl->setVariable("TXT_PASSWORD",$this->lng->txt('password'));
688  $this->tpl->setVariable("TXT_CONFIRM_ORDER",$this->lng->txt('pay_confirm_order'));
689 
690  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_send_order'));
691  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
692 
693  // fill defaults
694 
695  $this->tpl->setVariable("CARD_HOLDER",
696  $this->error != "" && isset($_POST['card_holder'])
697  ? ilUtil::prepareFormOutput($_POST['card_holder'],true)
698  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['karteninhaber'],true));
699  $this->tpl->setVariable("CARD_NUMBER_BLOCK_1",
700  $this->error != "" && isset($_POST['card_number']['block_1'])
701  ? ilUtil::prepareFormOutput($_POST['card_number']['block_1'],true)
702  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_1'],true));
703  $this->tpl->setVariable("CARD_NUMBER_BLOCK_2",
704  $this->error != "" && isset($_POST['card_number']['block_2'])
705  ? ilUtil::prepareFormOutput($_POST['card_number']['block_2'],true)
706  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_2'],true));
707  $this->tpl->setVariable("CARD_NUMBER_BLOCK_3",
708  $this->error != "" && isset($_POST['card_number']['block_3'])
709  ? ilUtil::prepareFormOutput($_POST['card_number']['block_3'],true)
710  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_3'],true));
711  $this->tpl->setVariable("CARD_NUMBER_BLOCK_4",
712  $this->error != "" && isset($_POST['card_number']['block_4'])
713  ? ilUtil::prepareFormOutput($_POST['card_number']['block_4'],true)
714  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_4'],true));
715  $this->tpl->setVariable("CHECK_NUMBER",
716  $this->error != "" && isset($_POST['check_number'])
717  ? ilUtil::prepareFormOutput($_POST['check_number'],true)
718  : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kartenpruefnummer'],true));
719  for ($i = 1; $i <= 12; $i++)
720  {
721  $this->tpl->setCurrentBlock("loop_validity_months");
722  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS", $i < 10 ? "0" . $i : $i);
723  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_TXT", $i < 10 ? "0" . $i : $i);
724  if ($this->error != "" &&
725  isset($_POST['validity']['month']))
726  {
727  if ($_POST['validity']['month'] == $i)
728  {
729  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_SELECTED", " selected");
730  }
731  }
732  else
733  {
734  if ($_SESSION["bmf"]["credit_card"]["gueltigkeit"]["monat"] == $i)
735  {
736  $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_SELECTED", " selected");
737  }
738  }
739  $this->tpl->parseCurrentBlock("loop_validity_months");
740  }
741  for ($i = date("Y"); $i <= (date("Y")+6); $i++)
742  {
743  $this->tpl->setCurrentBlock("loop_validity_years");
744  $this->tpl->setVariable("LOOP_VALIDITY_YEARS", $i);
745  $this->tpl->setVariable("LOOP_VALIDITY_YEARS_TXT", $i);
746  if ($this->error != "" &&
747  isset($_POST['validity']['year']))
748  {
749  if ($_POST['validity']['year'] == $i)
750  {
751  $this->tpl->setVariable("LOOP_VALIDITY_YEARS_SELECTED", " selected");
752  }
753  }
754  else
755  {
756  if ($_SESSION["bmf"]["credit_card"]["gueltigkeit"]["jahr"] == $i)
757  {
758  $this->tpl->setVariable("LOOP_VALIDITY_YEARS_SELECTED", " selected");
759  }
760  }
761  $this->tpl->parseCurrentBlock("loop_validity_years");
762  }
763 /* if ($this->error != "" &&
764  isset($_POST["terms_conditions"]))
765  {
766  $this->tpl->setVariable("TERMS_CONDITIONS_" . $_POST["terms_conditions"], " checked") ;
767  }*/
768 /* if ($this->error != "" &&
769  isset($_POST["password"]))
770  {
771  $this->tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST['password'],true));
772  }*/
773 
774  // Button
775  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
776  $this->tpl->setCurrentBlock("btn_cell");
777  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPaymentType"));
778  $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
779  $this->tpl->parseCurrentBlock("btn_cell");
780 
781  }
782  }
783 
784  function getCreditCard()
785  {
786  if ($_POST["card_holder"] == "" ||
787  $_POST["card_number"]["block_1"] == "" ||
788  $_POST["card_number"]["block_2"] == "" ||
789  $_POST["card_number"]["block_3"] == "" ||
790  $_POST["card_number"]["block_4"] == "" ||
791  $_POST["validity"]["month"] == "" ||
792  $_POST["validity"]["year"] == "" ||
793  $_POST["validity"]["year"]."-".$_POST["validity"]["month"] < date("Y-m"))
794  {
795  $this->error = $this->lng->txt('pay_bmf_credit_card_not_valid');
796  ilUtil::sendInfo($this->error);
797  $this->showCreditCard();
798  return;
799  }
800  if ($_POST["terms_conditions"] != 1)
801  {
802  $this->error = $this->lng->txt('pay_bmf_check_terms_conditions');
803  ilUtil::sendInfo($this->error);
804  $this->showCreditCard();
805  return;
806  }
807  if ($_POST["password"] == "" ||
808  md5($_POST["password"]) != $this->user_obj->getPasswd())
809  {
810  $this->error = $this->lng->txt('pay_bmf_password_not_valid');
811  ilUtil::sendInfo($this->error);
812  $this->showCreditCard();
813  return;
814  }
815 
816  $_SESSION["bmf"]["credit_card"]["gueltigkeit"]["monat"] = $_POST["validity"]["month"];
817  $_SESSION["bmf"]["credit_card"]["gueltigkeit"]["jahr"] = $_POST["validity"]["year"];
818  $_SESSION["bmf"]["credit_card"]["karteninhaber"] = $_POST["card_holder"];
819  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_1"] = $_POST["card_number"]["block_1"];
820  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_2"] = $_POST["card_number"]["block_2"];
821  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_3"] = $_POST["card_number"]["block_3"];
822  $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_4"] = $_POST["card_number"]["block_4"];
823  $_SESSION["bmf"]["credit_card"]["kartenpruefnummer"] = $_POST["check_number"];
824  # zum testen
825  $this->error = "";
826  $this->sendCreditCard();
827  }
828 
829  function sendCreditCard()
830  {
831  $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
832 
833  $this->psc_obj->clearCouponItemsSession();
834 
835  if(!count($items = $this->psc_obj->getEntries($this->pm_id)))
836  {
837 
838  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
839  $this->tpl->touchBlock("stop_floating");
840  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
841 
842  }
843  else
844  {
845  $payment = new KreditkartenzahlungWS();
846 
847  $customer = new Kunde($this->user_obj->getId());
848 
849  $creditCard = new Kreditkarte();
850 
851  $sc_obj = new ilPaymentShoppingCart($this->user_obj);
852 
853  $tmp_bookEntries = $sc_obj->getShoppingCart();
854  if (!is_array($tmp_bookEntries))
855  {
856  ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
857  }
858  else
859  {
860  $totalAmount = 0;
861  for ($i = 0; $i < count($tmp_bookEntries); $i++)
862  {
863  $booking = true;
864 
865  if (!empty($_SESSION["coupons"]["bmf"]))
866  {
867  $price = $tmp_bookEntries[$i]["price"];
868  $tmp_bookEntries[$i]["math_price"] = $price;
869 
870  foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
871  {
872  $this->coupon_obj->setId($coupon["pc_pk"]);
873  $this->coupon_obj->setCurrentCoupon($coupon);
874 
875  $tmp_pobject = new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']);
876 
877  if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
878  {
879  $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += $price;
880  $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i];
881 
882  $booking = false;
883  }
884 
885  unset($tmp_pobject);
886  }
887  }
888 
889  if ($booking)
890  {
891  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ",", ".");
892 
893  $bookEntries[] = new Buchung($tmp_bookEntries[$i]);
894  $totalAmount += $tmp_bookEntries[$i]["price"];
895  }
896  else
897  {
898  $tmp_bookEntries[$i]["price_string"] = number_format( (float) $tmp_bookEntries[$i]["price"] , 2, ",", ".");
899  }
900  }
901 
902  $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
903 
904  if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
905  {
906  foreach ($coupon_discount_items as $item)
907  {
908  $item["price"] = number_format((float)$item["discount_price"] , 2, ".", "");
909  $bookEntries[] = new Buchung($item);
910  $totalAmount += $item["discount_price"];
911  }
912  }
913 
914  $totalAmount = number_format((float)$totalAmount , 2, ".", "");
915  $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries);
916  $bookingList = new BuchungsListe($this->user_obj->getId(), $values);
917  }
918 
919  $resultObj = $payment->zahlenUndAnlegenKunde($customer, $creditCard, $bookingList);
920  $result = $resultObj->ergebnis;
921 
922  if (is_object($result))
923  {
924  if ($result->code < 0)
925  {
926  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
927  $this->tpl->touchBlock("stop_floating");
928  $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText;
929  if ($result->code == -103 ||
930  $result->code == -104 ||
931  $result->code == -107 ||
932  ($result->code <= -202 && $result->code >= -208) ||
933  $result->code == -213)
934  {
936  $this->showPersonalData();
937  }
938  else if ($result->code == -507 ||
939  $result->code == -510 ||
940  $result->code == -511)
941  {
943  $this->showPaymentType();
944  }
945  else if ($result->code == -701 ||
946  $result->code == -1701 ||
947  $result->code == -1706 ||
948  $result->code == -1707 ||
949  $result->code == -1710 ||
950  $result->code == -1711)
951  {
953  $this->showCreditCard();
954  }
955  else
956  {
957  $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
959  $this->showPersonalData();
960  }
961  }
962  else
963  {
964  // everything ok => send confirmation, fill statistik, delete session, delete shopping cart.
965  $external_data = array();
966  $external_data['voucher'] = $resultObj->buchungsListe->buchungen[$b++]->belegNr;
967  $external_data['transaction_extern'] = $resultObj->buchungsListe->kassenzeichen;
968  $external_data['street'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse).' '.utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
969  $external_data['po_box'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
970  $external_data['zipcode'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
971  $external_data['city'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
972  $external_data['country'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
973 
974  parent::__addbookings($external_data);
975 
976  $this->__emptyShoppingCart();
977  $this->__clearSession();
978 
979  $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
980  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_thanks'));
981  $this->tpl->touchBlock("stop_floating");
982 
983  ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'));
984 
985  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_bmf_credit_card.html','Services/Payment');
986 
987  if ($this->ilias->getSetting("https") != 1)
988  {
989  $this->tpl->setCurrentBlock("buyed_objects");
990  $link = $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui');
991  $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link);
992  $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects'));
993  $this->tpl->parseCurrentBlock("buyed_objects");
994  }
995  $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window'));
996  }
997  }
998  else
999  {
1000  $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
1001  $this->tpl->touchBlock("stop_floating");
1002  ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
1003  }
1004  #zum testen
1005  }
1006 
1007  }
1008 
1012  function &executeCommand()
1013  {
1014  global $tree;
1015 
1016  $cmd = $this->ctrl->getCmd();
1017 
1018  switch ($this->ctrl->getNextClass($this))
1019  {
1020 
1021  default:
1022  if(!$cmd = $this->ctrl->getCmd())
1023  {
1024  $cmd = 'showPersonalData';
1025  }
1026  $this->$cmd();
1027  break;
1028  }
1029  }
1030 }
1031 
1032 
1034 {
1035 
1036  var $_soapClient = NULL;
1037 
1039  {
1040  $bmfSetObj = ilBMFSettings::getInstance();
1041  $bmfConfig = $bmfSetObj->getAll();
1042 
1043  $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"])));
1044  }
1045 
1046  function anlegenKunde ($customer)
1047  {
1048  $bmfSetObj = ilBMFSettings::getInstance();
1049  $bmfConfig = $bmfSetObj->getAll();
1050 
1051  $tmp = array(
1052  'mandantNr' => $bmfConfig["mandantNr"],
1053  'kunde' => $customer
1054  );
1055 
1056  $result = $this->_soapClient->call("anlegenKunde", $tmp, "KundenstammdatenPflegeWS");
1057  return $result;
1058  }
1059 
1060 };
1061 
1063 {
1064  var $_soapClient = NULL;
1065 
1067  {
1068  $bmfSetObj = ilBMFSettings::getInstance();
1069  $bmfConfig = $bmfSetObj->getAll();
1070 
1071  $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"])));
1072  }
1073 
1074  function validierenKreditkarte($creditCard)
1075  {
1076  $bmfSetObj = ilBMFSettings::getInstance();
1077  $bmfConfig = $bmfSetObj->getAll();
1078 
1079  $tmp = array(
1080  'mandantNr' => $bmfConfig["mandantNr"],
1081  'kreditkarte' => $creditCard,
1082  'waehrungskennzeichen' => $bmfConfig["waehrungskennzeichen"]
1083  );
1084 
1085  $result = $this->_soapClient->call("validierenKreditkarte", $tmp, "KreditkartenzahlungWS");
1086  return $result;
1087  }
1088 
1089  function zahlenUndAnlegenKunde($customer, $creditCard, $bookingList)
1090  {
1091  $bmfSetObj = ilBMFSettings::getInstance();
1092  $bmfConfig = $bmfSetObj->getAll();
1093 
1094  $lieferadresse = new LieferAdresse();
1095 
1096  $tmp = array(
1097  'mandantNr' => $bmfConfig["mandantNr"],
1098  'Kunde' => $customer,
1099  'Kreditkarte' => $creditCard,
1100  'buchungsListe' => $bookingList,
1101  'lieferadresse' => $lieferadresse
1102  );
1103 
1104  $result = $this->_soapClient->call("zahlenUndAnlegenKunde", $tmp, "KreditkartenzahlungWS");
1105  return $result;
1106  }
1107 }
1108 
1110 {
1111 
1112  var $_soapClient = NULL;
1113 
1114  function LastschriftWS ()
1115  {
1116  $bmfSetObj = ilBMFSettings::getInstance();
1117  $bmfConfig = $bmfSetObj->getAll();
1118 
1119  $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"])));
1120  }
1121 
1122  function abbuchenOhneEinzugsermaechtigung($eShopCustomerNumber, $address, $bank, $bookingList)
1123  {
1124  $bmfSetObj = ilBMFSettings::getInstance();
1125  $bmfConfig = $bmfSetObj->getAll();
1126 
1127  $tmp = array(
1128  'mandantNr' => $bmfConfig["mandantNr"],
1129  'eShopKundenNr' => $eShopCustomerNumber,
1130  'lieferAdresse' => $address,
1131  'bankverbindung' => $bank,
1132  'buchungsListe' => $bookingList
1133  );
1134 
1135  $result = $this->_soapClient->call("abbuchenOhneEinzugsermaechtigung", $tmp, "LastschriftWS");
1136  return $result;
1137  }
1138 
1139 };
1140 
1141 class Kunde
1142 {
1143  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Kunde');
1144 
1145  function Kunde ($customerNumber = "", $values = "")
1146  {
1147 /* if ($customerNumber != "")
1148  {
1149  $this->EShopKundenNr = $customerNumber;
1150  }
1151  else
1152  {*/
1153  $this->EShopKundenNr = time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1154  if ($customerNumber != "")
1155  {
1156  $this->EShopKundenNr = $customerNumber . "_" . time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1157  }
1158 /* }*/
1159 
1160  if ($values == "")
1161  {
1162  $values = $_SESSION["bmf"]["personal_data"];
1163  }
1164 
1165  if ($values["language"] != NULL)
1166  {
1167  $this->sprache = $values["language"];
1168  }
1169  if ($values["firstname"] != NULL)
1170  {
1171  $this->vorname = utf8_decode($values["firstname"]);
1172  }
1173  if ($values["lastname"] != NULL)
1174  {
1175  $this->nachname = utf8_decode($values["lastname"]);
1176  }
1177  if ($values["email"] != NULL)
1178  {
1179  $this->EMailAdresse = utf8_decode($values["email"]);
1180  }
1181 
1182  $address = new Adresse();
1183 
1184  $this->rechnungsAdresse = $address;
1185  }
1186 
1188  {
1189  return $this->EShopKundenNr;
1190  }
1191 
1192 }
1193 
1194 class Adresse
1195 {
1196  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Adresse');
1197 
1198  function Adresse ($values = "")
1199  {
1200  if ($values == "")
1201  {
1202  $values = $_SESSION["bmf"]["personal_data"];
1203  }
1204 
1205  if (is_array($values))
1206  {
1207  if ($values["street"] != NULL)
1208  {
1209  $this->strasse = utf8_decode($values["street"]);
1210  }
1211  if ($values["house_number"] != NULL)
1212  {
1213  $this->hausNr = utf8_decode($values["house_number"]);
1214  }
1215  if ($values["po_box"] != NULL)
1216  {
1217  $this->postfach = utf8_decode($values["po_box"]);
1218  }
1219  if ($values["country"] != NULL)
1220  {
1221  $this->land = utf8_decode($values["country"]);
1222  }
1223  if ($values["zipcode"] != NULL)
1224  {
1225  $this->PLZ = utf8_decode($values["zipcode"]);
1226  }
1227  if ($values["city"] != NULL)
1228  {
1229  $this->ort = utf8_decode($values["city"]);
1230  }
1231  }
1232  }
1233 
1234 }
1235 
1237 {
1238  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Kreditkarte');
1239 
1240  function Kreditkarte ($values = "")
1241  {
1242  if ($values == "")
1243  {
1244  $values = $_SESSION["bmf"]["credit_card"];
1245  }
1246 
1247  if (is_array($values))
1248  {
1249  if ($values["karteninhaber"] != NULL)
1250  {
1251  $this->karteninhaber = utf8_decode($values["karteninhaber"]);
1252  }
1253  if ($values["kartenpruefnummer"] != NULL)
1254  {
1255  $this->kartenpruefnummer = utf8_decode($values["kartenpruefnummer"]);
1256  }
1257  if (is_array ($values["kreditkartenNr"]) &&
1258  count($values["kreditkartenNr"]) == 4)
1259  {
1260  for ($i = 1; $i <= count($values["kreditkartenNr"]); $i++)
1261  {
1262  $this->kreditkartenNr .= utf8_decode($values["kreditkartenNr"]["block_".$i]);# . "-";
1263  }
1264 # $this->kreditkartenNr = substr($this->kreditkartenNr, 0, strlen($this->kreditkartenNr)-1);
1265  }
1266  if (is_array($values["gueltigkeit"]) &&
1267  $values["gueltigkeit"]["monat"] != "" &&
1268  $values["gueltigkeit"]["jahr"] != "")
1269  {
1270  $this->gueltigkeit = utf8_decode($values["gueltigkeit"]["monat"]);
1271  $this->gueltigkeit .= utf8_decode($values["gueltigkeit"]["jahr"]);
1272  }
1273  }
1274  }
1275 
1276 }
1277 
1279 {
1280  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Lastschrift');
1281 
1282  function Lastschrift ($customerNumber = "", $values = "")
1283  {
1284  $this->EShopKundenNr = time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1285  if ($customerNumber != "")
1286  {
1287  $this->EShopKundenNr = $customerNumber . "_" . time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
1288  }
1289  }
1290 
1291 }
1292 
1294 {
1295  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Bankverbindung');
1296 
1297  function Bankverbindung ($values = "")
1298  {
1299  if ($values == "")
1300  {
1301  $values = $_SESSION["bmf"]["debit_entry"];
1302  }
1303 
1304  if (is_array($values))
1305  {
1306  if ($values["kontoinhaber"] != NULL)
1307  {
1308  $this->kontoinhaber = utf8_decode($values["kontoinhaber"]);
1309  }
1310  if ($values["kontoNr"] != NULL)
1311  {
1312  $this->kontoNr = utf8_decode($values["kontoNr"]);
1313  }
1314  if ($values["BLZ"] != NULL)
1315  {
1316  $this->BLZ = utf8_decode($values["BLZ"]);
1317  }
1318  }
1319  }
1320 
1321 }
1322 
1323 class Buchung
1324 {
1325  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');
1326 
1327  function Buchung($values = "")
1328  {
1329  $bmfSetObj = ilBMFSettings::getInstance();
1330  $bmfConfig = $bmfSetObj->getAll();
1331 
1332  if ($bmfConfig["haushaltsstelle"] != NULL)
1333  {
1334  $this->haushaltsstelle = $bmfConfig["haushaltsstelle"];
1335  }
1336  if ($bmfConfig["objektNr"] != NULL)
1337  {
1338  $this->objektnummer = $bmfConfig["objektNr"];
1339  }
1340 
1341  if (is_array($values))
1342  {
1343  if ($values["object_title"] != NULL)
1344  {
1345  $buchungstext = utf8_decode($values["object_title"]);
1346  if(strlen($buchungstext) > 16)
1347  {
1348  $buchungstext = substr($buchungstext,0,15).'...';
1349  }
1350 
1351  $this->buchungstext = $buchungstext;
1352  }
1353  if ($values["price"] != "")
1354  {
1355  $this->betrag = (float)$values["price"];
1356  }
1357  }
1358  }
1359 
1360  /* Die BelegNr wird vom BMF zur�ck geliefert */
1361  function setVoucherNumber($voucherNumber)
1362  {
1363  if ($voucherNumber != NULL)
1364  {
1365  $this->belegNr = $voucherNumber;
1366  }
1367  }
1368 
1369  function getVoucherNumber()
1370  {
1371  return $this->belegNr;
1372  }
1373 }
1374 
1376 {
1377  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment', 'nsPrefix' => 'ns2', 'type' => 'BuchungsListe');
1378 
1379  function BuchungsListe($userId, $values = "")
1380  {
1381  global $ilias;
1382 
1383  $bmfSetObj = ilBMFSettings::getInstance();
1384  $bmfConfig = $bmfSetObj->getAll();
1385 
1386  if ($bmfConfig["bewirtschafterNr"] != NULL)
1387  {
1388  $this->bewirtschafterNr = $bmfConfig["bewirtschafterNr"];
1389  }
1390  if ($bmfConfig["waehrungskennzeichen"] != NULL)
1391  {
1392  $this->waehrungskennzeichen = $bmfConfig["waehrungskennzeichen"];
1393  }
1394  $this->faelligkeitsdatum = date("Y-m-d") . "T" . date("H:i:s") . "Z";
1395  if ($bmfConfig["kennzeichenMahnverfahren"] != NULL)
1396  {
1397  $this->kennzeichenMahnverfahren = $bmfConfig["kennzeichenMahnverfahren"];
1398  }
1399 
1400  $inst_id_time = $ilias->getSetting('inst_id').'_'.$userId.'_'.substr((string) time(),-3);
1401  $this->EShopTransaktionsNr = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
1402 
1403  if (is_array($values))
1404  {
1405  if ($values["betrag"] != NULL)
1406  {
1407  $this->betrag = (float)$values["betrag"];
1408  }
1409  if ($values["buchungen"] != NULL)
1410  {
1411  $this->buchungen = $values["buchungen"];
1412  }
1413  }
1414  }
1415  function getTransaction()
1416  {
1417  return $this->EShopTransaktionsNr;
1418  }
1419 
1420  /* Das Kassenzeichen wird vom BMF zur�ck geliefert */
1421  function setKassenzeichen($kassenzeichen)
1422  {
1423  if ($kassenzeichen != NULL)
1424  {
1425  $this->kassenzeichen = $kassenzeichen;
1426  }
1427  }
1428 
1429  function getKassenzeichen()
1430  {
1431  return $this->kassenzeichen;
1432  }
1433 
1434 }
1435 
1437 {
1438  var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'LieferAdresse');
1439 
1440  function LieferAdresse ($values = "")
1441  {
1442  if ($values == "")
1443  {
1444  $values = $_SESSION["bmf"]["personal_data"];
1445  }
1446 
1447  if (is_array($values))
1448  {
1449  if ($values["firstname"] != NULL)
1450  {
1451  $this->vorname = utf8_decode($values["firstname"]);
1452  }
1453  if ($values["lastname"] != NULL)
1454  {
1455  $this->nachname = utf8_decode($values["lastname"]);
1456  }
1457  if ($values["street"] != NULL)
1458  {
1459  $this->strasse = utf8_decode($values["street"]);
1460  }
1461  if ($values["house_number"] != NULL)
1462  {
1463  $this->hausNr = utf8_decode($values["house_number"]);
1464  }
1465  if ($values["po_box"] != NULL)
1466  {
1467  $this->postfach = utf8_decode($values["po_box"]);
1468  }
1469  if ($values["country"] != NULL)
1470  {
1471  $this->land = utf8_decode($values["country"]);
1472  }
1473  if ($values["zipcode"] != NULL)
1474  {
1475  $this->PLZ = utf8_decode($values["zipcode"]);
1476  }
1477  if ($values["city"] != NULL)
1478  {
1479  $this->ort = utf8_decode($values["city"]);
1480  }
1481  }
1482  }
1483 }
1484 ?>