-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from conekta/feature/upgrade-1.1
Feature/upgrade 2.0
- Loading branch information
Showing
59 changed files
with
4,937 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# OS | ||
.DS_Store | ||
|
||
*~ | ||
# Composer | ||
composer.lock | ||
/vendor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.0.0 | ||
# Conekta PHP v.3.1.0 | ||
|
||
This is a php library that allows interaction with https://api.conekta.io API. | ||
|
||
|
@@ -17,55 +17,45 @@ To get started, add the following to your PHP script: | |
|
||
You can also install this library with composer: | ||
|
||
require: "conekta/conekta-php": "3.0.0" | ||
require: "conekta/conekta-php": "3.1.0" | ||
|
||
## Usage | ||
```php | ||
\Conekta\Conekta::setApiKey('1tv5yJp3xnVZ7eK67m4h'); | ||
try { | ||
$charge = \Conekta\Charge::create(array( | ||
"amount"=> 51000, | ||
"currency"=> "MXN", | ||
"description"=> "Pizza Delivery", | ||
"reference_id"=> "orden_de_id_interno", | ||
"card"=> $_POST['conektaTokenId'] | ||
//"tok_a4Ff0dD2xYZZq82d9" | ||
)); | ||
} catch (Conekta_Error $e) { | ||
echo $e->getMessage(); //Dev Message | ||
echo $e->message_to_purchaser; | ||
//El pago no pudo ser procesado | ||
} | ||
|
||
{ | ||
"id": "5286828b8ee31e64b7001739", | ||
"livemode": false, | ||
"created_at": 1384546955, | ||
"status": "paid", | ||
"currency": "MXN", | ||
"description": "Some desc", | ||
"reference_id": null, | ||
"failure_code": null, | ||
"failure_message": null, | ||
"object": "charge", | ||
"amount": 2000, | ||
"fee": 371, | ||
"payment_method": { | ||
"name": "Mario Moreno", | ||
"exp_month": "05", | ||
"exp_year": "15", | ||
"auth_code": "861491", | ||
"object": "card_payment", | ||
"last4": "4242", | ||
"brand": "visa" | ||
}, | ||
"details": { | ||
"name": null, | ||
"phone": null, | ||
"email": null, | ||
"line_items": [] | ||
} | ||
} | ||
setApiKey(); | ||
$valid_order = | ||
array( | ||
'line_items'=> array( | ||
array( | ||
'name' => 'Box of Cohiba S1s', | ||
'description' => 'Imported From Mex.', | ||
'unit_price' => 20000, | ||
'quantity' => 1, | ||
'sku' => 'cohb_s1', | ||
'category' => 'food', | ||
'type' => 'physical', | ||
'tags' => array('food', 'mexican food') | ||
) | ||
), | ||
'currency' => 'mxn', | ||
'metadata' => array('test' => 'extra info'), | ||
'charges' => array( | ||
array( | ||
'payment_source' => array( | ||
'type' => 'oxxo_cash', | ||
'expires_at' => strtotime(date("Y-m-d H:i:s")) + "36000" | ||
), | ||
'amount' => 20000 | ||
) | ||
), | ||
'currency' => 'mxn', | ||
'customer_info' => array( | ||
'name' => 'John Constantine', | ||
'phone' => '+5213353319758', | ||
'email' => '[email protected]' | ||
) | ||
); | ||
|
||
$order = \Conekta\Order::create($valid_order); | ||
``` | ||
|
||
## Documentation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
<?php | ||
<?php | ||
|
||
namespace Conekta; | ||
|
||
abstract class Conekta | ||
{ | ||
public static $apiKey; | ||
public static $apiBase = 'https://api.conekta.io'; | ||
public static $apiVersion = '1.0.0'; | ||
public static $apiVersion = '2.0.0'; | ||
public static $locale = 'es'; | ||
const VERSION = '3.0.0'; | ||
public static $plugin = ''; | ||
const VERSION = '3.1.0'; | ||
|
||
public static function setApiKey($apiKey) | ||
{ | ||
self::$apiKey = $apiKey; | ||
} | ||
|
||
public static function setApiVersion($version) | ||
{ | ||
self::$apiVersion = $version; | ||
} | ||
|
||
public static function setLocale($locale) | ||
{ | ||
self::$locale = $locale; | ||
} | ||
public static function setPlugin($plugin) | ||
{ | ||
self::$plugin = $plugin; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Conekta; | ||
|
||
use \Conekta\Resource; | ||
use \Conekta\Requestor; | ||
use \Conekta\Util; | ||
use \Conekta\Error; | ||
use \Conekta\Conekta; | ||
|
||
class ConektaList extends Object | ||
{ | ||
|
||
|
||
public function __construct($elements_type, $params = array()) | ||
{ | ||
parent::__construct(); | ||
$this->elements_type = $elements_type; | ||
$this->params = $params; | ||
$this->total = 0; | ||
} | ||
|
||
public function addElement($element) | ||
{ | ||
$element = Util::convertToConektaObject($element); | ||
$this[$this->total] = $element; | ||
$this->_values[$this->total] = $element; | ||
$this->total = $this->total + 1; | ||
|
||
return $this; | ||
} | ||
|
||
public function loadFromArray($values = null) | ||
{ | ||
if (isset($values)) { | ||
$this->has_more = $values['has_more']; | ||
$this->total = $values['total']; | ||
|
||
foreach ($this as $key => $value) { | ||
$this->_unsetKey($key); | ||
} | ||
} | ||
|
||
if (isset($values['data'])) { | ||
return parent::loadFromArray($values['data']); | ||
} | ||
} | ||
|
||
public function next($options = array()) | ||
{ | ||
if (sizeOf($this) > 0) { | ||
$this->params['next'] = end($this)->id; | ||
} | ||
|
||
$this->params['previous'] = null; | ||
|
||
return $this->_moveCursor($options['limit']); | ||
} | ||
|
||
public function previous($options = array()) | ||
{ | ||
if (sizeOf($this) > 0) { | ||
$this->params['previous'] = $this[0]->id; | ||
} | ||
|
||
$this->params['next'] = null; | ||
|
||
return $this->_moveCursor($options['limit']); | ||
} | ||
|
||
protected function _moveCursor($limit) | ||
{ | ||
if (isset($limit)) { | ||
$this->params['limit'] = $limit; | ||
} | ||
|
||
$class = Util::$types[strtolower($this->elements_type)]; | ||
$url = Resource::classUrl($class); | ||
$requestor = new Requestor(); | ||
$response = $requestor->request('get', $url, $this->params); | ||
|
||
return $this->loadFromArray($response); | ||
} | ||
} |
Oops, something went wrong.