public function __construct($user_obj) { $this->user_obj = $user_obj; $this->pay_method = ilPayMethods::_getIdByTitle('bill'); parent::__construct($user_obj, $this->pay_method); $this->setAccess(0); $this->setPayed(0); }
public function unlockPAYPALObjectsInShoppingCart() { include_once './Services/Payment/classes/class.ilPurchaseBaseGUI.php'; $purchase = new ilPurchaseBaseGUI($this->user_obj, ilPayMethods::_getIdByTitle('paypal')); $purchase->__addBookings(); ilUtil::sendSuccess($this->lng->txt('pay_paypal_success'), true); $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', ''); return true; }
public function checkData($fp) { global $ilUser; //Token from paypal account $auth_token = $this->paypalConfig["auth_token"]; //add 'cmd' as required $req = 'cmd=_notify-synch'; //Get token $tx_token = $_REQUEST['tx']; //append both tokens as required $req .= "&tx={$tx_token}&at={$auth_token}"; //send information back to paypal // info: https required!!! $submiturl = 'https://' . $this->paypalConfig["server_host"] . $this->paypalConfig["server_path"]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $submiturl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return into variable curl_setopt($ch, CURLOPT_POST, 1); //make it a post curl_setopt($ch, CURLOPT_POSTFIELDS, $req); //post request curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req))); curl_setopt($ch, CURLOPT_HEADER, 0); //dont return headers curl_setopt($ch, CURLOPT_VERBOSE, 1); //more informaiton in error curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //dont verify curl_setopt($ch, CURLOPT_TIMEOUT, 30); //define timeout $result = @curl_exec($ch); //get result curl_close($ch); //close connection // only for TEST // echo $result;//display response // parse the data $lines = explode("\n", $result); $keyarray = array(); $keyarray[0] = $lines[0]; // save payment status! 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"; return ERROR_WRONG_CUSTOMER; } // check the payment_status is Completed if (!in_array($keyarray["payment_status"], array("Completed", "In-Progress", "Pending", "Processed"))) { #echo "Not completed"; return ERROR_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"; return ERROR_PREV_TRANS_ID; } } // check that receiver_email is your Primary PayPal email if ($keyarray["receiver_email"] != $this->paypalConfig["vendor"]) { //echo "Wrong vendor"; return ERROR_WRONG_VENDOR; } // check that payment_amount/payment_currency are correct if (!$this->__checkItems($keyarray)) { //echo "Wrong items"; return ERROR_WRONG_ITEMS; } // if($ilUser->getId() == ANONYMOUS_USER_ID) // { // include_once './Services/Payment/classes/class.ilShopUtils.php'; // // anonymous user needs an account to use crs // $ilUser = ilShopUtils::_createRandomUserAccount($keyarray); // $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 = ilCourseParticipants::_getInstanceByObjId($obj_id); // $members_obj->add($user_id,IL_CRS_MEMBER); // } // } // } $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; } } }
function sendCreditCard() { $this->psc_obj = new ilPaymentShoppingCart($this->user_obj); $this->psc_obj->clearCouponItemsSession(); if (!count($items = $this->psc_obj->getEntries($this->pm_id))) { $this->tpl->setVariable("HEADER", $this->lng->txt('pay_bmf_your_order')); $this->tpl->touchBlock("stop_floating"); ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty')); } else { $payment = new KreditkartenzahlungWS(); $customer = new Kunde($this->user_obj->getId()); $creditCard = new Kreditkarte(); $sc_obj = new ilPaymentShoppingCart($this->user_obj); $tmp_bookEntries = $sc_obj->getShoppingCart(); if (!is_array($tmp_bookEntries)) { ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty')); } else { $totalAmount = 0; for ($i = 0; $i < count($tmp_bookEntries); $i++) { $booking = true; if (!empty($_SESSION["coupons"]["bmf"])) { $price = $tmp_bookEntries[$i]["price"]; $tmp_bookEntries[$i]["math_price"] = $price; foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon) { $this->coupon_obj->setId($coupon["pc_pk"]); $this->coupon_obj->setCurrentCoupon($coupon); $tmp_pobject = new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += $price; $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i]; $booking = false; } unset($tmp_pobject); } } if ($booking) { $tmp_bookEntries[$i]["price_string"] = number_format((double) $tmp_bookEntries[$i]["price"], 2, ",", "."); $bookEntries[] = new Buchung($tmp_bookEntries[$i]); $totalAmount += $tmp_bookEntries[$i]["price"]; } else { $tmp_bookEntries[$i]["price_string"] = number_format((double) $tmp_bookEntries[$i]["price"], 2, ",", "."); } } $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]); if (is_array($coupon_discount_items) && !empty($coupon_discount_items)) { foreach ($coupon_discount_items as $item) { $item["price"] = number_format((double) $item["discount_price"], 2, ".", ""); $bookEntries[] = new Buchung($item); $totalAmount += $item["discount_price"]; } } $totalAmount = number_format((double) $totalAmount, 2, ".", ""); $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries); $bookingList = new BuchungsListe($this->user_obj->getId(), $values); } $resultObj = $payment->zahlenUndAnlegenKunde($customer, $creditCard, $bookingList); $result = $resultObj->ergebnis; if (is_object($result)) { if ($result->code < 0) { $this->tpl->setVariable("HEADER", $this->lng->txt('error')); $this->tpl->touchBlock("stop_floating"); $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText; if ($result->code == -103 || $result->code == -104 || $result->code == -107 || $result->code <= -202 && $result->code >= -208 || $result->code == -213) { ilUtil::sendInfo($error); $this->showPersonalData(); } else { if ($result->code == -507 || $result->code == -510 || $result->code == -511) { ilUtil::sendInfo($error); $this->showPaymentType(); } else { if ($result->code == -701 || $result->code == -1701 || $result->code == -1706 || $result->code == -1707 || $result->code == -1710 || $result->code == -1711) { ilUtil::sendInfo($error); $this->showCreditCard(); } else { $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin'); ilUtil::sendInfo($error); $this->showPersonalData(); } } } } else { // everything ok => send confirmation, fill statistik, delete session, delete shopping cart. $external_data = array(); $external_data['voucher'] = $resultObj->buchungsListe->buchungen[$b++]->belegNr; $external_data['transaction_extern'] = $resultObj->buchungsListe->kassenzeichen; $external_data['street'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse) . ' ' . utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr); $external_data['po_box'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach); $external_data['zipcode'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ); $external_data['city'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort); $external_data['country'] = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land); parent::__addbookings($external_data); $this->__emptyShoppingCart(); $this->__clearSession(); $this->tpl->setVariable("HEADER", $this->lng->txt('pay_bmf_your_order')); $this->tpl->setVariable("DESCRIPTION", $this->lng->txt('pay_bmf_thanks')); $this->tpl->touchBlock("stop_floating"); ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks')); $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pay_bmf_credit_card.html', 'Services/Payment'); if ($this->ilias->getSetting("https") != 1) { $this->tpl->setCurrentBlock("buyed_objects"); $link = $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui'); $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link); $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects')); $this->tpl->parseCurrentBlock("buyed_objects"); } $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window')); } } else { $this->tpl->setVariable("HEADER", $this->lng->txt('error')); $this->tpl->touchBlock("stop_floating"); ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication')); } /**/ #zum testen } }