{
$this->deb->createInvoice();
$products = array();
foreach ($this->sc as $i)
{
$ilias_tid = $this->ilUser->getId() . "_" . $tid;
$bo->setPobjectId( isset($i['pobject_id']) ? $i['pobject_id'] : 0 );
$bo->setCustomerId( $this->ilUser->getId() );
$bo->setVendorId( $pod['vendor_id'] );
$bo->setPayMethod($this->paytype);
$bo->setOrderDate(time());
$bo->setDuration($i['dauer']);
$bo->setPrice( $i['betrag'] );
$bo->setDiscount(0);
$bo->setVoucher('');
$bo->setVatRate( $i['vat_rate'] );
$bo->setVatUnit( $i['vat_unit'] );
$bo->setTransactionExtern($tid);
$product_name = $i['buchungstext'];
$duration = $i['dauer'];
$amount = $i['betrag'];
include_once './payment/classes/class.ilPayMethods.php';
$save_adr = (int) ilPaymethods::_enabled('save_user_adr_epay') ? 1 : 0;
$bo->setStreet($this->ilUser->getStreet(), '');
$bo->setPoBox('');
$bo->setZipcode($this->ilUser->getZipcode());
$bo->setCity($this->ilUser->getCity);
$bo->setCountry($this->ilUser->getCountry());
$bo->setPayed(1);
$bo->setAccess(1);
$boid = $bo->add();
if ( $i['typ'] == 'crs')
{
include_once './Modules/Course/classes/class.ilCourseParticipants.php';
$this->deb->createInvoiceLine( 0, $product_name . " (" . $duration. ")", 1, $amount );
$products[] = $product_name;
$cp->sendNotification($cp->NOTIFY_ACCEPT_SUBSCRIBER, $this->ilUser->getId());
}
}
$inv = $this->deb->bookInvoice();
$invoice_number = $this->deb->getInvoiceNumber();
$attach = $this->deb->getInvoicePDF($inv);
$this->deb->saveInvoice($attach, false);
$lng->loadLanguageModule('payment');
$this->deb->sendInvoice($lng->txt('pay_order_paid_subject'),
$this->ilUser->getFullName() . ",\n" .
str_replace( '%products%', implode(", ", $products), $lng->txt('pay_order_paid_body')) ,
$this->ilUser->getEmail(),
$attach, $lng->txt('pays_invoice') ."-" . $invoice_number
);
$this->cart->emptyShoppingCart();
}