private function addBookings($pay_method, $coupon_session)
 {
     global $ilUser, $ilObjDataCache;
     include_once './Services/Payment/classes/class.ilPaymentBookings.php';
     include_once './Services/Payment/classes/class.ilPaymentObject.php';
     include_once './Services/Payment/classes/class.ilPaymentPrices.php';
     $booking_obj = new ilPaymentBookings();
     $sc_obj = new ilPaymentShoppingCart($this->user_obj);
     $items = $sc_obj->getEntries($pay_method);
     $sc_obj->clearCouponItemsSession();
     foreach ($items as $entry) {
         $pobject = new ilPaymentObject($this->user_obj, $entry['pobject_id']);
         $price = ilPaymentPrices::_getPrice($entry['price_id']);
         if (!empty($_SESSION['coupons'][$coupon_session])) {
             $entry['math_price'] = $entry['price'];
             // (float) ilPaymentPrices::_getPriceFromArray($price);
             foreach ($_SESSION['coupons'][$coupon_session] as $key => $coupon) {
                 $this->coupon_obj->setId($coupon['pc_pk']);
                 $this->coupon_obj->setCurrentCoupon($coupon);
                 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId())) {
                     $_SESSION['coupons'][$coupon_session][$key]['total_objects_coupon_price'] += $entry['price'];
                     //(float) ilPaymentPrices::_getPriceFromArray($price);
                     $_SESSION['coupons'][$coupon_session][$key]['items'][] = $entry;
                 }
             }
         }
         unset($pobject);
     }
     $coupon_discount_items = $sc_obj->calcDiscountPrices($_SESSION['coupons'][$coupon_session]);
     foreach ($items as $entry) {
         $pobject = new ilPaymentObject($this->user_obj, $entry['pobject_id']);
         $price = ilPaymentPrices::_getPrice($entry['price_id']);
         if (array_key_exists($entry['pobject_id'], $coupon_discount_items)) {
             $bonus = $coupon_discount_items[$entry['pobject_id']]['math_price'] - $coupon_discount_items[$entry['pobject_id']]['discount_price'];
         }
         $booking_obj->setPobjectId($entry['pobject_id']);
         $booking_obj->setCustomerId($this->user_obj->getId());
         $booking_obj->setVendorId($pobject->getVendorId());
         $booking_obj->setPayMethod($pobject->getPayMethod());
         $booking_obj->setOrderDate(time());
         $booking_obj->setDuration($price['duration']);
         $booking_obj->setPrice(ilPaymentPrices::_getPriceString($entry['price_id']));
         $booking_obj->setDiscount($bonus > 0 ? -1 * $bonus : 0);
         $booking_obj->setPayed(1);
         $booking_obj->setAccess(1);
         switch ($price['price_type']) {
             case ilPaymentPrices::TYPE_UNLIMITED_DURATION:
                 $booking_obj->setDuration(0);
                 break;
             case ilPaymentPrices::TYPE_DURATION_MONTH:
                 $booking_obj->setDuration($price['duration']);
                 break;
             case ilPaymentPrices::TYPE_DURATION_DATE:
                 $booking_obj->setAccessStartdate($price['duration_from']);
                 $booking_obj->setAccessEnddate($price['duration_until']);
                 break;
         }
         $booking_obj->setAccessExtension($price['extension']);
         $obj_id = $ilObjDataCache->lookupObjId($pobject->getRefId());
         $obj_title = $ilObjDataCache->lookupTitle($obj_id);
         $oVAT = new ilShopVats((int) $pobject->getVatId());
         $obj_vat_rate = $oVAT->getRate();
         if ($bonus > 0) {
             $tmp_price = $booking_obj->getPrice() - $bonus;
             $obj_vat_unit = $pobject->getVat($tmp_price);
         } else {
             $obj_vat_unit = $pobject->getVat($booking_obj->getPrice());
         }
         $booking_obj->setObjectTitle($obj_title);
         $booking_obj->setVatRate($obj_vat_rate);
         $booking_obj->setVatUnit($obj_vat_unit);
         if (ilPaymethods::_EnabledSaveUserAddress($booking_obj->getPayMethod())) {
             $booking_obj->setStreet($this->user_obj->getStreet(), $this->user_obj->getHouseNumber);
             $booking_obj->setZipcode($this->user_obj->getZipcode());
             $booking_obj->setCity($this->user_obj->getCity());
             $booking_obj->setCountry($this->user_obj->getCountry());
         }
         $current_booking_id = $booking_obj->add();
         if ($current_booking_id) {
             $sc_obj->delete($entry['psc_id']);
             if (!empty($_SESSION['coupons'][$coupon_session])) {
                 foreach ($_SESSION['coupons'][$coupon_session] as $coupon) {
                     $this->coupon_obj->setId($coupon['pc_pk']);
                     $this->coupon_obj->setCurrentCoupon($coupon);
                     if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId())) {
                         $this->coupon_obj->addCouponForBookingId($current_booking_id);
                     }
                 }
             }
         }
         unset($current_booking_id);
         unset($pobject);
     }
     if (!empty($_SESSION['coupons'][$coupon_session])) {
         foreach ($_SESSION['coupons'][$coupon_session] as $coupon) {
             $this->coupon_obj->setId($coupon['pc_pk']);
             $this->coupon_obj->setCurrentCoupon($coupon);
             $this->coupon_obj->addTracking();
         }
     }
 }