Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
barbeblance committed Jun 20, 2019
1 parent 59b4f52 commit e023ff1
Show file tree
Hide file tree
Showing 33 changed files with 1,500 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

21 changes: 21 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# KKIAPAY

KkiaPay allows businesses to safely receive payments by mobile money, credit card and bank account.

Kkiapay is developer friendly solution that allows you to accept mobile money and credit card, and direct bank payments in your application or website. Before using this plugin, make sure you have a right Merchant Account on Kkiapay, otherwise go and create your account. It is free and without pain.

KKIAPAY is available in:

* Benin
* Senegal [WIP]
* [More details at ](https://kkiapay.me/features/supported-countries)

### Prerequisites

Prestashop greater than or equal 1.6


## Usage

* Install and configure API public key on dashboard
* [More details at ](https://docs.kkiapay.me/v1/plugin-et-sdk/prestashop)
61 changes: 61 additions & 0 deletions controllers/front/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Hennes Hervé <[email protected]>
* @copyright 2013-2016 Hennes Hervé
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* http://www.h-hennes.fr/blog/
*/

class kkiapayapiModuleFrontController extends ModuleFrontController {


/**
* Retours de l'api de paiement
*/
public function postProcess()
{
//Vérification générales
$cart = $this->context->cart;

if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}

$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}

$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);


//Traitement de la réponse OK
if ( Tools::getValue('success') and Tools::getValue('success')=='kkiapayojhsbbbes12345' ) {
$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
} else {
//Erreur
$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_ERROR'),0, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order&step=1');
}
}
}
91 changes: 91 additions & 0 deletions controllers/front/confirmation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Hennes Hervé <[email protected]>
* @copyright 2013-2016 Hennes Hervé
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* http://www.h-hennes.fr/blog/
*/

class kkiapayconfirmationModuleFrontController extends ModuleFrontController
{


/**
* Retours de l'api de paiement
*/

/**
* @see FrontController::initContent()
*/
public function initContent()
{

parent::initContent();

//Vérification générales
$cart = $this->context->cart;

if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}

$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}

$key = Configuration::get('KKIAPAY_PUBLIC');
$color = Configuration::get('KKIAPAY_COLOR');
$test = Configuration::get('KKIAPAY_CHECKBOX');
$position= Configuration::get('KKIAPAY_POSITION');
$private_key= Configuration::get('KKIAPAY_PRIVATE');
$secret = Configuration::get('KKIAPAY_SECRET');
$price= (float)$cart->getOrderTotal(true, Cart::BOTH);
$firstname_customer=$customer->firstname;
$lastname_customer=$customer->lastname;
$mylink = $this->context->link->getModuleLink('kkiapay','api');
$mylink = $mylink.'?success=kkiapayojhsbbbes12345';

$this->context->smarty->assign(array(
'back_url' => $this->context->link->getPageLink('order', true, NULL, "step=3"),
'confirm_url' => $this->context->link->getModuleLink('kkiapay', 'api', [], true),
'num_cart' => $cart->id,
'moyen_payment' => $this->module->displayName,
'date' => $cart->date_add

));

$this->context->smarty->assign('firstname',$firstname_customer);
$this->context->smarty->assign('lastname',$lastname_customer);
$this->context->smarty->assign('api',$key);
$this->context->smarty->assign('price',$price);
$this->context->smarty->assign('color',$color);
$this->context->smarty->assign('position',$position);
$this->context->smarty->assign('url',$mylink);
$this->context->smarty->assign('secret',$secret);
$this->context->smarty->assign('test',$test);
$this->context->smarty->assign('private',$private_key);

//var_dump($cart);

$this->setTemplate('module:kkiapay/views/templates/admin/hook/front/api/payment_execution.tpl');
}
}
34 changes: 34 additions & 0 deletions controllers/front/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
34 changes: 34 additions & 0 deletions controllers/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
34 changes: 34 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
Loading

0 comments on commit e023ff1

Please sign in to comment.