Skip to content

Commit 6919d5a

Browse files
authored
Merge pull request open-pay#50 from open-pay/developer
Se agrega consulta para obtener la información del comercio
2 parents a58239d + 75d7919 commit 6919d5a

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

data/OpenpayApi.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Openpay
1818
private static $apiEndpoint = '';
1919
private static $apiSandboxEndpoint = '';
2020
private static $sandboxMode = true;
21+
private static $classification = '';
2122

2223
public function __construct() {
2324

@@ -49,6 +50,17 @@ public static function getUserAgent(){
4950
return $userAgent;
5051
}
5152

53+
public static function setClassificationMerchant($classification){
54+
if ($classification != '') {
55+
self::$classification = $classification;
56+
}
57+
}
58+
59+
public static function getClassificationMerchant(){
60+
$classification = self::$classification;
61+
return $classification;
62+
}
63+
5264
public static function setApiKey($key = '') {
5365
if ($key != '') {
5466
self::$apiKey = $key;
@@ -114,8 +126,13 @@ public static function setProductionMode($mode) {
114126

115127
public static function setEndpointUrl($country){
116128
if($country == 'MX'){
117-
self::$apiEndpoint = 'https://api.openpay.mx/v1';
118-
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.mx/v1';
129+
if(self::getClassificationMerchant() != 'eglobal'){
130+
self::$apiEndpoint = 'https://api.openpay.mx/v1';
131+
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.mx/v1';
132+
}else{
133+
self::$apiEndpoint = 'https://api.ecommercebbva.com/v1';
134+
self::$apiSandboxEndpoint = 'https://sand-api.ecommercebbva.com/v1';
135+
}
119136
}elseif($country == 'CO'){
120137
self::$apiEndpoint = 'https://api.openpay.co/v1';
121138
self::$apiSandboxEndpoint = 'https://sandbox-api.openpay.co/v1';
@@ -148,6 +165,10 @@ public static function getInstance($r, $p = null) {
148165
return parent::getInstance($resourceName);
149166
}
150167

168+
public function getMerchantInfo(){
169+
return parent::getMerchantInfo();
170+
}
171+
151172
protected function getResourceUrlName($p = true) {
152173
return '';
153174
}

data/OpenpayApiConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private function _request($method, $url, $params) {
5858
$userAgent = Openpay::getUserAgent();
5959

6060
if(empty($userAgent))
61-
$headers = array('User-Agent: OpenpayPhp/v1');
61+
$headers = array('User-Agent: OpenpayPhp/v2');
6262
else
6363
$headers = array('User-Agent: '.$userAgent);
6464

data/OpenpayApiResourceBase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ protected function validateId($id) {
256256
}
257257
}
258258

259+
protected function getMerchantInfo(){
260+
$response = OpenpayApiConnector::request('get', '/' , null);
261+
return json_decode(json_encode($response));
262+
}
263+
259264
protected function _create($resourceName, $params, $props = null) {
260265

261266
$resource = self::getInstance($resourceName, $props);

0 commit comments

Comments
 (0)