Skip to content

Commit

Permalink
Merge pull request #75 from conekta/dev
Browse files Browse the repository at this point in the history
API changes
  • Loading branch information
MauricioMurga authored Feb 15, 2017
2 parents 13e4b9a + 3bec6de commit e6a45b5
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 275 deletions.
6 changes: 5 additions & 1 deletion 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 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
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/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/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/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/FiscalEntity.php

This file was deleted.

37 changes: 13 additions & 24 deletions 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/OrderReturn.php

This file was deleted.

2 changes: 0 additions & 2 deletions 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 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 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 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 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);
}
}
61 changes: 0 additions & 61 deletions test/Conekta-2.0/FiscalEntityTest.php

This file was deleted.

Loading

0 comments on commit e6a45b5

Please sign in to comment.