Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Brayan Cruces committed Jun 19, 2019
2 parents 798fd4b + cb973c8 commit 258341f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
43 changes: 37 additions & 6 deletions culqi.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct()
{
$this->name = 'culqi';
$this->tab = 'payments_gateways';
$this->version = '2.3.0';
$this->version = '2.3.1';
$this->controllers = array('chargeajax', 'payment', 'validation', 'postpayment', 'postpendingpayment', 'orderajax');
$this->author = "Team Culqi (Brayan Cruces)";
$this->need_instance = 0;
Expand All @@ -44,6 +44,17 @@ public function __construct()

public function install()
{
// Run sql for creating DB tables
Db::getInstance()->execute("CREATE TABLE IF NOT EXISTS "._DB_PREFIX_."culqi_order (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
culqi_charge_id varchar(255) NULL,
amount int NULL,
installments int NULL,
email varchar(255) NULL,
prestashop_order_id varchar(255) NULL
) ENGINE=" . _MYSQL_ENGINE_ . " DEFAULT CHARSET=utf8
");

$this->createStates();

return (
Expand Down Expand Up @@ -102,9 +113,13 @@ public function charge($token_id, $installments)

$culqi = new Culqi\Culqi(array('api_key' => Configuration::get('CULQI_LLAVE_COMERCIO')));

$amount = $this->removeComma($cart->getOrderTotal(true, Cart::BOTH));
$email = $this->context->customer->email;
$order_id = (string)$cart->id;

$cargo = $culqi->Charges->create(
array(
"amount" => $this->removeComma($cart->getOrderTotal(true, Cart::BOTH)),
"amount" => $amount,
"antifraud_details" => array(
"address" => $this->getAddress($userAddress),
"address_city" => $userAddress->city,
Expand All @@ -117,11 +132,22 @@ public function charge($token_id, $installments)
"currency_code" => $this->context->currency->iso_code,
"description" => "Orden de compra ".$cart->id,
"installments" => $installments,
"metadata" => array("order_id"=>(string)$cart->id),
"email" => $this->context->customer->email,
"metadata" => array("order_id"=>$order_id),
"email" => $email,
"source_id" => $token_id
)
);

if($cargo->object == "charge") {
Db::getInstance()->insert('culqi_order', array(
'culqi_charge_id' => (string)$cargo->id,
'amount' => $amount,
'installments' => $installments,
'email' => $email,
'prestashop_order_id' => $order_id
));
}

return $cargo;
} catch(Exception $e){
return $e->getMessage();
Expand Down Expand Up @@ -206,8 +232,11 @@ public function hookPayment($params)
$this->smarty->assign(array(
'this_path' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
return $this->display(__FILE__, 'payment.tpl');
));

if(Configuration::get('CULQI_ENABLED_MULTIPAYMENT')) return $this->display(__FILE__, 'payment_multi.tpl');

return $this->display(__FILE__, 'payment.tpl');
}

public function hookPaymentReturn($params)
Expand Down Expand Up @@ -283,6 +312,8 @@ public function uninstallStates()

public function uninstall()
{
Db::getInstance()->execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'culqi_order');

if (!parent::uninstall()
|| !Configuration::deleteByName('CULQI_STATE_OK')
|| !Configuration::deleteByName('CULQI_STATE_ERROR')
Expand Down
2 changes: 1 addition & 1 deletion views/templates/hook/payment.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<style type="text/css">
.culqi-payment {
padding: 30px 0px 50px 200px !important;
background: url('http://i.imgur.com/LjiIq9g.png') 23px 22px no-repeat #fbfbfb;
background: url('https://i.imgur.com/6fbO8KQ.png') 23px 22px no-repeat #fbfbfb;
}
</style>

Expand Down
17 changes: 17 additions & 0 deletions views/templates/hook/payment_multi.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<style type="text/css">
.culqi-payment {
padding: 30px 0px 50px 200px !important;
background: url('https://i.imgur.com/10Nj1l0.png') 23px 22px no-repeat #fbfbfb;
}
</style>

<div class="row">
<div class="col-xs-12">
<p class="payment_module">
<a class="culqi-payment" href="{$link->getModuleLink('culqi', 'payment', [], true)|escape:'htmlall':'UTF-8'}" title="{l s='Pagar con tarjeta de crédito o débito' mod='culqi'}">
Pagar con Tarjeta
<span>Pague con tarjeta de crédito/debito.</span>
</a>
</p>
</div>
</div>

0 comments on commit 258341f

Please sign in to comment.