Skip to content

Commit 1b52bb2

Browse files
authored
Merge pull request open-pay#58 from open-pay/V3.0.0
V3.0.0
2 parents 73a9374 + c4744c7 commit 1b52bb2

50 files changed

Lines changed: 2170 additions & 923 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
nbproject/
1+
nbproject/
2+
.idea
3+
*.iml
4+
vendor

Openpay.php

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<?php
1+
<?php
22
/**
3-
* Openpay API v1 Client for PHP (version 1.0.0)
4-
*
3+
* Openpay API v1 Client for PHP (version 2.1.0)
4+
*
55
* Copyright © Openpay SAPI de C.V. All rights reserved.
66
* http://www.openpay.mx/
77
* soporte@openpay.mx
@@ -17,26 +17,42 @@
1717
throw new Exception('Multibyte String PHP extension is required to run Openpay client.');
1818
}
1919

20-
require(dirname(__FILE__) . '/data/OpenpayApiError.php');
21-
require(dirname(__FILE__) . '/data/OpenpayApiConsole.php');
22-
require(dirname(__FILE__) . '/data/OpenpayApiResourceBase.php');
23-
require(dirname(__FILE__) . '/data/OpenpayApiConnector.php');
24-
require(dirname(__FILE__) . '/data/OpenpayApiDerivedResource.php');
25-
require(dirname(__FILE__) . '/data/OpenpayApi.php');
20+
require(dirname(__FILE__) . '/Openpay/Data/Openpay.php');
21+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApi.php');
22+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiAuthError.php');
23+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiConnectionError.php');
24+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiConnector.php');
25+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiConsole.php');
26+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiDerivedResource.php');
27+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiError.php');
28+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiRequestError.php');
29+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiResourceBase.php');
30+
require(dirname(__FILE__) . '/Openpay/Data/OpenpayApiTransactionError.php');
2631

27-
require(dirname(__FILE__) . '/resources/OpenpayBankAccount.php');
28-
require(dirname(__FILE__) . '/resources/OpenpayBine.php');
29-
require(dirname(__FILE__) . '/resources/OpenpayCapture.php');
30-
require(dirname(__FILE__) . '/resources/OpenpayCard.php');
31-
require(dirname(__FILE__) . '/resources/OpenpayCharge.php');
32-
require(dirname(__FILE__) . '/resources/OpenpayCustomer.php');
33-
require(dirname(__FILE__) . '/resources/OpenpayFee.php');
34-
require(dirname(__FILE__) . '/resources/OpenpayPayout.php');
35-
require(dirname(__FILE__) . '/resources/OpenpayPlan.php');
36-
require(dirname(__FILE__) . '/resources/OpenpayRefund.php');
37-
require(dirname(__FILE__) . '/resources/OpenpaySubscription.php');
38-
require(dirname(__FILE__) . '/resources/OpenpayTransfer.php');
39-
require(dirname(__FILE__) . '/resources/OpenpayWebhook.php');
40-
require(dirname(__FILE__) . '/resources/OpenpayToken.php');
41-
require(dirname(__FILE__) . '/resources/OpenpayPse.php');
32+
33+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayBankAccount.php');
34+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayBankAccountList.php');
35+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayBine.php');
36+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCapture.php');
37+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCard.php');
38+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCardList.php');
39+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCharge.php');
40+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayChargeList.php');
41+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCustomer.php');
42+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayCustomerList.php');
43+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayFee.php');
44+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayFeeList.php');
45+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPayout.php');
46+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPayoutList.php');
47+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPlan.php');
48+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPlanList.php');
49+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPse.php');
50+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayPseList.php');
51+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayRefund.php');
52+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpaySubscription.php');
53+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpaySubscriptionList.php');
54+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayToken.php');
55+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayTransfer.php');
56+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayTransferList.php');
57+
require(dirname(__FILE__) . '/Openpay/Resources/OpenpayWebhook.php');
4258
?>
Lines changed: 49 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<?php
22

3-
/**
4-
* Openpay API v1 Client for PHP (version 2.0.0)
5-
*
6-
* Copyright © Openpay SAPI de C.V. All rights reserved.
7-
* http://www.openpay.mx/
8-
* soporte@openpay.mx
9-
*/
3+
namespace Openpay\Data;
4+
105
class Openpay
116
{
127

@@ -20,11 +15,13 @@ class Openpay
2015
private static $sandboxMode = true;
2116
private static $classification = '';
2217

23-
public function __construct() {
24-
18+
public function __construct()
19+
{
20+
2521
}
2622

27-
public static function getInstance($id = '', $apiKey = '', $country = 'MX') {
23+
public static function getInstance($id = '', $apiKey = '', $country = 'MX')
24+
{
2825
if ($id != '') {
2926
self::setId($id);
3027
}
@@ -39,144 +36,127 @@ public static function getInstance($id = '', $apiKey = '', $country = 'MX') {
3936
return $instance;
4037
}
4138

42-
public static function setUserAgent($userAgent){
39+
public static function setUserAgent($userAgent)
40+
{
4341
if ($userAgent != '') {
4442
self::$userAgent = $userAgent;
4543
}
4644
}
4745

48-
public static function getUserAgent(){
49-
$userAgent = self::$userAgent;
46+
public static function getUserAgent()
47+
{
48+
$userAgent = self::$userAgent;
5049
return $userAgent;
5150
}
5251

53-
public static function setClassificationMerchant($classification){
52+
public static function setClassificationMerchant($classification)
53+
{
5454
if ($classification != '') {
5555
self::$classification = $classification;
5656
}
5757
}
5858

59-
public static function getClassificationMerchant(){
60-
$classification = self::$classification;
59+
public static function getClassificationMerchant()
60+
{
61+
$classification = self::$classification;
6162
return $classification;
6263
}
6364

64-
public static function setApiKey($key = '') {
65+
public static function setApiKey($key = '')
66+
{
6567
if ($key != '') {
6668
self::$apiKey = $key;
6769
}
6870
}
6971

70-
public static function getApiKey() {
72+
public static function getApiKey()
73+
{
7174
$key = self::$apiKey;
7275
if (!$key) {
7376
$key = getenv('OPENPAY_API_KEY');
7477
}
7578
return $key;
7679
}
7780

78-
public static function setId($id = '') {
81+
public static function setId($id = '')
82+
{
7983
if ($id != '') {
8084
self::$id = $id;
8185
}
8286
}
8387

84-
public static function setCountry($country = ''){
88+
public static function setCountry($country = '')
89+
{
8590
if ($country != '') {
8691
self::$country = $country;
8792
}
8893
}
8994

90-
public static function getCountry(){
95+
public static function getCountry()
96+
{
9197
$country = self::$country;
9298
return $country;
9399
}
94100

95-
public static function getId() {
101+
public static function getId()
102+
{
96103
$id = self::$id;
97104
if (!$id) {
98105
$id = getenv('OPENPAY_MERCHANT_ID');
99106
}
100107
return $id;
101108
}
102109

103-
public static function getSandboxMode() {
110+
public static function getSandboxMode()
111+
{
104112
$sandbox = self::$sandboxMode;
105113
if (getenv('OPENPAY_PRODUCTION_MODE')) {
106114
$sandbox = (strtoupper(getenv('OPENPAY_PRODUCTION_MODE')) == 'FALSE');
107115
}
108116
return $sandbox;
109117
}
110118

111-
public static function setSandboxMode($mode) {
119+
public static function setSandboxMode($mode)
120+
{
112121
self::$sandboxMode = $mode ? true : false;
113122
}
114123

115-
public static function getProductionMode() {
124+
public static function getProductionMode()
125+
{
116126
$sandbox = self::$sandboxMode;
117127
if (getenv('OPENPAY_PRODUCTION_MODE')) {
118128
$sandbox = (strtoupper(getenv('OPENPAY_PRODUCTION_MODE')) == 'FALSE');
119129
}
120130
return !$sandbox;
121131
}
122132

123-
public static function setProductionMode($mode) {
133+
public static function setProductionMode($mode)
134+
{
124135
self::$sandboxMode = $mode ? false : true;
125136
}
126137

127-
public static function setEndpointUrl($country){
128-
if($country == 'MX'){
129-
if(self::getClassificationMerchant() != 'eglobal'){
138+
public static function setEndpointUrl($country)
139+
{
140+
if ($country == 'MX') {
141+
if (self::getClassificationMerchant() != 'eglobal') {
130142
self::$apiEndpoint = 'https://api.openpay.mx/v1';
131143
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.mx/v1';
132-
}else{
144+
} else {
133145
self::$apiEndpoint = 'https://api.ecommercebbva.com/v1';
134146
self::$apiSandboxEndpoint = 'https://sand-api.ecommercebbva.com/v1';
135147
}
136-
}elseif($country == 'CO'){
148+
} elseif ($country == 'CO') {
137149
self::$apiEndpoint = 'https://api.openpay.co/v1';
138150
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.co/v1';
151+
} elseif ($country == 'PE') {
152+
self::$apiEndpoint = 'https://api.openpay.pe/v1';
153+
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.pe/v1';
139154
}
140155
}
141-
public static function getEndpointUrl() {
142-
return (self::getSandboxMode() ? self::$apiSandboxEndpoint : self::$apiEndpoint);
143-
}
144-
145-
}
146-
147-
// ----------------------------------------------------------------------------
148-
class OpenpayApi extends OpenpayApiResourceBase
149-
{
150-
151-
protected $derivedResources = array(
152-
'Bine' => array(),
153-
'Customer' => array(),
154-
'Card' => array(),
155-
'Charge' => array(),
156-
'Pse' => array(),
157-
'Payout' => array(),
158-
'Fee' => array(),
159-
'Plan' => array(),
160-
'Webhook' => array(),
161-
'Token' => array());
162156

163-
public static function getInstance($r, $p = null) {
164-
$resourceName = get_class();
165-
return parent::getInstance($resourceName);
166-
}
167-
168-
public function getMerchantInfo(){
169-
return parent::getMerchantInfo();
170-
}
171-
172-
protected function getResourceUrlName($p = true) {
173-
return '';
174-
}
175-
176-
public function getFullURL() {
177-
return $this->getUrl();
157+
public static function getEndpointUrl()
158+
{
159+
return (self::getSandboxMode() ? self::$apiSandboxEndpoint : self::$apiEndpoint);
178160
}
179161

180162
}
181-
182-
?>

Openpay/Data/OpenpayApi.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Openpay\Data;
4+
5+
class OpenpayApi extends OpenpayApiResourceBase
6+
{
7+
8+
protected $derivedResources = array(
9+
'Bine' => array(),
10+
'Customer' => array(),
11+
'Card' => array(),
12+
'Charge' => array(),
13+
'Pse' => array(),
14+
'Payout' => array(),
15+
'Fee' => array(),
16+
'Plan' => array(),
17+
'Webhook' => array(),
18+
'Token' => array());
19+
20+
public static function getInstance($r, $p = null)
21+
{
22+
$resourceName = get_class();
23+
return parent::getInstance($resourceName);
24+
}
25+
26+
public function getMerchantInfo()
27+
{
28+
return parent::getMerchantInfo();
29+
}
30+
31+
protected function getResourceUrlName($p = true)
32+
{
33+
return '';
34+
}
35+
36+
public function getFullURL()
37+
{
38+
return $this->getUrl();
39+
}
40+
41+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Openpay\Data;
4+
5+
class OpenpayApiAuthError extends OpenpayApiError
6+
{
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Openpay\Data;
4+
5+
class OpenpayApiConnectionError extends OpenpayApiError
6+
{
7+
8+
}

0 commit comments

Comments
 (0)