Added Culqi payment process

pull/2487/head
José Loguercio 9 years ago
parent 2a7529b887
commit 94e347693c
  1. 21
      plugin/buycourses/database.php
  2. 2
      plugin/buycourses/lang/english.php
  3. 2
      plugin/buycourses/lang/french.php
  4. 7
      plugin/buycourses/lang/spanish.php
  5. 45
      plugin/buycourses/src/buy_course_plugin.class.php
  6. 107
      plugin/buycourses/src/buycourses.ajax.php
  7. 28
      plugin/buycourses/src/culqi.php
  8. 9
      plugin/buycourses/src/paymentsetup.php
  9. 22
      plugin/buycourses/src/process.php
  10. 81
      plugin/buycourses/src/process_confirm.php
  11. 2
      plugin/buycourses/src/service_process_confirm.php
  12. 44
      plugin/buycourses/view/catalog.tpl
  13. 13
      plugin/buycourses/view/paymentsetup.tpl
  14. 46
      plugin/buycourses/view/process.tpl
  15. 241
      plugin/buycourses/view/process_confirm.tpl

@ -280,8 +280,18 @@ $culqiTable->addColumn(
);
$culqiTable->addColumn('commerce_code', \Doctrine\DBAL\Types\Type::STRING);
$culqiTable->addColumn('api_key', \Doctrine\DBAL\Types\Type::STRING);
$culqiTable->addColumn('integration', \Doctrine\DBAL\Types\Type::INTEGER);
$culqiTable->setPrimaryKey(['id']);
$globalTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
$globalTable->addColumn(
'id',
\Doctrine\DBAL\Types\Type::INTEGER,
['autoincrement' => true, 'unsigned' => true]
);
$globalTable->addColumn('terms_and_conditions', \Doctrine\DBAL\Types\Type::TEXT);
$globalTable->setPrimaryKey(['id']);
$queries = $pluginSchema->toSql($platform);
foreach ($queries as $query) {
@ -296,6 +306,7 @@ $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE);
$commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
$extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);
$culqiTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CULQI);
$globalTable = Database::get_main_table(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
$paypalExtraField = Database::select(
"*",
@ -338,7 +349,15 @@ Database::insert(
$culqiTable,
[
'commerce_code' => '',
'api_key' => ''
'api_key' => '',
'integration' => 1
]
);
Database::insert(
$globalTable,
[
'terms_and_conditions' => ''
]
);

@ -112,7 +112,7 @@ $strings['PayPalAccount'] = "Paypal account";
$strings['NoPayPalAccountDetected'] = "No Paypal account detected";
$strings['PayPalConfig'] = "PayPal configuration:";
$strings['TransfersConfig'] = "Bank transfers configuration:";
$strings['PluginInstruction'] = "You can enable or disable the option to pay via PayPal or bank transfer settings in the configuration section of the plugin.";
$strings['PluginInstruction'] = "You can enable or disable the option to pay via PayPal, Culqi or bank transfer settings in the configuration section of the plugin.";
$strings['ClickHere'] = "<i>Click here</i> for more details";
$strings['CurrencyType'] = "Currency type";
$strings['InfoCurrency'] = "Sets the currency for the payment of your courses.";

@ -112,7 +112,7 @@ $strings['PayPalAccount'] = "Compte Paypal";
$strings['NoPayPalAccountDetected'] = "Pas de compte paypal détecté";
$strings['PayPalConfig'] = "Configuration PayPal:";
$strings['TransfersConfig'] = "Configuration des transfers bancaires:";
$strings['PluginInstruction'] = "Vous pouvez activer ou désactiver l'option de paiements via PayPal ou de transferts bancaires dans la section de configuration des plugins.";
$strings['PluginInstruction'] = "Vous pouvez activer ou désactiver l'option de paiements via PayPal, Culqi ou de transferts bancaires dans la section de configuration des plugins.";
$strings['ClickHere'] = "Cliquez ici pour plus d'infos";
$strings['CurrencyType'] = "Type de devise";
$strings['InfoCurrency'] = "Permet de configurer la devise pour l'achat des cours.";

@ -112,7 +112,7 @@ $strings['PayPalAccount'] = "Cuenta de Paypal";
$strings['NoPayPalAccountDetected'] = "No se ingresó una cuenta de Paypal";
$strings['PayPalConfig'] = "Configuración PayPal:";
$strings['TransfersConfig'] = "Configuraci&oacute;n de transferencias:";
$strings['PluginInstruction'] = "Puede activar o desactivar la opción de pagos vía PayPal o configuración de transferencias bancarias, en la sección del configuración del plugin.";
$strings['PluginInstruction'] = "Puede activar o desactivar la opción de pagos vía PayPal, Culqi o configuración de transferencias bancarias, en la sección del configuración del plugin.";
$strings['ClickHere'] = "<i>Clic aquí</i> para más detalles";
$strings['CurrencyType'] = "Tipo de moneda";
$strings['InfoCurrency'] = "Permite configurar el tipo de moneda (de pago) para sus cursos.";
@ -152,3 +152,8 @@ $strings['culqi_enable'] = "Habilitar Culqi";
$strings['CulqiConfig'] = "Configuración de CULQI:";
$strings['InfoCulqiCredentials'] = "Para obtener las credenciales es necesario crearse una cuenta en Culqi e ingresar en modo desarrollo, copiar el código de comercio que se encuentra en su panel de control, luego ingresar al apartado de API Keys y generar la Key correspondiente para copiarla aquí";
$strings['CommerceCode'] = "Codigo de comercio";
$strings['IConfirmIReadAndAcceptTermsAndCondition'] = "He leído y aceptado los terminos y condiciones del servicio";
$strings['NoTermsAndConditionsProvided'] = "Terminos y condiciones no establecidos";
$strings['GlobalConfig'] = "Configuración global:";
$strings['WriteHereTheTermsAndConditionsOfYourECommerce'] = "Escriba aquí los terminos y condiciones para su tienda virtual";
$strings['PleaseSelectThePaymentMethodBeforeConfirmYourOrder'] = "Porfavor seleccione el método de pago de su preferencia antes de confirmar su orden";

@ -26,6 +26,7 @@ class BuyCoursesPlugin extends Plugin
const TABLE_SERVICES = 'plugin_buycourses_services';
const TABLE_SERVICES_SALE = 'plugin_buycourses_service_sale';
const TABLE_CULQI = 'plugin_buycourses_culqi';
const TABLE_GLOBAL_CONFIG = 'plugin_buycourses_global_config';
const PRODUCT_TYPE_COURSE = 1;
const PRODUCT_TYPE_SESSION = 2;
const PAYMENT_TYPE_PAYPAL = 1;
@ -43,6 +44,8 @@ class BuyCoursesPlugin extends Plugin
const SERVICE_TYPE_USER = 1;
const SERVICE_TYPE_COURSE = 2;
const SERVICE_TYPE_SESSION = 3;
const CULQI_INTEGRATION_TYPE = 'INTEG';
const CULQI_PRODUCTION_TYPE = 'PRODUC';
/**
*
@ -95,7 +98,8 @@ class BuyCoursesPlugin extends Plugin
self::TABLE_COMMISSION,
self::TABLE_PAYPAL_PAYOUTS,
self::TABLE_SERVICES,
self::TABLE_SERVICES_SALE
self::TABLE_SERVICES_SALE,
self::TABLE_GLOBAL_CONFIG
);
$em = Database::getManager();
$cn = $em->getConnection();
@ -125,7 +129,8 @@ class BuyCoursesPlugin extends Plugin
self::TABLE_COMMISSION,
self::TABLE_PAYPAL_PAYOUTS,
self::TABLE_SERVICES_SALE,
self::TABLE_SERVICES
self::TABLE_SERVICES,
self::TABLE_GLOBAL_CONFIG
);
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
@ -654,6 +659,7 @@ class BuyCoursesPlugin extends Plugin
$courseInfo = [
'id' => $course->getId(),
'title' => $course->getTitle(),
'description' => $course->getDescription(),
'code' => $course->getCode(),
'visual_code' => $course->getVisualCode(),
'teachers' => [],
@ -781,7 +787,7 @@ class BuyCoursesPlugin extends Plugin
*/
public function registerSale($itemId, $paymentType)
{
if (!in_array($paymentType, [self::PAYMENT_TYPE_PAYPAL, self::PAYMENT_TYPE_TRANSFER])) {
if (!in_array($paymentType, [self::PAYMENT_TYPE_PAYPAL, self::PAYMENT_TYPE_TRANSFER, self::PAYMENT_TYPE_CULQI])) {
return false;
}
@ -2151,7 +2157,8 @@ class BuyCoursesPlugin extends Plugin
Database::get_main_table(BuyCoursesPlugin::TABLE_CULQI),
[
'commerce_code' => $params['commerce_code'],
'api_key' => $params['api_key']
'api_key' => $params['api_key'],
'integration' => $params['integration']
],
['id = ?' => 1]
);
@ -2171,4 +2178,34 @@ class BuyCoursesPlugin extends Plugin
);
}
/**
* Save Global Parameters
* @param array $params
* @return int Rows affected. Otherwise return false
*/
public function saveGlobalParameters($params)
{
return Database::update(
Database::get_main_table(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG),
[
'terms_and_conditions' => $params['terms_and_conditions']
],
['id = ?' => 1]
);
}
/**
* get Global Parameters
* @return array
*/
public function getGlobalParameters()
{
return Database::select(
'*',
Database::get_main_table(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG),
['id = ?' => 1],
'first'
);
}
}

@ -10,12 +10,15 @@ $cidReset = true;
require_once __DIR__.'/../../../main/inc/global.inc.php';
api_protect_admin_script(true);
if (api_is_anonymous()) {
api_not_allowed(true);
}
$plugin = BuyCoursesPlugin::create();
$paypalEnable = $plugin->get('paypal_enable');
$commissionsEnable = $plugin->get('commissions_enable');
$culqiEnable = $plugin->get('culqi_enable');
$action = isset($_GET['a']) ? $_GET['a'] : null;
@ -226,7 +229,7 @@ switch ($action) {
break;
case 'cancelPayout':
case 'cancelPayout':
if (api_is_anonymous()) {
break;
}
@ -237,6 +240,104 @@ switch ($action) {
echo '';
break;
case 'culqi_cargo':
if (!$culqiEnable) {
break;
}
$tokenId = $_REQUEST['token_id'];
$saleId = $_REQUEST['sale_id'];
if (!$tokenId || !$saleId) {
break;
}
$sale = $plugin->getSale($saleId);
if (!$sale) {
break;
}
require_once("Requests.php");
Requests::register_autoloader();
require_once("culqi.php");
$culqiParams = $plugin->getCulqiParams();
// API Key y autenticación
$SECRET_API_KEY = $culqiParams['api_key'];
$culqi = new Culqi\Culqi(array('api_key' => $SECRET_API_KEY));
$environment = $culqiParams['integration'];
$environment = $environment ? BuyCoursesPlugin::CULQI_INTEGRATION_TYPE : BuyCoursesPlugin::CULQI_PRODUCTION_TYPE;
$culqi->setEnv($environment);
$user = api_get_user_info();
$currency = $plugin->getSelectedCurrency();
try {
$cargo = $culqi->Cargos->create(array(
"moneda" => $currency['iso_code'],
"monto" => intval(floatval($sale['price']) * 100),
"usuario" => $user['username'],
"descripcion" => $sale['product_name'],
"pedido" => $sale['reference'],
"codigo_pais" => "PE",
"direccion" => get_lang('None'),
"ciudad" => get_lang('None'),
"telefono" => 0,
"nombres" => $user['firstname'],
"apellidos" => $user['lastname'],
"correo_electronico" => $user['email'],
"token" => $tokenId
));
if (is_object($cargo)) {
$saleIsCompleted = $plugin->completeSale($sale['id']);
if ($saleIsCompleted) {
Display::addFlash(
Display::return_message(
sprintf($plugin->get_lang('SubscriptionToCourseXSuccessful'), $sale['product_name']),
'success'
)
);
}
}
echo json_encode($cargo);
} catch(Exception $e) {
$cargo = json_decode($e->getMessage(), true);
$plugin->cancelSale($sale['id']);
unset($_SESSION['bc_sale_id']);
if (is_array($cargo)) {
Display::addFlash(
Display::return_message(
sprintf($plugin->get_lang('ErrorOccurred'), $cargo['codigo'], $cargo['mensaje']),
'error',
false
)
);
} else {
Display::addFlash(
Display::return_message(
$plugin->get_lang('ErrorContactPlatformAdmin'),
'error',
false
)
);
}
}
break;
}
exit;

File diff suppressed because one or more lines are too long

@ -39,6 +39,8 @@ if ($currencyForm->validate()) {
$currencyFormValues = $currencyForm->getSubmitValues();
$plugin->selectCurrency($currencyFormValues['currency']);
unset($currencyFormValues['currency']);
$plugin->saveGlobalParameters($currencyFormValues);
Display::addFlash(
Display::return_message(get_lang('Saved'), 'success')
@ -76,7 +78,11 @@ foreach ($currencies as $currency) {
}
}
$currencyForm->addTextarea('terms_and_conditions', [ get_lang('TermsAndConditions'), $plugin->get_lang('WriteHereTheTermsAndConditionsOfYourECommerce') ], '');
$currencyForm->addButtonSave(get_lang('Save'));
$currencyForm->setDefaults($plugin->getGlobalParameters());
$termsAndConditionsForm = new FormValidator('termsconditions');
$paypalForm = new FormValidator('paypal');
@ -209,6 +215,7 @@ $culqiForm->addText(
false,
['cols-size' => [3, 8, 1]]
);
$culqiForm->addCheckBox('integration', null, $plugin->get_lang('Sandbox'));
$culqiForm->addButtonSave(get_lang('Save'));
$culqiForm->setDefaults($plugin->getCulqiParams());
@ -221,7 +228,7 @@ $interbreadcrumb[] = [
$templateName = $plugin->get_lang('PaymentsConfiguration');
$tpl = new Template($templateName);
$tpl->assign('header', $templateName);
$tpl->assign('curency_form', $currencyForm->returnForm());
$tpl->assign('global_config_form', $currencyForm->returnForm());
$tpl->assign('paypal_form', $paypalForm->returnForm());
$tpl->assign('commission_form', $commissionForm->returnForm());
$tpl->assign('transfer_form', $transferForm->returnForm());

@ -20,8 +20,9 @@ $plugin = BuyCoursesPlugin::create();
$includeSession = $plugin->get('include_sessions') === 'true';
$paypalEnabled = $plugin->get('paypal_enable') === 'true';
$transferEnabled = $plugin->get('transfer_enable') === 'true';
$culqiEnabled = $plugin->get('culqi_enable') === 'true';
if (!$paypalEnabled && !$transferEnabled) {
if (!$paypalEnabled && !$transferEnabled && !$culqiEnabled) {
api_not_allowed(true);
}
@ -66,12 +67,6 @@ if ($form->validate()) {
exit;
}
$form->addHeader($plugin->get_lang('UserInformation'));
$form->addText('name', get_lang('Name'), false, ['cols-size' => [5, 7, 0]]);
$form->addText('username', get_lang('Username'), false, ['cols-size' => [5, 7, 0]]);
$form->addText('email', get_lang('EmailAddress'), false, ['cols-size' => [5, 7, 0]]);
$form->addHeader($plugin->get_lang('PaymentMethods'));
$paymentTypesOptions = $plugin->getPaymentTypes();
if (!$paypalEnabled) {
@ -82,15 +77,16 @@ if (!$transferEnabled) {
unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER]);
}
if (!$culqiEnabled) {
unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_CULQI]);
}
$form->addRadio('payment_type', null, $paymentTypesOptions);
$form->addHtml('<h3 class="panel-heading">'.$plugin->get_lang('AdditionalInfo').'</h3>');
$form->addHeader('');
$form->addHtml(Display::return_message($plugin->get_lang('PleaseSelectThePaymentMethodBeforeConfirmYourOrder'), 'info'));
$form->addHidden('t', intval($_GET['t']));
$form->addHidden('i', intval($_GET['i']));
$form->freeze(['name', 'username', 'email']);
$form->setDefaults([
'name' => $userInfo['complete_name'],
'username' => $userInfo['username'],
'email' => $userInfo['email']
]);
$form->addButton('submit', $plugin->get_lang('ConfirmOrder'), 'check', 'success');
// View

@ -19,11 +19,14 @@ if (empty($saleId)) {
$sale = $plugin->getSale($saleId);
$userInfo = api_get_user_info($sale['user_id']);
if (empty($sale)) {
api_not_allowed(true);
}
$currency = $plugin->getCurrency($sale['currency_id']);
$terms = $plugin->getGlobalParameters();
switch ($sale['payment_type']) {
case BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL:
@ -80,7 +83,6 @@ switch ($sale['payment_type']) {
}
$transferAccounts = $plugin->getTransferAccounts();
$userInfo = api_get_user_info($sale['user_id']);
$form = new FormValidator('success', 'POST', api_get_self(), null, null, FormValidator::LAYOUT_INLINE);
@ -133,7 +135,7 @@ switch ($sale['payment_type']) {
exit;
}
$form->addButton('confirm', $plugin->get_lang('ConfirmOrder'), 'check', 'success');
$form->addButton('confirm', $plugin->get_lang('ConfirmOrder'), 'check', 'success', 'default', null, ['id' => 'confirm']);
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
$template = new Template();
@ -147,16 +149,91 @@ switch ($sale['payment_type']) {
$template->assign('buying_course', $buyingCourse);
$template->assign('buying_session', $buyingSession);
$template->assign('terms', $terms['terms_and_conditions']);
$template->assign('title', $sale['product_name']);
$template->assign('price', $sale['price']);
$template->assign('currency', $sale['currency_id']);
$template->assign('user', $userInfo);
$template->assign('transfer_accounts', $transferAccounts);
$template->assign('form', $form->returnForm());
$template->assign('is_bank_transfer', true);
$content = $template->fetch('buycourses/view/process_confirm.tpl');
$template->assign('content', $content);
$template->display_one_col_template();
break;
case BuyCoursesPlugin::PAYMENT_TYPE_CULQI:
// We need to include the main online script, acording to the Culqi documentation the JS needs to be loeaded
// directly from the main url "https://integ-pago.culqi.com" because a local copy of this JS is not supported
$htmlHeadXtra[] = '<script src="//integ-pago.culqi.com/js/v1"></script>';
$buyingCourse = false;
$buyingSession = false;
switch ($sale['product_type']) {
case BuyCoursesPlugin::PRODUCT_TYPE_COURSE:
$buyingCourse = true;
$course = $plugin->getCourseInfo($sale['product_id']);
break;
case BuyCoursesPlugin::PRODUCT_TYPE_SESSION:
$buyingSession = true;
$session = $plugin->getSessionInfo($sale['product_id']);
break;
}
$form = new FormValidator('success', 'POST', api_get_self(), null, null, FormValidator::LAYOUT_INLINE);
if ($form->validate()) {
$formValues = $form->getSubmitValues();
if (isset($formValues['cancel'])) {
$plugin->cancelSale($sale['id']);
unset($_SESSION['bc_sale_id']);
Display::addFlash(
Display::return_message(
$plugin->get_lang('OrderCanceled'),
'warning',
false
)
);
header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/index.php');
exit;
}
}
$form->addButton('confirm', $plugin->get_lang('ConfirmOrder'), 'check', 'success', 'default', null, ['id' => 'confirm']);
$form->addButton('cancel', $plugin->get_lang('CancelOrder'), 'times', 'danger', 'default', null, ['id' => 'cancel']);
$template = new Template();
if ($buyingCourse) {
$template->assign('course', $course);
} elseif ($buyingSession) {
$template->assign('session', $session);
}
$template->assign('buying_course', $buyingCourse);
$template->assign('buying_session', $buyingSession);
$template->assign('terms', $terms['terms_and_conditions']);
$template->assign('title', $sale['product_name']);
$template->assign('price', floatval($sale['price']));
$template->assign('currency', $plugin->getSelectedCurrency());
$template->assign('user', $userInfo);
$template->assign('sale', $sale);
$template->assign('form', $form->returnForm());
$template->assign('is_culqi_payment', true);
$template->assign('culqi_params', $culqiParams = $plugin->getCulqiParams());
$content = $template->fetch('buycourses/view/process_confirm.tpl');
$template->assign('content', $content);
$template->display_one_col_template();
break;
}

@ -179,6 +179,8 @@ switch ($serviceSale['payment_type']) {
// directly from the main url "https://integ-pago.culqi.com" because a local copy of this JS is not supported
$htmlHeadXtra[] = '<script src="https://integ-pago.culqi.com/js/v1"></script>';
$template = new Template();
break;
}

@ -28,29 +28,35 @@
{% if showing_courses %}
{% for course in courses %}
<div class="col-md-4 col-sm-6">
<article class="thumbnail">
<img alt="{{ course.title }}" class="img-responsive" src="{{ course.course_img ? course.course_img : 'session_default.png'|icon() }}">
<div class="caption">
<article class="items-course">
<div class="items-course-image">
<img alt="{{ course.title }}" class="img-responsive" src="{{ course.course_img ? course.course_img : 'session_default.png'|icon() }}">
</div>
<div class="items-course-info">
{% set course_description_url = _p.web_ajax ~ 'course_home.ajax.php?' ~ {'code': course.code, 'a': 'show_course_information'}|url_encode() %}
<h3>
<h4 class="title">
<a class="ajax" href="{{ course_description_url }}" data-title="{{ course.title }}">{{ course.title }}</a>
</h3>
</h4>
<ul class="list-unstyled">
{% for teacher in course.teachers %}
<li><em class="fa fa-user"></em> {{ teacher }}</li>
{% endfor %}
{% endfor %}
</ul>
<p class="lead text-right">{{ course.currency }} {{ course.price }}</p>
<p class="text-right">
<span class="label label-primary">
{{ course.currency }} {{ course.price }}
</span>
</p>
{% if course.enrolled == "YES" %}
<div class="alert alert-success">
<em class="fa fa-check-square-o fa-fw"></em> {{ 'TheUserIsAlreadyRegisteredInTheCourse'|get_plugin_lang('BuyCoursesPlugin') }}
</div>
{% elseif course.enrolled == "NO" %}
<div class="text-center">
<a class="ajax btn btn-primary" title="" href="{{ course_description_url }}" data-title="{{ course.title }}">
<div class="toolbar">
<a class="ajax btn btn-info btn-block btn-sm" title="" href="{{ course_description_url }}" data-title="{{ course.title }}">
<em class="fa fa-file-text"></em> {{ 'SeeDescription'|get_plugin_lang('BuyCoursesPlugin') }}
</a>
<a class="btn btn-success" title="" href="{{ _p.web_plugin ~ 'buycourses/src/process.php?' ~ {'i': course.id, 't': 1}|url_encode() }}">
<a class="btn btn-success btn-block btn-sm" title="" href="{{ _p.web_plugin ~ 'buycourses/src/process.php?' ~ {'i': course.id, 't': 1}|url_encode() }}">
<em class="fa fa-shopping-cart"></em> {{ 'Buy'|get_plugin_lang('BuyCoursesPlugin') }}
</a>
</div>
@ -66,12 +72,14 @@
{% if showing_sessions %}
{% for session in sessions %}
<div class="col-md-4 col-sm-6">
<article class="thumbnail">
<img alt="{{ session.name }}" class="img-responsive" src="{{ session.image ? session.image : 'session_default.png'|icon() }}">
<div class="caption">
<h3>
<article class="items-course">
<div class="items-course-image">
<img alt="{{ session.name }}" class="img-responsive" src="{{ session.image ? session.image : 'session_default.png'|icon() }}">
</div>
<div class="items-course-info">
<h4 class="title">
<a href="{{ _p.web ~ 'session/' ~ session.id ~ '/about/' }}">{{ session.name }}</a>
</h3>
</h4>
{% if 'show_session_coach'|get_setting == 'true' %}
<p><em class="fa fa-user fa-fw"></em> {{ session.coach }}</p>
{% endif %}
@ -96,8 +104,8 @@
<em class="fa fa-check-square-o fa-fw"></em> {{ 'TheUserIsAlreadyRegisteredInTheSession'|get_plugin_lang('BuyCoursesPlugin') }}
</div>
{% elseif session.enrolled == "NO" %}
<div class="text-center">
<a class="btn btn-success" href="{{ _p.web_plugin ~ 'buycourses/src/process.php?' ~ {'i': session.id, 't': 2}|url_encode() }}">
<div class="toolbar">
<a class="btn btn-success btn-block btn-sm" href="{{ _p.web_plugin ~ 'buycourses/src/process.php?' ~ {'i': session.id, 't': 2}|url_encode() }}">
<em class="fa fa-shopping-cart"></em> {{ 'Buy'|get_plugin_lang('BuyCoursesPlugin') }}
</a>
</div>
@ -115,7 +123,7 @@
<div class="col-md-4 col-sm-6">
<div class="items-course">
<div class="items-course-image">
<a href="{{ _p.web }}service/{{ service.id }}"><img alt="{{ service.name }}" class="img-responsive" src="{{ service.image }}"></a>
<a href="{{ _p.web }}service/{{ service.id }}"><img alt="{{ service.name }}" class="img-responsive" src="{{ service.image ? service.image : 'session_default.png'|icon() }}"></a>
</div>
<div class="items-course-info">
<h4 class="title">

@ -2,7 +2,18 @@
<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/>
{{ curency_form }}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ 'GlobalConfig'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
{{ global_config_form }}
</div>
</div>
</div>
</div>
<p class="alert alert-info">
{{ 'PluginInstruction'|get_plugin_lang('BuyCoursesPlugin') }}

@ -4,27 +4,25 @@
<legend></legend>
<div class="row">
{% if buying_course %}
<div class="col-sm-6 col-md-5">
<p>
<img alt="{{ course.title }}" class="img-responsive" src="{{ course.course_img ? course.course_img : 'session_default.png'|icon() }}">
</p>
<p class="lead text-right">{{ course.currency }} {{ course.price }}</p>
<div class="col-sm-12 col-md-12 col-xs-12">
<a class="ajax" data-title="{{ course.title }}" href="{{ _p.web_ajax ~ 'course_home.ajax.php?' ~ {'a': 'show_course_information', 'code': course.code}|url_encode() }}">
<img alt="{{ course.title }}" class="img-responsive" style="width: 100%;" src="{{ course.course_img ? course.course_img : 'session_default.png'|icon() }}">
</a>
</div>
<div class="col-sm-6 col-md-7">
<h3 class="page-header">{{ course.title }}</h3>
<ul class="items-teacher list-unstyled">
<div class="col-sm-12 col-md-12 col-xs-12">
<h3>
<a class="ajax" data-title="{{ course.title }}" href="{{ _p.web_ajax ~ 'course_home.ajax.php?' ~ {'a': 'show_course_information', 'code': course.code}|url_encode() }}">{{ course.title }}</a>
</h3>
<ul class="list-unstyled">
{% for teacher in course.teachers %}
<li><em class="fa fa-user"></em> {{ teacher }}</li>
{% endfor %}
</ul>
<p>
<a class="ajax btn btn-primary btn-sm" data-title="{{ course.title }}" href="{{ _p.web_ajax ~ 'course_home.ajax.php?' ~ {'a': 'show_course_information', 'code': course.code}|url_encode() }}">
{{'Description'|get_lang }}
</a>
</p>
<p id="n-price" class="lead text-right" style="color: white;"><span class="label label-primary">{{ course.currency == 'BRL' ? 'R$' : course.currency }} {{ course.price }}</span></p>
<p id="s-price" class="lead text-right"></p>
</div>
{% elseif buying_session %}
<div class="col-sm-6 col-md-5">
<div class="col-sm-12 col-md-12 col-xs-12">
<p>
<img alt="{{ session.name }}" class="img-responsive" src="{{ session.image ? session.image : 'session_default.png'|icon() }}">
</p>
@ -69,16 +67,6 @@
<p id="n-price" class="lead text-right" style="color: white;"><span class="label label-primary">{{ service.currency == 'BRL' ? 'R$' : service.currency }} {{ service.price }}</span></p>
<p id="s-price" class="lead text-right"></p>
</div>
<script>
$(document).ready(function() {
$("label").removeClass('control-label');
$('.form_required').remove();
$("small").remove();
$("label[for=submit]").remove();
});
</script>
{% endif %}
</div>
</div>
@ -89,3 +77,13 @@
{{ form }}
</div>
</div>
<script>
$(document).ready(function() {
$("label").removeClass('control-label');
$('.form_required').remove();
$("small").remove();
$("label[for=submit]").remove();
});
</script>

@ -1,48 +1,40 @@
<div class="row">
<div class="col-sm-6 col-md-5">
<h3 class="page-header">{{ 'UserInformation'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
<dl class="dl-horizontal">
<dt>{{ 'Name'|get_lang }}<dt>
<dd>{{ user.complete_name }}</dd>
<dt>{{ 'Username'|get_lang }}<dt>
<dd>{{ user.username }}</dd>
<dt>{{ 'EmailAddress'|get_lang }}<dt>
<dd>{{ user.email }}</dd>
</dl>
<div id="message-alert">
</div>
<div class="col-sm-6 col-md-7">
<div class="col-md-5 panel panel-default buycourse-panel-default">
<h3 class="panel-heading">{{ 'PurchaseData'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
<legend></legend>
{% if buying_course %}
<div class="row">
<div class="col-sm-6 col-md-5">
<p>
<img alt="{{ course.title }}" class="img-responsive" src="{{ course.course_img ? course.course_img : 'session_default.png'|icon() }}">
</p>
<p class="lead text-right">{{ course.currency }} {{ course.price }}</p>
<div class="col-sm-12 col-md-12 col-xs-12">
<a class="ajax" data-title="{{ course.title }}" href="{{ _p.web_ajax ~ 'course_home.ajax.php?' ~ {'a': 'show_course_information', 'code': course.code}|url_encode() }}">
<img alt="{{ course.title }}" class="img-responsive" style="width: 100%;" src="{{ course.course_img ? course.course_img : 'session_default.png'|icon() }}">
</a>
</div>
<div class="col-sm-6 col-md-7">
<h3 class="page-header">{{ course.title }}</h3>
<ul class="items-teacher list-unstyled">
<div class="col-sm-12 col-md-12 col-xs-12">
<h3>
<a class="ajax" data-title="{{ course.title }}" href="{{ _p.web_ajax ~ 'course_home.ajax.php?' ~ {'a': 'show_course_information', 'code': course.code}|url_encode() }}">{{ course.title }}</a>
</h3>
<ul class="list-unstyled">
{% for teacher in course.teachers %}
<li><em class="fa fa-user"></em> {{ teacher }}</li>
{% endfor %}
</ul>
<p>
<a class="ajax btn btn-primary btn-sm" data-title="{{ course.title }}" href="{{ _p.web_ajax ~ 'course_home.ajax.php?' ~ {'a': 'show_course_information', 'code': course.code}|url_encode() }}">
{{'Description'|get_lang }}
</a>
</p>
<p id="n-price" class="lead text-right" style="color: white;"><span class="label label-primary">{{ course.currency == 'BRL' ? 'R$' : course.currency }} {{ course.price }}</span></p>
<p id="s-price" class="lead text-right"></p>
</div>
</div>
{% elseif buying_session %}
<h3 class="page-header">{{ session.name }}</h3>
<div class="row">
<div class="col-sm-12 col-md-5">
<div class="col-sm-12 col-md-12 col-xs-12">
<p>
<img alt="{{ session.name }}" class="img-responsive" src="{{ session.image ? session.image : 'session_default.png'|icon() }}">
</p>
<p class="lead text-right">{{ session.currency }} {{ session.price }}</p>
</div>
<div class="col-sm-12 col-md-7">
<div class="col-sm-6 col-md-7">
<h3 class="page-header">{{ session.name }}</h3>
<p>{{ session.dates.display }}</p>
<dl>
{% for course in session.courses %}
@ -55,57 +47,164 @@
</div>
</div>
{% elseif buying_service %}
<h3 class="page-header">{{ service.service.name }}</h3>
<div class="row">
<div class="col-sm-12 col-md-5">
<p>
{% if service.node_type == 0 %}
<img alt="{{ service.service.name }}" class="img-responsive" src="{{ 'session_default.png'|icon() }}">
{% elseif service.node_type == 1 %}
<img alt="{{ service.service.name }}" class="img-responsive" style="margin: auto;" src="{{ _p.web }}plugin/buycourses/resources/img/bc-user.png">
{% elseif service.node_type == 2 %}
<img alt="{{ service.service.name }}" class="img-responsive" style="margin: auto;" src="{{ _p.web }}plugin/buycourses/resources/img/bc-course.png">
{% elseif service.node_type == 3 %}
<img alt="{{ service.service.name }}" class="img-responsive" style="margin: auto;" src="{{ _p.web }}plugin/buycourses/resources/img/bc-session.png">
{% endif %}
</p>
<p class="lead text-right">{{ service.currency == 'BRL' ? 'R$' : service.currency }} {{ service.price }}</p>
</div>
<div class="col-sm-12 col-md-7">
<p><b>{{ 'StartDate'|get_plugin_lang('BuyCoursesPlugin') }}</b></p>
<li>{{ service.date_start | format_date() }}</li>
<p><b>{{ 'EndDate'|get_plugin_lang('BuyCoursesPlugin') }}</b></p>
<li>{{ service.date_end | format_date() }}</li>
</div>
<div class="col-sm-12 col-md-12 col-xs-12">
<a href='{{ _p.web }}service/{{ service.id }}'>
<img alt="{{ service.name }}" class="img-responsive" src="{{ _p.web }}plugin/buycourses/uploads/services/images/{{ service.image }}">
</a>
</div>
<div class="col-sm-12 col-md-12 col-xs-12">
<h3>
<a href='{{ _p.web }}service/{{ service.id }}'>{{ service.name }}</a>
</h3>
<ul class="list-unstyled">
{% if service.applies_to == 0 %}
<li><em class="fa fa-hand-o-right"></em> {{ 'AppliesTo'|get_plugin_lang('BuyCoursesPlugin') }} {{ 'None' | get_lang }}</li>
{% elseif service.applies_to == 1 %}
<li><em class="fa fa-hand-o-right"></em> {{ 'AppliesTo'|get_plugin_lang('BuyCoursesPlugin') }} {{ 'User' | get_lang }}</li>
{% elseif service.applies_to == 2 %}
<li><em class="fa fa-hand-o-right"></em> {{ 'AppliesTo'|get_plugin_lang('BuyCoursesPlugin') }} {{ 'Course' | get_lang }}</li>
{% elseif service.applies_to == 3 %}
<li><em class="fa fa-hand-o-right"></em> {{ 'AppliesTo'|get_plugin_lang('BuyCoursesPlugin') }} {{ 'Session' | get_lang }}</li>
{% endif %}
<li><em class="fa fa-money"></em> {{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }} : {{ service.currency == 'BRL' ? 'R$' : service.currency }} {{ service.price }} / {{ service.duration_days == 0 ? 'NoLimit' | get_lang : service.duration_days ~ ' ' ~ 'Days' | get_lang }} </li>
<li><em class="fa fa-user"></em> {{ service.owner_name }}</li>
<li><em class="fa fa-align-justify"></em> {{ service.description }}</li>
</ul>
<p id="n-price" class="lead text-right" style="color: white;"><span class="label label-primary">{{ service.currency == 'BRL' ? 'R$' : service.currency }} {{ service.price }}</span></p>
<p id="s-price" class="lead text-right"></p>
</div>
{% endif %}
</div>
<div class="col-md-1">
</div>
<div class="col-md-6 panel panel-default buycourse-panel-default">
<h3 class="panel-heading">{{ 'TermsAndConditions' | get_plugin_lang('BuyCoursesPlugin') }}</h3>
<legend></legend>
<textarea style="width: 100%; height: 345px;" readonly>
{{ terms ? terms : 'NoTermsAndConditionsProvided' | get_plugin_lang('BuyCoursesPlugin') }}
</textarea>
<br />
<div class="form-group">
<div class="col-sm-1"><input class="" type="checkbox" id="confirmTermsAndConditons" name="confirmTermsAndConditons" > </div>
<label class="col-sm-11">{{ 'IConfirmIReadAndAcceptTermsAndCondition'|get_plugin_lang('BuyCoursesPlugin') }}</label>
</div>
<br/>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h3 class="page-header">{{ 'BankAccountInformation'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>{{ 'Name'|get_lang }}</th>
<th class="text-center">{{ 'BankAccount'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'SWIFT'|get_plugin_lang('BuyCoursesPlugin') }}</th>
</tr>
</thead>
<tbody>
{% for account in transfer_accounts %}
{% if is_bank_transfer %}
<div class="row">
<div class="col-xs-12">
<h3 class="page-header">{{ 'BankAccountInformation'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<td>{{ account.name }}</td>
<td class="text-center">{{ account.account }}</td>
<td class="text-center">{{ account.swift }}</td>
<th>{{ 'Name'|get_lang }}</th>
<th class="text-center">{{ 'BankAccount'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'SWIFT'|get_plugin_lang('BuyCoursesPlugin') }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for account in transfer_accounts %}
<tr>
<td>{{ account.name }}</td>
<td class="text-center">{{ account.account }}</td>
<td class="text-center">{{ account.swift }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<p>{{ 'OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'|get_plugin_lang('BuyCoursesPlugin') }}</p>
</div>
<p>{{ 'OnceItIsConfirmedYouWillReceiveAnEmailWithTheBankInformationAndAnOrderReference'|get_plugin_lang('BuyCoursesPlugin') }}</p>
</div>
</div>
{% endif %}
{{ form }}
<script>
$(document).ready(function () {
$("#confirm").prop( "disabled", true );
$("#confirmTermsAndConditons").click(function () {
if ($("#confirmTermsAndConditons").is(':checked')) {
$("#confirm").prop( "disabled", false );
} else {
$("#confirm").prop( "disabled", true );
}
});
{% if is_culqi_payment %}
var price = {{ price }} * 100;
Culqi.codigoComercio = '{{ culqi_params.commerce_code }}';
Culqi.configurar({
nombre: '{{ _s.institution }}',
orden: '{{ sale.reference }}',
moneda: '{{ currency.iso_code }}',
descripcion: '{{ title }}',
monto: price
});
$("#confirm").click(function (e) {
Culqi.abrir();
e.preventDefault();
$(".culqi_checkout").watch('style', function() {
if (Culqi.error) {
$("#message-alert").html('<div class="col-md-12 alert alert-danger">{{ 'ErrorOccurred'|get_plugin_lang('BuyCoursesPlugin')|format(Culqi.error.codigo, Culqi.error.mensaje) }}</div>')
} else if (Culqi.token) {
$.ajax({
type: 'POST',
url: '{{ _p.web_plugin }}buycourses/src/buycourses.ajax.php?a=culqi_cargo&token_id=' + Culqi.token.id + '&sale_id=' + {{ sale.id }},
beforeSend: function() {
$("#confirm").html('<em class="fa fa-spinner fa-pulse fa-fw" ></em> {{ 'Loading' | get_lang }}');
$("#confirm").prop( "disabled", true );
$("#cancel").prop( "disabled", true );
},
success: function() {
window.location = "{{ _p.web_plugin }}buycourses/index.php";
}
})
}
});
return false;
});
$.fn.watch = function(property, callback) {
return $(this).each(function() {
var old_property_val = this[property];
var timer;
function watch() {
var self = $(".culqi_checkout");
self = self[0];
if ($(self).data(property + '-watch-abort') == true) {
timer = clearInterval(timer);
$(self).data(property + '-watch-abort', null);
return;
}
if (self[property] != old_property_val) {
old_property_val = self[property];
callback.call(self);
}
}
timer = setInterval(watch, 700);
});
};
$.fn.unwatch = function(property) {
return $(this).each(function() {
$(this).data(property + '-watch-abort', true);
});
};
{% endif %}
})
</script>

Loading…
Cancel
Save