ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilShopShoppingCartGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
5
6include_once './Services/Payment/classes/class.ilShopBaseGUI.php';
7include_once './Services/Payment/classes/class.ilPaypalSettings.php';
8//include_once './Services/Payment/classes/class.ilEPaySettings.php';
9include_once './Services/Payment/classes/class.ilPaymentCoupons.php';
10include_once './Services/Payment/classes/class.ilShopVatsList.php';
11include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
12include_once './Services/Payment/classes/class.ilPayMethods.php';
13
14include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
15include_once './Services/Payment/classes/class.ilShopBoughtObjectsGUI.php';
16
27{
28 private $user_obj;
29 private $psc_obj = null;
30 private $paypal_obj = null;
31
32 private $totalAmount = array();
33 private $totalVat = 0;
34 private $epSet;
35
36 #private $default_currency = 1;
37 private $session_id;
38
39 public function __construct($user_obj)
40 {
41 global $ilUser;
42
43 parent::__construct();
44
45 if(isset($_SESSION['shop_user_id']) && $_SESSION['shop_user_id'] != ANONYMOUS_USER_ID)
46 {
48 $this->user_obj = new ilObjUser($_SESSION['shop_user_id']);
49 }
50 else if($user_obj != NULL)
51 {
52 $this->user_obj = $user_obj;
53 }
54 else if($ilUser->getId() != ANONYMOUS_USER_ID)
55 {
56 $this->user_obj = $ilUser;
57 $_SESSION['shop_user_id'] = null;
58 }
59 else
60 {
61 $this->session_id = session_id();
62 }
63
64 $this->coupon_obj = new ilPaymentCoupons($this->user_obj);
65
67 $this->paypalConfig = $ppSet->getAll();
68
69// $this->epSet = ilEPaySettings::getInstance();
70// $this->epayConfig = $this->epSet->getAll();
71
73
74 #$this->default_currency = ilPaymentCurrency::_getDefaultCurrency();
75 }
76
80 public function executeCommand()
81 {
82 $cmd = $this->ctrl->getCmd();
83 $next_class = $this->ctrl->getNextClass($this);
84
85 switch ($next_class)
86 {
87 default:
88 $this->prepareOutput();
89 if (!$cmd = $this->ctrl->getCmd())
90 {
91 $cmd = 'showItems';
92 }
93 $this->$cmd();
94 break;
95 }
96
97 return true;
98 }
99
100 protected function prepareOutput()
101 {
102 global $ilTabs;
103
104 parent::prepareOutput();
105
106 $ilTabs->setTabActive('paya_shopping_cart');
107 }
109 {
110 include_once './Services/Payment/classes/class.ilPurchaseBaseGUI.php';
111 $purchase = new ilPurchaseBaseGUI($this->user_obj, ilPayMethods::_getIdByTitle('paypal'));
112 $purchase->__addBookings();
113
114 $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
115
116 return true;
117 }
118
120 {
121 $this->addBookings(PAY_METHOD_BMF, 'bmf');
122
123 $_SESSION['coupons']['bmf'] = '';
124 $_SESSION['bmf']['payment_type'] = '';
125 $_SESSION['bmf']['debit_entry'] = array();
126 $_SESSION['bmf']['credit_card'] = array();
127
128 ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'), true);
129
130 $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
131
132 return true;
133 }
134
136 {
137 include_once './Services/Payment/classes/class.ilPurchaseBaseGUI.php';
138 $purchase = new ilPurchaseBaseGUI($this->user_obj, ilPayMethods::_getIdByTitle('paypal'));
139 $purchase->__addBookings();
140
141 ilUtil::sendSuccess($this->lng->txt('pay_paypal_success'), true);
142 $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
143
144 return true;
145 }
146
147 private function addBookings($pay_method, $coupon_session)
148 {
149 global $ilUser, $ilObjDataCache;
150
151 include_once './Services/Payment/classes/class.ilPaymentBookings.php';
152 include_once './Services/Payment/classes/class.ilPaymentObject.php';
153 include_once './Services/Payment/classes/class.ilPaymentPrices.php';
154
155 $booking_obj = new ilPaymentBookings();
156 $sc_obj = new ilPaymentShoppingCart($this->user_obj);
157 $items = $sc_obj->getEntries($pay_method);
158 $sc_obj->clearCouponItemsSession();
159
160 foreach($items as $entry)
161 {
162 $pobject = new ilPaymentObject($this->user_obj, $entry['pobject_id']);
163 $price = ilPaymentPrices::_getPrice($entry['price_id']);
164
165 if (!empty($_SESSION['coupons'][$coupon_session]))
166 {
167 $entry['math_price'] = $entry['price']; // (float) ilPaymentPrices::_getPriceFromArray($price);
168 foreach ($_SESSION['coupons'][$coupon_session] as $key => $coupon)
169 {
170 $this->coupon_obj->setId($coupon['pc_pk']);
171 $this->coupon_obj->setCurrentCoupon($coupon);
172
173 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
174 {
175 $_SESSION['coupons'][$coupon_session][$key]['total_objects_coupon_price'] += $entry['price']; //(float) ilPaymentPrices::_getPriceFromArray($price);
176 $_SESSION['coupons'][$coupon_session][$key]['items'][] = $entry;
177 }
178 }
179 }
180 unset($pobject);
181 }
182
183 $coupon_discount_items = $sc_obj->calcDiscountPrices($_SESSION['coupons'][$coupon_session]);
184
185 foreach($items as $entry)
186 {
187 $pobject = new ilPaymentObject($this->user_obj, $entry['pobject_id']);
188
189 $price = ilPaymentPrices::_getPrice($entry['price_id']);
190
191 if (array_key_exists($entry['pobject_id'], $coupon_discount_items))
192 {
193 $bonus = $coupon_discount_items[$entry['pobject_id']]['math_price'] - $coupon_discount_items[$entry['pobject_id']]['discount_price'];
194 }
195
196 $booking_obj->setPobjectId($entry['pobject_id']);
197
198 $booking_obj->setCustomerId($this->user_obj->getId());
199 $booking_obj->setVendorId($pobject->getVendorId());
200 $booking_obj->setPayMethod($pobject->getPayMethod());
201 $booking_obj->setOrderDate(time());
202 $booking_obj->setDuration($price['duration']);
203 $booking_obj->setPrice(ilPaymentPrices::_getPriceString($entry['price_id']));
204 $booking_obj->setDiscount($bonus > 0 ? ((-1) * $bonus) : 0);
205 $booking_obj->setPayed(1);
206 $booking_obj->setAccess(1);
207
208 switch($price['price_type'])
209 {
211 $booking_obj->setDuration(0);
212 break;
214 $booking_obj->setDuration($price['duration']);
215 break;
217 $booking_obj->setAccessStartdate($price['duration_from']);
218 $booking_obj->setAccessEnddate($price['duration_until']);
219 break;
220 }
221
222 $booking_obj->setAccessExtension($price['extension']);
223
224 $obj_id = $ilObjDataCache->lookupObjId($pobject->getRefId());
225 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
226
227 $oVAT = new ilShopVats((int)$pobject->getVatId());
228 $obj_vat_rate = $oVAT->getRate();
229
230 if($bonus > 0)
231 {
232 $tmp_price = $booking_obj->getPrice()-$bonus;
233 $obj_vat_unit = $pobject->getVat($tmp_price);
234 }else
235 $obj_vat_unit = $pobject->getVat($booking_obj->getPrice());
236
237 $booking_obj->setObjectTitle($obj_title);
238 $booking_obj->setVatRate($obj_vat_rate);
239 $booking_obj->setVatUnit($obj_vat_unit);
240
241 if(ilPaymethods::_EnabledSaveUserAddress($booking_obj->getPayMethod()))
242 {
243 $booking_obj->setStreet($this->user_obj->getStreet(), $this->user_obj->getHouseNumber);
244 $booking_obj->setZipcode($this->user_obj->getZipcode());
245 $booking_obj->setCity($this->user_obj->getCity());
246 $booking_obj->setCountry($this->user_obj->getCountry());
247 }
248
249 $current_booking_id = $booking_obj->add();
250
251 if ($current_booking_id)
252 {
253 $sc_obj->delete($entry['psc_id']);
254
255 if (!empty($_SESSION['coupons'][$coupon_session]))
256 {
257 foreach ($_SESSION['coupons'][$coupon_session] as $coupon)
258 {
259 $this->coupon_obj->setId($coupon['pc_pk']);
260 $this->coupon_obj->setCurrentCoupon($coupon);
261
262 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
263 {
264 $this->coupon_obj->addCouponForBookingId($current_booking_id);
265 }
266 }
267 }
268 }
269
270 unset($current_booking_id);
271 unset($pobject);
272 }
273
274 if (!empty($_SESSION['coupons'][$coupon_session]))
275 {
276 foreach ($_SESSION['coupons'][$coupon_session] as $coupon)
277 {
278 $this->coupon_obj->setId($coupon['pc_pk']);
279 $this->coupon_obj->setCurrentCoupon($coupon);
280 $this->coupon_obj->addTracking();
281 }
282 }
283 }
284
286 {
287 $objPM = new ilPayMethods();
288 $get_paymethods = $objPM->readAll();
289
290 foreach($get_paymethods as $pm)
291 {
292 $pay_methods[$pm['pm_id']]['pm_title'] = $pm['pm_title'];
293 $pay_methods[$pm['pm_id']]['pm_id'] = $pm['pm_id'];
294 }
295
296 if (is_array($pay_methods))
297 {
298 foreach($pay_methods as $pay_method)
299 {
300 $coupon_session_id = $pay_method['pm_title'];
301
302 if (!is_array($_SESSION['coupons'][$coupon_session_id]))
303 {
304 $_SESSION['coupons'][$coupon_session_id] = array();
305 }
306 else // check if coupons are valid anymore
307 {
308 foreach ($_SESSION['coupons'][$coupon_session_id] as $coupon_id => $session_coupon)
309 {
310 $coupon = $this->coupon_obj->getCouponByCode($session_coupon['pcc_code']);
311
312 if ($this->coupon_obj->checkCouponValidity() == 0)
313 {
314 $assignedItems = 0;
315 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
316
317 if (count($items = $this->psc_obj->getEntries($pay_method['pm_id'])))
318 {
319 foreach($items as $item)
320 {
321 $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']);
322
323 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
324 {
325 ++$assignedItems;
326 }
327 }
328 }
329 if (!$assignedItems)
330 {
331 unset($_SESSION['coupons'][$coupon_session_id][$coupon_id]);
332 }
333 }
334 else
335 {
336 unset($_SESSION['coupons'][$coupon_session_id][$coupon_id]);
337 }
338 }
339 }
340 }
341 }
342 }
343
349 public function finishEPay()
350 {
351// global $ilUser;
352// require_once './Services/Payment/classes/class.ilPurchase.php';
353//
354// try
355// {
356// $pm_id = ilPayMethods::_getIdByTitle('epay');
357// $buy = new ilPurchase( $ilUser->getId(), $pm_id );
358// $buy->purchase($_REQUEST['tid'] );
359// }
360// catch (ilERPException $e)
361// {
362// $msg = $e->getMessage();
363// if (DEVMODE) $msg .= " " . print_r($_REQUEST, true);
364// ilUtil::sendFailure($msg);
365// }
366// ilUtil::sendSuccess($this->lng->txt('pay_epay_success'));
367// $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
368 }
369
370 public function finishPaypal()
371 {
372 global $ilUser;
373 $this->initPaypalObject();
374
375 if (!($fp = $this->paypal_obj->openSocket()))
376 {
377 ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_unreachable').'<br />'.$this->lng->txt('pay_paypal_error_info'));
378 $this->showItems();
379 }
380 else
381 {
382
383 $res = $this->paypal_obj->checkData($fp);
384
385
386 if ($res == SUCCESS)
387 {
388 ilUtil::sendSuccess($this->lng->txt('pay_paypal_success'), true);
389 if($this->user_obj->getId() == ANONYMOUS_USER_ID || $_SESSION['is_crs_object'] || $_SESSION['is_lm_object'] || $_SESSION['is_file_object'])
390 {
391
392 $this->ctrl->redirectByClass('ilShopShoppingCartGUI', '');
393 }
394 else
395 {
396 # $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
397 $this->ctrl->redirectByClass('ilShopShoppingCartGUI', '');
398 }
399 }
400 else
401 {
402 switch ($res)
403 {
404 case ERROR_WRONG_CUSTOMER : ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_error_wrong_customer').'<br />'.$this->lng->txt('pay_paypal_error_info'));
405 break;
406 case ERROR_NOT_COMPLETED : ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_error_not_completed').'<br />'.$this->lng->txt('pay_paypal_error_info'));
407 break;
408 case ERROR_PREV_TRANS_ID : ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_error_prev_trans_id').'<br />'.$this->lng->txt('pay_paypal_error_info'));
409 break;
410 case ERROR_WRONG_VENDOR : ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_error_wrong_vendor').'<br />'.$this->lng->txt('pay_paypal_error_info'));
411 break;
412 case ERROR_WRONG_ITEMS : ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_error_wrong_items').'<br />'.$this->lng->txt('pay_paypal_error_info'));
413 break;
414 case ERROR_FAIL : ilUtil::sendFailure($this->lng->txt('pay_paypal_failed').'<br />'.$this->lng->txt('pay_paypal_error_fails').'<br />'.$this->lng->txt('pay_paypal_error_info'));
415 break;
416 }
417 $this->showItems();
418 }
419 fclose($fp);
420 }
421 }
422
423
424 public function cancelEPay()
425 {
426// ilUtil::sendInfo($this->lng->txt('pay_epay_canceled'));
427// $this->showItems();
428 }
429
430 public function cancelPaypal()
431 {
432 ilUtil::sendInfo($this->lng->txt('pay_paypal_canceled'));
433 $this->showItems();
434 }
435
436 private function _getPayMethods( $limitToEnabled = false )
437 {
438 $objPM = new ilPayMethods();
439 $get_paymethods = $objPM->readAll();
440
441 if(!$limitToEnabled)
442 {
443 foreach($get_paymethods as $pm)
444 {
445 $pay_methods[$pm['pm_id']]['pm_title'] = $pm['pm_title'];
446 $pay_methods[$pm['pm_id']]['pm_id'] = $pm['pm_id'];
447 $pay_methods[$pm['pm_id']]['pm_enabled'] = $pm['pm_enabled'];
448 $pay_methods[$pm['pm_id']]['save_usr_adr'] = $pm['save_usr_adr'];
449 }
450 }
451 else
452 {
453 foreach($get_paymethods as $pm)
454 {
455 if($pm['pm_enabled'] == 1)
456 {
457 $pay_methods[$pm['pm_id']]['pm_title'] = $pm['pm_title'];
458 $pay_methods[$pm['pm_id']]['pm_id'] = $pm['pm_id'];
459 $pay_methods[$pm['pm_id']]['pm_enabled'] = $pm['pm_enabled'];
460 $pay_methods[$pm['pm_id']]['save_usr_adr'] = $pm['save_usr_adr'];
461 }
462 }
463 }
464 return $pay_methods;
465 }
466
467 /*
468 *
469 */
470 private function _getTemplateFilename( $a_pm_title )
471 {
472 // use payment_paymethods -> pm_title
473 $base = "./Services/Payment/templates/default/tpl.pay_shopping_cart_";
474 $suffix = ".html";
475
476 return $base . $a_pm_title . $suffix;
477 }
478
480 {
481 if(isset($_GET['user']))
482 {
483 $_SESSION['shop_user_id'] = (int)$_GET['user'];
484 }
485 $_SESSION['forceShoppingCartRedirect'] ='1';
487 $this->user_obj = new ilObjUser($_SESSION['shop_user_id']);
488
489 $this->showItems();
490 }
491
492 public function showItems()
493 {
494 global $ilObjDataCache, $ilUser, $ilToolbar;
495
496 include_once './Services/Payment/classes/class.ilPaymentPrices.php';
497 include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
498
499 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_shopping_cart.html','Services/Payment');
500// var_dump($_SESSION['shop_user_id']);
501// if(isset($_SESSION['shop_user_id']))
502// {
503//
504// $this->user_obj->_toggleActiveStatusOfUsers(array($this->user_obj->getId()), 1);
505// }
506
507 if($_SESSION['forceShoppingCartRedirect'] == '1')
508// && $this->user_obj->getId() != ANONYMOUS_USER_ID)
509 {
510 $_SESSION['forceShoppingCartRedirect'] = 0;
511 $this->tpl->touchBlock("close_js");
512 return true;
513 }
514
515 $this->initShoppingCartObject();
516
517 include_once './Services/Payment/classes/class.ilPaymentSettings.php';
519 $pay_methods = $this->_getPayMethods( true );
520 $num_items = 0;
521 $desc = array();
522
523 //course_objects
524 $is_crs_object = false;
525 $crs_obj_ids = array();
526
527 //file_objects,exercise_objects
528 $is_file_object = false;
529
530 // learning_modules,
531 $is_lm_object = false;
532 $lm_obj_ids = array();
533
534 if($genSet->get('show_sr_shoppingcart') == 1)
535 {
536 require_once 'Services/RTE/classes/class.ilRTE.php';
537 $regulations = ilRTE::_replaceMediaObjectImageSrc($genSet->get('statutory_regulations'),1);
538 $this->tpl->setVariable('REGULATIONS_TITLE', $this->lng->txt('statutory_regulations'));
539 $this->tpl->setVariable('REGULATIONS', $regulations);
540 }
541
542 $ilToolbar->addButton($this->lng->txt('payment_back_to_shop'),'ilias.php?baseClass=ilShopController');
543
544 foreach($pay_methods as $pay_method)
545 {
546 $this->totalVat = 0;
547 $tpl = new ilTemplate( $this->_getTemplateFilename( $pay_method['pm_title'] ), true,'Services/Payment');
548 $coupon_session_id = $pay_method['pm_title'];
549
550 if (count($items = $this->psc_obj->getEntries( $pay_method['pm_id'])))
551 {
552 $counter = 0;
553 $paypal_counter = 0;
554 $total_price = 0;
555
556 foreach ($items as $item)
557 {
558 $tmp_pobject = new ilPaymentObject($this->user_obj,$item['pobject_id']);
559
560 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
561 $obj_type = $ilObjDataCache->lookupType($obj_id);
562 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
563 $desc[] = "[" . $obj_type . "] " . $obj_title;
564 $price_arr = ilPaymentPrices::_getPrice($item['price_id']);
565
566 # checks object_type: needed for purchasing file or crs objects without login
567 switch ($obj_type)
568 {
569 case 'crs':
570 // if is_crs there an user-account will be autogenerated
571 $is_crs_object = true;
572 $_SESSION['is_crs_object'] = true;
573 $crs_obj_ids[] = $obj_id;
574 $_SESSION['crs_obj_ids'] = $crs_obj_ids;
575 break;
576 case 'lm':
577 case 'sahs':
578 case 'htlm':
579 case 'tst':
580 $is_lm_object = true;
581 $_SESSION['is_lm_object'] = true;
582 $lm_obj_ids[] = $obj_id;
583 $_SESSION['lm_obj_ids'] = $lm_obj_ids;
584 break;
585
586 case 'exc':
587 case 'file':
588 $is_file_object = true;
589 break;
590 default:
591
592 break;
593 }
594
595 $direct_paypal_info_output = true;
596
597 $assigned_coupons = '';
598 if (!empty($_SESSION['coupons'][$coupon_session_id]))
599 {
600 $price = $price_arr['price'];
601 $item['math_price'] = (float) $price;
602
603 foreach ($_SESSION['coupons'][$coupon_session_id] as $key => $coupon)
604 {
605 $this->coupon_obj->setId($coupon['pc_pk']);
606 $this->coupon_obj->setCurrentCoupon($coupon);
607
608 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
609 {
610 $assigned_coupons .= $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon['pcc_code'];
611
612 $_SESSION['coupons'][$coupon_session_id][$key]['total_objects_coupon_price'] += (float) $price;
613 $_SESSION['coupons'][$coupon_session_id][$key]['items'][] = $item;
614 $direct_paypal_info_output = false;
615 }
616 }
617 }
618
619 $f_result[$counter]['item'] = ilUtil::formCheckBox(0,'item[]',$item['psc_id']);
620 $subtype = '';
621 if($obj_type == 'exc')
622 {
623 $subtype = ' ('.$this->lng->txt($tmp_pobject->getSubtype()).')';
624 $f_result[$counter]['title'] = "<a href=\"goto.php?target=".$obj_type."_".$tmp_pobject->getRefId() . "\">".$obj_title."</a>".$subtype ;
625 }
626 else
627 $f_result[$counter]['title'] = "<a href=\"ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=".$tmp_pobject->getRefId() . "\">".$obj_title."</a>".$subtype ;
628
629 if ($assigned_coupons != '')
630 {
631 // !!! $f_result[$counter][count($f_result[$counter]) - 1] .= $assigned_coupons;
632 $f_result[$counter]['assigned_coupons'] .= $assigned_coupons;
633 }
634
635 switch($price_arr['price_type'])
636 {
638 $f_result[$counter]['duration'] = $price_arr['duration'].' '.$this->lng->txt('paya_months');
639 break;
641 $f_result[$counter]['duration'] =
642 ilDatePresentation::formatDate(new ilDate($price_arr['duration_from'], IL_CAL_DATE))
643 .' - '.ilDatePresentation::formatDate(new ilDate($price_arr['duration_until'], IL_CAL_DATE));
644 break;
646 $f_result[$counter]['duration'] = $this->lng->txt('unlimited_duration');
647 break;
648 }
649
650 $float_price = $price_arr['price'];
651 $total_price += $float_price;
652
653 $oVAT = new ilShopVats((int)$tmp_pobject->getVatId());
654 $f_result[$counter]['vat_rate'] = ilShopUtils::_formatVAT($oVAT->getRate());
655
656 $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price);
657
658 $f_result[$counter]['price'] = ilPaymentPrices::_getPriceString($item['price_id']).' '.$genSet->get('currency_unit');
659 $f_result[$counter]['vat_unit'] = ilPaymentPrices::_getGUIPrice($tmp_pobject->getVat($float_price, 'CALCULATION'))
660 .' '.$genSet->get('currency_unit');
661
662 if ($pay_method['pm_title'] == 'paypal')
663 {
664 if ($direct_paypal_info_output == true) // Paypal information in hidden fields
665 {
666 $tpl->setCurrentBlock('loop_items');
667 $tpl->setVariable('LOOP_ITEMS_NO', (++$paypal_counter));
668 $tpl->setVariable('LOOP_ITEMS_NAME', "[".$obj_id."]: ".$obj_title);
669 $tpl->setVariable('LOOP_ITEMS_AMOUNT', $float_price);
670 $tpl->parseCurrentBlock('loop_items');
671 }
672 }
673
674 ++$counter;
675 unset($tmp_pobject);
676 } // foreach
677
678 $this->showItemsTable($tpl, $f_result, $pay_method);
679
680 if (!(bool)$genSet->get('hide_coupons'))
681 {
682 $tpl->setVariable('COUPON_TABLE', $this->showCouponInput($pay_method['pm_title']));
683 }
684 $tpl->setCurrentBlock('buy_link');
685 # $tpl->setCurrentBlock('terms_checkbox');
686
687 $link_target = $this->ctrl->getLinkTargetByClass('iltermsconditionsgui','');
688 $terms_link = '<a href="'.$link_target.'">'.$this->lng->txt('terms_conditions').'</a>';
689 $tpl->setVariable('TERMS_CONDITIONS', sprintf($this->lng->txt('accept_terms_conditions'), $terms_link));
690
691 switch($pay_method['pm_title'])
692 {
693 case 'bill':
694 if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID == $this->user_obj->getId())
695 {
696 $tpl->setVariable('TXT_UNLOCK', $this->lng->txt('pay_click_to_buy'));
697 $tpl->setVariable('LINK_UNLOCK', $this->ctrl->getLinkTarget($this, 'unlockBillObjectsInShoppingCart'));
698 }
699 else
700 {
701 # Anonymous user has to login
702 if(ANONYMOUS_USER_ID == $this->user_obj->getId())
703 {
704 ilUtil::sendInfo($this->lng->txt('click_to_continue_info'));
705 $tpl->touchBlock('attach_submit_event_bill');
706 $tpl->setVariable('TXT_BUY', $this->lng->txt('continue'));
707 $tpl->setVariable('SCRIPT_LINK','login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
708 }
709 else
710 {
711 ilUtil::sendInfo($this->lng->txt('click_to_buy_info'));
712 $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
713 $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTargetByClass('ilPurchaseBillGUI', ''));
714 $tpl->parseCurrentBlock('terms_checkbox');
715 }
716 }
717 break;
718
719 case 'bmf':
720 #$tpl->setVariable("SCRIPT_LINK", './payment.php?view=start_bmf');
721 if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId())
722 {
723 $tpl->setVariable('TXT_UNLOCK', $this->lng->txt('pay_click_to_buy'));
724 $tpl->setVariable('LINK_UNLOCK', $this->ctrl->getLinkTarget($this, 'unlockBMFObjectsInShoppingCart'));
725 }
726 else
727 {
728 # Anonymous user has to login
729 if(ANONYMOUS_USER_ID == $this->user_obj->getId())
730 {
731 ilUtil::sendInfo($this->lng->txt('click_to_continue_info'));
732 $tpl->setVariable('TXT_BUY', $this->lng->txt('continue'));
733 $tpl->setVariable('SCRIPT_LINK','login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
734 }
735 else
736 {
737 $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
738 $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTargetByClass('ilPurchaseBMFGUI', ''));
739 }
740 }
741 break;
742
743 case 'epay':
744 # Anonymous user has to login
745// if(ANONYMOUS_USER_ID == $ilUser->getId())
746// {
747// $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
748// $tpl->setVariable('SCRIPT_LINK','login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
749// }
750// else
751// {
752// /// http://uk.epay.dk/support/docs.asp?solution=2#pfinput
753// $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
754// $tpl->setVariable('SCRIPT_LINK', 'https://'.$this->epayConfig['server_host'].$this->epayConfig['server_path']);
755// $tpl->setVariable('MERCHANT_NUMBER', $this->epayConfig['merchant_number']);
756// $tpl->setVariable('AMOUNT', $total_price * 100);
757// $tpl->setVariable('CURRENCY', "208");
758// $tpl->setVariable('ORDERID', $ilUser->getId()."_".uniqid());
759// $tpl->setVariable('ACCEPT_URL', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'finishEPay'));
760// $tpl->setVariable('DECLINE_URL', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'cancelEPay'));
761// $tpl->setVariable('INSTANT_CAPTURE', $this->epayConfig['instant_capture'] ? "1" : "0");
762// $tpl->setVariable('ADDFEE', 1);
763// $tpl->setVariable('LANGUAGE', 1);
764// $tpl->setVariable('GROUP', "");
765// $tpl->setVariable('CARDTYPE', "");
766// $tpl->setVariable("CALLBACK_URL", ILIAS_HTTP_PATH . "/Services/Payment/classes/class.ilCallback.php?ilUser=" .$ilUser->getId() . "&pay_method=". PAY_METHOD_EPAY);
767//
768// $tpl->setVariable('DESCRIPTION', $ilUser->getFullName() . " (" . $ilUser->getEmail() . ") #" . $ilUser->getId() . " " . implode(",", $desc));
769// $tpl->setVariable('AUTH_MAIL', $this->epayConfig['auth_email']);
770// $tpl->setVariable('MD5KEY', $this->epSet->generateKeyForEpay(208, $total_price*100, $ilUser->getId()."_".uniqid()));
771// }
772 break;
773
774 case 'paypal':
775 if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId())
776 {
777 $tpl->touchBlock('attach_submit_event');
778 $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
779 $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTarget($this, 'unlockPAYPALObjectsInShoppingCart'));
780 }
781 else
782 {
783 if(ANONYMOUS_USER_ID == $this->user_obj->getId())# && $force_user_login == true)
784 {
785 ilUtil::sendInfo($this->lng->txt('click_to_continue_info'));
786 $tpl->touchBlock('attach_submit_event');
787 $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
788 $tpl->setVariable('SCRIPT_LINK','login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
789 }
790 else
791 {
792 $tpl->setCurrentBlock('terms_checkbox');
793 ilUtil::sendInfo($this->lng->txt('click_to_buy_info'));
794 $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
795 $tpl->setVariable('SCRIPT_LINK', 'https://'.$this->paypalConfig['server_host'].$this->paypalConfig['server_path']);
796 $tpl->parseCurrentBlock('terms_checkbox');
797 }
798 }
799
800 $tpl->setVariable('POPUP_BLOCKER', $this->lng->txt('popup_blocker'));
801 $tpl->setVariable('VENDOR', $this->paypalConfig['vendor']);
802 $tpl->setVariable('RETURN', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'finishPaypal'));
803 $tpl->setVariable('CANCEL_RETURN', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'cancelPaypal'));
804 $tpl->setVariable('CUSTOM', $this->user_obj->getId());
805 $tpl->setVariable('CURRENCY', $genSet->get('currency_unit'));
806 $tpl->setVariable('PAGE_STYLE', $this->paypalConfig['page_style']);
807
808 if (!empty($_SESSION['coupons'][$coupon_session_id]))
809 {
810 $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION['coupons'][$coupon_session_id]);
811
812 if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
813 {
814 foreach ($coupon_discount_items as $item)
815 {
816 $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']);
817
818 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
819 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
820
821 $tmp_amount = round($item['discount_price'], 2);
822 $loop_items_amount = str_replace(',','.',$tmp_amount);
823
824 $tpl->setCurrentBlock('loop_items');
825 $tpl->setVariable('LOOP_ITEMS_NO', (++$paypal_counter));
826 $tpl->setVariable('LOOP_ITEMS_NAME', "[".$obj_id."]: ".$obj_title);
827 $tpl->setVariable('LOOP_ITEMS_AMOUNT',$loop_items_amount );
828
829 $tpl->parseCurrentBlock('loop_items');
830
831 unset($tmp_pobject);
832 }
833 }
834 }
835 break;
836 }
837
838 if ($pay_method['pm_title'] == 'paypal')
839 {
840 $tpl->setVariable('PAYPAL_HINT', $this->lng->txt('pay_hint_paypal'));
841 $tpl->setVariable('PAYPAL_INFO', $this->lng->txt('pay_info_paypal'));
842 }
843 else if ($pay_method['pm_title'] == 'epay')
844 {
845 $tpl->setVariable('EPAY_HINT', $this->lng->txt('pay_hint_epay'));
846 $tpl->setVariable('EPAY_INFO', $this->lng->txt('pay_info_epay'));
847 }
848
849 $tpl->parseCurrentBlock('buy_link');
850
851 $tpl->setCurrentBlock('loop');
852 unset($f_result);
853
854 $tpl->parseCurrentBlock('loop');
855
856 $this->tpl->setVariable(''.strtoupper($pay_method['pm_title']).'', $tpl->get());
857
858 $num_items += $counter;
859 }
860 }
861
862 if ($num_items == 0)
863 {
864 # ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
865 return false;
866 }
867 return true;
868 }
869
870 public function removeCoupon()
871 {
872 if (is_array($_SESSION['coupons']))
873 {
874 foreach ($_SESSION['coupons'] as $key => $val)
875 {
876 unset($_SESSION['coupons'][$key][$_GET['coupon_id']]);
877 }
878 }
879
880 $this->showItems();
881 return true;
882 }
883
884 public function setCoupon()
885 {
886 if ($_POST['coupon_code'] != '')
887 {
888 $coupon = $this->coupon_obj->getCouponByCode($_POST['coupon_code']);
889 switch ($this->coupon_obj->checkCouponValidity())
890 {
891 case 1:
892 case 2:
893 ilUtil::sendInfo($this->lng->txt('paya_coupons_not_valid'));
894 $this->showItems();
895 return true;
896 case 3:
897 ilUtil::sendInfo($this->lng->txt('paya_coupons_coupon_not_found'));
898 $this->showItems();
899 return true;
900 }
901 $assignedItems = 0;
902 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
903 if (count($items = $this->psc_obj->getEntries(isset($_POST['payment_type']) ? $_POST['payment_type'] : 'bmf')))
904 {
905 foreach($items as $item)
906 {
907 $tmp_pobject = new ilPaymentObject($this->user_obj,$item['pobject_id']);
908 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
909 {
910 ++$assignedItems;
911 }
912 }
913 }
914 if (!$assignedItems)
915 {
916 ilUtil::sendInfo($this->lng->txt('paya_coupons_no_object_assigned'));
917 $this->showItems();
918 return true;
919 }
920 $coupon_session_id = $_POST['payment_type'];
921 if (!array_key_exists($coupon['pc_pk'], $_SESSION['coupons'][$coupon_session_id]))
922 {
923 if (is_array($_SESSION['coupons']))
924 {
925 foreach ($_SESSION['coupons'] as $key => $val)
926 {
927 unset($_SESSION['coupons'][$key][$coupon['pc_pk']]);
928 }
929 }
930 ilUtil::sendInfo($this->lng->txt('paya_coupons_coupon_added'));
931 $_SESSION['coupons'][$coupon_session_id][$coupon['pc_pk']] = $coupon;
932 }
933 else
934 {
935 ilUtil::sendInfo($this->lng->txt('paya_coupons_already_in_use'));
936 }
937 $this->showItems();
938 return true;
939 }
940 $this->showItems();
941 return true;
942 }
943/*
944 *
945 * @param string $payment_type pm_title
946 *
947 */
948 private function showCouponInput($payment_type = '')
949 {
950 include_once './Services/Payment/classes/class.ilPaymentSettings.php';
952
953 $tpl = new ilTemplate('tpl.pay_shopping_cart_coupons.html', true, true, 'Services/Payment');
954
955 $tpl->setVariable('COUPON_FORMACTION', $this->ctrl->getFormAction($this));
956 $tpl->setVariable('TITLE', $this->lng->txt('paya_coupons_coupons'));
957 $tpl->setVariable('TYPE_IMG', ilObject::_getIcon('', '', 'pays'));
958 $tpl->setVariable('ALT_IMG', $this->lng->txt('obj_usr'));
959
960 $tpl->setVariable('TXT_CODE', $this->lng->txt('paya_coupons_code'));
961 $tpl->setVariable('CMD_VALUE', $this->lng->txt('send'));
962 $tpl->setVariable('CMD', 'setCoupon');
963
964 $tpl->setVariable('PAYMENT_TYPE', $payment_type);
965
966 $coupon_session = $payment_type;
967
968 if (!empty($_SESSION['coupons'][$coupon_session]))
969 {
970 $i = 0;
971 foreach ($_SESSION['coupons'][$coupon_session] as $coupon)
972 {
973 $tpl->setCurrentBlock('loop');
974 $tpl->setVariable('LOOP_ROW', ilUtil::switchColor($i++, '1', '2'));
975 $tpl->setVariable('LOOP_TXT_COUPON', $this->lng->txt('paya_coupons_coupon'));
976 $tpl->setVariable('LOOP_CODE', $coupon['pcc_code']);
977 $this->ctrl->setParameter($this, 'coupon_id', $coupon['pc_pk']);
978 $this->ctrl->setParameter($this, 'payment_type', $_SESSION['bmf']['payment_type']);
979 $tpl->setVariable('LOOP_TITLE', $coupon['pc_title']);
980 if ($coupon['pc_description'] != '') $tpl->setVariable('LOOP_DESCRIPTION', nl2br($coupon['pc_description']));
981 $tpl->setVariable("LOOP_TYPE",
982 sprintf($this->lng->txt('paya_coupons_'.($coupon['pc_type'] == "fix" ? 'fix' : 'percentaged').'_'.(count($coupon['objects']) == 0 ? 'all' : 'selected').'_objects'),
983 (((float)$coupon['pc_value'] / round($coupon['pc_value'], 2) == 1 && $coupon['pc_type'] == "percent")
984 ? round($coupon['pc_value'], 2)
985 : number_format($coupon['pc_value'], 2, ',', '.')),
986 ($coupon['pc_type'] == "percent" ? "%" :$genSet->get('currency_unit'))));
987 $tpl->setVariable("LOOP_REMOVE", "<div class=\"il_ContainerItemCommands\" style=\"float: right;\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this, 'removeCoupon')."\">".$this->lng->txt('remove')."</a></div>");
988
989 $tpl->parseCurrentBlock();
990 }
991 }
992
993 return $tpl->get();
994 }
995/*
996 *
997 * @param array $a_pay_method
998 *
999 */
1000 private function showItemsTable(&$a_tpl, $a_result_set, $a_pay_method = 0)
1001 {
1002 include_once './Services/Payment/classes/class.ilPaymentSettings.php';
1004
1005 include_once './Services/Payment/classes/class.ilShoppingCartTableGUI.php';
1006
1007 $tbl = new ilShoppingCartTableGUI($this);
1008 $tbl->setId('tbl_id_'.$a_pay_method);
1009 $tbl->setTitle($this->lng->txt('paya_shopping_cart').
1010 " (".$this->lng->txt('payment_system').": ".
1011 ilPayMethods::getStringByPaymethod($a_pay_method['pm_title']) .")");
1012
1013 $coupon_session = $a_pay_method['pm_title'];
1014
1015 $tbl->setRowTemplate("tpl.shop_shoppingcart_row.html", "Services/Payment");
1016 $tbl->addColumn('', 'item', '1%', true);
1017 $tbl->addColumn($this->lng->txt('title'), "table". $a_pay_method['pm_title']."_title", '30%');
1018 $tbl->addColumn($this->lng->txt('duration'), "table". $a_pay_method['pm_title']."_duration", '30%');
1019 $tbl->addColumn($this->lng->txt('vat_rate'), "table". $a_pay_method['pm_title']."_vat_rate", '15%');
1020 $tbl->addColumn($this->lng->txt('vat_unit'), "table". $a_pay_method['pm_title']."_vat_unit", '15%');
1021 $tbl->addColumn($this->lng->txt('price_a'), "table". $a_pay_method['pm_title']."_price", '10%');
1022
1023 $tbl->setPrefix("table". $a_pay_method['pm_title']."_");
1024 $tbl->addMultiCommand('deleteItem', $this->lng->txt('delete'));
1025
1026 // show total amount of costs
1027 $sc_obj = new ilPaymentShoppingCart($this->user_obj);
1028 $totalAmount = $sc_obj->getTotalAmount();
1029
1030 if (!empty($_SESSION['coupons'][$coupon_session]))
1031 {
1032 if (count($items = $sc_obj->getEntries($a_pay_method['pm_id'])))
1033 {
1034 $tbl->setTotalData('TXT_SUB_TOTAL', $this->lng->txt('pay_bmf_subtotal_amount') . ": ");
1035 $tbl->setTotalData('VAL_SUB_TOTAL', number_format($totalAmount[$a_pay_method['pm_id']], 2, ',', '.') . " " . $genSet->get('currency_unit'));
1036
1037 foreach ($_SESSION['coupons'][$coupon_session] as $coupon)
1038 {
1039 $this->coupon_obj->setId($coupon['pc_pk']);
1040 $this->coupon_obj->setCurrentCoupon($coupon);
1041
1042 $total_object_price = 0.0;
1043 $current_coupon_bonus = 0.0;
1044
1045 foreach ($items as $item)
1046 {
1047 $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']);
1048
1049 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
1050 {
1051 $price_data = ilPaymentPrices::_getPrice($item['price_id']);
1052 $price = (float) $price_data['price'];
1053
1054 $total_object_price += $price;
1055 }
1056 unset($tmp_pobject);
1057 }
1058
1059 $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
1060 $totalAmount[$current_coupon_bonus] += $current_coupon_bonus * (-1);
1061 }
1062 $tbl->setTotalData('TXT_COUPON_BONUS', $this->lng->txt('paya_coupons_coupon') . ": ");# . $coupon['pcc_code'] . ": ");
1063 #$tbl->setTotalData('VAL_COUPON_BONUS', number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get('currency_unit'));
1064 $tbl->setTotalData('VAL_COUPON_BONUS', number_format($totalAmount[$current_coupon_bonus], 2, ',', '.') . " " . $genSet->get('currency_unit'));
1065
1066 if ($totalAmount[$a_pay_method['pm_id']] < 0)
1067 {
1068 $totalAmount[$a_pay_method['pm_id']] = 0;
1069 $this->totalVat = 0;
1070 }
1071 }
1072 }
1073
1074 $this->totalAmount[$a_pay_method['pm_id']] = $totalAmount[$a_pay_method['pm_id']]-($totalAmount[$current_coupon_bonus] * (-1));
1075 $tbl->setTotalData('TXT_TOTAL_AMOUNT', $this->lng->txt('pay_bmf_total_amount').": ");
1076 $tbl->setTotalData('VAL_TOTAL_AMOUNT', number_format($this->totalAmount[$a_pay_method['pm_id']] , 2, ',', '.') . " " . $genSet->get('currency_unit')); #.$item['currency']);
1077
1078 if ($this->totalVat > 0)
1079 {
1080 $tbl->setTotalData('TXT_TOTAL_VAT', $this->lng->txt('pay_bmf_vat_included') . ": ");
1081 $tbl->setTotalData('VAL_TOTAL_VAT', number_format($this->totalVat , 2, ',', '.') . " " . $genSet->get('currency_unit'));
1082 }
1083
1084 $tbl->setData($a_result_set);
1085 $a_tpl->setVariable('ITEMS_TABLE',$tbl->getCartHTML());
1086
1087 return true;
1088 }
1089
1090 public function deleteItem()
1091 {
1092 if(!count($_POST['item']))
1093 {
1094 ilUtil::sendInfo($this->lng->txt('pay_select_one_item'));
1095
1096 $this->showItems();
1097 return true;
1098 }
1099 $this->initShoppingCartObject();
1100
1101 foreach($_POST['item'] as $id)
1102 {
1103 $this->psc_obj->delete($id);
1105 }
1106 ilUtil::sendInfo($this->lng->txt('pay_deleted_items'));
1107 $this->showItems();
1108
1109 return true;
1110 }
1111
1112 private function initShoppingCartObject()
1113 {
1114 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
1115 $this->psc_obj->clearCouponItemsSession();
1116 }
1117
1118 private function initPaypalObject()
1119 {
1120 include_once './Services/Payment/classes/class.ilPurchasePaypal.php';
1121 $this->paypal_obj = new ilPurchasePaypal($this->user_obj);
1122 }
1123
1130 private function encryptButton($buttonParams)
1131 {
1132 $merchant_cert = $this->paypalConfig["vendor_cert"];
1133 $merchant_key = $this->paypalConfig["vendor_key"];
1134 $end_cert = $this->paypalConfig["enc_cert"];
1135
1136 $tmpin_file = tempnam('/tmp', 'paypal_');
1137 $tmpout_file = tempnam('/tmp', 'paypal_');
1138 $tmpfinal_file = tempnam('/tmp', 'paypal_');
1139
1140 $rawdata = array();
1141 $buttonParams['cert_id'] = $this->paypalConfig["cert_id"];
1142 foreach ($buttonParams as $name => $value) {
1143 $rawdata[] = "$name=$value";
1144 }
1145 $rawdata = implode("\n", $rawdata);
1146
1147 $fp = fopen($tmpin_file, 'w');
1148 if (!$fp) {
1149 echo "Could not open temporary file '$tmpin_file')";
1150 return false;
1151# return PayPal::raiseError("Could not open temporary file '$tmpin_file')");
1152 }
1153 fwrite($fp, $rawdata);
1154 fclose($fp);
1155
1156 if (!@openssl_pkcs7_sign($tmpin_file, $tmpout_file, $merchant_cert,
1157 array($merchant_key, $this->paypalConfig["private_key_password"]),
1158 array(), PKCS7_BINARY)) {
1159 echo "Could not sign encrypted data: " . openssl_error_string();
1160 return false;
1161# return PayPal::raiseError("Could not sign encrypted data: " . openssl_error_string());
1162 }
1163
1164 $data = file_get_contents($tmpout_file);
1165 $data = explode("\n\n", $data);
1166 $data = $data[1];
1167 $data = base64_decode($data);
1168 $fp = fopen($tmpout_file, 'w');
1169 if (!$fp) {
1170 echo "Could not open temporary file '$tmpin_file')";
1171 return false;
1172# return PayPal::raiseError("Could not open temporary file '$tmpin_file')");
1173 }
1174 fwrite($fp, $data);
1175 fclose($fp);
1176
1177 if (!@openssl_pkcs7_encrypt($tmpout_file, $tmpfinal_file, $end_cert, array(), PKCS7_BINARY)) {
1178 echo "Could not encrypt data:" . openssl_error_string();
1179 return false;
1180# return PayPal::raiseError("Could not encrypt data:" . openssl_error_string());
1181 }
1182
1183 $encdata = @file_get_contents($tmpfinal_file, false);
1184 if (!$encdata) {
1185 echo "Encryption and signature of data failed.";
1186 return false;
1187# return PayPal::raiseError("Encryption and signature of data failed.");
1188 }
1189
1190 $encdata = explode("\n\n", $encdata);
1191 $encdata = trim(str_replace("\n", '', $encdata[1]));
1192 $encdata = "-----BEGIN PKCS7-----$encdata-----END PKCS7-----";
1193
1194 @unlink($tmpfinal_file);
1195 @unlink($tmpin_file);
1196 @unlink($tmpout_file);
1197
1198 return $encdata;
1199 }
1200}
1201?>
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_CAL_DATE
const ERROR_PREV_TRANS_ID
const SUCCESS
const ERROR_WRONG_ITEMS
const ERROR_FAIL
const ERROR_WRONG_VENDOR
const ERROR_WRONG_CUSTOMER
const ERROR_NOT_COMPLETED
static formatDate(ilDateTime $date)
Format a date @access public.
Class for single dates.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Class ilObjPaymentSettingsGUI.
static getStringByPaymethod($a_type)
static _getIdByTitle($a_pm_title)
static _getGUIPrice($a_price)
static _getPriceString($a_price_id)
static _getPrice($a_price_id)
static _assignObjectsToUserId($a_user_id)
static getInstance()
Static method to get the singleton instance.
Class class.ilPurchaseBaseGUI.php.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Class ilShopBaseGUI.
Class ilShopShoppingCartGUI.
encryptButton($buttonParams)
Creates a new encrypted button HTML block.
showItemsTable(&$a_tpl, $a_result_set, $a_pay_method=0)
_getPayMethods( $limitToEnabled=false)
addBookings($pay_method, $coupon_session)
static _formatVAT($a_vat)
Formats a vat rate for gui output.
Class ilShopVats.
Class ilShoppingCartTableGUI.
special template class to simplify handling of ITX/PEAR
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
$data
$tbl
Definition: example_048.php:81
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15