Skip to content

Commit e023ff1

Browse files
committed
initial commit
1 parent 59b4f52 commit e023ff1

33 files changed

+1500
-1
lines changed

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

Readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# KKIAPAY
2+
3+
KkiaPay allows businesses to safely receive payments by mobile money, credit card and bank account.
4+
5+
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.
6+
7+
KKIAPAY is available in:
8+
9+
* Benin
10+
* Senegal [WIP]
11+
* [More details at ](https://kkiapay.me/features/supported-countries)
12+
13+
### Prerequisites
14+
15+
Prestashop greater than or equal 1.6
16+
17+
18+
## Usage
19+
20+
* Install and configure API public key on dashboard
21+
* [More details at ](https://docs.kkiapay.me/v1/plugin-et-sdk/prestashop)

controllers/front/api.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* 2007-2016 PrestaShop
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License (AFL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/afl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to http://www.prestashop.com for more information.
20+
*
21+
* @author Hennes Hervé <contact@h-hennes.fr>
22+
* @copyright 2013-2016 Hennes Hervé
23+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+
* http://www.h-hennes.fr/blog/
25+
*/
26+
27+
class kkiapayapiModuleFrontController extends ModuleFrontController {
28+
29+
30+
/**
31+
* Retours de l'api de paiement
32+
*/
33+
public function postProcess()
34+
{
35+
//Vérification générales
36+
$cart = $this->context->cart;
37+
38+
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
39+
Tools::redirect('index.php?controller=order&step=1');
40+
}
41+
42+
$customer = new Customer($cart->id_customer);
43+
if (!Validate::isLoadedObject($customer)) {
44+
Tools::redirect('index.php?controller=order&step=1');
45+
}
46+
47+
$currency = $this->context->currency;
48+
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
49+
50+
51+
//Traitement de la réponse OK
52+
if ( Tools::getValue('success') and Tools::getValue('success')=='kkiapayojhsbbbes12345' ) {
53+
$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
54+
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);
55+
} else {
56+
//Erreur
57+
$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_ERROR'),0, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
58+
Tools::redirect('index.php?controller=order&step=1');
59+
}
60+
}
61+
}

controllers/front/confirmation.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* 2007-2016 PrestaShop
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License (AFL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/afl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to http://www.prestashop.com for more information.
20+
*
21+
* @author Hennes Hervé <contact@h-hennes.fr>
22+
* @copyright 2013-2016 Hennes Hervé
23+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+
* http://www.h-hennes.fr/blog/
25+
*/
26+
27+
class kkiapayconfirmationModuleFrontController extends ModuleFrontController
28+
{
29+
30+
31+
/**
32+
* Retours de l'api de paiement
33+
*/
34+
35+
/**
36+
* @see FrontController::initContent()
37+
*/
38+
public function initContent()
39+
{
40+
41+
parent::initContent();
42+
43+
//Vérification générales
44+
$cart = $this->context->cart;
45+
46+
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
47+
Tools::redirect('index.php?controller=order&step=1');
48+
}
49+
50+
$customer = new Customer($cart->id_customer);
51+
if (!Validate::isLoadedObject($customer)) {
52+
Tools::redirect('index.php?controller=order&step=1');
53+
}
54+
55+
$key = Configuration::get('KKIAPAY_PUBLIC');
56+
$color = Configuration::get('KKIAPAY_COLOR');
57+
$test = Configuration::get('KKIAPAY_CHECKBOX');
58+
$position= Configuration::get('KKIAPAY_POSITION');
59+
$private_key= Configuration::get('KKIAPAY_PRIVATE');
60+
$secret = Configuration::get('KKIAPAY_SECRET');
61+
$price= (float)$cart->getOrderTotal(true, Cart::BOTH);
62+
$firstname_customer=$customer->firstname;
63+
$lastname_customer=$customer->lastname;
64+
$mylink = $this->context->link->getModuleLink('kkiapay','api');
65+
$mylink = $mylink.'?success=kkiapayojhsbbbes12345';
66+
67+
$this->context->smarty->assign(array(
68+
'back_url' => $this->context->link->getPageLink('order', true, NULL, "step=3"),
69+
'confirm_url' => $this->context->link->getModuleLink('kkiapay', 'api', [], true),
70+
'num_cart' => $cart->id,
71+
'moyen_payment' => $this->module->displayName,
72+
'date' => $cart->date_add
73+
74+
));
75+
76+
$this->context->smarty->assign('firstname',$firstname_customer);
77+
$this->context->smarty->assign('lastname',$lastname_customer);
78+
$this->context->smarty->assign('api',$key);
79+
$this->context->smarty->assign('price',$price);
80+
$this->context->smarty->assign('color',$color);
81+
$this->context->smarty->assign('position',$position);
82+
$this->context->smarty->assign('url',$mylink);
83+
$this->context->smarty->assign('secret',$secret);
84+
$this->context->smarty->assign('test',$test);
85+
$this->context->smarty->assign('private',$private_key);
86+
87+
//var_dump($cart);
88+
89+
$this->setTemplate('module:kkiapay/views/templates/admin/hook/front/api/payment_execution.tpl');
90+
}
91+
}

controllers/front/index.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* 2007-2019 PrestaShop
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License (AFL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/afl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to http://www.prestashop.com for more information.
20+
*
21+
* @author PrestaShop SA <contact@prestashop.com>
22+
* @copyright 2007-2019 PrestaShop SA
23+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+
* International Registered Trademark & Property of PrestaShop SA
25+
*/
26+
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
27+
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
28+
29+
header('Cache-Control: no-store, no-cache, must-revalidate');
30+
header('Cache-Control: post-check=0, pre-check=0', false);
31+
header('Pragma: no-cache');
32+
33+
header('Location: ../');
34+
exit;

controllers/index.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* 2007-2019 PrestaShop
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License (AFL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/afl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to http://www.prestashop.com for more information.
20+
*
21+
* @author PrestaShop SA <contact@prestashop.com>
22+
* @copyright 2007-2019 PrestaShop SA
23+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+
* International Registered Trademark & Property of PrestaShop SA
25+
*/
26+
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
27+
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
28+
29+
header('Cache-Control: no-store, no-cache, must-revalidate');
30+
header('Cache-Control: post-check=0, pre-check=0', false);
31+
header('Pragma: no-cache');
32+
33+
header('Location: ../');
34+
exit;

index.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* 2007-2019 PrestaShop
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License (AFL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/afl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to http://www.prestashop.com for more information.
20+
*
21+
* @author PrestaShop SA <contact@prestashop.com>
22+
* @copyright 2007-2019 PrestaShop SA
23+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+
* International Registered Trademark & Property of PrestaShop SA
25+
*/
26+
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
27+
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
28+
29+
header('Cache-Control: no-store, no-cache, must-revalidate');
30+
header('Cache-Control: post-check=0, pre-check=0', false);
31+
header('Pragma: no-cache');
32+
33+
header('Location: ../');
34+
exit;

0 commit comments

Comments
 (0)