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;
44 $this->session_id = session_id();
49 $this->paypalConfig = $ppSet->getAll();
56 #$this->default_currency = ilPaymentCurrency::_getDefaultCurrency();
64 $cmd = $this->ctrl->getCmd();
65 $next_class = $this->ctrl->getNextClass($this);
71 if (!
$cmd = $this->ctrl->getCmd())
88 $ilTabs->setTabActive(
'paya_shopping_cart');
92 include_once
'./Services/Payment/classes/class.ilPurchaseBaseGUI.php';
94 $purchase->__addBookings();
96 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
107 $_SESSION[
'bmf'][
'debit_entry'] = array();
108 $_SESSION[
'bmf'][
'credit_card'] = array();
112 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
119 include_once
'./Services/Payment/classes/class.ilPurchaseBaseGUI.php';
121 $purchase->__addBookings();
124 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
131 global
$ilUser, $ilObjDataCache;
133 include_once
'./Services/Payment/classes/class.ilPaymentBookings.php';
134 include_once
'./Services/Payment/classes/class.ilPaymentObject.php';
135 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
140 $sc_obj->clearCouponItemsSession();
142 foreach($items as $entry)
147 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
149 $entry[
'math_price'] = $entry[
'price'];
150 foreach (
$_SESSION[
'coupons'][$coupon_session] as $key => $coupon)
152 $this->coupon_obj->setId($coupon[
'pc_pk']);
153 $this->coupon_obj->setCurrentCoupon($coupon);
155 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
157 $_SESSION[
'coupons'][$coupon_session][$key][
'total_objects_coupon_price'] += $entry[
'price'];
158 $_SESSION[
'coupons'][$coupon_session][$key][
'items'][] = $entry;
165 $coupon_discount_items = $sc_obj->calcDiscountPrices(
$_SESSION[
'coupons'][$coupon_session]);
167 foreach($items as $entry)
173 if (array_key_exists($entry[
'pobject_id'], $coupon_discount_items))
175 $bonus = $coupon_discount_items[$entry[
'pobject_id']][
'math_price'] - $coupon_discount_items[$entry[
'pobject_id']][
'discount_price'];
178 $booking_obj->setPobjectId($entry[
'pobject_id']);
180 $booking_obj->setCustomerId($this->user_obj->getId());
181 $booking_obj->setVendorId($pobject->getVendorId());
182 $booking_obj->setPayMethod($pobject->getPayMethod());
183 $booking_obj->setOrderDate(time());
184 $booking_obj->setDuration($price[
'duration']);
186 $booking_obj->setDiscount($bonus > 0 ? ((-1) * $bonus) : 0);
187 $booking_obj->setPayed(1);
188 $booking_obj->setAccess(1);
190 switch($price[
'price_type'])
193 $booking_obj->setDuration(0);
196 $booking_obj->setDuration($price[
'duration']);
199 $booking_obj->setAccessStartdate($price[
'duration_from']);
200 $booking_obj->setAccessEnddate($price[
'duration_until']);
204 $booking_obj->setAccessExtension($price[
'extension']);
206 $obj_id = $ilObjDataCache->lookupObjId($pobject->getRefId());
207 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
209 $oVAT =
new ilShopVats((
int)$pobject->getVatId());
210 $obj_vat_rate = $oVAT->
getRate();
214 $tmp_price = $booking_obj->getPrice()-$bonus;
215 $obj_vat_unit = $pobject->getVat($tmp_price);
217 $obj_vat_unit = $pobject->getVat($booking_obj->getPrice());
219 $booking_obj->setObjectTitle($obj_title);
220 $booking_obj->setVatRate($obj_vat_rate);
221 $booking_obj->setVatUnit($obj_vat_unit);
223 if(ilPaymethods::_EnabledSaveUserAddress($booking_obj->getPayMethod()))
225 $booking_obj->setStreet($ilUser->getStreet(), $ilUser->getHouseNumber);
226 $booking_obj->setZipcode($ilUser->getZipcode());
227 $booking_obj->setCity($ilUser->getCity());
228 $booking_obj->setCountry($ilUser->getCountry());
231 $current_booking_id = $booking_obj->add();
233 if ($current_booking_id)
235 $sc_obj->delete($entry[
'psc_id']);
237 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
239 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
241 $this->coupon_obj->setId($coupon[
'pc_pk']);
242 $this->coupon_obj->setCurrentCoupon($coupon);
244 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
246 $this->coupon_obj->addCouponForBookingId($current_booking_id);
252 unset($current_booking_id);
256 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
258 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
260 $this->coupon_obj->setId($coupon[
'pc_pk']);
261 $this->coupon_obj->setCurrentCoupon($coupon);
262 $this->coupon_obj->addTracking();
270 $get_paymethods = $objPM->readAll();
272 foreach($get_paymethods as $pm)
274 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
275 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
278 if (is_array($pay_methods))
282 $coupon_session_id = $pay_method[
'pm_title'];
284 if (!is_array(
$_SESSION[
'coupons'][$coupon_session_id]))
286 $_SESSION[
'coupons'][$coupon_session_id] = array();
290 foreach (
$_SESSION[
'coupons'][$coupon_session_id] as $coupon_id => $session_coupon)
292 $coupon = $this->coupon_obj->getCouponByCode($session_coupon[
'pcc_code']);
294 if ($this->coupon_obj->checkCouponValidity() == 0)
299 if (count($items = $this->psc_obj->getEntries($pay_method[
'pm_id'])))
301 foreach($items as $item)
303 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
305 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
313 unset(
$_SESSION[
'coupons'][$coupon_session_id][$coupon_id]);
318 unset(
$_SESSION[
'coupons'][$coupon_session_id][$coupon_id]);
357 if (!($fp = $this->paypal_obj->openSocket()))
359 ilUtil::sendFailure($this->lng->txt(
'pay_paypal_failed').
'<br />'.$this->lng->txt(
'pay_paypal_unreachable').
'<br />'.$this->lng->txt(
'pay_paypal_error_info'));
365 $res = $this->paypal_obj->checkData($fp);
371 if($ilUser->getId() == ANONYMOUS_USER_ID ||
$_SESSION[
'is_crs_object'] ||
$_SESSION[
'is_lm_object'] ||
$_SESSION[
'is_file_object'])
374 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
378 # $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
379 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
386 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'));
388 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'));
390 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'));
392 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'));
394 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'));
396 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'));
421 $get_paymethods = $objPM->readAll();
425 foreach($get_paymethods as $pm)
427 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
428 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
429 $pay_methods[$pm[
'pm_id']][
'pm_enabled'] = $pm[
'pm_enabled'];
430 $pay_methods[$pm[
'pm_id']][
'save_usr_adr'] = $pm[
'save_usr_adr'];
435 foreach($get_paymethods as $pm)
437 if($pm[
'pm_enabled'] == 1)
439 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
440 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
441 $pay_methods[$pm[
'pm_id']][
'pm_enabled'] = $pm[
'pm_enabled'];
442 $pay_methods[$pm[
'pm_id']][
'save_usr_adr'] = $pm[
'save_usr_adr'];
455 $base =
"./Services/Payment/templates/default/tpl.pay_shopping_cart_";
458 return $base . $a_pm_title . $suffix;
463 global $ilObjDataCache,
$ilUser, $ilToolbar;
465 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
466 include_once
'./Services/Payment/classes/class.ilPaymentCurrency.php';
468 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.pay_shopping_cart.html',
'Services/Payment');
470 if(
$_SESSION[
'forceShoppingCartRedirect'] ==
'1' && $ilUser->getId() != ANONYMOUS_USER_ID)
472 $_SESSION[
'forceShoppingCartRedirect'] = 0;
473 $this->tpl->touchBlock(
"close_js");
479 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
486 $is_crs_object =
false;
487 $crs_obj_ids = array();
490 $is_file_object =
false;
493 $is_lm_object =
false;
494 $lm_obj_ids = array();
496 if($genSet->get(
'show_sr_shoppingcart') == 1)
498 require_once
'Services/RTE/classes/class.ilRTE.php';
500 $this->tpl->setVariable(
'REGULATIONS_TITLE', $this->lng->txt(
'statutory_regulations'));
501 $this->tpl->setVariable(
'REGULATIONS', $regulations);
504 $ilToolbar->addButton($this->lng->txt(
'payment_back_to_shop'),
'ilias.php?baseClass=ilShopController');
510 $coupon_session_id = $pay_method[
'pm_title'];
512 if (count($items = $this->psc_obj->getEntries( $pay_method[
'pm_id'])))
518 foreach ($items as $item)
520 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
522 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
523 $obj_type = $ilObjDataCache->lookupType($obj_id);
524 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
525 $desc[] =
"[" . $obj_type .
"] " . $obj_title;
528 # checks object_type: needed for purchasing file or crs objects without login
533 $is_crs_object =
true;
535 $crs_obj_ids[] = $obj_id;
542 $is_lm_object =
true;
544 $lm_obj_ids[] = $obj_id;
550 $is_file_object =
true;
557 $direct_paypal_info_output =
true;
559 $assigned_coupons =
'';
560 if (!empty(
$_SESSION[
'coupons'][$coupon_session_id]))
562 $price = $price_arr[
'price'];
563 $item[
'math_price'] = (float) $price;
565 foreach (
$_SESSION[
'coupons'][$coupon_session_id] as $key => $coupon)
567 $this->coupon_obj->setId($coupon[
'pc_pk']);
568 $this->coupon_obj->setCurrentCoupon($coupon);
570 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
572 $assigned_coupons .= $this->lng->txt(
'paya_coupons_coupon') .
': ' . $coupon[
'pcc_code'];
574 $_SESSION[
'coupons'][$coupon_session_id][$key][
'total_objects_coupon_price'] += (float) $price;
575 $_SESSION[
'coupons'][$coupon_session_id][$key][
'items'][] = $item;
576 $direct_paypal_info_output =
false;
581 $f_result[$counter][
'item'] = ilUtil::formCheckBox(0,
'item[]',$item[
'psc_id']);
583 if($obj_type ==
'exc')
585 $subtype =
' ('.$this->lng->txt($tmp_pobject->getSubtype()).
')';
586 $f_result[$counter][
'title'] =
"<a href=\"goto.php?target=".$obj_type.
"_".$tmp_pobject->getRefId() .
"\">".$obj_title.
"</a>".$subtype ;
589 $f_result[$counter][
'title'] =
"<a href=\"ilias.php?baseClass=ilRepositoryGUI&ref_id=".$tmp_pobject->getRefId() .
"\">".$obj_title.
"</a>".$subtype ;
591 if ($assigned_coupons !=
'')
594 $f_result[$counter][
'assigned_coupons'] .= $assigned_coupons;
597 switch($price_arr[
'price_type'])
600 $f_result[$counter][
'duration'] = $price_arr[
'duration'].
' '.$this->lng->txt(
'paya_months');
603 $f_result[$counter][
'duration'] =
608 $f_result[$counter][
'duration'] = $this->lng->txt(
'unlimited_duration');
612 $float_price = $price_arr[
'price'];
613 $total_price += $float_price;
615 $oVAT =
new ilShopVats((
int)$tmp_pobject->getVatId());
618 $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price);
622 .
' '.$genSet->get(
'currency_unit');
624 if ($pay_method[
'pm_title'] ==
'paypal')
626 if ($direct_paypal_info_output ==
true)
628 $tpl->setCurrentBlock(
'loop_items');
629 $tpl->setVariable(
'LOOP_ITEMS_NO', (++$paypal_counter));
630 $tpl->setVariable(
'LOOP_ITEMS_NAME',
"[".$obj_id.
"]: ".$obj_title);
631 $tpl->setVariable(
'LOOP_ITEMS_AMOUNT', $float_price);
632 $tpl->parseCurrentBlock(
'loop_items');
642 if (!(
bool)$genSet->get(
'hide_coupons'))
646 $tpl->setCurrentBlock(
'buy_link');
647 # $tpl->setCurrentBlock('terms_checkbox');
649 $link_target = $this->ctrl->getLinkTargetByClass(
'iltermsconditionsgui',
'');
650 $terms_link =
'<a href="'.$link_target.
'">'.$this->lng->txt(
'terms_conditions').
'</a>';
651 $tpl->setVariable(
'TERMS_CONDITIONS', sprintf($this->lng->txt(
'accept_terms_conditions'), $terms_link));
653 switch($pay_method[
'pm_title'])
656 if ($this->totalAmount[$pay_method[
'pm_id']] <= 0 && ANONYMOUS_USER_ID == $ilUser->getId())
658 $tpl->setVariable(
'TXT_UNLOCK', $this->lng->txt(
'pay_click_to_buy'));
659 $tpl->setVariable(
'LINK_UNLOCK', $this->ctrl->getLinkTarget($this,
'unlockBillObjectsInShoppingCart'));
663 # Anonymous user has to login
664 if(ANONYMOUS_USER_ID == $ilUser->getId())
667 $tpl->touchBlock(
'attach_submit_event_bill');
668 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'continue'));
669 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
674 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
675 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTargetByClass(
'ilPurchaseBillGUI',
''));
676 $tpl->parseCurrentBlock(
'terms_checkbox');
682 #$tpl->setVariable("SCRIPT_LINK", './payment.php?view=start_bmf');
683 if ($this->totalAmount[$pay_method[
'pm_id']] <= 0 && ANONYMOUS_USER_ID != $ilUser->getId())
685 $tpl->setVariable(
'TXT_UNLOCK', $this->lng->txt(
'pay_click_to_buy'));
686 $tpl->setVariable(
'LINK_UNLOCK', $this->ctrl->getLinkTarget($this,
'unlockBMFObjectsInShoppingCart'));
690 # Anonymous user has to login
691 if(ANONYMOUS_USER_ID == $ilUser->getId())
694 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'continue'));
695 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
699 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
700 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTargetByClass(
'ilPurchaseBMFGUI',
''));
706 # Anonymous user has to login
737 if ($this->totalAmount[$pay_method[
'pm_id']] <= 0 && ANONYMOUS_USER_ID != $ilUser->getId())
739 $tpl->touchBlock(
'attach_submit_event');
740 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
741 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTarget($this,
'unlockPAYPALObjectsInShoppingCart'));
745 if(ANONYMOUS_USER_ID == $ilUser->getId())# && $force_user_login ==
true)
748 $tpl->touchBlock(
'attach_submit_event');
749 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
750 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
754 $tpl->setCurrentBlock(
'terms_checkbox');
756 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
757 $tpl->setVariable(
'SCRIPT_LINK',
'https://'.$this->paypalConfig[
'server_host'].$this->paypalConfig[
'server_path']);
758 $tpl->parseCurrentBlock(
'terms_checkbox');
762 $tpl->setVariable(
'POPUP_BLOCKER', $this->lng->txt(
'popup_blocker'));
763 $tpl->setVariable(
'VENDOR', $this->paypalConfig[
'vendor']);
764 $tpl->setVariable(
'RETURN', ILIAS_HTTP_PATH .
"/" . $this->ctrl->getLinkTarget($this,
'finishPaypal'));
765 $tpl->setVariable(
'CANCEL_RETURN', ILIAS_HTTP_PATH .
"/" . $this->ctrl->getLinkTarget($this,
'cancelPaypal'));
766 $tpl->setVariable(
'CUSTOM', $ilUser->getId());
767 $tpl->setVariable(
'CURRENCY', $genSet->get(
'currency_unit'));
768 $tpl->setVariable(
'PAGE_STYLE', $this->paypalConfig[
'page_style']);
770 if (!empty(
$_SESSION[
'coupons'][$coupon_session_id]))
772 $coupon_discount_items = $this->psc_obj->calcDiscountPrices(
$_SESSION[
'coupons'][$coupon_session_id]);
774 if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
776 foreach ($coupon_discount_items as $item)
778 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
780 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
781 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
783 $tmp_amount = round($item[
'discount_price'], 2);
784 $loop_items_amount = str_replace(
',',
'.',$tmp_amount);
786 $tpl->setCurrentBlock(
'loop_items');
787 $tpl->setVariable(
'LOOP_ITEMS_NO', (++$paypal_counter));
788 $tpl->setVariable(
'LOOP_ITEMS_NAME',
"[".$obj_id.
"]: ".$obj_title);
789 $tpl->setVariable(
'LOOP_ITEMS_AMOUNT',$loop_items_amount );
791 $tpl->parseCurrentBlock(
'loop_items');
800 if ($pay_method[
'pm_title'] ==
'paypal')
802 $tpl->setVariable(
'PAYPAL_HINT', $this->lng->txt(
'pay_hint_paypal'));
803 $tpl->setVariable(
'PAYPAL_INFO', $this->lng->txt(
'pay_info_paypal'));
805 else if ($pay_method[
'pm_title'] ==
'epay')
807 $tpl->setVariable(
'EPAY_HINT', $this->lng->txt(
'pay_hint_epay'));
808 $tpl->setVariable(
'EPAY_INFO', $this->lng->txt(
'pay_info_epay'));
811 $tpl->parseCurrentBlock(
'buy_link');
813 $tpl->setCurrentBlock(
'loop');
816 $tpl->parseCurrentBlock(
'loop');
818 $this->tpl->setVariable(
''.strtoupper($pay_method[
'pm_title']).
'',
$tpl->get());
820 $num_items += $counter;
826 # ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
836 foreach (
$_SESSION[
'coupons'] as $key => $val)
848 if (
$_POST[
'coupon_code'] !=
'')
850 $coupon = $this->coupon_obj->getCouponByCode(
$_POST[
'coupon_code']);
851 switch ($this->coupon_obj->checkCouponValidity())
865 if (count($items = $this->psc_obj->getEntries(isset(
$_POST[
'payment_type']) ?
$_POST[
'payment_type'] :
'bmf')))
867 foreach($items as $item)
869 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
870 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
882 $coupon_session_id = $_POST[
'payment_type'];
883 if (!array_key_exists($coupon[
'pc_pk'],
$_SESSION[
'coupons'][$coupon_session_id]))
887 foreach (
$_SESSION[
'coupons'] as $key => $val)
889 unset(
$_SESSION[
'coupons'][$key][$coupon[
'pc_pk']]);
893 $_SESSION[
'coupons'][$coupon_session_id][$coupon[
'pc_pk']] = $coupon;
912 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
915 $tpl =
new ilTemplate(
'tpl.pay_shopping_cart_coupons.html',
true,
true,
'Services/Payment');
917 $tpl->setVariable(
'COUPON_FORMACTION', $this->ctrl->getFormAction($this));
918 $tpl->setVariable(
'TITLE', $this->lng->txt(
'paya_coupons_coupons'));
920 $tpl->setVariable(
'ALT_IMG', $this->lng->txt(
'obj_usr'));
922 $tpl->setVariable(
'TXT_CODE', $this->lng->txt(
'paya_coupons_code'));
923 $tpl->setVariable(
'CMD_VALUE', $this->lng->txt(
'send'));
924 $tpl->setVariable(
'CMD',
'setCoupon');
926 $tpl->setVariable(
'PAYMENT_TYPE', $payment_type);
928 $coupon_session = $payment_type;
930 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
933 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
935 $tpl->setCurrentBlock(
'loop');
937 $tpl->setVariable(
'LOOP_TXT_COUPON', $this->lng->txt(
'paya_coupons_coupon'));
938 $tpl->setVariable(
'LOOP_CODE', $coupon[
'pcc_code']);
939 $this->ctrl->setParameter($this,
'coupon_id', $coupon[
'pc_pk']);
940 $this->ctrl->setParameter($this,
'payment_type',
$_SESSION[
'bmf'][
'payment_type']);
941 $tpl->setVariable(
'LOOP_TITLE', $coupon[
'pc_title']);
942 if ($coupon[
'pc_description'] !=
'')
$tpl->setVariable(
'LOOP_DESCRIPTION', nl2br($coupon[
'pc_description']));
943 $tpl->setVariable(
"LOOP_TYPE",
944 sprintf($this->lng->txt(
'paya_coupons_'.($coupon[
'pc_type'] ==
"fix" ?
'fix' :
'percentaged').
'_'.(count($coupon[
'objects']) == 0 ?
'all' :
'selected').
'_objects'),
945 (((float)$coupon[
'pc_value'] / round($coupon[
'pc_value'], 2) == 1 && $coupon[
'pc_type'] ==
"percent")
946 ? round($coupon[
'pc_value'], 2)
947 : number_format($coupon[
'pc_value'], 2,
',',
'.')),
948 ($coupon[
'pc_type'] ==
"percent" ?
"%" :$genSet->get(
'currency_unit'))));
949 $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>");
951 $tpl->parseCurrentBlock();
964 include_once
'./Services/Payment/classes/class.ilPaymentSettings.php';
967 include_once
'./Services/Payment/classes/class.ilShoppingCartTableGUI.php';
970 $tbl->setId(
'tbl_id_'.$a_pay_method);
971 $tbl->setTitle($this->lng->txt(
'paya_shopping_cart').
972 " (".$this->lng->txt(
'payment_system').
": ".
975 $coupon_session = $a_pay_method[
'pm_title'];
977 $tbl->setRowTemplate(
"tpl.shop_shoppingcart_row.html",
"Services/Payment");
978 $tbl->addColumn(
'',
'item',
'1%',
true);
979 $tbl->addColumn($this->lng->txt(
'title'),
"table". $a_pay_method[
'pm_title'].
"_title",
'30%');
980 $tbl->addColumn($this->lng->txt(
'duration'),
"table". $a_pay_method[
'pm_title'].
"_duration",
'30%');
981 $tbl->addColumn($this->lng->txt(
'vat_rate'),
"table". $a_pay_method[
'pm_title'].
"_vat_rate",
'15%');
982 $tbl->addColumn($this->lng->txt(
'vat_unit'),
"table". $a_pay_method[
'pm_title'].
"_vat_unit",
'15%');
983 $tbl->addColumn($this->lng->txt(
'price_a'),
"table". $a_pay_method[
'pm_title'].
"_price",
'10%');
985 $tbl->setPrefix(
"table". $a_pay_method[
'pm_title'].
"_");
986 $tbl->addMultiCommand(
'deleteItem', $this->lng->txt(
'delete'));
992 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
994 if (count($items = $sc_obj->getEntries($a_pay_method[
'pm_id'])))
996 $tbl->setTotalData(
'TXT_SUB_TOTAL', $this->lng->txt(
'pay_bmf_subtotal_amount') .
": ");
997 $tbl->setTotalData(
'VAL_SUB_TOTAL', number_format(
$totalAmount[$a_pay_method[
'pm_id']], 2,
',',
'.') .
" " . $genSet->get(
'currency_unit'));
999 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
1001 $this->coupon_obj->setId($coupon[
'pc_pk']);
1002 $this->coupon_obj->setCurrentCoupon($coupon);
1004 $total_object_price = 0.0;
1005 $current_coupon_bonus = 0.0;
1007 foreach ($items as $item)
1009 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
1011 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
1014 $price = (float) $price_data[
'price'];
1016 $total_object_price += $price;
1018 unset($tmp_pobject);
1021 $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
1022 $totalAmount[$current_coupon_bonus] += $current_coupon_bonus * (-1);
1024 $tbl->setTotalData(
'TXT_COUPON_BONUS', $this->lng->txt(
'paya_coupons_coupon') .
": ");# . $coupon[
'pcc_code'] .
": ");
1025 #$tbl->setTotalData('VAL_COUPON_BONUS', number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get('currency_unit'));
1026 $tbl->setTotalData(
'VAL_COUPON_BONUS', number_format(
$totalAmount[$current_coupon_bonus], 2,
',',
'.') .
" " . $genSet->get(
'currency_unit'));
1031 $this->totalVat = 0;
1036 $this->totalAmount[$a_pay_method[
'pm_id']] =
$totalAmount[$a_pay_method[
'pm_id']]-(
$totalAmount[$current_coupon_bonus] * (-1));
1037 $tbl->setTotalData(
'TXT_TOTAL_AMOUNT', $this->lng->txt(
'pay_bmf_total_amount').
": ");
1038 $tbl->setTotalData(
'VAL_TOTAL_AMOUNT', number_format($this->totalAmount[$a_pay_method[
'pm_id']] , 2,
',',
'.') .
" " . $genSet->get(
'currency_unit')); #.$item[
'currency']);
1040 if ($this->totalVat > 0)
1042 $tbl->setTotalData(
'TXT_TOTAL_VAT', $this->lng->txt(
'pay_bmf_vat_included') .
": ");
1043 $tbl->setTotalData(
'VAL_TOTAL_VAT', number_format($this->totalVat , 2,
',',
'.') .
" " . $genSet->get(
'currency_unit'));
1046 $tbl->setData($a_result_set);
1047 $a_tpl->setVariable(
'ITEMS_TABLE',$tbl->getCartHTML());
1054 if(!count(
$_POST[
'item']))
1063 foreach(
$_POST[
'item'] as $id)
1065 $this->psc_obj->delete($id);
1077 $this->psc_obj->clearCouponItemsSession();
1082 include_once
'./Services/Payment/classes/class.ilPurchasePaypal.php';
1094 $merchant_cert = $this->paypalConfig[
"vendor_cert"];
1095 $merchant_key = $this->paypalConfig[
"vendor_key"];
1096 $end_cert = $this->paypalConfig[
"enc_cert"];
1098 $tmpin_file = tempnam(
'/tmp',
'paypal_');
1099 $tmpout_file = tempnam(
'/tmp',
'paypal_');
1100 $tmpfinal_file = tempnam(
'/tmp',
'paypal_');
1103 $buttonParams[
'cert_id'] = $this->paypalConfig[
"cert_id"];
1104 foreach ($buttonParams as $name => $value) {
1105 $rawdata[] =
"$name=$value";
1107 $rawdata = implode(
"\n", $rawdata);
1109 $fp = fopen($tmpin_file,
'w');
1111 echo
"Could not open temporary file '$tmpin_file')";
1113 # return PayPal::raiseError("Could not open temporary file '$tmpin_file')");
1115 fwrite($fp, $rawdata);
1118 if (!@openssl_pkcs7_sign($tmpin_file, $tmpout_file, $merchant_cert,
1119 array($merchant_key, $this->paypalConfig[
"private_key_password"]),
1120 array(), PKCS7_BINARY)) {
1121 echo
"Could not sign encrypted data: " . openssl_error_string();
1123 # return PayPal::raiseError("Could not sign encrypted data: " . openssl_error_string());
1126 $data = file_get_contents($tmpout_file);
1130 $fp = fopen($tmpout_file,
'w');
1132 echo
"Could not open temporary file '$tmpin_file')";
1134 # return PayPal::raiseError("Could not open temporary file '$tmpin_file')");
1139 if (!@openssl_pkcs7_encrypt($tmpout_file, $tmpfinal_file, $end_cert, array(), PKCS7_BINARY)) {
1140 echo
"Could not encrypt data:" . openssl_error_string();
1142 # return PayPal::raiseError("Could not encrypt data:" . openssl_error_string());
1145 $encdata = @file_get_contents($tmpfinal_file,
false);
1147 echo
"Encryption and signature of data failed.";
1149 # return PayPal::raiseError("Encryption and signature of data failed.");
1152 $encdata = explode(
"\n\n", $encdata);
1153 $encdata = trim(str_replace(
"\n",
'', $encdata[1]));
1154 $encdata =
"-----BEGIN PKCS7-----$encdata-----END PKCS7-----";
1156 @unlink($tmpfinal_file);
1157 @unlink($tmpin_file);
1158 @unlink($tmpout_file);