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