Skip to content

Commit

Permalink
Initial Release of Moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
prabalsslw committed Jul 16, 2020
0 parents commit dd77f79
Show file tree
Hide file tree
Showing 19 changed files with 1,725 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SSLCommerz-Moodle 3.9

Enrolment in Moodle using SSLCommerz payment gateway for paid courses

This plugin helps admins and webmasters use SSLCommerz as the payment gateway. SSLCommerz is one of the most commonly used payment gateways and offers considerable number of features unsupported by other payment gateways like Paypal. This plugin has all the settings for development as well as for production usage. Its easy to install, set up and effective.

## Installation Guidence :

Login to your moodle site as an `admin user` and follow the steps.

1) Upload the zip package from `Site administration` > `Plugins` > `Install plugins`. Choose Plugin type `Enrolment method (enrol)`. Upload the ZIP package, check the acknowledgement and install.

2) Go to `Enrolments` > `Manage enrol plugins` > `Enable SSLCOmmerz` from list

3) Click `Settings` which will lead to the settings page of the plugin

4) Provide merchant credentials for SSLCommerz, select the checkbox as per requirement. Save the settings.

5) Select any course from course listing page.

6) Go to `Course administration` > `Users` > `Enrolment methods` > `Add method` `SSLCommerz` from the dropdown. Set `Custom instance name`, `Enrol cost` etc and add the method.

This completes all the steps from the administrator end. Now registered users can login to the Moodle site and view the course after a successful payment.


## Contributor

- Author : Prabal Mallick
- Team Email: [email protected] (For any query)
- More info: https://www.sslcommerz.com

© 2019 SSLCOMMERZ ALL RIGHTS RESERVED
89 changes: 89 additions & 0 deletions sslcommerz/api/Sslcommerz.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
namespace Sslcommerz\API;

class Sslcommerz_API
{
public static function requestToSSL($store_id, $password, $env, $post_data)
{
if($env == "yes"){
$direct_api_url = "https://securepay.sslcommerz.com/gwprocess/v4/api.php";
} else{
$direct_api_url = "https://sandbox.sslcommerz.com/gwprocess/v4/api.php";
}

$post_data['store_id'] = $store_id;
$post_data['store_passwd'] = $password;

$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $direct_api_url );
curl_setopt($handle, CURLOPT_TIMEOUT, 30);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($handle, CURLOPT_POST, 1 );
curl_setopt($handle, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE); # KEEP IT FALSE IF YOU RUN FROM LOCAL PC


$content = curl_exec($handle );

$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);

if($code == 200 && !( curl_errno($handle))) {
curl_close( $handle);
$sslcommerzResponse = $content;
} else {
curl_close( $handle);
echo "FAILED TO CONNECT WITH SSLCOMMERZ API";
exit;
}

# PARSE THE JSON RESPONSE
$sslcz = json_decode($sslcommerzResponse, true );

if(isset($sslcz['GatewayPageURL']) && $sslcz['GatewayPageURL']!="" ) {
# THERE ARE MANY WAYS TO REDIRECT - Javascript, Meta Tag or Php Header Redirect or Other
# echo "<script>window.location.href = '". $sslcz['GatewayPageURL'] ."';</script>";
echo "<meta http-equiv='refresh' content='0;url=".$sslcz['GatewayPageURL']."'>";
# header("Location: ". $sslcz['GatewayPageURL']);
exit;
} else {
echo "JSON Data parsing error!";
}
}

public static function orderValidation($store_id, $password, $env, $val_id)
{
if($env == "yes"){
$direct_api_url = "https://securepay.sslcommerz.com/validator/api/validationserverAPI.php";
} else{
$direct_api_url = "https://sandbox.sslcommerz.com/validator/api/validationserverAPI.php";
}

$requested_url = $direct_api_url."?val_id=".$val_id."&store_id=".$store_id."&store_passwd=".$password."&v=1&format=json";

$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $requested_url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false); # IF YOU RUN FROM LOCAL PC
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); # IF YOU RUN FROM LOCAL PC

$result = curl_exec($handle);

$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);

if($code == 200 && !( curl_errno($handle)))
{
# TO CONVERT AS ARRAY
# $result = json_decode($result, true);
# $status = $result['status'];

# TO CONVERT AS OBJECT
$result = json_decode($result, true);
return $result;
}
else {
echo "Failed to connect with SSLCOMMERZ";
}
}
}
?>
57 changes: 57 additions & 0 deletions sslcommerz/db/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Capabilities for SSLCommerz enrolment plugin.
*
* @package enrol_sslcommerz
* @copyright 2015 Dualcube, Moumita Ray, Parthajeet Chakraborty
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$capabilities = array(

'enrol/sslcommerz:config' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'manager' => CAP_ALLOW,
)
),
'enrol/sslcommerz:manage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'manager' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
)
),
'enrol/sslcommerz:unenrol' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'manager' => CAP_ALLOW,
)
),
'enrol/sslcommerz:unenrolself' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
)
),
);
33 changes: 33 additions & 0 deletions sslcommerz/db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* SSLCommerz - database creation.
*
* @package enrol_sslcommerz
* @copyright 2015 Dualcube, Moumita Ray, Parthajeet Chakraborty
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
/**
* Sets up installation script.
* @return void
*/
function xmldb_enrol_sslcommerz_install() {
global $CFG, $DB;

}
46 changes: 46 additions & 0 deletions sslcommerz/db/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="enrol/sslcommerz/db" VERSION="20150624" COMMENT="XMLDB file for Moodle enrol/sslcommerz"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
<TABLES>
<TABLE NAME="enrol_sslcommerz" COMMENT="Holds all known information about SSLCommerz transactions">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="item_name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="amount" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="tax" TYPE="char" LENGTH="255" NOTNULL="false" DEFAULT="00.00" SEQUENCE="false"/>
<FIELD NAME="duty" TYPE="char" LENGTH="255" NOTNULL="false" DEFAULT="00.00" SEQUENCE="false"/>
<FIELD NAME="payment_status" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="response_code" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="response_reason_code" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="response_reason_text" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="auth_code" TYPE="char" LENGTH="6" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="trans_id" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="method" TYPE="char" LENGTH="6" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="account_number" TYPE="char" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="card_type" TYPE="char" LENGTH="30" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="invoice_num" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="test_request" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="first_name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="last_name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="company" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="phone" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="fax" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="email" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="address" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="city" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="state" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="zip" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="country" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="auth_json" TYPE="text" LENGTH="" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="timeupdated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
29 changes: 29 additions & 0 deletions sslcommerz/db/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Defines message providers (types of message sent) for the Stripe enrolment plugin.
*
* @package enrol_sslcommerz
* @copyright 2015 Dualcube, Arkaprava Midya, Parthajeet Chakraborty
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$messageproviders = array(
'sslcommerz_enrolment' => array(),
);
Loading

0 comments on commit dd77f79

Please sign in to comment.