6 include_once
'./Services/Payment/classes/class.ilShopBaseGUI.php';
7 include_once
'./Services/Payment/classes/class.ilPaypalSettings.php';
9 include_once
'./Services/Payment/classes/class.ilPaymentCoupons.php';
10 include_once
'./Services/Payment/classes/class.ilShopVatsList.php';
11 include_once
'./Services/Payment/classes/class.ilPaymentShoppingCart.php';
12 include_once
'./Services/Payment/classes/class.ilPayMethods.php';
14 include_once
'./Services/Payment/classes/class.ilPaymentCurrency.php';
15 include_once
'./Services/Payment/classes/class.ilShopBoughtObjectsGUI.php';
36 #private $default_currency = 1; 43 parent::__construct();
54 else if($ilUser->getId() != ANONYMOUS_USER_ID)
61 $this->session_id = session_id();
67 $this->paypalConfig = $ppSet->getAll();
74 #$this->default_currency = ilPaymentCurrency::_getDefaultCurrency(); 82 $cmd = $this->ctrl->getCmd();
83 $next_class = $this->ctrl->getNextClass($this);
89 if (!
$cmd = $this->ctrl->getCmd())
104 parent::prepareOutput();
106 $ilTabs->setTabActive(
'paya_shopping_cart');
110 include_once
'./Services/Payment/classes/class.ilPurchaseBaseGUI.php';
112 $purchase->__addBookings();
114 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
125 $_SESSION[
'bmf'][
'debit_entry'] = array();
126 $_SESSION[
'bmf'][
'credit_card'] = array();
130 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
137 include_once
'./Services/Payment/classes/class.ilPurchaseBaseGUI.php';
139 $purchase->__addBookings();
142 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
149 global
$ilUser, $ilObjDataCache;
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';
158 $sc_obj->clearCouponItemsSession();
160 foreach($items as $entry)
165 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
167 $entry[
'math_price'] = $entry[
'price'];
168 foreach (
$_SESSION[
'coupons'][$coupon_session] as $key => $coupon)
170 $this->coupon_obj->setId($coupon[
'pc_pk']);
171 $this->coupon_obj->setCurrentCoupon($coupon);
173 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
175 $_SESSION[
'coupons'][$coupon_session][$key][
'total_objects_coupon_price'] += $entry[
'price'];
176 $_SESSION[
'coupons'][$coupon_session][$key][
'items'][] = $entry;
183 $coupon_discount_items = $sc_obj->calcDiscountPrices(
$_SESSION[
'coupons'][$coupon_session]);
185 foreach($items as $entry)
191 if (array_key_exists($entry[
'pobject_id'], $coupon_discount_items))
193 $bonus = $coupon_discount_items[$entry[
'pobject_id']][
'math_price'] - $coupon_discount_items[$entry[
'pobject_id']][
'discount_price'];
196 $booking_obj->setPobjectId($entry[
'pobject_id']);
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']);
204 $booking_obj->setDiscount($bonus > 0 ? ((-1) * $bonus) : 0);
205 $booking_obj->setPayed(1);
206 $booking_obj->setAccess(1);
208 switch($price[
'price_type'])
211 $booking_obj->setDuration(0);
214 $booking_obj->setDuration($price[
'duration']);
217 $booking_obj->setAccessStartdate($price[
'duration_from']);
218 $booking_obj->setAccessEnddate($price[
'duration_until']);
222 $booking_obj->setAccessExtension($price[
'extension']);
224 $obj_id = $ilObjDataCache->lookupObjId($pobject->getRefId());
225 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
227 $oVAT =
new ilShopVats((
int)$pobject->getVatId());
228 $obj_vat_rate = $oVAT->
getRate();
232 $tmp_price = $booking_obj->getPrice()-$bonus;
233 $obj_vat_unit = $pobject->getVat($tmp_price);
235 $obj_vat_unit = $pobject->getVat($booking_obj->getPrice());
237 $booking_obj->setObjectTitle($obj_title);
238 $booking_obj->setVatRate($obj_vat_rate);
239 $booking_obj->setVatUnit($obj_vat_unit);
241 if(ilPaymethods::_EnabledSaveUserAddress($booking_obj->getPayMethod()))
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());
249 $current_booking_id = $booking_obj->add();
251 if ($current_booking_id)
253 $sc_obj->delete($entry[
'psc_id']);
255 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
257 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
259 $this->coupon_obj->setId($coupon[
'pc_pk']);
260 $this->coupon_obj->setCurrentCoupon($coupon);
262 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
264 $this->coupon_obj->addCouponForBookingId($current_booking_id);
270 unset($current_booking_id);
274 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
276 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
278 $this->coupon_obj->setId($coupon[
'pc_pk']);
279 $this->coupon_obj->setCurrentCoupon($coupon);
280 $this->coupon_obj->addTracking();
288 $get_paymethods = $objPM->readAll();
290 foreach($get_paymethods as $pm)
292 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
293 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
296 if (is_array($pay_methods))
300 $coupon_session_id = $pay_method[
'pm_title'];
302 if (!is_array(
$_SESSION[
'coupons'][$coupon_session_id]))
304 $_SESSION[
'coupons'][$coupon_session_id] = array();
308 foreach (
$_SESSION[
'coupons'][$coupon_session_id] as $coupon_id => $session_coupon)
310 $coupon = $this->coupon_obj->getCouponByCode($session_coupon[
'pcc_code']);
312 if ($this->coupon_obj->checkCouponValidity() == 0)
317 if (count($items = $this->psc_obj->getEntries($pay_method[
'pm_id'])))
319 foreach($items as $item)
321 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
323 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
331 unset(
$_SESSION[
'coupons'][$coupon_session_id][$coupon_id]);
336 unset(
$_SESSION[
'coupons'][$coupon_session_id][$coupon_id]);
375 if (!($fp = $this->paypal_obj->openSocket()))
377 ilUtil::sendFailure($this->lng->txt(
'pay_paypal_failed').
'<br />'.$this->lng->txt(
'pay_paypal_unreachable').
'<br />'.$this->lng->txt(
'pay_paypal_error_info'));
383 $res = $this->paypal_obj->checkData($fp);
389 if($this->user_obj->getId() == ANONYMOUS_USER_ID ||
$_SESSION[
'is_crs_object'] ||
$_SESSION[
'is_lm_object'] ||
$_SESSION[
'is_file_object'])
392 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
396 # $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', ''); 397 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
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'));
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'));
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'));
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'));
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'));
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'));
439 $get_paymethods = $objPM->readAll();
443 foreach($get_paymethods as $pm)
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'];
453 foreach($get_paymethods as $pm)
455 if($pm[
'pm_enabled'] == 1)
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'];
473 $base =
"./Services/Payment/templates/default/tpl.pay_shopping_cart_";
476 return $base . $a_pm_title . $suffix;
481 if(isset(
$_GET[
'user']))
485 $_SESSION[
'forceShoppingCartRedirect'] =
'1';
494 global $ilObjDataCache,
$ilUser, $ilToolbar;
496 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
497 include_once
'./Services/Payment/classes/class.ilPaymentCurrency.php';
499 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.pay_shopping_cart.html',
'Services/Payment');
507 if(
$_SESSION[
'forceShoppingCartRedirect'] ==
'1')
510 $_SESSION[
'forceShoppingCartRedirect'] = 0;
511 $this->tpl->touchBlock(
"close_js");
517 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
524 $is_crs_object =
false;
525 $crs_obj_ids = array();
528 $is_file_object =
false;
531 $is_lm_object =
false;
532 $lm_obj_ids = array();
534 if($genSet->get(
'show_sr_shoppingcart') == 1)
536 require_once
'Services/RTE/classes/class.ilRTE.php';
538 $this->tpl->setVariable(
'REGULATIONS_TITLE', $this->lng->txt(
'statutory_regulations'));
539 $this->tpl->setVariable(
'REGULATIONS', $regulations);
542 $ilToolbar->addButton($this->lng->txt(
'payment_back_to_shop'),
'ilias.php?baseClass=ilShopController');
548 $coupon_session_id = $pay_method[
'pm_title'];
550 if (count($items = $this->psc_obj->getEntries( $pay_method[
'pm_id'])))
556 foreach ($items as $item)
558 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
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;
566 # checks object_type: needed for purchasing file or crs objects without login 571 $is_crs_object =
true;
573 $crs_obj_ids[] = $obj_id;
580 $is_lm_object =
true;
582 $lm_obj_ids[] = $obj_id;
588 $is_file_object =
true;
595 $direct_paypal_info_output =
true;
597 $assigned_coupons =
'';
598 if (!empty(
$_SESSION[
'coupons'][$coupon_session_id]))
600 $price = $price_arr[
'price'];
601 $item[
'math_price'] = (float) $price;
603 foreach (
$_SESSION[
'coupons'][$coupon_session_id] as $key => $coupon)
605 $this->coupon_obj->setId($coupon[
'pc_pk']);
606 $this->coupon_obj->setCurrentCoupon($coupon);
608 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
610 $assigned_coupons .= $this->lng->txt(
'paya_coupons_coupon') .
': ' . $coupon[
'pcc_code'];
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;
619 $f_result[$counter][
'item'] = ilUtil::formCheckBox(0,
'item[]',$item[
'psc_id']);
621 if($obj_type ==
'exc')
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 ;
627 $f_result[$counter][
'title'] =
"<a href=\"ilias.php?baseClass=ilRepositoryGUI&ref_id=".$tmp_pobject->getRefId() .
"\">".$obj_title.
"</a>".$subtype ;
629 if ($assigned_coupons !=
'')
632 $f_result[$counter][
'assigned_coupons'] .= $assigned_coupons;
635 switch($price_arr[
'price_type'])
638 $f_result[$counter][
'duration'] = $price_arr[
'duration'].
' '.$this->lng->txt(
'paya_months');
641 $f_result[$counter][
'duration'] =
646 $f_result[$counter][
'duration'] = $this->lng->txt(
'unlimited_duration');
650 $float_price = $price_arr[
'price'];
651 $total_price += $float_price;
653 $oVAT =
new ilShopVats((
int)$tmp_pobject->getVatId());
656 $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price);
660 .
' '.$genSet->get(
'currency_unit');
662 if ($pay_method[
'pm_title'] ==
'paypal')
664 if ($direct_paypal_info_output ==
true)
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');
680 if (!(
bool)$genSet->get(
'hide_coupons'))
684 $tpl->setCurrentBlock(
'buy_link');
685 # $tpl->setCurrentBlock('terms_checkbox'); 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));
691 switch($pay_method[
'pm_title'])
694 if ($this->totalAmount[$pay_method[
'pm_id']] <= 0 && ANONYMOUS_USER_ID == $this->user_obj->getId())
696 $tpl->setVariable(
'TXT_UNLOCK', $this->lng->txt(
'pay_click_to_buy'));
697 $tpl->setVariable(
'LINK_UNLOCK', $this->ctrl->getLinkTarget($this,
'unlockBillObjectsInShoppingCart'));
701 # Anonymous user has to login 702 if(ANONYMOUS_USER_ID == $this->user_obj->getId())
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');
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');
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())
723 $tpl->setVariable(
'TXT_UNLOCK', $this->lng->txt(
'pay_click_to_buy'));
724 $tpl->setVariable(
'LINK_UNLOCK', $this->ctrl->getLinkTarget($this,
'unlockBMFObjectsInShoppingCart'));
728 # Anonymous user has to login 729 if(ANONYMOUS_USER_ID == $this->user_obj->getId())
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');
737 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
738 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTargetByClass(
'ilPurchaseBMFGUI',
''));
744 # Anonymous user has to login 775 if ($this->totalAmount[$pay_method[
'pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId())
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'));
783 if(ANONYMOUS_USER_ID == $this->user_obj->getId())# && $force_user_login ==
true)
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');
792 $tpl->setCurrentBlock(
'terms_checkbox');
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');
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']);
808 if (!empty(
$_SESSION[
'coupons'][$coupon_session_id]))
810 $coupon_discount_items = $this->psc_obj->calcDiscountPrices(
$_SESSION[
'coupons'][$coupon_session_id]);
812 if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
814 foreach ($coupon_discount_items as $item)
816 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
818 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
819 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
821 $tmp_amount = round($item[
'discount_price'], 2);
822 $loop_items_amount = str_replace(
',',
'.',$tmp_amount);
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 );
829 $tpl->parseCurrentBlock(
'loop_items');
838 if ($pay_method[
'pm_title'] ==
'paypal')
840 $tpl->setVariable(
'PAYPAL_HINT', $this->lng->txt(
'pay_hint_paypal'));
841 $tpl->setVariable(
'PAYPAL_INFO', $this->lng->txt(
'pay_info_paypal'));
843 else if ($pay_method[
'pm_title'] ==
'epay')
845 $tpl->setVariable(
'EPAY_HINT', $this->lng->txt(
'pay_hint_epay'));
846 $tpl->setVariable(
'EPAY_INFO', $this->lng->txt(
'pay_info_epay'));
849 $tpl->parseCurrentBlock(
'buy_link');
851 $tpl->setCurrentBlock(
'loop');
854 $tpl->parseCurrentBlock(
'loop');
856 $this->tpl->setVariable(
''.strtoupper($pay_method[
'pm_title']).
'',
$tpl->get());
858 $num_items += $counter;
864 # ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty')); 874 foreach (
$_SESSION[
'coupons'] as $key => $val)
886 if (
$_POST[
'coupon_code'] !=
'')
888 $coupon = $this->coupon_obj->getCouponByCode(
$_POST[
'coupon_code']);
889 switch ($this->coupon_obj->checkCouponValidity())
903 if (count($items = $this->psc_obj->getEntries(isset(
$_POST[
'payment_type']) ?
$_POST[
'payment_type'] :
'bmf')))
905 foreach($items as $item)
907 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
908 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
920 $coupon_session_id = $_POST[
'payment_type'];
921 if (!array_key_exists($coupon[
'pc_pk'],
$_SESSION[
'coupons'][$coupon_session_id]))
925 foreach (
$_SESSION[
'coupons'] as $key => $val)
927 unset(
$_SESSION[
'coupons'][$key][$coupon[
'pc_pk']]);
931 $_SESSION[
'coupons'][$coupon_session_id][$coupon[
'pc_pk']] = $coupon;
950 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
953 $tpl =
new ilTemplate(
'tpl.pay_shopping_cart_coupons.html',
true,
true,
'Services/Payment');
955 $tpl->setVariable(
'COUPON_FORMACTION', $this->ctrl->getFormAction($this));
956 $tpl->setVariable(
'TITLE', $this->lng->txt(
'paya_coupons_coupons'));
958 $tpl->setVariable(
'ALT_IMG', $this->lng->txt(
'obj_usr'));
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');
964 $tpl->setVariable(
'PAYMENT_TYPE', $payment_type);
966 $coupon_session = $payment_type;
968 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
971 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
973 $tpl->setCurrentBlock(
'loop');
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>");
989 $tpl->parseCurrentBlock();
1002 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
1005 include_once
'./Services/Payment/classes/class.ilShoppingCartTableGUI.php';
1008 $tbl->setId(
'tbl_id_'.$a_pay_method);
1009 $tbl->setTitle($this->lng->txt(
'paya_shopping_cart').
1010 " (".$this->lng->txt(
'payment_system').
": ".
1013 $coupon_session = $a_pay_method[
'pm_title'];
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%');
1023 $tbl->setPrefix(
"table". $a_pay_method[
'pm_title'].
"_");
1024 $tbl->addMultiCommand(
'deleteItem', $this->lng->txt(
'delete'));
1030 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
1032 if (count($items = $sc_obj->getEntries($a_pay_method[
'pm_id'])))
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'));
1037 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
1039 $this->coupon_obj->setId($coupon[
'pc_pk']);
1040 $this->coupon_obj->setCurrentCoupon($coupon);
1042 $total_object_price = 0.0;
1043 $current_coupon_bonus = 0.0;
1045 foreach ($items as $item)
1047 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
1049 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
1052 $price = (float) $price_data[
'price'];
1054 $total_object_price += $price;
1056 unset($tmp_pobject);
1059 $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
1060 $totalAmount[$current_coupon_bonus] += $current_coupon_bonus * (-1);
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'));
1069 $this->totalVat = 0;
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']);
1078 if ($this->totalVat > 0)
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'));
1084 $tbl->setData($a_result_set);
1085 $a_tpl->setVariable(
'ITEMS_TABLE',$tbl->getCartHTML());
1092 if(!count(
$_POST[
'item']))
1101 foreach(
$_POST[
'item'] as $id)
1103 $this->psc_obj->delete($id);
1115 $this->psc_obj->clearCouponItemsSession();
1120 include_once
'./Services/Payment/classes/class.ilPurchasePaypal.php';
1132 $merchant_cert = $this->paypalConfig[
"vendor_cert"];
1133 $merchant_key = $this->paypalConfig[
"vendor_key"];
1134 $end_cert = $this->paypalConfig[
"enc_cert"];
1136 $tmpin_file = tempnam(
'/tmp',
'paypal_');
1137 $tmpout_file = tempnam(
'/tmp',
'paypal_');
1138 $tmpfinal_file = tempnam(
'/tmp',
'paypal_');
1141 $buttonParams[
'cert_id'] = $this->paypalConfig[
"cert_id"];
1142 foreach ($buttonParams as $name => $value) {
1143 $rawdata[] =
"$name=$value";
1145 $rawdata = implode(
"\n", $rawdata);
1147 $fp = fopen($tmpin_file,
'w');
1149 echo
"Could not open temporary file '$tmpin_file')";
1151 # return PayPal::raiseError("Could not open temporary file '$tmpin_file')"); 1153 fwrite($fp, $rawdata);
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();
1161 # return PayPal::raiseError("Could not sign encrypted data: " . openssl_error_string()); 1164 $data = file_get_contents($tmpout_file);
1168 $fp = fopen($tmpout_file,
'w');
1170 echo
"Could not open temporary file '$tmpin_file')";
1172 # return PayPal::raiseError("Could not open temporary file '$tmpin_file')"); 1177 if (!@openssl_pkcs7_encrypt($tmpout_file, $tmpfinal_file, $end_cert, array(), PKCS7_BINARY)) {
1178 echo
"Could not encrypt data:" . openssl_error_string();
1180 # return PayPal::raiseError("Could not encrypt data:" . openssl_error_string()); 1183 $encdata = @file_get_contents($tmpfinal_file,
false);
1185 echo
"Encryption and signature of data failed.";
1187 # return PayPal::raiseError("Encryption and signature of data failed."); 1190 $encdata = explode(
"\n\n", $encdata);
1191 $encdata = trim(str_replace(
"\n",
'', $encdata[1]));
1192 $encdata =
"-----BEGIN PKCS7-----$encdata-----END PKCS7-----";
1194 @unlink($tmpfinal_file);
1195 @unlink($tmpin_file);
1196 @unlink($tmpout_file);
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const TYPE_UNLIMITED_DURATION
Class class.ilPurchaseBaseGUI.php.
const ERROR_NOT_COMPLETED
static _getPrice($a_price_id)
const TYPE_DURATION_MONTH
static getStringByPaymethod($a_type)
static _getGUIPrice($a_price)
const ERROR_PREV_TRANS_ID
const ERROR_WRONG_CUSTOMER
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilObjPaymentSettingsGUI.
static _getPriceString($a_price_id)
static getInstance()
Static method to get the singleton instance.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _formatVAT($a_vat)
Formats a vat rate for gui output.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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 _getIdByTitle($a_pm_title)