Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integración con PagoEfectivo #11

Open
wants to merge 36 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dec4f3e
Merge pull request #1 from culqi/development
LizRuelasB Aug 31, 2017
14794cd
Update README.md
LizRuelasB Aug 31, 2017
77deca3
Update culqi.php
LizRuelasB Aug 31, 2017
b71aae2
update linea 55
LizRuelasB Aug 31, 2017
004ed3f
Responsive
LizRuelasB Aug 31, 2017
fc951e8
Update culqi.php
LizRuelasB Aug 31, 2017
9ed772a
Integración de Modulo
LizRuelasB Sep 6, 2017
9b8646d
update_lizruelas
LizRuelasB Sep 20, 2017
4e5dad1
update_tildes_final
LizRuelasB Sep 21, 2017
bb51dac
Merge pull request #2 from LizRuelas/master
Sep 21, 2017
2e29111
avoid multiple charge
Jun 17, 2020
94c93de
Correcion de codigo
victorcastro Jul 20, 2020
f778a05
Adicicon de order CUlqi
victorcastro Jul 20, 2020
3941f3b
Correcion de reload
victorcastro Jul 20, 2020
1881aba
Correcion de codigo
victorcastro Jul 20, 2020
8b55c2b
Correciones generales de Prestashop 1.7
victorcastro Jul 20, 2020
f88bc3a
Limpieza de coigo
victorcastro Jul 23, 2020
1646bf6
Correcion de susccess payment
victorcastro Jul 23, 2020
4da6073
Optimizacion de codigo y limpieza
Jul 28, 2020
9f59630
Correcion de feature
Jul 28, 2020
4913390
Correcion de codigo y validaciones
Jul 28, 2020
986972f
Validacion de pago
Aug 2, 2020
8828011
Validando respose de cylwi
Aug 2, 2020
3180bec
Comments after meet
Aug 6, 2020
2da2c5a
Correcion en genracion de pedido
victorcastro Aug 9, 2020
688f16b
Correcion de gitignore
victorcastro Aug 9, 2020
ae14c21
Implementacion de PaymentReturn
victorcastro Aug 10, 2020
03bb37f
Actualizacion de pago desde Webhook
victorcastro Aug 10, 2020
2e4b3c4
fixed postpayment
Nicerova7 Aug 20, 2020
3d8d878
Merge pull request #12 from Nicerova7/master
william-muro-culqi Sep 1, 2020
e3e06a6
Merge branch 'master' into feature-pagoefectivo
Sep 9, 2020
09b45b3
Merge pull request #8 from Nicerova7/feature/oneclick
william-muro-culqi Sep 14, 2020
67bd2bb
Adding config_es.xml on gitignore
Oct 4, 2020
4528f8e
Merge branch 'master' into feature-pagoefectivo
Oct 4, 2020
b9fef68
Correcion de sintxys
Oct 4, 2020
2784a1b
Correcion de descripcion y order_id
Oct 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.DS_Store
logs/*
config_*.xml
71 changes: 66 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,69 @@
# Culqi Prestashop 1.7 (v3.0.4)
# Culqi JS v2 - Prestashop 1.7

![configuracion inicial](/docs/config.png)
* Es necesario indicar el campo telefono como requerido ya que por defecto no esta configurado.*
### Pasos para la integración del Módulo de Culqi

> Integración del formulario de Culqi
#### 1. Registrarse en Culqi `<link>` : <https://www.culqi.com/>

![form](/docs/form.png)
Así podrás tener acceso al ambiente de pruebas de Culqi `<link>` : <https://integ-panel.culqi.com/>
donde encontrarás tus llaves `<link>` : <https://integ-panel.culqi.com/#/desarrollo/llaves/>

`Llave publica: pk_test_xxxxxxxxxxxxxx`

`Llave privada: sk_test_xxxxxxxxxxxxxx`

#### 2. Descargar el Módulo de Culqi 3.0.4

`<link>` : <https://github.com/culqi/culqi-prestashop-1.7/releases/tag/v3.0.4/>

![Imgur](https://i.imgur.com/sWLEajr.png)

#### 3. Subir el Módulo de Culqi en tu administrador de Prestashop 1.7

##### 3.1
![Imgur](https://i.imgur.com/zcE8bUp.png)

##### 3.2
![Imgur](https://i.imgur.com/S0nIcXt.png)

#### 4. Configurar el Módulo de Culqi en tu administrador de Prestashop 1.7

##### 4.1
![Imgur](https://i.imgur.com/vdwhGv3.png)

##### 4.2
![Imgur](https://i.imgur.com/dTwx3Pw.png)
> Aquí van tus llaves que mencionamos en el paso 1 ( Registrarse en Culqi ).

### Finalmente debes tener a Culqi como pasarela de pago de esta manera:

![Imgur](https://i.imgur.com/Zu66mdM.png)

> Debes usar las tarjetas de prueba que Culqi te ofrece para hacer las pruebas necesarias

`<link>` : <https://culqi.com/docs/#/desarrollo/tarjetas/>

### Pase a producción:

#### 1. Cumplir con los requisitos técnicos

`<link>` : < https://culqi.com/docs/#/desarrollo/produccion/>

#### 2. Activar comercio desde tu panel de integración de Culqi

![Imgur](https://i.imgur.com/wVOz6cc.png)

> Si tienes más dudas con respecto al proceso de "Activación de comercio" escríbenos a [email protected]

Cuando te envien los accesos a tu panel de producción de Culqi debes reemplazar
tus llaves de pruebas por tus llaves de producción como en el paso 4.2

`Llave publica: pk_live_xxxxxxxxxxxxxx`

`Llave privada: sk_live_xxxxxxxxxxxxxx`

> En el ambiente de producción podrás comenzar a usar tarjetas reales.


### Si tienes dudas de Integración escríbenos a [email protected]

### Si tienes dudas comerciales escríbenos a [email protected]
13 changes: 13 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>culqi</name>
<displayName><![CDATA[Culqi]]></displayName>
<version><![CDATA[3.0.4]]></version>
<description><![CDATA[Acepta tarjetas de cr&eacute;dito y d&eacute;bito en tu tienda online.]]></description>
<author><![CDATA[Team Culqi (Willy Aguirre, Brayan Cruces, Liz Ruelas)]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[¿Estás seguro que quieres desintalar el módulo de Culqi?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
1 change: 1 addition & 0 deletions controllers/front/chargeajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function initContent()
public function displayAjax()
{
$result = $this->module->charge(Tools::getValue("token_id"), Tools::getValue("installments"));
if($result->id) Configuration::updateValue($result->id,'generatedCharge');
die(Tools::jsonEncode($result));
}

Expand Down
36 changes: 35 additions & 1 deletion controllers/front/index.php
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
<?php // Silence is golden
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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;
9 changes: 7 additions & 2 deletions controllers/front/postpayment.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

class CulqiPostpaymentModuleFrontController extends ModuleFrontController
{
{

public function initContent()
{
Expand All @@ -10,9 +10,14 @@ public function initContent()

$cart = $this->context->cart;
$customer = new Customer($cart->id_customer);

if(!Configuration::get(Tools::getValue('validation'))) die($this->l('Primero, debes pagar la order...'));
if(Configuration::get(Tools::getValue('validation')) !== 'generatedCharge') die($this->l('Primero, debes pagar la orden... '));
Configuration::deleteByName(Tools::getValue('validation'));
$this->module->validateOrder((int)$cart->id, Configuration::get('CULQI_STATE_OK'), (float)$cart->getordertotal(true), 'Culqi', null, array(), (int)$cart->id_currency, 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);

}

}

}
36 changes: 36 additions & 0 deletions controllers/front/validation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class CulqiValidationModuleFrontController extends ModuleFrontController
{

public function initContent()
{
parent::initContent();

$type = Tools::getValue('clqtype');
$code = Tools::getValue('clqcode');
$cart = $this->context->cart;
$customer = new Customer($cart->id_customer);

switch ($type) {
case 'charge':
$ps_os_payment = $code == "AUT0000" ? Configuration::get('CULQI_STATE_OK') : Configuration::get('CULQI_STATE_ERROR');
$cip = '';
break;

case 'order':
$ps_os_payment = $code != "" ? Configuration::get('CULQI_STATE_PENDING') : Configuration::get('CULQI_STATE_ERROR');
$cip = $code;
break;

default:
$ps_os_payment = Configuration::get('CULQI_STATE_ERROR');
$cip = '';
}

$this->module->validateOrder((int)$cart->id, $ps_os_payment, (float)$cart->getordertotal(true), 'Culqi', null, array(), (int)$cart->id_currency, 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.'&cip='.$cip);
}

}
65 changes: 65 additions & 0 deletions controllers/front/webhookOrderStatusChanged.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

class CulqiWebhookOrderStatusChangedModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$this->ajax = true;

$input = file_get_contents("php://input");

if (Configuration::get('CULQI_WEBHOOK_CATCH_LOG')) {
$date = new DateTime();
$fp1 = fopen(dirname(__FILE__). '/../../logs/webhook.txt', 'w');
$fp2 = fopen(dirname(__FILE__). '/../../logs/'. $date->format('Ymd_His') . '_webhook.txt', 'w');
fwrite($fp1, $input);
fwrite($fp2, $input);
fclose($fp1);
fclose($fp2);
}

if ($input === '') {
$this->response(403, 'This url is only use to Webhooks from Culqi.');
} else {
$event_json = json_decode($input, true);

if (isset($event_json['data'])) {
$data = json_decode($event_json['data'], true);
$idCart = substr($data['description'], 16);

$cart = new Cart($idCart);

switch ($data['state']) {
case 'paid':
$ps_os_payment = Configuration::get('CULQI_STATE_OK');
break;

case 'expired':
$ps_os_payment = Configuration::get('CULQI_STATE_EXPIRED');
break;

default:
$ps_os_payment = Configuration::get('CULQI_STATE_ERROR');
}

$orderObject = new Order();
$order = new Order($orderObject->getOrderByCartId((int)$cart->id));

$history = new OrderHistory();
$history->id_order = (int)$order->id;
$history->changeIdOrderState((int)$ps_os_payment, (int)($order->id));

$this->response(200, 'Order updated successfully.');
} else {
$this->response(422, 'No contiene la estructura correcta.');
}
}
}

private function response($code, $message) {
http_response_code($code);
header('Content-Type: application/json');
echo json_encode(['message' => $this->trans($message, [], 'Modules.Culqi.Shop')]);
die;
}
}
36 changes: 35 additions & 1 deletion controllers/index.php
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
<?php // Silence is golden
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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:
* https://opensource.org/licenses/OSL-3.0
* 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 https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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