ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPurchasePaypal Class Reference
+ Inheritance diagram for ilPurchasePaypal:
+ Collaboration diagram for ilPurchasePaypal:

Public Member Functions

 ilPurchasePaypal ($user_obj)
 openSocket ()
 checkData ($fp)
 __checkTransactionId ($a_id)
 __checkItems ($a_array)
 __saveTransaction ($keyarray)
 __sendBill ($bookings, $a_array)
 __initShoppingCartObject ()
 __getCountries ()
 shows select box f�r countries
 __getCountryCode ($value="")
 __getCountryName ($value="")
- Public Member Functions inherited from ilPurchaseBaseGUI
 ilPurchaseBaseGUI ($user_obj, $pay_method)
 cancel ()
 showPersonalData ()
 getPersonalData ()
 showBillConfirm ()
 executeCommand ()
 execute command
 __addBookings ($external_data=null)
 __sendBill ($bookings)
 __emptyShoppingCart ()
 __clearSession ()
 __loadTemplate ()
 __buildStatusline ()
 __buildLocator ()
 __buildStylesheet ()
 __getShoppingCart ()
 __getTotalAmount ()
 getBill ()
 __showShoppingCart ()
 __showItemsTable ($a_result_set)

Data Fields

 $psc_obj = null
 $user_obj = null
 $pay_method = null
 $currency = null
 $db = null
 $paypalConfig
- Data Fields inherited from ilPurchaseBaseGUI
 $ctrl
 $tpl
 $psc_obj = null
 $user_obj = null
 $coupon_obj = null
 $error
 $pmethod_obj = null

Private Attributes

 $totalVat = 0

Detailed Description

Definition at line 31 of file class.ilPurchasePaypal.php.

Member Function Documentation

ilPurchasePaypal::__checkItems (   $a_array)

Definition at line 224 of file class.ilPurchasePaypal.php.

References $_SESSION, and $total.

Referenced by checkData().

{
/*TODO : CURRENCY
#$genSet = new ilGeneralSettings();
include_once './Services/Payment/classes/class.ilPayMethods.php';
// pretty quick and dirty
include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
$currency = ilPaymentCurrency::_getUnit(1);
// Wrong currency
if ($a_array["mc_currency"] != $currency)#$genSet->get("currency_unit"))
*/
$genSet = new ilGeneralSettings();
include_once './Services/Payment/classes/class.ilPayMethods.php';
// Wrong currency
if ($a_array["mc_currency"] != $genSet->get("currency_unit"))
{
return false;
}
$sc = $this->psc_obj->getShoppingCart($this->pay_method);
$this->psc_obj->clearCouponItemsSession();
if (is_array($sc) && count($sc) > 0)
{
for ($i = 0; $i < count($sc); $i++)
{
$items[$i] = array(
"name" => $a_array["item_name".($i+1)],
"amount" => $a_array["mc_gross_".($i+1)]
);
if (!empty($_SESSION["coupons"]["paypal"]))
{
$sc[$i]["math_price"] = (float) $sc[$i]["price"];
$tmp_pobject = new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']);
foreach ($_SESSION["coupons"]["paypal"] as $key => $coupon)
{
$this->coupon_obj->setId($coupon["pc_pk"]);
$this->coupon_obj->setCurrentCoupon($coupon);
if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
{
$_SESSION["coupons"]["paypal"][$key]["total_objects_coupon_price"] += (float) $sc[$i]["price"];
$_SESSION["coupons"]["paypal"][$key]["items"][] = $sc[$i];
}
}
unset($tmp_pobject);
}
}
$coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["paypal"]);
$found = 0;
$total = 0;
for ($i = 0; $i < count($sc); $i++)
{
if (array_key_exists($sc[$i]["pobject_id"], $coupon_discount_items))
{
$sc[$i]["price"] = round($coupon_discount_items[$sc[$i]["pobject_id"]]["discount_price"], 2);
if ($sc[$i]["price"] < 0) $sc[$i]["price"] = 0.0;
}
for ($j = 0; $j < count($items); $j++)
{
if (substr($items[$j]["name"], 0, strlen($sc[$i]["obj_id"])+2) == "[".$sc[$i]["obj_id"]."]" &&
$items[$j]["amount"] == $sc[$i]["price"])
{
$total += $items[$j]["amount"];
$found++;
}
}
}
// The number of items, the items themselves and their amounts and the total amount correct
if (number_format($total, 2, ".", "") == $a_array["mc_gross"] &&
$found == count($sc))
{
return true;
}
}
return false;
}

+ Here is the caller graph for this function:

ilPurchasePaypal::__checkTransactionId (   $a_id)

Definition at line 214 of file class.ilPurchasePaypal.php.

References $ilDB, and $res.

Referenced by checkData().

{
global $ilDB;
$res = $ilDB->queryF('SELECT * FROM payment_statistic WHERE transaction_extern = %s',
array('text'), array($a_id));
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilPurchasePaypal::__getCountries ( )

shows select box f�r countries

Reimplemented from ilPurchaseBaseGUI.

Definition at line 719 of file class.ilPurchasePaypal.php.

References $lng.

Referenced by __getCountryCode(), and __getCountryName().

{
global $lng;
$lng->loadLanguageModule("meta");
$cntcodes = array ("DE","ES","FR","GB","AT","CH","AF","AL","DZ","AS","AD","AO",
"AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY",
"BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","BN","BG","BF",
"BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM",
"CG","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","TP","EC",
"EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","FX","GF","PF",
"TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GN",
"GW","GY","HT","HM","HN","HU","IS","IN","ID","IR","IQ","IE","IL","IT",
"JM","JP","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS",
"LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH",
"MQ","MR","MU","YT","MX","FM","MD","MC","MN","MS","MA","MZ","MM","NA",
"NR","NP","NL","AN","NC","NZ","NI","NE","NG","NU","NF","MP","NO","OM",
"PK","PW","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RE","RO",
"RU","RW","KN","LC","VC","WS","SM","ST","SA","CH","SN","SC","SL","SG",
"SK","SI","SB","SO","ZA","GS","ES","LK","SH","PM","SD","SR","SJ","SZ",
"SE","SY","TW","TJ","TZ","TH","TG","TK","TO","TT","TN","TR","TM","TC",
"TV","UG","UA","AE","GB","UY","US","UM","UZ","VU","VA","VE","VN","VG",
"VI","WF","EH","YE","ZR","ZM","ZW");
$cntrs = array();
foreach($cntcodes as $cntcode)
{
$cntrs[$cntcode] = $lng->txt("meta_c_".$cntcode);
}
asort($cntrs);
return $cntrs;
}

+ Here is the caller graph for this function:

ilPurchasePaypal::__getCountryCode (   $value = "")

Reimplemented from ilPurchaseBaseGUI.

Definition at line 752 of file class.ilPurchasePaypal.php.

References __getCountries().

{
$countries = $this->__getCountries();
foreach($countries as $code => $text)
{
if ($text == $value)
{
return $code;
}
}
return;
}

+ Here is the call graph for this function:

ilPurchasePaypal::__getCountryName (   $value = "")

Reimplemented from ilPurchaseBaseGUI.

Definition at line 765 of file class.ilPurchasePaypal.php.

References __getCountries().

{
$countries = $this->__getCountries();
return $countries[$value];
}

+ Here is the call graph for this function:

ilPurchasePaypal::__initShoppingCartObject ( )

Definition at line 714 of file class.ilPurchasePaypal.php.

{
$this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
}
ilPurchasePaypal::__saveTransaction (   $keyarray)

content of $keyarray

'mc_gross' => string '2.00' (length=4) 'protection_eligibility' => string 'Ineligible' (length=10) 'address_status' => string 'unconfirmed' (length=11) 'item_number1' => string '' (length=0) 'payer_id' => string 'TZSNWLFE2DF58' (length=13) 'tax' => string '0.00' (length=4) 'address_street' => string 'ESpachstr. 1' (length=12) 'payment_date' => string '00:48:45 Feb 22, 2010 PST' (length=25) 'payment_status' => string 'Pending' (length=7) 'charset' => string 'windows-1252' (length=12) 'address_zip' => string '79111' (length=5) 'mc_shipping' => string '0.00' (length=4) 'mc_handling' => string '0.00' (length=4) 'first_name' => string 'Test' (length=4) 'mc_fee' => string '0.39' (length=4) 'address_country_code' => string 'DE' (length=2) 'address_name' => string 'Test User' (length=9) 'custom' => string '13' (length=2) 'payer_status' => string 'verified' (length=8) 'business' => string '12402.nosp@m.1391.nosp@m.@data.nosp@m.bay..nosp@m.de' (length=32) 'address_country' => string 'Germany' (length=7) 'num_cart_items' => string '1' (length=1) 'mc_handling1' => string '0.00' (length=4) 'address_city' => string 'Freiburg' (length=8) 'payer_email' => string '12402.nosp@m.1404.nosp@m.3@dat.nosp@m.abay.nosp@m..de' (length=32) 'mc_shipping1' => string '0.00' (length=4) 'txn_id' => string '3UB51507EB277381H' (length=17) 'payment_type' => string 'instant' (length=7) 'last_name' => string 'User' (length=4) 'address_state' => string 'Empty' (length=5) 'item_name1' => string '[216]: test.jpg' (length=17) 'receiver_email' => string '24021.nosp@m.3918.nosp@m.@data.nosp@m.bay..nosp@m.de' (length=32) 'payment_fee' => string '' (length=0) 'quantity1' => string '1' (length=1) 'receiver_id' => string 'TE2KBY9PBMN2L' (length=13) 'pending_reason' => string 'paymentreview' (length=13) 'txn_type' => string 'cart' (length=4) 'mc_gross_1' => string '2.00' (length=4) 'mc_currency' => string 'EUR' (length=3) 'residence_country' => string 'DE' (length=2) 'transaction_subject' => string '13' (length=2) 'payment_gross' => string '' (length=0) '' => string '' (length=0)

Definition at line 316 of file class.ilPurchasePaypal.php.

References $_SESSION, $total, ilPayMethods\_EnabledSaveUserAddress(), ilPaymentObject\_getObjectData(), ilRepositoryExplorer\buildFrameTarget(), and ilRepositoryExplorer\buildLinkTarget().

Referenced by checkData().

{
global $ilias, $ilUser, $ilObjDataCache;
$sc = $this->psc_obj->getShoppingCart($this->pay_method);
$this->psc_obj->clearCouponItemsSession();
if (is_array($sc) && count($sc) > 0)
{
include_once './Services/Payment/classes/class.ilPaymentBookings.php';
$book_obj =& new ilPaymentBookings($this->usr_obj);
for ($i = 0; $i < count($sc); $i++)
{
if (!empty($_SESSION["coupons"]["paypal"]))
{
$sc[$i]["math_price"] = (float) $sc[$i]["price"];
$tmp_pobject =& new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']);
foreach ($_SESSION["coupons"]["paypal"] as $key => $coupon)
{
$this->coupon_obj->setId($coupon["pc_pk"]);
$this->coupon_obj->setCurrentCoupon($coupon);
if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
{
$_SESSION["coupons"]["paypal"][$key]["total_objects_coupon_price"] += (float) $sc[$i]["price"];
$_SESSION["coupons"]["paypal"][$key]["items"][] = $sc[$i];
}
}
unset($tmp_pobject);
}
}
$coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["paypal"]);
$inst_id_time = $ilias->getSetting('inst_id').'_'.$ilUser->getId().'_'.substr((string) time(),-3);
$transaction = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
for ($i = 0; $i < count($sc); $i++)
{
$pobjectData = ilPaymentObject::_getObjectData($sc[$i]["pobject_id"]);
$pobject = new ilPaymentObject($this->user_obj,$sc[$i]['pobject_id']);
$price = $sc[$i]["price"];
$bonus = 0.0;
if (array_key_exists($sc[$i]["pobject_id"], $coupon_discount_items))
{
$bonus = $coupon_discount_items[$sc[$i]["pobject_id"]]["math_price"] - $coupon_discount_items[$sc[$i]["pobject_id"]]["discount_price"];
}
$book_obj->setTransaction($transaction);
$book_obj->setPobjectId($sc[$i]["pobject_id"]);
$book_obj->setCustomerId($ilUser->getId());
$book_obj->setVendorId($pobjectData["vendor_id"]);
$book_obj->setPayMethod($pobjectData["pay_method"]);
$book_obj->setOrderDate(time());
$book_obj->setDuration($sc[$i]["duration"]);
$book_obj->setPrice($sc[$i]["price_string"]);
// $book_obj->setDiscount($bonus > 0 ? ilPaymentPrices::_getPriceStringFromAmount($bonus * (-1)) : 0);
$book_obj->setDiscount($bonus > 0 ? ($bonus * (-1)) : 0);
$book_obj->setPayed(1);
$book_obj->setAccess(1);
$book_obj->setVoucher('');
$book_obj->setTransactionExtern($keyarray['txn_id']);
$book_obj->setObjectTitle($sc[$i]['object_title']);
$book_obj->setVatRate($sc[$i]['vat_rate']);
$book_obj->setVatUnit($sc[$i]['vat_unit']);
$book_obj->setEmailExtern($keyarray['payer_email']);
$book_obj->setNameExtern($keyarray['address_name']);
$_SESSION['transaction']=$book_obj->getTransaction();
include_once './Services/Payment/classes/class.ilPayMethods.php';
//$save_user_adr_bill = (int) ilPayMethods::_enabled('save_user_adr_paypal') ? 1 : 0;
$save_user_adr = (int) ilPayMethods::_EnabledSaveUserAddress($this->pay_method) ? 1 : 0;
if($save_user_adr == '1' || (ANONYMOUS_USER_ID == $ilUser->getId()))
{
$book_obj->setStreet($keyarray['address_street'],'');
$book_obj->setZipCode($keyarray['address_zip']);
$book_obj->setCity($keyarray['address_city']);
$book_obj->setCountry($keyarray['address_country_code']);
$_SESSION['paypal']['personal_data']['name'] = $keyarray['address_name'];
$_SESSION['paypal']['personal_data']['email'] = $keyarray['payer_email'];
}
$booking_id = $book_obj->add();
if (!empty($_SESSION["coupons"]["paypal"]) && $booking_id)
{
foreach ($_SESSION["coupons"]["paypal"] 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($booking_id);
}
}
}
unset($booking_id);
unset($pobject);
$obj_id = $ilObjDataCache->lookupObjId($pobjectData["ref_id"]);
$obj_type = $ilObjDataCache->lookupType($obj_id);
$obj_title = $ilObjDataCache->lookupTitle($obj_id);
include_once "./Services/Repository/classes/class.ilRepositoryExplorer.php";
$obj_link = ilRepositoryExplorer::buildLinkTarget($pobjectData["ref_id"],$obj_type);
$obj_target = ilRepositoryExplorer::buildFrameTarget($obj_type,$pobjectData["ref_id"],$obj_id);
$message_link = "" . ILIAS_HTTP_PATH."/".$obj_link."&transaction=".$book_obj->getTransaction();
if($obj_type == 'file')
$download_links[] = $message_link;
$bookings["list"][] = array(
"type" => $obj_type,
"title" => "[".$obj_id."]: " . $obj_title,
"message_link" => $message_link,
"duration" => $sc[$i]["duration"],
"vat_rate" => $sc[$i]["vat_rate"],
"vat_unit" => $sc[$i]["vat_unit"],
'price_string' => $sc[$i]['price_string'],
'price' => $sc[$i]['price'],
'bonus'=> $bonus,
'currency_unit' =>$sc[$i]['currency_unit']
);
$total += $sc[$i]["price"];
$total_vat += $sc[$i]['vat_unit'];
if ($sc[$i]["psc_id"]) $this->psc_obj->delete($sc[$i]["psc_id"]);
}
if (!empty($_SESSION["coupons"]["paypal"]))
{
foreach ($_SESSION["coupons"]["paypal"] as $coupon)
{
$this->coupon_obj->setId($coupon["pc_pk"]);
$this->coupon_obj->setCurrentCoupon($coupon);
$this->coupon_obj->addTracking();
}
}
}
$bookings["total"] = $total;
$bookings['total_vat'] = $total_vat;
$bookings['email_extern'] = $keyarray['payer_email'];
$bookings['name_extern'] = $keyarray['address_name'];
$_SESSION['download_links'] = $download_links;
return $bookings;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPurchasePaypal::__sendBill (   $bookings,
  $a_array 
)

Definition at line 529 of file class.ilPurchasePaypal.php.

References $_SESSION, ilPurchaseBaseGUI\$tpl, ilShopUtils\_formatFloat(), ilShopUtils\_formatVAT(), ilUtil\html2pdf(), ilUtil\makeDir(), and ilMimeMail\Subject().

Referenced by checkData().

{
global $ilUser, $ilias;
$transaction = $a_array["txn_id"];
include_once './classes/class.ilTemplate.php';
include_once './Services/Utilities/classes/class.ilUtil.php';
include_once './Services/Payment/classes/class.ilGeneralSettings.php';
include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
include_once 'Services/Mail/classes/class.ilMimeMail.php';
$genSet = new ilGeneralSettings();
$tpl = new ilTemplate('tpl.pay_bill.html', true, true, 'Services/Payment');
$tpl->setVariable("VENDOR_ADDRESS", nl2br(utf8_decode($genSet->get("address"))));
$tpl->setVariable("VENDOR_ADD_INFO", nl2br(utf8_decode($genSet->get("add_info"))));
$tpl->setVariable("VENDOR_BANK_DATA", nl2br(utf8_decode($genSet->get("bank_data"))));
$tpl->setVariable("TXT_BANK_DATA", utf8_decode($this->lng->txt("pay_bank_data")));
$tpl->setVariable("CUSTOMER_FIRSTNAME", $a_array["first_name"]);
$tpl->setVariable("CUSTOMER_LASTNAME", $a_array["last_name"]);
$tpl->setVariable("CUSTOMER_STREET", $a_array["address_street"]);
$tpl->setVariable("CUSTOMER_ZIPCODE", $a_array["address_zip"]);
$tpl->setVariable("CUSTOMER_CITY", $a_array["address_city"]);
$tpl->setVariable("CUSTOMER_COUNTRY", $a_array["address_country"]);
$tpl->setVariable("BILL_NO", $transaction);
$tpl->setVariable("DATE", date("d.m.Y"));
$tpl->setVariable("TXT_BILL", utf8_decode($this->lng->txt("pays_bill")));
$tpl->setVariable("TXT_BILL_NO", utf8_decode($this->lng->txt("pay_bill_no")));
$tpl->setVariable("TXT_DATE", utf8_decode($this->lng->txt("date")));
$tpl->setVariable("TXT_ARTICLE", utf8_decode($this->lng->txt("pay_article")));
$tpl->setVariable('TXT_VAT_RATE', utf8_decode($this->lng->txt('vat_rate')));
$tpl->setVariable('TXT_VAT_UNIT', utf8_decode($this->lng->txt('vat_unit')));
$tpl->setVariable("TXT_PRICE", utf8_decode($this->lng->txt("price_a")));
for ($i = 0; $i < count($bookings["list"]); $i++)
{
$tmp_pobject = new ilPaymentObject($this->user_obj, $bookings["list"][$i]['pobject_id']);
$assigned_coupons = '';
if (!empty($_SESSION["coupons"]["paypal"]))
{
foreach ($_SESSION["coupons"]["paypal"] as $key => $coupon)
{
$this->coupon_obj->setId($coupon["pc_pk"]);
$this->coupon_obj->setCurrentCoupon($coupon);
if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
{
$assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon["pcc_code"];
}
}
}
if($bookings["list"][$i]["type"] == 'file')
{
$message_link .= $bookings['list'][$i]['message_link'] . "\n\n";
}
$tpl->setCurrentBlock("loop");
$tpl->setVariable("LOOP_OBJ_TYPE", utf8_decode($this->lng->txt($bookings["list"][$i]["type"])));
$tpl->setVariable("LOOP_TITLE", utf8_decode($bookings["list"][$i]["title"]) . $assigned_coupons);
$tpl->setVariable("LOOP_TXT_ENTITLED_RETRIEVE", utf8_decode($this->lng->txt("pay_entitled_retrieve")));
if( $bookings['list'][$i]['duration'] == 0)
{
$tpl->setVariable('LOOP_DURATION', utf8_decode($this->lng->txt('unlimited_duration')));
}
else
$tpl->setVariable('LOOP_DURATION', $bookings['list'][$i]['duration'] . ' ' . utf8_decode($this->lng->txt('paya_months')));
$tpl->setVariable("LOOP_VAT_RATE", ilShopUtils::_formatVAT($bookings["list"][$i]["vat_rate"]));
$tpl->setVariable('LOOP_VAT_UNIT', ilShopUtils::_formatFloat($bookings['list'][$i]['vat_unit']).' '.$genSet->get('currency_unit'));
$tpl->setVariable("LOOP_PRICE", $bookings["list"][$i]["price"].' '.$bookings["list"][$i]['currency_unit']);
$tpl->parseCurrentBlock("loop");
unset($tmp_pobject);
}
if (!empty($_SESSION["coupons"]["paypal"]))
{
if (count($items = $bookings["list"]))
{
$sub_total_amount = $bookings["total"];
foreach ($_SESSION["coupons"]["paypal"] as $coupon)
{
$this->coupon_obj->setId($coupon["pc_pk"]);
$this->coupon_obj->setCurrentCoupon($coupon);
$total_object_price = 0.0;
$current_coupon_bonus = 0.0;
foreach ($bookings["list"] as $item)
{
$tmp_pobject =& new ilPaymentObject($this->user_obj, $item['pobject_id']);
if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
{
$total_object_price += $item["price"];
}
unset($tmp_pobject);
}
$current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
$bookings["total"] += $current_coupon_bonus * (-1);
$tpl->setCurrentBlock("cloop");
$tpl->setVariable("TXT_COUPON", utf8_decode($this->lng->txt("paya_coupons_coupon") . " " . $coupon["pcc_code"]));
$tpl->setVariable("BONUS", number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get("currency_unit"));
$tpl->parseCurrentBlock();
}
$tpl->setVariable("TXT_SUBTOTAL_AMOUNT", utf8_decode($this->lng->txt("pay_bmf_subtotal_amount")));
$tpl->setVariable("SUBTOTAL_AMOUNT", number_format($sub_total_amount, 2, ",", ".") . " " . $genSet->get("currency_unit"));
}
}
if ($bookings["total"] < 0)
{
$bookings["total"] = 0.0;
$bookings["total_vat"] = 0.0;
}
$tpl->setVariable("TXT_TOTAL_AMOUNT", utf8_decode($this->lng->txt("pay_bmf_total_amount")));
$tpl->setVariable("TOTAL_AMOUNT", number_format($bookings["total"], 2, ",", ".") . " " . $genSet->get("currency_unit"));
if ($bookings["total_vat"] > 0)
{
$tpl->setVariable("TOTAL_VAT", ilShopUtils::_formatFloat($bookings["total_vat"]). " " . $genSet->get("currency_unit"));
$tpl->setVariable("TXT_TOTAL_VAT", utf8_decode($this->lng->txt("pay_bmf_vat_included")));
}
$tpl->setVariable("TXT_PAYMENT_TYPE", utf8_decode($this->lng->txt("pay_payed_paypal")));
if (!@file_exists($genSet->get("pdf_path")))
{
ilUtil::makeDir($genSet->get("pdf_path"));
}
if (@file_exists($genSet->get("pdf_path")))
{
ilUtil::html2pdf($tpl->get(), $genSet->get("pdf_path") . "/" . $transaction . ".pdf");
}
if (@file_exists($genSet->get("pdf_path") . "/" . $transaction . ".pdf") &&
$ilUser->getEmail() != "" &&
$ilias->getSetting("admin_email") != "")
{
$m= new ilMimeMail; // create the mail
$m->Subject( $this->lng->txt("pay_message_subject") );
$m->From( $ilias->getSetting("admin_email") );
if(ANONYMOUS_USER_ID == $ilUser->getId())
{
$m->To($bookings['payer_email']);
$message = $this->lng->txt("pay_message_hello") . " " .$booking['address_name']. ",\n\n";
}
else
{
$m->To( $ilUser->getEmail() );
$message = $this->lng->txt("pay_message_hello") . " " . $ilUser->getFirstname() . " " . $ilUser->getLastname() . ",\n\n";
}
$message .= $this->lng->txt("pay_message_thanks") . "\n\n";
$message .= $message_link."\n\n";
$message .= $this->lng->txt("pay_message_attachment") . "\n\n";
$message .= $this->lng->txt("pay_message_regards") . "\n\n";
$message .= strip_tags($genSet->get("address"));
$m->Body( $message ); // set the body
$m->Attach( $genSet->get("pdf_path") . "/" . $transaction . ".pdf", "application/pdf" ) ; // attach a file of type image/gif
$m->Send(); // send the mail
}
@unlink($genSet->get("pdf_path") . "/" . $transaction . ".html");
@unlink($genSet->get("pdf_path") . "/" . $transaction . ".pdf");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPurchasePaypal::checkData (   $fp)

Definition at line 64 of file class.ilPurchasePaypal.php.

References $_REQUEST, $_SESSION, $auth_token, $res, __checkItems(), __checkTransactionId(), __saveTransaction(), __sendBill(), ilShopUtils\_createRandomUserAccount(), ilCourseParticipants\_getInstanceByObjId(), ERROR_FAIL, ERROR_NOT_COMPLETED, ERROR_PREV_TRANS_ID, ERROR_WRONG_CUSTOMER, ERROR_WRONG_ITEMS, ERROR_WRONG_VENDOR, IL_CRS_MEMBER, and SUCCESS.

{
global $ilUser;
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_REQUEST['tx'];
$auth_token = $this->paypalConfig["auth_token"];
$req .= "&tx=$tx_token&at=$auth_token";
$header .= "POST " . $this->paypalConfig["server_path"] . " HTTP/1.0\r\n";
$header .= "Host:".$this->paypalConfig["server_host"]."\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp))
{
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0)
{
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0)
{
for ($i=1; $i<count($lines);$i++)
{
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check customer
if ($ilUser->getId() != $keyarray["custom"])
{
#echo "Wrong customer";
}
// check the payment_status is Completed
if (!in_array($keyarray["payment_status"], array("Completed", "In-Progress", "Pending", "Processed")))
{
#echo "Not completed";
}
// check that txn_id has not been previously processed
if ($this->__checkTransactionId($keyarray["txn_id"]))
{
if($_SESSION['tmp_transaction']['result'] == 'success'
&& $_SESSION['tmp_transaction']['tx_id'] == $keyarray["txn_id"])
{
// this is for catching the problem, if the user doubleklicks on the paypal
// site to return to the ilias shop and his purchasings already exists in db
return SUCCESS;
}
else
#echo "Prev. processed trans. id";
}
// check that receiver_email is your Primary PayPal email
if ($keyarray["receiver_email"] != $this->paypalConfig["vendor"])
{
#echo "Wrong vendor";
}
// check that payment_amount/payment_currency are correct
if (!$this->__checkItems($keyarray))
{
#echo "Wrong items";
}
if($ilUser->getId() == ANONYMOUS_USER_ID)
{
include_once './Services/Payment/classes/class.ilShopUtils.php';
// anonymous user needs an account to use crs
$user_id = $ilUser->getId();
$_SESSION['tmp_transaction']['tx_id'] = $keyarray["txn_id"];
$_SESSION['tmp_transaction']['usr_id'] = $user_id;
if($_SESSION['is_crs_object'] && ($ilUser->getId() == ANONYMOUS_USER_ID))
{
include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
foreach ($_SESSION['crs_obj_ids'] as $obj_id)
{
$members_obj->add($user_id,IL_CRS_MEMBER);
}
}
}
//#else
//if(($_SESSION['is_lm_object'] || $_SESSION['is_file_object'] ) && ($ilUser->getId() == ANONYMOUS_USER_ID))
/* if($ilUser->getId() == ANONYMOUS_USER_ID)
{
include_once './Services/Payment/classes/class.ilShopUtils.php';
// anonymous user needs an account to use lm
$ilUser = ilShopUtils::_createRandomUserAccount($keyarray);
$user_id = $ilUser->getId();
$_SESSION['tmp_transaction']['tx_id'] = $keyarray["txn_id"];
$_SESSION['tmp_transaction']['usr_id'] = $user_id;
}
*/
// old one TODO: if possible use ilPurchaseBaseGUI
$bookings = $this->__saveTransaction($keyarray);
$this->__sendBill($bookings, $keyarray);
/* new one
$external_data = array();
$external_data['transaction_extern'] = $keyarray["txn_id"];
$external_data['street'] = $keyarray["address_street"];
$external_data['zipcode'] = $keyarray["address_zip"];
$external_data['city'] = $keyarray["address_city"];
$external_data['country'] = $keyarray["address_country"];
parent::__addBookings($external_data);
*/
$_SESSION["coupons"]["paypal"] = array();
$_SESSION['tmp_transaction']['result'] = 'success';
return SUCCESS;
}
else if (strcmp ($lines[0], "FAIL") == 0)
{
return ERROR_FAIL;
}
else
return ERROR_FAIL;
}

+ Here is the call graph for this function:

ilPurchasePaypal::ilPurchasePaypal (   $user_obj)

Definition at line 44 of file class.ilPurchasePaypal.php.

References $ilDB, $lng, $user_obj, ilPayMethods\_getIdByTitle(), and ilPaypalSettings\getInstance().

{
global $ilDB, $lng;
$this->user_obj = $user_obj;
$this->pay_method = ilPayMethods::_getIdByTitle('paypal');
$this->paypalConfig = $ppSet->getAll();
parent::__construct($this->user_obj, $this->pay_method);
}

+ Here is the call graph for this function:

ilPurchasePaypal::openSocket ( )

Definition at line 57 of file class.ilPurchasePaypal.php.

References $path.

{
// post back to PayPal system to validate
$fp = @fsockopen ($path = $this->paypalConfig["server_host"], 80, $errno, $errstr, 30);
return $fp;
}

Field Documentation

ilPurchasePaypal::$currency = null

Definition at line 39 of file class.ilPurchasePaypal.php.

ilPurchasePaypal::$db = null

Definition at line 40 of file class.ilPurchasePaypal.php.

ilPurchasePaypal::$pay_method = null

Definition at line 38 of file class.ilPurchasePaypal.php.

ilPurchasePaypal::$paypalConfig

Definition at line 41 of file class.ilPurchasePaypal.php.

ilPurchasePaypal::$psc_obj = null

Definition at line 36 of file class.ilPurchasePaypal.php.

ilPurchasePaypal::$totalVat = 0
private

Definition at line 42 of file class.ilPurchasePaypal.php.

ilPurchasePaypal::$user_obj = null

Definition at line 37 of file class.ilPurchasePaypal.php.

Referenced by ilPurchasePaypal().


The documentation for this class was generated from the following file: