4 include_once
'./Services/Payment/classes/class.ilPurchasePaypal.php';
6 include_once
'./Services/Payment/classes/class.ilShopBaseGUI.php';
7 include_once
'./Services/Payment/classes/class.ilPaypalSettings.php';
8 include_once
'./Services/Payment/classes/class.ilEPaySettings.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();
52 $this->epayConfig = $this->epSet->getAll();
56 #$this->default_currency = ilPaymentCurrency::_getDefaultCurrency();
66 $cmd = $this->ctrl->getCmd();
67 switch ($this->ctrl->getNextClass($this))
71 if (!
$cmd = $this->ctrl->getCmd())
88 $ilTabs->setTabActive(
'paya_shopping_cart');
97 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
108 $_SESSION[
'bmf'][
'debit_entry'] = array();
109 $_SESSION[
'bmf'][
'credit_card'] = array();
113 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
123 $_SESSION[
'coupons'][
'paypal'] = array();
127 if(ANONYMOUS_USER_ID == $ilUser->getId() || isset(
$_SESSION[
'user_name']))
129 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
133 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
140 global
$ilias, $ilUser, $ilObjDataCache;
142 include_once
'./Services/Payment/classes/class.ilPaymentBookings.php';
143 include_once
'./Services/Payment/classes/class.ilPaymentObject.php';
144 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
149 $sc_obj->clearCouponItemsSession();
151 foreach($items as $entry)
156 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
158 $entry[
'math_price'] = $entry[
'price'];
159 foreach (
$_SESSION[
'coupons'][$coupon_session] as $key => $coupon)
161 $this->coupon_obj->setId($coupon[
'pc_pk']);
162 $this->coupon_obj->setCurrentCoupon($coupon);
164 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
166 $_SESSION[
'coupons'][$coupon_session][$key][
'total_objects_coupon_price'] += $entry[
'price'];
167 $_SESSION[
'coupons'][$coupon_session][$key][
'items'][] = $entry;
174 $coupon_discount_items = $sc_obj->calcDiscountPrices(
$_SESSION[
'coupons'][$coupon_session]);
177 foreach($items as $entry)
183 if (array_key_exists($entry[
'pobject_id'], $coupon_discount_items))
185 $bonus = $coupon_discount_items[$entry[
'pobject_id']][
'math_price'] - $coupon_discount_items[$entry[
'pobject_id']][
'discount_price'];
188 $booking_obj->setPobjectId($entry[
'pobject_id']);
190 $booking_obj->setCustomerId($this->user_obj->getId());
191 $booking_obj->setVendorId($pobject->getVendorId());
192 $booking_obj->setPayMethod($pobject->getPayMethod());
193 $booking_obj->setOrderDate(time());
194 $booking_obj->setDuration($price[
'duration']);
196 $booking_obj->setDiscount($bonus > 0 ? ((-1) * $bonus) : 0);
197 $booking_obj->setPayed(1);
198 $booking_obj->setAccess(1);
200 $obj_id = $ilObjDataCache->lookupObjId($pobject->getRefId());
201 $obj_type = $ilObjDataCache->lookupType($obj_id);
202 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
204 $oVAT =
new ilShopVats((
int)$pobject->getVatId());
205 $obj_vat_rate = $oVAT->
getRate();
209 $tmp_price = $booking_obj->getPrice()-$bonus;
210 $obj_vat_unit = $pobject->getVat($tmp_price);
212 $obj_vat_unit = $pobject->getVat($booking_obj->getPrice());
214 $booking_obj->setObjectTitle($obj_title);
215 $booking_obj->setVatRate($obj_vat_rate);
216 $booking_obj->setVatUnit($obj_vat_unit);
218 if(ilPaymethods::_EnabledSaveUserAddress($booking_obj->getPayMethod()))
220 $booking_obj->setStreet($ilUser->getStreet(), $ilUser->getHouseNumber);
221 $booking_obj->setZipcode($ilUser->getZipcode());
222 $booking_obj->setCity($ilUser->getCity());
223 $booking_obj->setCountry($ilUser->getCountry());
226 $current_booking_id = $booking_obj->add();
228 if ($current_booking_id)
230 $sc_obj->delete($entry[
'psc_id']);
232 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
234 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
236 $this->coupon_obj->setId($coupon[
'pc_pk']);
237 $this->coupon_obj->setCurrentCoupon($coupon);
239 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
241 $this->coupon_obj->addCouponForBookingId($current_booking_id);
247 unset($current_booking_id);
251 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
253 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
255 $this->coupon_obj->setId($coupon[
'pc_pk']);
256 $this->coupon_obj->setCurrentCoupon($coupon);
257 $this->coupon_obj->addTracking();
265 $get_paymethods = $objPM->readAll();
267 foreach($get_paymethods as $pm)
269 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
270 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
273 if (is_array($pay_methods))
277 $coupon_session_id = $pay_method[
'pm_title'];
279 if (!is_array(
$_SESSION[
'coupons'][$coupon_session_id]))
281 $_SESSION[
'coupons'][$coupon_session_id] = array();
285 foreach (
$_SESSION[
'coupons'][$coupon_session_id] as $coupon_id => $session_coupon)
287 $coupon = $this->coupon_obj->getCouponByCode($session_coupon[
'pcc_code']);
289 if ($this->coupon_obj->checkCouponValidity() == 0)
294 if (count($items = $this->psc_obj->getEntries($pay_method[
'pm_id'])))
296 foreach($items as $item)
298 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
300 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
308 unset(
$_SESSION[
'coupons'][$coupon_session_id][$coupon_id]);
313 unset(
$_SESSION[
'coupons'][$coupon_session_id][$coupon_id]);
329 require_once
'./Services/Payment/classes/class.ilPurchase.php';
334 $buy =
new ilPurchase( $ilUser->getId(), $pm_id );
339 $msg = $e->getMessage();
340 if (DEVMODE) $msg .=
" " . print_r(
$_REQUEST,
true);
344 $this->ctrl->redirectByClass(
'ilShopBoughtObjectsGUI',
'');
352 if (!($fp = $this->paypal_obj->openSocket()))
354 ilUtil::sendFailure($this->lng->txt(
'pay_paypal_failed').
'<br />'.$this->lng->txt(
'pay_paypal_unreachable').
'<br />'.$this->lng->txt(
'pay_paypal_error_info'));
360 $res = $this->paypal_obj->checkData($fp);
366 if($ilUser->getId() == ANONYMOUS_USER_ID ||
$_SESSION[
'is_crs_object'] ||
$_SESSION[
'is_lm_object'] ||
$_SESSION[
'is_file_object'])
369 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
373 # $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', '');
374 $this->ctrl->redirectByClass(
'ilShopShoppingCartGUI',
'');
381 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'));
383 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'));
385 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'));
387 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'));
389 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'));
391 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'));
416 $get_paymethods = $objPM->readAll();
420 foreach($get_paymethods as $pm)
422 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
423 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
424 $pay_methods[$pm[
'pm_id']][
'pm_enabled'] = $pm[
'pm_enabled'];
425 $pay_methods[$pm[
'pm_id']][
'save_usr_adr'] = $pm[
'save_usr_adr'];
430 foreach($get_paymethods as $pm)
432 if($pm[
'pm_enabled'] == 1)
434 $pay_methods[$pm[
'pm_id']][
'pm_title'] = $pm[
'pm_title'];
435 $pay_methods[$pm[
'pm_id']][
'pm_id'] = $pm[
'pm_id'];
436 $pay_methods[$pm[
'pm_id']][
'pm_enabled'] = $pm[
'pm_enabled'];
437 $pay_methods[$pm[
'pm_id']][
'save_usr_adr'] = $pm[
'save_usr_adr'];
450 $base =
"./Services/Payment/templates/default/tpl.pay_shopping_cart_";
453 return $base . $a_pm_title . $suffix;
459 if (is_array($pay_methods))
460 for ($p = 0; $p < count($pay_methods); $p++)
462 if (count($items = $this->psc_obj->getEntries($pay_methods[
'pm_id'])))
464 foreach ($items as $item)
475 global $ilObjDataCache, $ilUser;
477 include_once
'./Services/Payment/classes/class.ilPaymentPrices.php';
478 include_once
'./Services/Payment/classes/class.ilPaymentCurrency.php';
480 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.pay_shopping_cart.html',
'Services/Payment');
483 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
488 $is_crs_object =
false;
489 $crs_obj_ids = array();
491 $is_file_object =
false;
493 $is_lm_object =
false;
494 $lm_obj_ids = array();
496 $force_user_login =
false;
502 $coupon_session_id = $pay_method[
'pm_title'];
504 if (count($items = $this->psc_obj->getEntries( $pay_method[
'pm_id'])))
510 $total_price_in_default_currency = 0;
511 $total_vat_in_default_currency = 0;
512 foreach ($items as $item)
514 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
516 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
517 $obj_type = $ilObjDataCache->lookupType($obj_id);
518 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
519 $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;
549 $is_file_object =
true;
552 $force_user_login =
true;
556 $direct_paypal_info_output =
true;
558 $assigned_coupons =
'';
559 if (!empty(
$_SESSION[
'coupons'][$coupon_session_id]))
561 $price = $price_arr[
'price'];
562 $item[
'math_price'] = (float) $price;
564 foreach (
$_SESSION[
'coupons'][$coupon_session_id] as $key => $coupon)
566 $this->coupon_obj->setId($coupon[
'pc_pk']);
567 $this->coupon_obj->setCurrentCoupon($coupon);
569 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
571 $assigned_coupons .= $this->lng->txt(
'paya_coupons_coupon') .
': ' . $coupon[
'pcc_code'];
573 $_SESSION[
'coupons'][$coupon_session_id][$key][
'total_objects_coupon_price'] += (float) $price;
574 $_SESSION[
'coupons'][$coupon_session_id][$key][
'items'][] = $item;
575 $direct_paypal_info_output =
false;
580 $f_result[$counter][
'item'] = ilUtil::formCheckBox(0,
'item[]',$item[
'psc_id']);
581 $f_result[$counter][
'title'] =
"<a href=\"goto.php?target=".$obj_type.
"_".$tmp_pobject->getRefId() .
"\">".$obj_title.
"</a>";
582 if ($assigned_coupons !=
'')
585 $f_result[$counter][
'assigned_coupons'] .= $assigned_coupons;
588 if($price_arr[
'duration'] == 0)
590 $f_result[$counter][
'duration'] = $this->lng->txt(
'unlimited_duration');
593 $f_result[$counter][
'duration'] = $price_arr[
'duration'].
' '.$this->lng->txt(
'paya_months');
595 $float_price = $price_arr[
'price'];
596 $total_price += $float_price;
598 $oVAT =
new ilShopVats((
int)$tmp_pobject->getVatId());
631 $f_result[$counter][
'vat_unit'] = $tmp_pobject->getVat($float_price,
'GUI').
' '.$genSet->get(
'currency_unit');
632 $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price);
636 if ($pay_method[
'pm_title'] ==
'paypal')
638 if ($direct_paypal_info_output ==
true)
640 $tpl->setCurrentBlock(
'loop_items');
641 $tpl->setVariable(
'LOOP_ITEMS_NO', (++$paypal_counter));
642 $tpl->setVariable(
'LOOP_ITEMS_NAME',
"[".$obj_id.
"]: ".$obj_title);
643 $tpl->setVariable(
'LOOP_ITEMS_AMOUNT', $float_price);
645 $tpl->parseCurrentBlock(
'loop_items');
655 if (!(
bool)$genSet->get(
'hide_coupons'))
659 $tpl->setCurrentBlock(
'buy_link');
661 switch($pay_method[
'pm_title'])
664 if ($this->totalAmount[$pay_method[
'pm_id']] == 0)
666 $tpl->setVariable(
'TXT_UNLOCK', $this->lng->txt(
'pay_click_to_buy'));
667 $tpl->setVariable(
'LINK_UNLOCK', $this->ctrl->getLinkTarget($this,
'unlockBillObjectsInShoppingCart'));
671 # Anonymous user has to login
672 if(ANONYMOUS_USER_ID == $ilUser->getId())
675 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
676 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
680 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
681 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTargetByClass(
'ilPurchaseBillGUI',
''));
687 #$tpl->setVariable("SCRIPT_LINK", './payment.php?view=start_bmf');
688 if ($this->totalAmount[$pay_method[
'pm_id']] == 0)
690 $tpl->setVariable(
'TXT_UNLOCK', $this->lng->txt(
'pay_click_to_buy'));
691 $tpl->setVariable(
'LINK_UNLOCK', $this->ctrl->getLinkTarget($this,
'unlockBMFObjectsInShoppingCart'));
695 # Anonymous user has to login
696 if(ANONYMOUS_USER_ID == $ilUser->getId())
698 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
699 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
703 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
704 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTargetByClass(
'ilPurchaseBMFGUI',
''));
710 # Anonymous user has to login
711 if(ANONYMOUS_USER_ID == $ilUser->getId())
713 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
714 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
719 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
720 $tpl->setVariable(
'SCRIPT_LINK',
'https://'.$this->epayConfig[
'server_host'].$this->epayConfig[
'server_path']);
721 $tpl->setVariable(
'MERCHANT_NUMBER', $this->epayConfig[
'merchant_number']);
722 $tpl->setVariable(
'AMOUNT', $total_price * 100);
723 $tpl->setVariable(
'CURRENCY',
"208");
724 $tpl->setVariable(
'ORDERID', $ilUser->getId().
"_".uniqid());
725 $tpl->setVariable(
'ACCEPT_URL', ILIAS_HTTP_PATH .
"/" . $this->ctrl->getLinkTarget($this,
'finishEPay'));
726 $tpl->setVariable(
'DECLINE_URL', ILIAS_HTTP_PATH .
"/" . $this->ctrl->getLinkTarget($this,
'cancelEPay'));
727 $tpl->setVariable(
'INSTANT_CAPTURE', $this->epayConfig[
'instant_capture'] ?
"1" :
"0");
728 $tpl->setVariable(
'ADDFEE', 1);
729 $tpl->setVariable(
'LANGUAGE', 1);
730 $tpl->setVariable(
'GROUP',
"");
731 $tpl->setVariable(
'CARDTYPE',
"");
732 $tpl->setVariable(
"CALLBACK_URL", ILIAS_HTTP_PATH .
"/Services/Payment/classes/class.ilCallback.php?ilUser=" .$ilUser->getId() .
"&pay_method=". PAY_METHOD_EPAY);
734 $tpl->setVariable(
'DESCRIPTION', $ilUser->getFullName() .
" (" . $ilUser->getEmail() .
") #" . $ilUser->getId() .
" " . implode(
",",
$desc));
735 $tpl->setVariable(
'AUTH_MAIL', $this->epayConfig[
'auth_email']);
736 $tpl->setVariable(
'MD5KEY', $this->epSet->generateKeyForEpay(208, $total_price*100, $ilUser->getId().
"_".uniqid()));
741 if ($this->totalAmount[$pay_method[
'pm_id']] == 0)
743 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
744 $tpl->setVariable(
'SCRIPT_LINK', $this->ctrl->getLinkTarget($this,
'unlockPAYPALObjectsInShoppingCart'));
748 if(ANONYMOUS_USER_ID == $ilUser->getId() && $force_user_login ==
true)
751 $tpl->setVariable(
'TXT_BUY', $this->lng->txt(
'pay_click_to_buy'));
752 $tpl->setVariable(
'SCRIPT_LINK',
'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
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']);
761 $tpl->setVariable(
'POPUP_BLOCKER', $this->lng->txt(
'popup_blocker'));
762 $tpl->setVariable(
'VENDOR', $this->paypalConfig[
'vendor']);
763 $tpl->setVariable(
'RETURN', ILIAS_HTTP_PATH .
"/" . $this->ctrl->getLinkTarget($this,
'finishPaypal'));
764 $tpl->setVariable(
'CANCEL_RETURN', ILIAS_HTTP_PATH .
"/" . $this->ctrl->getLinkTarget($this,
'cancelPaypal'));
765 $tpl->setVariable(
'CUSTOM', $ilUser->getId());
766 $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 $tpl->setCurrentBlock(
'loop_items');
784 $tpl->setVariable(
'LOOP_ITEMS_NO', (++$paypal_counter));
785 $tpl->setVariable(
'LOOP_ITEMS_NAME',
"[".$obj_id.
"]: ".$obj_title);
786 $tpl->setVariable(
'LOOP_ITEMS_AMOUNT', round($item[
'discount_price'], 2));
788 $tpl->parseCurrentBlock(
'loop_items');
795 # $buttonParams["upload"] = 1;
796 # $buttonParams["charset"] = "utf-8";
797 # $buttonParams["business"] = $this->paypalConfig["vendor"];
798 # $buttonParams["currency_code"] = "EUR";
799 # $buttonParams["return"] = "http://www.databay.de/user/jens/paypal.php";
800 # $buttonParams["rm"] = 2;
801 # $buttonParams["cancel_return"] = "http://www.databay.de/user/jens/paypal.php";
802 # $buttonParams["custom"] = "HALLO";
803 # $buttonParams["invoice"] = "0987654321";
804 # if ($enc_data = $this->__encryptButton($buttonParams))
806 # $tpl->setVariable("ENCDATA", $enc_data);
810 if ($pay_method[
'pm_title'] ==
'paypal')
812 $tpl->setVariable(
'PAYPAL_HINT', $this->lng->txt(
'pay_hint_paypal'));
813 $tpl->setVariable(
'PAYPAL_INFO', $this->lng->txt(
'pay_info_paypal'));
815 else if ($pay_method[
'pm_title'] ==
'epay')
817 $tpl->setVariable(
'EPAY_HINT', $this->lng->txt(
'pay_hint_epay'));
818 $tpl->setVariable(
'EPAY_INFO', $this->lng->txt(
'pay_info_epay'));
821 $tpl->parseCurrentBlock(
'buy_link');
823 $tpl->setCurrentBlock(
'loop');
826 $tpl->parseCurrentBlock(
'loop');
828 $this->tpl->setVariable(
''.strtoupper($pay_method[
'pm_title']).
'',
$tpl->get());
830 $num_items += $counter;
837 $question = $this->lng->txt(
'have_existing_account');
840 $question .= sprintf($this->lng->txt(
'have_no_existing_account'),
$_SESSION[
'tmp_user_account'][
'login'],
$_SESSION[
'tmp_user_account'][
'passwd'][0]);
842 $question .= $this->lng->txt(
'please_use_account');
846 if(
$_SESSION[
'tmp_transaction'] || ANONYMOUS_USER_ID == $ilUser->getId())
853 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
855 $form->setTitle($this->lng->txt(
'download'));
857 foreach (
$_SESSION[
'download_links'] as $link)
860 $form_item->setValue(
'<a href='.$link.
'>'.$link.
'</a>');
861 $form->addItem($form_item);
862 $this->tpl->setVariable(
'FORM', $form->getHTML());
884 if (
$_POST[
'coupon_code'] !=
'')
886 $coupon = $this->coupon_obj->getCouponByCode(
$_POST[
'coupon_code']);
888 switch ($this->coupon_obj->checkCouponValidity())
904 if (count($items = $this->psc_obj->getEntries(isset(
$_POST[
'payment_type']) ?
$_POST[
'payment_type'] :
'bmf')))
906 foreach($items as $item)
908 $tmp_pobject =
new ilPaymentObject($this->user_obj,$item[
'pobject_id']);
910 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
923 $coupon_session_id = $_POST[
'payment_type'];
925 if (!array_key_exists($coupon[
'pc_pk'],
$_SESSION[
'coupons'][$coupon_session_id]))
929 foreach (
$_SESSION[
'coupons'] as $key => $val)
931 unset(
$_SESSION[
'coupons'][$key][$coupon[
'pc_pk']]);
935 $_SESSION[
'coupons'][$coupon_session_id][$coupon[
'pc_pk']] = $coupon;
954 foreach (
$_SESSION[
'coupons'] as $key => $val)
970 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
973 $tpl =
new ilTemplate(
'tpl.pay_shopping_cart_coupons.html',
true,
true,
'Services/Payment');
975 $tpl->setVariable(
'COUPON_FORMACTION', $this->ctrl->getFormAction($this));
976 $tpl->setVariable(
'TITLE', $this->lng->txt(
'paya_coupons_coupons'));
978 $tpl->setVariable(
'ALT_IMG', $this->lng->txt(
'obj_usr'));
980 $tpl->setVariable(
'TXT_CODE', $this->lng->txt(
'paya_coupons_code'));
981 $tpl->setVariable(
'CMD_VALUE', $this->lng->txt(
'send'));
983 $tpl->setVariable(
'PAYMENT_TYPE', $payment_type);
985 $coupon_session = $payment_type;
987 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
990 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
992 $tpl->setCurrentBlock(
'loop');
994 $tpl->setVariable(
'LOOP_TXT_COUPON', $this->lng->txt(
'paya_coupons_coupon'));
995 $tpl->setVariable(
'LOOP_CODE', $coupon[
'pcc_code']);
996 $this->ctrl->setParameter($this,
'coupon_id', $coupon[
'pc_pk']);
997 $this->ctrl->setParameter($this,
'payment_type',
$_SESSION[
'bmf'][
'payment_type']);
998 $tpl->setVariable(
'LOOP_TITLE', $coupon[
'pc_title']);
999 if ($coupon[
'pc_description'] !=
'')
$tpl->setVariable(
'LOOP_DESCRIPTION', nl2br($coupon[
'pc_description']));
1000 $tpl->setVariable(
"LOOP_TYPE", sprintf($this->lng->txt(
'paya_coupons_'.($coupon[
'pc_type'] ==
"fix" ?
'fix' :
'percentaged').
'_'.(count($coupon[
'objects']) == 0 ?
'all' :
'selected').
'_objects'),
1001 ($coupon[
'pc_value'] / round($coupon[
'pc_value'], 0) == 1 && $coupon[
'pc_type'] ==
"percent" ? round($coupon[
'pc_value'], 0) : number_format($coupon[
'pc_value'], 2,
',',
'.')),
1002 ($coupon[
'pc_type'] ==
"percent" ?
"%" :$genSet->get(
'currency_unit'))));
1003 $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>");
1005 $tpl->parseCurrentBlock();
1018 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
1021 include_once
'./Services/Payment/classes/class.ilShoppingCartTableGUI.php';
1024 $tbl->setId(
'tbl_id_'.$a_pay_method);
1025 $tbl->setTitle($this->lng->txt(
'paya_shopping_cart').
1026 " (".$this->lng->txt(
'payment_system').
": ".
1029 $coupon_session = $a_pay_method[
'pm_title'];
1031 $tbl->setRowTemplate(
"tpl.shop_shoppingcart_row.html",
"Services/Payment");
1032 $tbl->addColumn(
'',
'item',
'1%',
true);
1033 $tbl->addColumn($this->lng->txt(
'title'),
"table". $a_pay_method[
'pm_title'].
"_title",
'30%');
1034 $tbl->addColumn($this->lng->txt(
'duration'),
"table". $a_pay_method[
'pm_title'].
"_duration",
'30%');
1035 $tbl->addColumn($this->lng->txt(
'vat_rate'),
"table". $a_pay_method[
'pm_title'].
"_vat_rate",
'15%');
1036 $tbl->addColumn($this->lng->txt(
'vat_unit'),
"table". $a_pay_method[
'pm_title'].
"_vat_unit",
'15%');
1037 $tbl->addColumn($this->lng->txt(
'price_a'),
"table". $a_pay_method[
'pm_title'].
"_price",
'10%');
1039 $tbl->setPrefix(
"table". $a_pay_method[
'pm_title'].
"_");
1040 $tbl->addMultiCommand(
'deleteItem', $this->lng->txt(
'delete'));
1046 if (!empty(
$_SESSION[
'coupons'][$coupon_session]))
1048 if (count($items = $sc_obj->getEntries($a_pay_method[
'pm_id'])))
1050 $tbl->setTotalData(
'TXT_SUB_TOTAL', $this->lng->txt(
'pay_bmf_subtotal_amount') .
": ");
1051 $tbl->setTotalData(
'VAL_SUB_TOTAL', number_format(
$totalAmount[$a_pay_method[
'pm_id']], 2,
',',
'.') .
" " . $genSet->get(
'currency_unit'));
1054 foreach (
$_SESSION[
'coupons'][$coupon_session] as $coupon)
1056 $this->coupon_obj->setId($coupon[
'pc_pk']);
1057 $this->coupon_obj->setCurrentCoupon($coupon);
1059 $total_object_price = 0.0;
1060 $current_coupon_bonus = 0.0;
1062 foreach ($items as $item)
1064 $tmp_pobject =
new ilPaymentObject($this->user_obj, $item[
'pobject_id']);
1066 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
1069 $price = (float) $price_data[
'price'];
1071 $total_object_price += $price;
1073 unset($tmp_pobject);
1076 $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
1077 $totalAmount[$current_coupon_bonus] += $current_coupon_bonus * (-1);
1078 $tbl->setTotalData(
'TXT_COUPON_BONUS', $this->lng->txt(
'paya_coupons_coupon') .
" " . $coupon[
'pcc_code'] .
": ");
1079 $tbl->setTotalData(
'VAL_COUPON_BONUS', number_format($current_coupon_bonus * (-1), 2,
',',
'.') .
" " . $genSet->get(
'currency_unit'));
1085 $this->totalVat = 0;
1090 $this->totalAmount[$a_pay_method[
'pm_id']] =
$totalAmount[$a_pay_method[
'pm_id']]-$current_coupon_bonus;
1091 $tbl->setTotalData(
'TXT_TOTAL_AMOUNT', $this->lng->txt(
'pay_bmf_total_amount').
": ");
1092 $tbl->setTotalData(
'VAL_TOTAL_AMOUNT', number_format($this->totalAmount[$a_pay_method[
'pm_id']] , 2,
',',
'.') .
" " . $genSet->get(
'currency_unit')); #.$item[
'currency']);
1095 #$currency_conversion_totalvat = (float)$_SESSION['currency_conversion'][$a_pay_method['pm_title']]['total_vat'];
1096 #if($currency_conversion_totalvat > 0) $this->totalVat = $currency_conversion_totalvat;
1098 if ($this->totalVat > 0)
1100 $tbl->setTotalData(
'TXT_TOTAL_VAT', $this->lng->txt(
'pay_bmf_vat_included') .
": ");
1101 $tbl->setTotalData(
'VAL_TOTAL_VAT', number_format($this->totalVat , 2,
',',
'.') .
" " . $genSet->get(
'currency_unit'));
1104 $tbl->setData($a_result_set);
1105 $a_tpl->setVariable(
'ITEMS_TABLE',$tbl->getCartHTML());
1112 if(!count(
$_POST[
'item']))
1121 foreach(
$_POST[
'item'] as $id)
1123 $this->psc_obj->delete($id);
1135 $this->psc_obj->clearCouponItemsSession();
1151 $merchant_cert = $this->paypalConfig[
"vendor_cert"];
1152 $merchant_key = $this->paypalConfig[
"vendor_key"];
1153 $end_cert = $this->paypalConfig[
"enc_cert"];
1155 $tmpin_file = tempnam(
'/tmp',
'paypal_');
1156 $tmpout_file = tempnam(
'/tmp',
'paypal_');
1157 $tmpfinal_file = tempnam(
'/tmp',
'paypal_');
1160 $buttonParams[
'cert_id'] = $this->paypalConfig[
"cert_id"];
1161 foreach ($buttonParams as
$name => $value) {
1162 $rawdata[] =
"$name=$value";
1164 $rawdata = implode(
"\n", $rawdata);
1166 $fp = fopen($tmpin_file,
'w');
1168 echo
"Could not open temporary file '$tmpin_file')";
1170 # return PayPal::raiseError("Could not open temporary file '$tmpin_file')");
1172 fwrite($fp, $rawdata);
1175 if (!@openssl_pkcs7_sign($tmpin_file, $tmpout_file, $merchant_cert,
1176 array($merchant_key, $this->paypalConfig[
"private_key_password"]),
1177 array(), PKCS7_BINARY)) {
1178 echo
"Could not sign encrypted data: " . openssl_error_string();
1180 # return PayPal::raiseError("Could not sign encrypted data: " . openssl_error_string());
1183 $data = file_get_contents($tmpout_file);
1187 $fp = fopen($tmpout_file,
'w');
1189 echo
"Could not open temporary file '$tmpin_file')";
1191 # return PayPal::raiseError("Could not open temporary file '$tmpin_file')");
1196 if (!@openssl_pkcs7_encrypt($tmpout_file, $tmpfinal_file, $end_cert, array(), PKCS7_BINARY)) {
1197 echo
"Could not encrypt data:" . openssl_error_string();
1199 # return PayPal::raiseError("Could not encrypt data:" . openssl_error_string());
1202 $encdata = @file_get_contents($tmpfinal_file,
false);
1204 echo
"Encryption and signature of data failed.";
1206 # return PayPal::raiseError("Encryption and signature of data failed.");
1209 $encdata = explode(
"\n\n", $encdata);
1210 $encdata = trim(str_replace(
"\n",
'', $encdata[1]));
1211 $encdata =
"-----BEGIN PKCS7-----$encdata-----END PKCS7-----";
1213 @unlink($tmpfinal_file);
1214 @unlink($tmpin_file);
1215 @unlink($tmpout_file);
1224 include_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
1227 $form_2->setFormAction($ilCtrl->getFormAction($this,
'validateNewUser'));
1228 $form_2->setTitle($lng->txt(
'login'));
1229 $form_2->setId(
'user_frm');
1231 $form_2->addCommandButton(
'validateNewUser',$lng->txt(
'save'));
1235 $form_2->addItem($formName);
1239 $formPass->setValue(
$_SESSION[
'user_pass']);
1240 $form_2->addItem($formPass);
1242 $tpl->setVariable(
'USER_FORM',$form_2->getHTML());
1249 require_once
'Services/User/classes/class.ilObjUser.php';
1250 include_once
'./Services/Payment/classes/class.ilShopUtils.php';
1255 $old_user_id =
$_SESSION[
'tmp_transaction'][
'usr_id'];
1256 $transaction_extern =
$_SESSION[
'tmp_transaction'][
'tx_id'];
1258 if($user_id != ANONYMOUS_USER_ID && $user_id != $old_user_id && $user_id != NULL)
1262 if($obj_user->getPasswd() == md5(
$_POST[
"user_pass"]))
1269 include_once
"./Modules/Course/classes/class.ilCourseParticipants.php";
1270 foreach (
$_SESSION[
'crs_obj_ids'] as $obj_id)
1277 if($obj =& $ilias->obj_factory->getInstanceByObjId($old_user_id))
1280 $ilUser =
new ilObjUser(ANONYMOUS_USER_ID);