|
| 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 | +} |
0 commit comments