From daa94d70f2fa6da5cc714f5de79813e168f2dc48 Mon Sep 17 00:00:00 2001 From: Francis Gonzales Date: Tue, 27 May 2014 17:58:17 -0500 Subject: [PATCH] rename variables --- plugin/buy_courses/js/funciones.js | 20 +- plugin/buy_courses/resources/plugin.css | 4 + plugin/buy_courses/src/ajax.php | 8 +- plugin/buy_courses/src/expresscheckout.php | 63 ++- plugin/buy_courses/src/function.php | 17 +- plugin/buy_courses/src/paypalfunctions.php | 470 ++++++-------------- plugin/buy_courses/src/pending_orders.php | 3 +- plugin/buy_courses/src/process.php | 3 +- plugin/buy_courses/src/process_confirm.php | 36 +- plugin/buy_courses/src/success.php | 180 ++++---- plugin/buy_courses/view/configuration.tpl | 33 +- plugin/buy_courses/view/list.tpl | 2 +- plugin/buy_courses/view/paymentsetup.tpl | 2 +- plugin/buy_courses/view/process.tpl | 49 +- plugin/buy_courses/view/process_confirm.tpl | 4 +- 15 files changed, 344 insertions(+), 550 deletions(-) diff --git a/plugin/buy_courses/js/funciones.js b/plugin/buy_courses/js/funciones.js index aa0802e4b9..d59f194287 100644 --- a/plugin/buy_courses/js/funciones.js +++ b/plugin/buy_courses/js/funciones.js @@ -26,19 +26,19 @@ $(document).ready(function () { }); }); - $(".guardar").click(function () { - var vvisible = $(this).parent().parent().prev().prev().children().attr("checked"); - var vprice = $(this).parent().parent().prev().children().attr("value"); - var courseid = $(this).parent().parent().attr("id"); - $.post("function.php", {tab: "save_mod", id: courseid, visible: vvisible, price: vprice}, + $(".save").click(function () { + var visible = $(this).parent().parent().prev().prev().children().attr("checked"); + var price = $(this).parent().parent().prev().children().attr("value"); + var id_course = $(this).attr('id'); + $.post("function.php", {tab: "save_mod", id_course: id_course, visible: visible, price: price}, function (data) { if (data.status == "false") { - alert("Error database"); + alert("Database Error"); } else { - $("#course" + data.id).children().attr("style", "display:''"); - $("#course" + data.id).children().next().attr("style", "display:none"); - $("#course" + data.id).parent().removeClass("fmod") - $("#course" + data.id).parent().children().each(function () { + $("#course" + data.id_course).children().attr("style", "display:''"); + $("#course" + data.id_course).children().next().attr("style", "display:none"); + $("#course" + data.id_course).parent().removeClass("fmod") + $("#course" + data.id_course).parent().children().each(function () { $(this).removeClass("btop"); }); } diff --git a/plugin/buy_courses/resources/plugin.css b/plugin/buy_courses/resources/plugin.css index 3d72411cf7..1b32b9091d 100644 --- a/plugin/buy_courses/resources/plugin.css +++ b/plugin/buy_courses/resources/plugin.css @@ -72,4 +72,8 @@ select#lsessions, select#lcourses, select#lexercises, select#status { .height5 { height: 5px; +} + +.margin-left-fifty{ + margin-left: 50px !important; } \ No newline at end of file diff --git a/plugin/buy_courses/src/ajax.php b/plugin/buy_courses/src/ajax.php index 75332aea38..8e9bfed230 100644 --- a/plugin/buy_courses/src/ajax.php +++ b/plugin/buy_courses/src/ajax.php @@ -1,15 +1,15 @@ '; diff --git a/plugin/buy_courses/src/expresscheckout.php b/plugin/buy_courses/src/expresscheckout.php index d949faa59e..727698385c 100644 --- a/plugin/buy_courses/src/expresscheckout.php +++ b/plugin/buy_courses/src/expresscheckout.php @@ -1,47 +1,44 @@ '; $content .= '' . get_lang('Description') . ' '; if ($course['enrolled'] != "YES") { - $content .= '' . $buy_name . ''; + $content .= '' . $buy_name . ''; } $content .= ''; $content .= ''; @@ -224,23 +223,23 @@ if ($_REQUEST['tab'] == 'delete_account') { } if ($_REQUEST['tab'] == 'save_mod') { - $_REQUEST['id'] = intval($_REQUEST['id']); - $id = substr($_REQUEST['id'], 5); + $_REQUEST['id'] = Database::escape_string($_REQUEST['id']); + $idCourse = intval($_REQUEST['id_course']); $visible = ($_REQUEST['visible'] == "checked") ? 1 : 0; - $price = mysql_real_escape_string($_REQUEST['price']); + $price = Database::escape_string($_REQUEST['price']); $obj = $_REQUEST['obj']; $sql = "UPDATE $tableBuyCourse SET visible = " . $visible . ", price = '" . $price . "' - WHERE id_course = '" . $id . "';"; + WHERE id_course = '" . $idCourse . "';"; $res = Database::query($sql); if (!res) { $content = $plugin->get_lang('ProblemToSaveTheMessage') . Database::error(); echo json_encode(array("status" => "false", "content" => $content)); } else { - echo json_encode(array("status" => "true", "id" => $id)); + echo json_encode(array("status" => "true", "id_course" => $idCourse)); } } diff --git a/plugin/buy_courses/src/paypalfunctions.php b/plugin/buy_courses/src/paypalfunctions.php index 32f33556a4..96921e4321 100644 --- a/plugin/buy_courses/src/paypalfunctions.php +++ b/plugin/buy_courses/src/paypalfunctions.php @@ -9,33 +9,27 @@ $PROXY_PORT = '808'; $SandboxFlag = $pruebas; - -//'------------------------------------ -//' PayPal API Credentials -//' Replace with your API Username -//' Replace with your API Password -//' Replace with your Signature -//'------------------------------------ -//$API_UserName="vendedor_api1.calidadeorigen.com"; -//$API_Password="1385456693"; -//$API_Signature="An5ns1Kso7MWUdW4ErQKJJJ4qi4-AmFnLvPhhq5VHgESNLWwWusSKk4T"; - +/** + * PayPal API Credentials + * Replace with your API Username + * Replace with your API Password + * Replace with your Signature + */ $API_UserName = $paypal_username; $API_Password = $paypal_password; $API_Signature = $paypal_firma; -// BN Code is only applicable for partners +// BN Code is only applicable for partners $sBNCode = "PP-ECWizard"; - -/* -' Define the PayPal Redirect URLs. -' This is the URL that the buyer is first sent to do authorize payment with their paypal account -' change the URL depending if you are testing on the sandbox or the live PayPal site -' -' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= -' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= -*/ +/** + * Define the PayPal Redirect URLs. + * This is the URL that the buyer is first sent to do authorize payment with their paypal account + * change the URL depending if you are testing on the sandbox or the live PayPal site + * + * For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= + * For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= + */ if ($SandboxFlag == true) { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; @@ -51,28 +45,26 @@ $version = "93"; if (session_id() == "") session_start(); -/* An express checkout transaction starts with a token, that - identifies to PayPal your transaction - In this example, when the script sees a token, the script - knows that the buyer has already authorized payment through - paypal. If no token was found, the action is to send the buyer - to PayPal to first authorize payment - */ - -/* -'------------------------------------------------------------------------------------------------------------------------------------------- -' Purpose: Prepares the parameters for the SetExpressCheckout API Call. -' Inputs: -' paymentAmount: Total value of the shopping cart -' currencyCodeType: Currency code value the PayPal API -' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization -' returnURL: the page where buyers return to after they are done with the payment review on PayPal -' cancelURL: the page where buyers return to when they cancel the payment review on PayPal -'-------------------------------------------------------------------------------------------------------------------------------------------- -*/ +/** + * An express checkout transaction starts with a token, that + * identifies to PayPal your transaction + * In this example, when the script sees a token, the script + * knows that the buyer has already authorized payment through + * paypal. If no token was found, the action is to send the buyer + * to PayPal to first authorize payment + */ + +/** + * Purpose: Prepares the parameters for the SetExpressCheckout API Call. + * Inputs: + * paymentAmount: Total value of the shopping cart + * currencyCodeType: Currency code value the PayPal API + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * returnURL: the page where buyers return to after they are done with the payment review on PayPal + * cancelURL: the page where buyers return to when they cancel the payment review on PayPal + */ function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra) { - //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; @@ -82,17 +74,15 @@ function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $payment $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; $nvpstr = $nvpstr . $extra; - //echo $nvpstr; - //exit; $_SESSION["currencyCodeType"] = $currencyCodeType; $_SESSION["PaymentType"] = $paymentType; - //'--------------------------------------------------------------------------------------------------------------- - //' Make the API call to PayPal - //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. - //' If an error occured, show the resulting errors - //'--------------------------------------------------------------------------------------------------------------- + /** + * Make the API call to PayPal + * If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + * If an error occured, show the resulting errors + */ $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { @@ -103,33 +93,29 @@ function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $payment return $resArray; } -/* -'------------------------------------------------------------------------------------------------------------------------------------------- -' Purpose: Prepares the parameters for the SetExpressCheckout API Call. -' Inputs: -' paymentAmount: Total value of the shopping cart -' currencyCodeType: Currency code value the PayPal API -' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization -' returnURL: the page where buyers return to after they are done with the payment review on PayPal -' cancelURL: the page where buyers return to when they cancel the payment review on PayPal -' shipToName: the Ship to name entered on the merchant's site -' shipToStreet: the Ship to Street entered on the merchant's site -' shipToCity: the Ship to City entered on the merchant's site -' shipToState: the Ship to State entered on the merchant's site -' shipToCountryCode: the Code for Ship to Country entered on the merchant's site -' shipToZip: the Ship to ZipCode entered on the merchant's site -' shipToStreet2: the Ship to Street2 entered on the merchant's site -' phoneNum: the phoneNum entered on the merchant's site -'-------------------------------------------------------------------------------------------------------------------------------------------- -*/ +/** + * Purpose: Prepares the parameters for the SetExpressCheckout API Call. + * Inputs: + * paymentAmount: Total value of the shopping cart + * currencyCodeType: Currency code value the PayPal API + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * returnURL: the page where buyers return to after they are done with the payment review on PayPal + * cancelURL: the page where buyers return to when they cancel the payment review on PayPal + * shipToName: the Ship to name entered on the merchant's site + * shipToStreet: the Ship to Street entered on the merchant's site + * shipToCity: the Ship to City entered on the merchant's site + * shipToState: the Ship to State entered on the merchant's site + * shipToCountryCode: the Code for Ship to Country entered on the merchant's site + * shipToZip: the Ship to ZipCode entered on the merchant's site + * shipToStreet2: the Ship to Street2 entered on the merchant's site + * phoneNum: the phoneNum entered on the merchant's site + */ function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum ) { - //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation - $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount; $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL; @@ -148,11 +134,11 @@ function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType $_SESSION["currencyCodeType"] = $currencyCodeType; $_SESSION["PaymentType"] = $paymentType; - //'--------------------------------------------------------------------------------------------------------------- - //' Make the API call to PayPal - //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. - //' If an error occured, show the resulting errors - //'--------------------------------------------------------------------------------------------------------------- + /** + * Make the API call to PayPal + * If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. + * If an error occured, show the resulting errors + */ $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { @@ -163,40 +149,37 @@ function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType return $resArray; } -/* -'------------------------------------------------------------------------------------------- -' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. -' -' Inputs: -' None -' Returns: -' The NVP Collection object of the GetExpressCheckoutDetails Call Response. -'------------------------------------------------------------------------------------------- -*/ +/** + * + * Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. + * + * Inputs: + * None + * Returns: + * The NVP Collection object of the GetExpressCheckoutDetails Call Response. + */ function GetShippingDetails($token) { - //'-------------------------------------------------------------- - //' At this point, the buyer has completed authorizing the payment - //' at PayPal. The function will call PayPal to obtain the details - //' of the authorization, incuding any shipping information of the - //' buyer. Remember, the authorization is not a completed transaction - //' at this state - the buyer still needs an additional step to finalize - //' the transaction - //'-------------------------------------------------------------- - - //'--------------------------------------------------------------------------- - //' Build a second API request to PayPal, using the token as the - //' ID to get the details on the payment authorization - //'--------------------------------------------------------------------------- + /** + * At this point, the buyer has completed authorizing the payment + * at PayPal. The function will call PayPal to obtain the details + * of the authorization, incuding any shipping information of the + * buyer. Remember, the authorization is not a completed transaction + * at this state - the buyer still needs an additional step to finalize + * the transaction + * + * Build a second API request to PayPal, using the token as the + * ID to get the details on the payment authorization + */ $nvpstr = "&TOKEN=" . $token; - //'--------------------------------------------------------------------------- - //' Make the API call and store the results in an array. - //' If the call was a success, show the authorization details, and provide - //' an action to complete the payment. - //' If failed, show the error - //'--------------------------------------------------------------------------- + /** + * Make the API call and store the results in an array. + * If the call was a success, show the authorization details, and provide + * an action to complete the payment. + * If failed, show the error + */ $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { @@ -205,366 +188,197 @@ function GetShippingDetails($token) return $resArray; } -/* -'------------------------------------------------------------------------------------------------------------------------------------------- - -' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. - -' - -' Inputs: - -' sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. - -' Returns: - -' The NVP Collection object of the GetExpressCheckoutDetails Call Response. - -'-------------------------------------------------------------------------------------------------------------------------------------------- - -*/ +/** + * Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. + * Inputs: + * sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. + * Returns: + * The NVP Collection object of the GetExpressCheckoutDetails Call Response. + */ function ConfirmPayment($FinalPaymentAmt) - { - - /* Gather the information to make the final call to - - finalize the PayPal payment. The variable nvpstr - - holds the name value pairs - - */ - + /** + * Gather the information to make the final call to + * finalize the PayPal payment. The variable nvpstr + * holds the name value pairs + */ //Format the other parameters that were stored in the session from the previous calls $token = urlencode($_SESSION['TOKEN']); - $paymentType = urlencode($_SESSION['PaymentType']); - $currencyCodeType = urlencode($_SESSION['currencyCodeType']); - $payerID = urlencode($_SESSION['payer_id']); - - $serverName = urlencode($_SERVER['SERVER_NAME']); - $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt; - $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; - - /* Make the call to PayPal to finalize payment - - If an error occured, show the resulting errors - - */ + /** + * Make the call to PayPal to finalize payment + * If an error occured, show the resulting errors + */ $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); - - /* Display the API response back to the browser. - - If the response from PayPal was a success, display the response parameters' - - If the response was an error, display the errors received using APIError.php. - - */ + /** + * Display the API response back to the browser. + * If the response from PayPal was a success, display the response parameters + * If the response was an error, display the errors received using APIError.php. + */ $ack = strtoupper($resArray["ACK"]); - - return $resArray; - } -/* - -'------------------------------------------------------------------------------------------------------------------------------------------- - -' Purpose: This function makes a DoDirectPayment API call - -' - -' Inputs: - -' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization - -' paymentAmount: total value of the shopping cart - -' currencyCode: currency code value the PayPal API - -' firstName: first name as it appears on credit card - -' lastName: last name as it appears on credit card - -' street: buyer's street address line as it appears on credit card - -' city: buyer's city - -' state: buyer's state - -' countryCode: buyer's country code - -' zip: buyer's zip - -' creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) - -' creditCardNumber: buyers credit card number without any spaces, dashes or any other characters - -' expDate: credit card expiration date - -' cvv2: Card Verification Value - -' - -'------------------------------------------------------------------------------------------- - -' - -' Returns: - -' The NVP Collection object of the DoDirectPayment Call Response. - -'-------------------------------------------------------------------------------------------------------------------------------------------- - -*/ - +/** + * Purpose: This function makes a DoDirectPayment API call + * Inputs: + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * paymentAmount: total value of the shopping cart + * currencyCode: currency code value the PayPal API + * firstName: first name as it appears on credit card + * lastName: last name as it appears on credit card + * street: buyer's street address line as it appears on credit card + * city: buyer's city + * state: buyer's state + * countryCode: buyer's country code + * zip: buyer's zip + * creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) + * creditCardNumber: buyers credit card number without any spaces, dashes or any other characters + * expDate: credit card expiration date + * cvv2: Card Verification Value + * Returns: + * The NVP Collection object of the DoDirectPayment Call Response. + */ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, - $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, - $countryCode, $currencyCode) - { - //Construct the parameter string that describes DoDirectPayment - $nvpstr = "&AMT=" . $paymentAmount; - $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode; - $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType; - $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType; - $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber; - $nvpstr = $nvpstr . "&EXPDATE=" . $expDate; - $nvpstr = $nvpstr . "&CVV2=" . $cvv2; - $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName; - $nvpstr = $nvpstr . "&LASTNAME=" . $lastName; - $nvpstr = $nvpstr . "&STREET=" . $street; - $nvpstr = $nvpstr . "&CITY=" . $city; - $nvpstr = $nvpstr . "&STATE=" . $state; - $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode; - $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR']; - $resArray = hash_call("DoDirectPayment", $nvpstr); - return $resArray; } - /** * - * '------------------------------------------------------------------------------------------------------------------------------------------- * hash_call: Function to perform the API call to PayPal using API signature * @methodName is name of API method. * @nvpStr is nvp string. * returns an associtive array containing the response from the server. * - * '------------------------------------------------------------------------------------------------------------------------------------------- - */ - function hash_call($methodName, $nvpStr) - { - //declaring of global variables - global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; - global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; - global $gv_ApiErrorURL; - global $sBNCode; - //setting the curl parameters. - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $API_Endpoint); - curl_setopt($ch, CURLOPT_VERBOSE, 1); - - //turning off the server and peer verification(TrustManager Concept). - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); - //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. - //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php - if ($USE_PROXY) - + if ($USE_PROXY) { curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT); - + } //NVPRequest for submitting to server - - $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); - + $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . + "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . + "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); //setting the nvpreq as POST FIELD to curl - curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); - - //getting response from server - $response = curl_exec($ch); - - - //convrting NVPResponse to an Associative Array - + //converting NVPResponse to an Associative Array $nvpResArray = deformatNVP($response); - $nvpReqArray = deformatNVP($nvpreq); $_SESSION['nvpReqArray'] = $nvpReqArray; - if (curl_errno($ch)) { - // moving to display page to display curl errors - $_SESSION['curl_error_no'] = curl_errno($ch); - $_SESSION['curl_error_msg'] = curl_error($ch); - - //Execute the Error handling module to display errors. - } else { - //closing the curl - curl_close($ch); - } - return $nvpResArray; - } - -/*'---------------------------------------------------------------------------------- - - Purpose: Redirects to PayPal.com site. - - Inputs: NVP string. - - Returns: - ----------------------------------------------------------------------------------- - -*/ +/** + * Purpose: Redirects to PayPal.com site. + * Inputs: NVP string. + */ function RedirectToPayPal($token) - { - global $PAYPAL_URL; - - // Redirect to paypal.com here - $payPalURL = $PAYPAL_URL . $token; - header("Location: " . $payPalURL); - exit; - } - -/*'---------------------------------------------------------------------------------- - +/** * This function will take NVPString and convert it to an Associative Array and it will decode the response. - - * It is usefull to search for a particular key and displaying arrays. - - * @nvpstr is NVPString. - - * @nvpArray is Associative Array. - - ---------------------------------------------------------------------------------- - - */ + * It is usefull to search for a particular key and displaying arrays. + * @nvpstr is NVPString. + * @nvpArray is Associative Array. + */ function deformatNVP($nvpstr) - { - $intial = 0; - $nvpArray = array(); - while (strlen($nvpstr)) { - //postion of Key - $keypos = strpos($nvpstr, '='); - //position of value - $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); - - /*getting the Key and Value values and storing in a Associative Array*/ - $keyval = substr($nvpstr, $intial, $keypos); - $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); - //decoding the respose - $nvpArray[urldecode($keyval)] = urldecode($valval); - $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); - } return $nvpArray; - } \ No newline at end of file diff --git a/plugin/buy_courses/src/pending_orders.php b/plugin/buy_courses/src/pending_orders.php index 0ae1144775..c34cafee2c 100644 --- a/plugin/buy_courses/src/pending_orders.php +++ b/plugin/buy_courses/src/pending_orders.php @@ -2,9 +2,8 @@ /** * Initialization */ +require_once '../config.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; -require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; diff --git a/plugin/buy_courses/src/process.php b/plugin/buy_courses/src/process.php index b1958966b6..9f557f179f 100644 --- a/plugin/buy_courses/src/process.php +++ b/plugin/buy_courses/src/process.php @@ -2,9 +2,8 @@ /** * Initialization */ +require_once '../config.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; -require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; $plugin = Buy_CoursesPlugin::create(); $_cid = 0; diff --git a/plugin/buy_courses/src/process_confirm.php b/plugin/buy_courses/src/process_confirm.php index f3a37bfbf9..ade9156d3f 100644 --- a/plugin/buy_courses/src/process_confirm.php +++ b/plugin/buy_courses/src/process_confirm.php @@ -1,15 +1,16 @@ '; + $text = '

Datos Bancarios

'; foreach ($accountsList as $account) { - $texto .= ''; - $texto .= ''; + $text .= ''; + $text .= 'Cuenta Bancaria: ' . htmlspecialchars($account['account']) . '
'; + $text .= ''; } - $texto .= '

Datos Bancarios

'; - $texto .= '' . htmlspecialchars($account['name']) . '
'; + $text .= '
'; + $text .= '' . htmlspecialchars($account['name']) . '
'; if ($account['swift'] != '') { - $texto .= 'SWIFT: ' . htmlspecialchars($account['swift']) . '
'; + $text .= 'SWIFT: ' . htmlspecialchars($account['swift']) . '
'; } - $texto .= 'Cuenta Bancaria: ' . htmlspecialchars($account['account']) . '
'; - $texto .= '
'; + $text .= ''; $plugin = Buy_CoursesPlugin::create(); $asunto = utf8_encode($plugin->get_lang('bc_subject')); @@ -60,7 +62,7 @@ if (isset($_POST['Aceptar'])) { $message = str_replace("{{name}}", $name, $message); $message = str_replace("{{course}}", $title_course, $message); $message = str_replace("{{reference}}", $reference, $message); - $message .= $texto; + $message .= $text; api_mail($name, $email, $asunto, $message); // Return to course list @@ -73,14 +75,14 @@ $_SESSION['bc_currency_type'] = $currencyType; $server = $_POST['server']; if ($_POST['payment_type'] == "PayPal") { - $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $pruebas = ($row['sandbox'] == "YES") ? true: false; $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; - require_once("function/paypalfunctions.php"); + require_once("paypalfunctions.php"); // PayPal Express Checkout Module $paymentAmount = $_SESSION["Payment_Amount"]; $currencyCodeType = $currencyType; @@ -119,7 +121,7 @@ if ($_POST['payment_type'] == "Transference") { $_cid = 0; $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); - $tpl = new Template('Tipo de pago'); + $tpl = new Template('PaymentType'); $code = $_SESSION['bc_course_code']; $courseInfo = courseInfo($code); diff --git a/plugin/buy_courses/src/success.php b/plugin/buy_courses/src/success.php index 31d05b328b..5aa56c5267 100644 --- a/plugin/buy_courses/src/success.php +++ b/plugin/buy_courses/src/success.php @@ -2,31 +2,31 @@ use ChamiloSession as Session; +require_once '../config.php'; require_once dirname(__FILE__) . '/buy_course.lib.php'; -require_once '../../../main/inc/global.inc.php'; -require_once 'lib/buy_course_plugin.class.php'; require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php'; require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; +$tableBuyCoursePaypal = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL); + $plugin = Buy_CoursesPlugin::create(); -/* -================================================================== - // DATOS DE PAYPAL // -================================================================== -*/ -$sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + +/** + * Paypal data + */ +$sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $pruebas = ($row['sandbox'] == "YES") ? true: false; $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; -require_once("function/paypalfunctions.php"); +require_once("paypalfunctions.php"); + +/** + * PayPal Express Checkout Call + */ -/*================================================================== - PayPal Express Checkout Call - =================================================================== -*/ // Check to see if the Request object contains a variable named 'token' $token = ""; if (isset($_REQUEST['token'])) { @@ -35,28 +35,26 @@ if (isset($_REQUEST['token'])) { // If the Request object contains the variable 'token' then it means that the user is coming from PayPal site. if ($token != "") { - $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; - require_once("function/paypalfunctions.php"); - /* - '------------------------------------ - ' Calls the GetExpressCheckoutDetails API call - ' - ' The GetShippingDetails function is defined in PayPalFunctions.jsp - ' included at the top of this file. - '------------------------------------------------- - */ + require_once 'paypalfunctions.php'; + + /** + * Calls the GetExpressCheckoutDetails API call + * The GetShippingDetails function is defined in PayPalFunctions.jsp + *included at the top of this file. + */ $resArray = GetShippingDetails($token); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCESSWITHWARNING") { - /* - ' The information that is returned by the GetExpressCheckoutDetails call should be integrated by the partner into his Order Review - ' page - */ + /** + * The information that is returned by the GetExpressCheckoutDetails + * call should be integrated by the partner into his Order Review page + */ $email = $resArray["EMAIL"]; // ' Email address of payer. $payerId = $resArray["PAYERID"]; // ' Unique PayPal customer account identification number. $payerStatus = $resArray["PAYERSTATUS"]; // ' Status of payer. Character length and limitations: 10 single-byte alphabetic characters. @@ -94,7 +92,7 @@ if ($token != "") { if (!isset($_POST['paymentOption'])) { - //PANTALLA DE CONFIRMACION DEL PEDIDO + // Confirm the order $_cid = 0; $interbreadcrumb[] = array("url" => "list.php", "name" => $plugin->get_lang('CourseListOnSale')); @@ -125,49 +123,41 @@ if (!isset($_POST['paymentOption'])) { $tpl->display_one_col_template(); } else { - /*================================================================== - PayPal Express Checkout Call - =================================================================== - */ + /** + * PayPal Express Checkout Call + */ $PaymentOption = $_POST['paymentOption']; - $sql = "SELECT * FROM plugin_bc_paypal WHERE id='1';"; + $sql = "SELECT * FROM $tableBuyCoursePaypal WHERE id='1';"; $res = Database::query($sql); $row = Database::fetch_assoc($res); $paypal_username = $row['username']; $paypal_password = $row['password']; $paypal_firma = $row['signature']; - require_once("function/paypalfunctions.php"); + require_once("paypalfunctions.php"); if ($PaymentOption == "PayPal") { - /* - '------------------------------------ - ' The paymentAmount is the total value of - ' the shopping cart, that was set - ' earlier in a session variable - ' by the shopping cart page - '------------------------------------ - */ + + /** + * The paymentAmount is the total value of + * the shopping cart, that was set + * earlier in a session variable + * by the shopping cart page + */ $finalPaymentAmount = $_SESSION["Payment_Amount"]; - /* - '------------------------------------ - ' Calls the DoExpressCheckoutPayment API call - ' - ' The ConfirmPayment function is defined in the file PayPalFunctions.jsp, - ' that is included at the top of this file. - '------------------------------------------------- - */ + + /** + * Calls the DoExpressCheckoutPayment API call + * The ConfirmPayment function is defined in the file PayPalFunctions.jsp, + * that is included at the top of this file. + */ $resArray = ConfirmPayment($finalPaymentAmount); $ack = strtoupper($resArray["ACK"]); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { - /* - '******************************************************************************************************************** - ' - ' THE PARTNER SHOULD SAVE THE KEY TRANSACTION RELATED INFORMATION LIKE - ' transactionId & orderTime - ' IN THEIR OWN DATABASE - ' AND THE REST OF THE INFORMATION CAN BE USED TO UNDERSTAND THE STATUS OF THE PAYMENT - ' - '******************************************************************************************************************** - */ + + /** + * THE PARTNER SHOULD SAVE THE KEY TRANSACTION RELATED INFORMATION LIKE transactionId & orderTime + * IN THEIR OWN DATABASE + * AND THE REST OF THE INFORMATION CAN BE USED TO UNDERSTAND THE STATUS OF THE PAYMENT + */ $transactionId = $resArray["PAYMENTINFO_0_TRANSACTIONID"]; // ' Unique transaction ID of the payment. Note: If the PaymentAction of the request was Authorization or Order, this value is your AuthorizationID for use with the Authorization & Capture APIs. $transactionType = $resArray["PAYMENTINFO_0_TRANSACTIONTYPE"]; //' The type of transaction Possible values: l cart l express-checkout @@ -180,44 +170,45 @@ if (!isset($_POST['paymentOption'])) { $taxAmt = $resArray["PAYMENTINFO_0_TAXAMT"]; //' Tax charged on the transaction. $exchangeRate = $resArray["PAYMENTINFO_0_EXCHANGERATE"]; //' Exchange rate if a currency conversion occurred. Relevant only if your are billing in their non-primary currency. If the customer chooses to pay with a currency other than the non-primary currency, the conversion occurs in the customer's account. - /* - ' Status of the payment: - 'Completed: The payment has been completed, and the funds have been added successfully to your account balance. - - 'Pending: The payment is pending. See the PendingReason element for more information. - */ + /** + * Status of the payment: + * Completed: The payment has been completed, and the funds have been added successfully to your account balance. + * Pending: The payment is pending. See the PendingReason element for more information. + */ $paymentStatus = $resArray["PAYMENTINFO_0_PAYMENTSTATUS"]; - /* - 'The reason the payment is pending: - ' none: No pending reason - ' address: The payment is pending because your customer did not include a confirmed shipping address and your Payment Receiving Preferences is set such that you want to manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile. - ' echeck: The payment is pending because it was made by an eCheck that has not yet cleared. - ' intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview. - - ' multi-currency: You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment. - ' verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment. - ' other: The payment is pending for a reason other than those listed above. For more information, contact PayPal customer service. - */ - + /** + * The reason the payment is pending: + * none: No pending reason + * address: The payment is pending because your customer did not include a confirmed + * shipping address and your Payment Receiving Preferences is set such that you want to + * manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile. + * echeck: The payment is pending because it was made by an eCheck that has not yet cleared. + * intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. + * You must manually accept or deny this payment from your Account Overview. + * multi-currency: You do not have a balance in the currency sent, and you do not have your + * Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment. + * verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment. + * other: The payment is pending for a reason other than those listed above. For more information, contact PayPal customer service. + */ $pendingReason = $resArray["PAYMENTINFO_0_PENDINGREASON"]; - /* - 'The reason for a reversal if TransactionType is reversal: - ' none: No reason code - ' chargeback: A reversal has occurred on this transaction due to a chargeback by your customer. - ' guarantee: A reversal has occurred on this transaction due to your customer triggering a money-back guarantee. - ' buyer-complaint: A reversal has occurred on this transaction due to a complaint about the transaction from your customer. - ' refund: A reversal has occurred on this transaction because you have given the customer a refund. - ' other: A reversal has occurred on this transaction due to a reason not listed above. - */ + /** + * The reason for a reversal if TransactionType is reversal: + * none: No reason code + * chargeback: A reversal has occurred on this transaction due to a chargeback by your customer. + * guarantee: A reversal has occurred on this transaction due to your customer triggering a money-back guarantee. + * buyer-complaint: A reversal has occurred on this transaction due to a complaint about the transaction from your customer. + * refund: A reversal has occurred on this transaction because you have given the customer a refund. + * other: A reversal has occurred on this transaction due to a reason not listed above. + */ $reasonCode = $resArray["PAYMENTINFO_0_REASONCODE"]; -//INSERTAMOS LOS REGISTROS NECESARIOS EN LAS TABLAS DE BASES DE DATOS PARA DAR AL USUARIO DE ALTA + // Insert the user information to activate the user if ($paymentStatus == "Completed") { - $user_id = $_SESSION['bc_user_id']; //api_get_user_id(); + $user_id = $_SESSION['bc_user_id']; $course_code = $_SESSION['bc_course_codetext']; $all_course_information = CourseManager::get_course_information($course_code); @@ -232,21 +223,15 @@ if (!isset($_POST['paymentOption'])) { $_SESSION['bc_message'] = 'EnrollToCourseXSuccessful'; $_SESSION['bc_url'] = $url; $_SESSION['bc_success'] = true; - //$message = sprintf($plugin->get_lang('EnrollToCourseXSuccessful'), $url); } else { $_SESSION['bc_message'] = 'ErrorContactPlatformAdmin'; $_SESSION['bc_success'] = false; - //$message = $plugin->get_lang('ErrorContactPlatformAdmin'); } - //Activamos al usuario su cuenta + // Activate the use $TABLE_USER = Database::get_main_table(TABLE_MAIN_USER); - // 1. set account inactive $sql = "UPDATE " . $TABLE_USER . " SET active='1' WHERE user_id='" . $_SESSION['bc_user_id'] . "'"; Database::query($sql); - //Logueamos al user - - // a uid is given (log in succeeded) $user_table = Database::get_main_table(TABLE_MAIN_USER); $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); $track_e_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); @@ -264,7 +249,6 @@ if (!isset($_POST['paymentOption'])) { if (Database::num_rows($result) > 0) { // Extracting the user data - $uData = Database::fetch_array($result); $_user = _api_format_user($uData, false); @@ -283,7 +267,7 @@ if (!isset($_POST['paymentOption'])) { header('location:' . api_get_path(WEB_PATH)); } - //Eliminamos las variables + // Delete variables unset($_SESSION['bc_user_id']); unset($_SESSION['bc_course_code']); unset($_SESSION['bc_course_codetext']); diff --git a/plugin/buy_courses/view/configuration.tpl b/plugin/buy_courses/view/configuration.tpl index 27cfbb7c63..c27fdf4320 100644 --- a/plugin/buy_courses/view/configuration.tpl +++ b/plugin/buy_courses/view/configuration.tpl @@ -15,28 +15,27 @@ {% set i = 0 %} {% for course in courses %} - {{ i%2==0 ? ' - ' : ' - ' }} + {{ i%2 == 0 ? '' : '' }} {% set i = i + 1 %} - {{ $visibility[course.visibility] }} - {{course.title}} - {{ course.visual_code }} - - {{course.code}} + {{ visibility[course.visibility] }} + {{course.title}} + {{ course.visual_code }} + + + {{course.code}} + - {% if course.visible == 1 %} - - {% else %} - - {% endif %} + {% if course.visible == 1 %} + + {% else %} + + {% endif %} {{ currency }} - -
ok
- + +
ok
+ {% endfor %} diff --git a/plugin/buy_courses/view/list.tpl b/plugin/buy_courses/view/list.tpl index 08cea72dfc..3fa9f515b8 100644 --- a/plugin/buy_courses/view/list.tpl +++ b/plugin/buy_courses/view/list.tpl @@ -38,7 +38,7 @@
diff --git a/plugin/buy_courses/view/paymentsetup.tpl b/plugin/buy_courses/view/paymentsetup.tpl index 4578da8b4a..5388954891 100644 --- a/plugin/buy_courses/view/paymentsetup.tpl +++ b/plugin/buy_courses/view/paymentsetup.tpl @@ -16,7 +16,7 @@ {% endif %} {% endfor %} - + {% if paypal_enable == "true" %}
diff --git a/plugin/buy_courses/view/process.tpl b/plugin/buy_courses/view/process.tpl index 22de8db224..41c7b79453 100644 --- a/plugin/buy_courses/view/process.tpl +++ b/plugin/buy_courses/view/process.tpl @@ -24,7 +24,7 @@
- -
-
-
-
- - - - - {% if paypal_enable == "true" %} - - {% endif %} - - {% if transference_enable == "true" %} - - {% endif %} - -
-

Métodos de Pago:

-
{{ 'paypal'|get_lang }}
{{ 'BankTransference'|get_lang }}
+ +
+ {{ 'PaymentMethods'|get_lang }} +
+
+ {% if paypal_enable == "true" %} + + {% endif %} + {% if transference_enable == "true" %} + + {% endif %} +
+
- -
-
-
+ + + +
\ No newline at end of file diff --git a/plugin/buy_courses/view/process_confirm.tpl b/plugin/buy_courses/view/process_confirm.tpl index 7dc2c14673..2022b58bb1 100644 --- a/plugin/buy_courses/view/process_confirm.tpl +++ b/plugin/buy_courses/view/process_confirm.tpl @@ -24,7 +24,7 @@