Skip to content

Commit

Permalink
Merge pull request conekta#41 from conekta/fix/removing-codebar
Browse files Browse the repository at this point in the history
Fix/removing codebar
  • Loading branch information
MauricioMurga authored Feb 16, 2017
2 parents da5afb7 + 567faf5 commit b766d9f
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 305 deletions.
23 changes: 5 additions & 18 deletions conektaprestashop.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,6 @@ public function processPayment($token, $type, $monthly_installments)
);
}

$fiscal_entity = array(
"name" => $address_fiscal->firstname . " " . $address_fiscal->lastname,
"address" => array(
"street1" => $address_fiscal->address1,
"city" => $address_fiscal->city,
"country" => Country::getIsoById($address_fiscal->id_country),
"postal_code" => $address_fiscal->postcode,
"state" => State::getNameById($address_fiscal->id_state)
),
"metadata" => array("soft_validations" => true)
);

$shipping_contact = array(
"receiver" => $customer->firstname . " " . $customer->lastname,
"phone" => $address_delivery->phone,
Expand All @@ -590,7 +578,6 @@ public function processPayment($token, $type, $monthly_installments)
"currency" => $this->context->currency->iso_code,
"line_items" => $line_items,
"shipping_contact" => $shipping_contact,
"fiscal_entity" => $fiscal_entity,
"customer_info" => $customer_info,
"metadata" => array("soft_validations" => true)
);
Expand Down Expand Up @@ -640,7 +627,7 @@ public function processPayment($token, $type, $monthly_installments)
if ($type == "cash") {
$charge_params =
array(
'payment_source' => array('type' => 'oxxo_cash'),
'payment_method' => array('type' => 'oxxo_cash'),
'amount' => $amount
);
$charge_response = $order->createCharge($charge_params);
Expand All @@ -658,7 +645,7 @@ public function processPayment($token, $type, $monthly_installments)
} elseif ($type == "spei") {
$charge_params =
array(
'payment_source' => array( 'type' => 'spei'),
'payment_method' => array( 'type' => 'spei'),
'amount' => $amount
);
$charge_response = $order->createCharge($charge_params);
Expand All @@ -672,7 +659,7 @@ public function processPayment($token, $type, $monthly_installments)
} elseif ($type == "banorte") {
$charge_params =
array(
'payment_source' => array('type' => 'banorte'),
'payment_method' => array('type' => 'banorte'),
'amount' => $amount
);
$charge_response = $order->createCharge($charge_params);
Expand All @@ -690,7 +677,7 @@ public function processPayment($token, $type, $monthly_installments)
} else {
$charge_params =
array(
'payment_source' => array(
'payment_method' => array(
'type' => 'card',
'token_id' => $token
),
Expand Down Expand Up @@ -718,7 +705,7 @@ public function processPayment($token, $type, $monthly_installments)
}

if (isset($charge_response->id) && $type == "cash") {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_conekta_order, id_transaction, amount, status, currency, mode, date_add, reference, barcode, captured) VALUES (\'payment\', ' . pSQL((int) $this->context->cart->id) . ', ' . pSQL((int) $this->currentOrder) . ', \'' . pSQL($order->id) . '\', \'' . pSQL($charge_response->id) . '\',\'' . ($order->amount * 0.01) . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' . $reference . '\',\'' . $barcode_url . '\',\'' . ($charge_response->livemode == 'true' ? '1' : '0') . '\' )');
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_conekta_order, id_transaction, amount, status, currency, mode, date_add, reference, barcode, captured) VALUES (\'payment\', ' . pSQL((int) $this->context->cart->id) . ', ' . pSQL((int) $this->currentOrder) . ', \'' . pSQL($order->id) . '\', \'' . pSQL($charge_response->id) . '\',\'' . ($order->amount * 0.01) . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' . $reference . '\',\'' . $reference . '\',\'' . ($charge_response->livemode == 'true' ? '1' : '0') . '\' )');
} elseif (isset($charge_response->id) && $type == "spei") {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_conekta_order, id_transaction, amount, status, currency, mode, date_add, reference, captured) VALUES (\'payment\', ' . (int) $this->context->cart->id . ', ' . (int) $this->currentOrder . ', \'' . pSQL($order->id) . '\', \'' . pSQL($charge_response->id) . '\', \'' . ($charge_response->amount * 0.01) . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' . $reference . '\', \'' . ($charge_response->livemode == 'true' ? '1' : '0') . '\' )');
} elseif (isset($charge_response->id) && $type == "banorte") {
Expand Down
6 changes: 5 additions & 1 deletion lib/conekta-php/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@

* Order's submodels added. New Order flow
* Supporting now API 2.0
* Check https://www.conekta.io/es/docs/api v1.1 for further information
* Check https://www.conekta.io/es/docs/api v1.1 for further information

=== 3.2.0 2017-02-15

* Stable version of API 2.0.0.
4 changes: 2 additions & 2 deletions lib/conekta-php/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

![alt tag](https://raw.github.com/conekta/conekta-php/master/readme_files/cover.png)

# Conekta PHP v.3.1.0
# Conekta PHP v.3.2.0

This is a php library that allows interaction with https://api.conekta.io API.

Expand Down Expand Up @@ -70,7 +70,7 @@ In order to run tests you have to install SimpleTest (https://github.com/simplet

Run test suite:

php ./test/Conekta.php
php ./test/Conekta-2.0.php

License
-------
Expand Down
2 changes: 0 additions & 2 deletions lib/conekta-php/lib/Conekta.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@
require_once dirname(__FILE__).'/Conekta/ErrorList.php';
require_once dirname(__FILE__).'/Conekta/ConektaList.php';
require_once dirname(__FILE__).'/Conekta/ShippingContact.php';
require_once dirname(__FILE__).'/Conekta/FiscalEntity.php';
require_once dirname(__FILE__).'/Conekta/OrderReturn.php';
4 changes: 2 additions & 2 deletions lib/conekta-php/lib/Conekta/Charge.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

namespace Conekta;

Expand All @@ -25,7 +25,7 @@ class Charge extends Resource
var $checkout_order_count = "";

public function __get($property)
{
{
if (property_exists($this, $property)) {
return $this->$property;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/conekta-php/lib/Conekta/Conekta.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class Conekta
public static $apiVersion = '2.0.0';
public static $locale = 'es';
public static $plugin = '';
const VERSION = '3.1.0';
const VERSION = '3.2.0';

public static function setApiKey($apiKey)
{
Expand Down
8 changes: 1 addition & 7 deletions lib/conekta-php/lib/Conekta/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Customer extends Resource
var $email = "";
var $phone = "";
var $default_shipping_contact_id = "";
var $default_fiscal_entity_id = "";
var $default_payment_source_id = "";
var $referrer = "";
var $account_age = "";
Expand Down Expand Up @@ -39,7 +38,7 @@ public function loadFromArray($values = null)

if(Conekta::$apiVersion == '2.0.0'){
$submodels = array(
'payment_sources', 'fiscal_entities', 'shipping_contacts'
'payment_sources', 'shipping_contacts'
);
foreach ($submodels as $submodel) {
if (isset($values[$submodel])){
Expand Down Expand Up @@ -116,11 +115,6 @@ public function createPaymentSource($params = null)
return parent::_createMemberWithRelation('payment_sources', $params, $this);
}

public function createFiscalEntity($params = null)
{
return parent::_createMemberWithRelation('fiscal_entities', $params, $this);
}

public function createCard($params = null)
{
return parent::_createMemberWithRelation('cards', $params, $this);
Expand Down
57 changes: 0 additions & 57 deletions lib/conekta-php/lib/Conekta/FiscalEntity.php

This file was deleted.

37 changes: 13 additions & 24 deletions lib/conekta-php/lib/Conekta/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

class Order extends Resource
{
var $livemode = "";
var $amount = "";
var $status = "";
var $customer_id = "";
var $currency = "";
var $capture = "";
var $metadata = "";
var $created_at = "";
var $updated_at = "";
var $livemode = "";
var $amount = "";
var $payment_status = "";
var $customer_id = "";
var $currency = "";
var $capture = "";
var $metadata = "";
var $created_at = "";
var $updated_at = "";

public function __get($property)
{
{
if (property_exists($this, $property)) {
return $this->$property;
}
Expand Down Expand Up @@ -52,10 +52,6 @@ public function loadFromArray($values = null)
$this->$submodel = new ConektaList($submodel, array());
}
}

if (isset($this->fiscal_entity)) {
$this->fiscal_entity->order = $this;
}
}

public static function where($params = null)
Expand Down Expand Up @@ -109,20 +105,13 @@ public function createLineItem($params = null)
return parent::_createMemberWithRelation('line_items', $params, $this);
}

public function createFiscalEntity($params = null)
{
$order = parent::_update(array('fiscal_entity' => $params));

return $order->fiscal_entity;
}

public function createCharge($params = null)
{
return parent::_createMember('charges', $params);
}

public function createReturn($params = null)
public function refund($params = null)
{
return parent::_createMember('returns', $params);
return parent::_customAction('post', 'refund', $params);
}
}
46 changes: 0 additions & 46 deletions lib/conekta-php/lib/Conekta/OrderReturn.php

This file was deleted.

2 changes: 0 additions & 2 deletions lib/conekta-php/lib/Conekta/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ abstract class Util
'lang' => '\Conekta\Lang',
'line_item' => '\Conekta\LineItem',
'order' => '\Conekta\Order',
'fiscal_entity' => '\Conekta\FiscalEntity',
'return' => '\Conekta\OrderReturn',
'token' => '\Conekta\Token'
);

Expand Down
2 changes: 1 addition & 1 deletion lib/conekta-php/test/Conekta-1.0/ChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testSuccesfulCapture()
setApiVersion('1.0.0');
$pm = self::$valid_payment_method;
$card = self::$valid_visa_card;
$capture = array('preauthorize' => true);
$capture = array('capture' => false);
setApiKey();
$cpm = \Conekta\Charge::create(array_merge($pm, $card, $capture));
$this->assertTrue($cpm->status == 'pre_authorized');
Expand Down
2 changes: 1 addition & 1 deletion lib/conekta-php/test/Conekta-1.0/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function testUnsuccesfulSubscriptionCreate()
$subscription = $customer->createSubscription(array(
'plan' => 'unexistent-plan', ));
} catch (Exception $e) {
$this->assertTrue(strpos($e->getMessage(), 'The object Plan unexistent-plan could not be found.') !== false);
$this->assertTrue(strpos($e->getMessage(), 'The object Plan "unexistent-plan" could not be found.') !== false);
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/conekta-php/test/Conekta-2.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ function exception_error_handler($errno, $errstr, $errfile, $errline)
require_once dirname(__FILE__).'/Conekta-2.0/ShippingLineTest.php';
require_once dirname(__FILE__).'/Conekta-2.0/LineItemTest.php';
require_once dirname(__FILE__).'/Conekta-2.0/DiscountLineTest.php';
require_once dirname(__FILE__).'/Conekta-2.0/FiscalEntityTest.php';
require_once dirname(__FILE__).'/Conekta-2.0/ErrorListTest.php';
require_once dirname(__FILE__).'/Conekta-2.0/ConektaTest.php';
25 changes: 0 additions & 25 deletions lib/conekta-php/test/Conekta-2.0/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,4 @@ public function testSuccesfulShippingContactCreate()
$this->assertTrue(strpos(get_class($customer->shipping_contacts), 'ConektaList') !== false);
$this->assertTrue($customer->shipping_contacts->total == 1);
}

public function testSuccesfulFiscalEntityCreate()
{
setApiKey();
$customer = \Conekta\Customer::create(self::$valid_customer);
$fiscal_entity = $customer->createFiscalEntity(array(
'tax_id' => 'AMGH851205MN1',
'company_name' => 'Test SA de CV',
'email' => 'test@conekta.io',
'phone' => '+5213353319758',
'address' => array(
'street1' => '250 Alexis St',
'internal_number' => '19',
'external_number' => '10',
'city' => 'Red Deer',
'state' => 'Alberta',
'country' => 'MX',
'postal_code' => '78216'
)
));

$this->assertTrue(strpos(get_class($fiscal_entity), 'FiscalEntity') !== false);
$this->assertTrue(strpos(get_class($customer->fiscal_entities), 'ConektaList') !== false);
$this->assertTrue($customer->fiscal_entities->total == 1);
}
}
Loading

0 comments on commit b766d9f

Please sign in to comment.