From 7c11754157f53499c4eeb0f940e6bd00954f6ced Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 11:26:34 -0300
Subject: [PATCH 01/75] feat(PPWP-377): unified calls
---
src/MercadoPago/Core/Helper/Data.php | 13 ++++++++++---
src/MercadoPago/Core/Lib/Api.php | 3 ++-
src/MercadoPago/Core/Model/BasicConfigProvider.php | 3 ++-
src/MercadoPago/Core/Model/Core.php | 4 +++-
src/MercadoPago/Core/Model/CustomConfigProvider.php | 3 ++-
.../PaymentMethods/PaymentMethodsAbstract.php | 6 ++++--
.../System/Config/Source/PaymentMethodsTicket.php | 5 +++--
7 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index 067a6dc7..e7f94d4b 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -353,15 +353,22 @@ public function getMercadoPagoPaymentMethods($accessToken)
try {
$mp = $this->getApiInstance($accessToken);
- $response = $mp->get("/v1/payment_methods");
- if ($response['status'] == 401 || $response['status'] == 400) {
+ $payment_methods = $mp->get("/v1/payment_methods");
+ if ($payment_methods['status'] == 401 || $payment_methods['status'] == 400) {
return false;
}
+
+ foreach ($payment_methods['response'] as $payment_method) {
+ if (!isset($payment_method['payment_places'])) {
+ $payment_method['payment_places'] = [];
+ }
+ }
+
} catch (Exception $e) {
return false;
}
- return $response['response'];
+ return $payment_methods['response'];
}
/**
diff --git a/src/MercadoPago/Core/Lib/Api.php b/src/MercadoPago/Core/Lib/Api.php
index 9ee00730..da80adfa 100644
--- a/src/MercadoPago/Core/Lib/Api.php
+++ b/src/MercadoPago/Core/Lib/Api.php
@@ -358,7 +358,8 @@ public function is_valid_access_token()
}
try {
- $response = $this->get("/v1/payment_methods");
+ #$response = $this->get("/v1/payment_methods");
+ $response = $this->$coreHelper->getMercadoPagoPaymentMethods($this->get_access_token());
if (empty($response)) {
return false;
diff --git a/src/MercadoPago/Core/Model/BasicConfigProvider.php b/src/MercadoPago/Core/Model/BasicConfigProvider.php
index 9d3e582d..0b47811e 100644
--- a/src/MercadoPago/Core/Model/BasicConfigProvider.php
+++ b/src/MercadoPago/Core/Model/BasicConfigProvider.php
@@ -149,7 +149,8 @@ public function makeBannerCheckout()
$ticket = 0;
$choMethods = [];
- $paymentMethods = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
+ //$paymentMethods = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
+ $paymentMethods = $coreHelper->getMercadoPagoPaymentMethods($accessToken);
foreach ($paymentMethods['response'] as $pm) {
if (!in_array($pm['id'], $excludePaymentMethods)) {
diff --git a/src/MercadoPago/Core/Model/Core.php b/src/MercadoPago/Core/Model/Core.php
index 635a5d28..d87ce359 100644
--- a/src/MercadoPago/Core/Model/Core.php
+++ b/src/MercadoPago/Core/Model/Core.php
@@ -679,7 +679,8 @@ public function getPaymentV1($payment_id)
*/
public function getPaymentMethods()
{
- return $this->getMercadoPagoInstance()->get("/v1/payment_methods");
+ #return $this->getMercadoPagoInstance()->get("/v1/payment_methods");
+ return $this->coreHelper->getMercadoPagoPaymentMethods($this->_accessToken);
}
/**
@@ -799,6 +800,7 @@ protected function getMercadoPagoInstance()
if (!$this->_accessToken) {
$this->_accessToken = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\ConfigData::PATH_ACCESS_TOKEN, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}
+
return $this->_coreHelper->getApiInstance($this->_accessToken);
}
diff --git a/src/MercadoPago/Core/Model/CustomConfigProvider.php b/src/MercadoPago/Core/Model/CustomConfigProvider.php
index bc394922..aea7e8b8 100644
--- a/src/MercadoPago/Core/Model/CustomConfigProvider.php
+++ b/src/MercadoPago/Core/Model/CustomConfigProvider.php
@@ -192,7 +192,8 @@ public function getPaymentMethods()
try {
$cards = [];
- $paymentMethods = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
+ #$paymentMethods = $this->$coreHelperRestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
+ $paymentMethods = $this->$coreHelper->getMercadoPagoPaymentMethods($accessToken);
$response = $paymentMethods['response'];
foreach ($response as $card) {
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
index 57ba76d0..4d52418a 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
@@ -45,9 +45,11 @@ public function toOptionArray()
return ['methods' => $methods];
}
- $this->coreHelper->log("GET /v1/payment_methods", 'mercadopago');
+ $this->coreHelper->log('GET /v1/payment_methods' . 'abstractßß', 'mercadopago');
+
try {
- $response = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
+ #$response = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
+ $paymentMethods = $this->$coreHelper->getMercadoPagoPaymentMethods($accessToken);
if ($response['status'] > 201) {
return ['methods' => $methods];
}
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
index 5b215d82..a1636701 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
@@ -70,10 +70,11 @@ public function toOptionArray()
return $methods;
}
- $this->coreHelper->log('GET /v1/payment_methods', 'mercadopago');
+ $this->coreHelper->log('GET /v1/payment_methods' . 'ticket', 'mercadopago');
try {
- $response = RestClient::get('/v1/payment_methods', null, ['Authorization: Bearer ' . $accessToken]);
+ #$response = RestClient::get('/v1/payment_methods', null, ['Authorization: Bearer ' . $accessToken]);
+ $response = $this->$coreHelper->getMercadoPagoPaymentMethods($accessToken);
} catch (Exception $e) {
$this->coreHelper->log('PaymentMethodsTicket:: An error occurred at the time of obtaining the ticket payment methods: ' . $e);
return [];
From 5c51d9941b9bc6cfc6e0e20c947238761cd5cff0 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 11:41:45 -0300
Subject: [PATCH 02/75] fix(PPWP-377): unified calls
---
src/MercadoPago/Core/Lib/Api.php | 2 +-
src/MercadoPago/Core/Model/BasicConfigProvider.php | 2 +-
src/MercadoPago/Core/Model/Core.php | 2 +-
src/MercadoPago/Core/Model/CustomConfigProvider.php | 2 +-
.../Config/Source/PaymentMethods/PaymentMethodsAbstract.php | 4 ++--
.../Core/Model/System/Config/Source/PaymentMethodsTicket.php | 4 ++--
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/MercadoPago/Core/Lib/Api.php b/src/MercadoPago/Core/Lib/Api.php
index da80adfa..8d5308e4 100644
--- a/src/MercadoPago/Core/Lib/Api.php
+++ b/src/MercadoPago/Core/Lib/Api.php
@@ -359,7 +359,7 @@ public function is_valid_access_token()
try {
#$response = $this->get("/v1/payment_methods");
- $response = $this->$coreHelper->getMercadoPagoPaymentMethods($this->get_access_token());
+ $response = $this->coreHelper->getMercadoPagoPaymentMethods($this->get_access_token());
if (empty($response)) {
return false;
diff --git a/src/MercadoPago/Core/Model/BasicConfigProvider.php b/src/MercadoPago/Core/Model/BasicConfigProvider.php
index 0b47811e..3aadb998 100644
--- a/src/MercadoPago/Core/Model/BasicConfigProvider.php
+++ b/src/MercadoPago/Core/Model/BasicConfigProvider.php
@@ -150,7 +150,7 @@ public function makeBannerCheckout()
$choMethods = [];
//$paymentMethods = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
- $paymentMethods = $coreHelper->getMercadoPagoPaymentMethods($accessToken);
+ $paymentMethods = $this->_coreHelper->getMercadoPagoPaymentMethods($accessToken);
foreach ($paymentMethods['response'] as $pm) {
if (!in_array($pm['id'], $excludePaymentMethods)) {
diff --git a/src/MercadoPago/Core/Model/Core.php b/src/MercadoPago/Core/Model/Core.php
index d87ce359..673314db 100644
--- a/src/MercadoPago/Core/Model/Core.php
+++ b/src/MercadoPago/Core/Model/Core.php
@@ -680,7 +680,7 @@ public function getPaymentV1($payment_id)
public function getPaymentMethods()
{
#return $this->getMercadoPagoInstance()->get("/v1/payment_methods");
- return $this->coreHelper->getMercadoPagoPaymentMethods($this->_accessToken);
+ return $this->_coreHelper->getMercadoPagoPaymentMethods($this->_accessToken);
}
/**
diff --git a/src/MercadoPago/Core/Model/CustomConfigProvider.php b/src/MercadoPago/Core/Model/CustomConfigProvider.php
index aea7e8b8..d76b8daa 100644
--- a/src/MercadoPago/Core/Model/CustomConfigProvider.php
+++ b/src/MercadoPago/Core/Model/CustomConfigProvider.php
@@ -193,7 +193,7 @@ public function getPaymentMethods()
try {
$cards = [];
#$paymentMethods = $this->$coreHelperRestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
- $paymentMethods = $this->$coreHelper->getMercadoPagoPaymentMethods($accessToken);
+ $paymentMethods = $this->_coreHelper->getMercadoPagoPaymentMethods($accessToken);
$response = $paymentMethods['response'];
foreach ($response as $card) {
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
index 4d52418a..30988aae 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
@@ -45,11 +45,11 @@ public function toOptionArray()
return ['methods' => $methods];
}
- $this->coreHelper->log('GET /v1/payment_methods' . 'abstractßß', 'mercadopago');
+ $this->coreHelper->log('GET /v1/payment_methods' . ' abstract', 'mercadopago');
try {
#$response = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
- $paymentMethods = $this->$coreHelper->getMercadoPagoPaymentMethods($accessToken);
+ $paymentMethods = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
if ($response['status'] > 201) {
return ['methods' => $methods];
}
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
index a1636701..ff159b94 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
@@ -70,11 +70,11 @@ public function toOptionArray()
return $methods;
}
- $this->coreHelper->log('GET /v1/payment_methods' . 'ticket', 'mercadopago');
+ $this->coreHelper->log('GET /v1/payment_methods' . ' ticket', 'mercadopago');
try {
#$response = RestClient::get('/v1/payment_methods', null, ['Authorization: Bearer ' . $accessToken]);
- $response = $this->$coreHelper->getMercadoPagoPaymentMethods($accessToken);
+ $response = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
} catch (Exception $e) {
$this->coreHelper->log('PaymentMethodsTicket:: An error occurred at the time of obtaining the ticket payment methods: ' . $e);
return [];
From 1d11b455715e747c7a4af722323ad1c16440c3e6 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 11:46:58 -0300
Subject: [PATCH 03/75] fix(PPWP-377): unified calls
---
.../Config/Source/PaymentMethods/PaymentMethodsAbstract.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
index 30988aae..644e0904 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
@@ -49,7 +49,7 @@ public function toOptionArray()
try {
#$response = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
- $paymentMethods = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
+ $response = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
if ($response['status'] > 201) {
return ['methods' => $methods];
}
From f4e5c8b7703c7eeaa67017a9dadbaca06ce9899a Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 11:58:11 -0300
Subject: [PATCH 04/75] fix(PPWP-377): unified calls
---
src/MercadoPago/Core/Helper/Data.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index e7f94d4b..eebf570b 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -354,9 +354,6 @@ public function getMercadoPagoPaymentMethods($accessToken)
$mp = $this->getApiInstance($accessToken);
$payment_methods = $mp->get("/v1/payment_methods");
- if ($payment_methods['status'] == 401 || $payment_methods['status'] == 400) {
- return false;
- }
foreach ($payment_methods['response'] as $payment_method) {
if (!isset($payment_method['payment_places'])) {
From 5236746c90c7275cb142d3f22415cbdd633cfe3e Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 12:16:16 -0300
Subject: [PATCH 05/75] fix(PPWP-377): unified calls
---
src/MercadoPago/Core/Helper/Data.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index eebf570b..51ca37d4 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -365,7 +365,7 @@ public function getMercadoPagoPaymentMethods($accessToken)
return false;
}
- return $payment_methods['response'];
+ return $payment_methods;
}
/**
From 8d5b07d2afee349464ec28ee78012a199d16dfa6 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 16:00:28 -0300
Subject: [PATCH 06/75] added payment places method
---
src/MercadoPago/Core/Helper/Data.php | 3 +-
src/MercadoPago/Core/Helper/PaymentPlaces.php | 49 ++++++
.../web/template/payment/custom_ticket.html | 150 ++++--------------
3 files changed, 86 insertions(+), 116 deletions(-)
create mode 100644 src/MercadoPago/Core/Helper/PaymentPlaces.php
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index 51ca37d4..04409228 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -23,6 +23,7 @@
use MercadoPago\Core\Lib\RestClient;
use MercadoPago\Core\Logger\Logger;
use MercadoPago\Core\Model\Custom\Payment;
+use MercadoPago\Core\Helper\PaymentPlaces;
/**
* Class Data
@@ -357,7 +358,7 @@ public function getMercadoPagoPaymentMethods($accessToken)
foreach ($payment_methods['response'] as $payment_method) {
if (!isset($payment_method['payment_places'])) {
- $payment_method['payment_places'] = [];
+ $payment_method['payment_places'] = PaymentPlaces::getPaymentPlaces($payment_method['id']);
}
}
diff --git a/src/MercadoPago/Core/Helper/PaymentPlaces.php b/src/MercadoPago/Core/Helper/PaymentPlaces.php
new file mode 100644
index 00000000..03d453ca
--- /dev/null
+++ b/src/MercadoPago/Core/Helper/PaymentPlaces.php
@@ -0,0 +1,49 @@
+ [
+ [
+ "payment_option_id" => "7eleven",
+ "name" => "7 Eleven",
+ "status" => "active",
+ "thumbnail" => "https://http2.mlstatic.com/storage/logos-api-admin/417ddb90-34ab-11e9-b8b8-15cad73057aa-s.png"
+ ],
+ [
+ "payment_option_id" => "circlek",
+ "name" => "Circle K",
+ "status" => "active",
+ "thumbnail" => "https://http2.mlstatic.com/storage/logos-api-admin/6f952c90-34ab-11e9-8357-f13e9b392369-s.png"
+ ],
+ [
+ "payment_option_id" => "soriana",
+ "name" => "Soriana",
+ "status" => "active",
+ "thumbnail" => "https://http2.mlstatic.com/storage/logos-api-admin/dac0bf10-01eb-11ec-ad92-052532916206-s.png"
+ ],
+ [
+ "payment_option_id" => "extra",
+ "name" => "Extra",
+ "status" => "active",
+ "thumbnail" => "https://http2.mlstatic.com/storage/logos-api-admin/9c8f26b0-34ab-11e9-b8b8-15cad73057aa-s.png"
+ ],
+ [
+ "payment_option_id" => "calimax",
+ "name" => "Calimax",
+ "status" => "active",
+ "thumbnail" => "https://http2.mlstatic.com/storage/logos-api-admin/52efa730-01ec-11ec-ba6b-c5f27048193b-s.png"
+ ]
+ ],
+ ];
+
+ return $payment_places[$paymentId] ;
+ }
+}
diff --git a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
index 65c120db..2281a888 100644
--- a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
+++ b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
@@ -1,16 +1,12 @@
@@ -164,51 +117,26 @@
-
+
+
@@ -294,7 +216,8 @@
-
+
+
@@ -302,24 +225,21 @@
-
+
\ No newline at end of file
From 1e36617ae1a3b7f94e2771a642421fe0f9533447 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 16:11:05 -0300
Subject: [PATCH 07/75] comments removed
---
src/MercadoPago/Core/Helper/Data.php | 5 ++++-
src/MercadoPago/Core/Lib/Api.php | 1 -
src/MercadoPago/Core/Model/BasicConfigProvider.php | 1 -
src/MercadoPago/Core/Model/Core.php | 1 -
src/MercadoPago/Core/Model/CustomConfigProvider.php | 1 -
.../Config/Source/PaymentMethods/PaymentMethodsAbstract.php | 3 ---
.../Core/Model/System/Config/Source/PaymentMethodsTicket.php | 3 ---
7 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index 04409228..11eca7ee 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -343,7 +343,7 @@ protected function _getMultiCardValue($data, $field)
}
/**
- * return the list of payment methods or null
+ * return the list of payment methods or false
*
* @param mixed|null $accessToken
*
@@ -351,6 +351,9 @@ protected function _getMultiCardValue($data, $field)
*/
public function getMercadoPagoPaymentMethods($accessToken)
{
+
+ $this->log('GET /v1/payment_methods', 'mercadopago');
+
try {
$mp = $this->getApiInstance($accessToken);
diff --git a/src/MercadoPago/Core/Lib/Api.php b/src/MercadoPago/Core/Lib/Api.php
index 8d5308e4..f4466f84 100644
--- a/src/MercadoPago/Core/Lib/Api.php
+++ b/src/MercadoPago/Core/Lib/Api.php
@@ -358,7 +358,6 @@ public function is_valid_access_token()
}
try {
- #$response = $this->get("/v1/payment_methods");
$response = $this->coreHelper->getMercadoPagoPaymentMethods($this->get_access_token());
if (empty($response)) {
diff --git a/src/MercadoPago/Core/Model/BasicConfigProvider.php b/src/MercadoPago/Core/Model/BasicConfigProvider.php
index 3aadb998..82956ad8 100644
--- a/src/MercadoPago/Core/Model/BasicConfigProvider.php
+++ b/src/MercadoPago/Core/Model/BasicConfigProvider.php
@@ -149,7 +149,6 @@ public function makeBannerCheckout()
$ticket = 0;
$choMethods = [];
- //$paymentMethods = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
$paymentMethods = $this->_coreHelper->getMercadoPagoPaymentMethods($accessToken);
foreach ($paymentMethods['response'] as $pm) {
diff --git a/src/MercadoPago/Core/Model/Core.php b/src/MercadoPago/Core/Model/Core.php
index 673314db..87061ed3 100644
--- a/src/MercadoPago/Core/Model/Core.php
+++ b/src/MercadoPago/Core/Model/Core.php
@@ -679,7 +679,6 @@ public function getPaymentV1($payment_id)
*/
public function getPaymentMethods()
{
- #return $this->getMercadoPagoInstance()->get("/v1/payment_methods");
return $this->_coreHelper->getMercadoPagoPaymentMethods($this->_accessToken);
}
diff --git a/src/MercadoPago/Core/Model/CustomConfigProvider.php b/src/MercadoPago/Core/Model/CustomConfigProvider.php
index d76b8daa..0f338371 100644
--- a/src/MercadoPago/Core/Model/CustomConfigProvider.php
+++ b/src/MercadoPago/Core/Model/CustomConfigProvider.php
@@ -192,7 +192,6 @@ public function getPaymentMethods()
try {
$cards = [];
- #$paymentMethods = $this->$coreHelperRestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
$paymentMethods = $this->_coreHelper->getMercadoPagoPaymentMethods($accessToken);
$response = $paymentMethods['response'];
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
index 644e0904..dafadeaf 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsAbstract.php
@@ -45,10 +45,7 @@ public function toOptionArray()
return ['methods' => $methods];
}
- $this->coreHelper->log('GET /v1/payment_methods' . ' abstract', 'mercadopago');
-
try {
- #$response = RestClient::get("/v1/payment_methods", null, ["Authorization: Bearer " . $accessToken]);
$response = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
if ($response['status'] > 201) {
return ['methods' => $methods];
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
index ff159b94..526a14e0 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
@@ -70,10 +70,7 @@ public function toOptionArray()
return $methods;
}
- $this->coreHelper->log('GET /v1/payment_methods' . ' ticket', 'mercadopago');
-
try {
- #$response = RestClient::get('/v1/payment_methods', null, ['Authorization: Bearer ' . $accessToken]);
$response = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
} catch (Exception $e) {
$this->coreHelper->log('PaymentMethodsTicket:: An error occurred at the time of obtaining the ticket payment methods: ' . $e);
From f356c423c53591f7ecddc8223b9ebc057dd5c9ee Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 17:06:34 -0300
Subject: [PATCH 08/75] refactored access token validation
---
src/MercadoPago/Core/Helper/Data.php | 11 +++++---
src/MercadoPago/Core/Lib/Api.php | 28 +------------------
.../web/template/payment/custom_ticket.html | 20 +------------
3 files changed, 9 insertions(+), 50 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index 11eca7ee..6928e495 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -202,11 +202,14 @@ public function isValidAccessToken($accessToken)
return true;
}
- $mp = $this->getApiInstance($accessToken);
- $isValid = $mp->is_valid_access_token();
+ $response = $this->getMercadoPagoPaymentMethods($accessToken);
- $this->_mpCache->saveCache($cacheKey, $isValid);
- return $isValid;
+ if (empty($response) || (isset($response['status']) && ($response['status'] == 401 || $response['status'] == 400))) {
+ return false;
+ }
+
+ $this->_mpCache->saveCache($cacheKey, true);
+ return true;
}
/**
diff --git a/src/MercadoPago/Core/Lib/Api.php b/src/MercadoPago/Core/Lib/Api.php
index f4466f84..49154028 100644
--- a/src/MercadoPago/Core/Lib/Api.php
+++ b/src/MercadoPago/Core/Lib/Api.php
@@ -347,33 +347,7 @@ public function check_discount_campaigns($transaction_amount, $payer_email, $cou
$url = "/discount_campaigns?transaction_amount=$transaction_amount&payer_email=$payer_email&coupon_code=$coupon_code";
return RestClient::get($url, null, ["Authorization: Bearer " . $access_token]);
}
-
- /**
- * @return bool
- */
- public function is_valid_access_token()
- {
- if (empty($this->ll_access_token)) {
- return false;
- }
-
- try {
- $response = $this->coreHelper->getMercadoPagoPaymentMethods($this->get_access_token());
-
- if (empty($response)) {
- return false;
- }
-
- if ((isset($response['status'])) && ($response['status'] == 401 || $response['status'] == 400)) {
- return false;
- }
-
- return true;
- } catch (\Exception $e) {
- return false;
- }
- }
-
+
/**
* @param $id
* @return array
diff --git a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
index 2281a888..383ffee2 100644
--- a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
+++ b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
@@ -37,12 +37,10 @@
-
-
-
-
-
-
From 7a048baa1fb93deda4dd641530a0bbf386c166b9 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 18:02:36 -0300
Subject: [PATCH 09/75] fixed ternary if structure
---
src/MercadoPago/Core/Helper/PaymentPlaces.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/PaymentPlaces.php b/src/MercadoPago/Core/Helper/PaymentPlaces.php
index 03d453ca..7164a6fd 100644
--- a/src/MercadoPago/Core/Helper/PaymentPlaces.php
+++ b/src/MercadoPago/Core/Helper/PaymentPlaces.php
@@ -10,7 +10,7 @@ class PaymentPlaces
public static function getPaymentPlaces($paymentId)
{
$payment_places = [
- 'paycash' => [
+ "paycash" => [
[
"payment_option_id" => "7eleven",
"name" => "7 Eleven",
@@ -44,6 +44,6 @@ public static function getPaymentPlaces($paymentId)
],
];
- return $payment_places[$paymentId] ;
+ return $payment_places[$paymentId] ?? [];
}
}
From de9a58d9848f33c56828a68ecffd2ee68d562b7e Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 9 Nov 2021 19:14:35 -0300
Subject: [PATCH 10/75] fixed instantiation of access token
---
src/MercadoPago/Core/Helper/Data.php | 4 ++--
src/MercadoPago/Core/Model/Core.php | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index 6928e495..d787911a 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -204,7 +204,7 @@ public function isValidAccessToken($accessToken)
$response = $this->getMercadoPagoPaymentMethods($accessToken);
- if (empty($response) || (isset($response['status']) && ($response['status'] == 401 || $response['status'] == 400))) {
+ if ((!$response) || (isset($response['status']) && ($response['status'] == 401 || $response['status'] == 400))) {
return false;
}
@@ -355,7 +355,7 @@ protected function _getMultiCardValue($data, $field)
public function getMercadoPagoPaymentMethods($accessToken)
{
- $this->log('GET /v1/payment_methods', 'mercadopago');
+ $this->log('GET /v1/payment_methods', 'mercadopago', $accessToken);
try {
$mp = $this->getApiInstance($accessToken);
diff --git a/src/MercadoPago/Core/Model/Core.php b/src/MercadoPago/Core/Model/Core.php
index 87061ed3..daa00570 100644
--- a/src/MercadoPago/Core/Model/Core.php
+++ b/src/MercadoPago/Core/Model/Core.php
@@ -679,6 +679,7 @@ public function getPaymentV1($payment_id)
*/
public function getPaymentMethods()
{
+ $this->getMercadoPagoInstance();
return $this->_coreHelper->getMercadoPagoPaymentMethods($this->_accessToken);
}
From 4bbfdca31a8ebc116a234af5f82d02246902c453 Mon Sep 17 00:00:00 2001
From: Douglas
Date: Wed, 10 Nov 2021 11:51:51 -0300
Subject: [PATCH 11/75] :bug: Fix the PR cover checker when there is no test
(#189)
This fixes an issue that is workflow failure when the pull request does not contain tests and Added hotfix branch filter to check tests
---
bin/pull-request-coverage.sh | 7 +-
.../Test/pull-request-coverage-checker.php | 123 +++++++++++++-----
2 files changed, 94 insertions(+), 36 deletions(-)
diff --git a/bin/pull-request-coverage.sh b/bin/pull-request-coverage.sh
index e0e69a72..35824690 100644
--- a/bin/pull-request-coverage.sh
+++ b/bin/pull-request-coverage.sh
@@ -1,9 +1,14 @@
#!/bin/bash
+echo "Getting pull request head branch..."
+export PHPUNIT_HEAD_BRANCH=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/PluginAndPartners/cart-magento2/pulls/${PR_NUMBER} \
+| jq ".head.ref" \
+| xargs)
+
echo "Getting pull request files..."
export PHPUNIT_FILES=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/PluginAndPartners/cart-magento2/pulls/${PR_NUMBER}/files \
| jq ".[].filename" \
| grep -E 'php"$' \
| xargs)
-php magento2/app/code/MercadoPago/Test/pull-request-coverage-checker.php clover.xml 40 $PHPUNIT_FILES
+php magento2/app/code/MercadoPago/Test/pull-request-coverage-checker.php clover.xml 40 $PHPUNIT_HEAD_BRANCH $PHPUNIT_FILES
diff --git a/src/MercadoPago/Test/pull-request-coverage-checker.php b/src/MercadoPago/Test/pull-request-coverage-checker.php
index fb15a51b..6979a9a0 100644
--- a/src/MercadoPago/Test/pull-request-coverage-checker.php
+++ b/src/MercadoPago/Test/pull-request-coverage-checker.php
@@ -1,56 +1,109 @@
xpath('//class');
+ $totalElements = 0;
+ $checkedElements = 0;
-for ($i = 3; $i < count($argv); $i++) {
- $filename = str_replace('src/', '', $argv[$i]);
- $filename = str_replace('/', '\\', $filename);
- $filename = str_replace('.php', '', $filename);
+ foreach ($classes as $class) {
+ if (in_array($class['name'], $pullRequestFiles)) {
+ $totalElements += (int) $class->metrics['elements'];
+ $checkedElements += (int) $class->metrics['coveredelements'];
+ }
+ }
- $pullRequestFiles[] = $filename;
+ return [
+ 'totalElements' => $totalElements,
+ 'checkedElements' => $checkedElements,
+ ];
}
-if (!file_exists($cloverFile)) {
- throw new InvalidArgumentException('Invalid clover file provided');
-}
+function parse_pull_request_files($argv) {
+ $pullRequestFiles = [];
+
+ for ($i = 4; $i < count($argv); $i++) {
+ $filename = str_replace('src/', '', $argv[$i]);
+ $filename = str_replace('/', '\\', $filename);
+ $filename = str_replace('.php', '', $filename);
+
+ if (is_testable($filename)) {
+ $pullRequestFiles[] = $filename;
+ print_r($filename . ' is a testable file' . PHP_EOL);
+ }
+ }
-if (!$percentage) {
- throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
+ return $pullRequestFiles;
}
-if (count($pullRequestFiles) == 0) {
- print_r('Pull Request does not contain any php file to check code coverage');
- return;
+function is_testable($filename) {
+ // Add all untestable php files
+ $whitelist = [
+ 'MercadoPago\Test\coverage-checker',
+ 'MercadoPago\Test\pull-request-coverage-checker',
+ ];
+
+ return in_array($filename, $whitelist) ? false : true;
}
-$xml = new SimpleXMLElement(file_get_contents($cloverFile));
-$classes = $xml->xpath('//class');
-$totalElements = 0;
-$checkedElements = 0;
+function is_hotfix_branch($branchName) {
+ return strpos($branchName, 'hotfix');
+}
-foreach ($classes as $class) {
- if (in_array($class['name'], $pullRequestFiles)) {
- $totalElements += (int) $class->metrics['elements'];
- $checkedElements += (int) $class->metrics['coveredelements'];
+function validate_clover_file($cloverFile) {
+ if (!file_exists($cloverFile)) {
+ throw new InvalidArgumentException('Invalid clover file provided');
}
}
-if ($totalElements == 0 || $checkedElements == 0) {
- print_r('Pull Request does not contain tested php files to check code coverage');
- return;
+function validate_percentage_param($percentage) {
+ if (!$percentage) {
+ throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
+ }
}
-$coverage = ($checkedElements / $totalElements) * 100;
+function validate_pull_request_coverage($totalElements, $checkedElements, $percentage) {
+ $coverage = ($checkedElements / $totalElements) * 100;
+
+ if ($coverage >= $percentage) {
+ print_r('Code coverage is ' . $coverage);
+ print_r(' -> Pull Request OK');
+ return;
+ }
-if ($coverage >= $percentage) {
- print_r('Code coverage is ' . $coverage);
- print_r(' -> Pull Request OK');
- return;
+ print_r('Code coverage is ' . round($coverage, 2) . '%, which is below the accepted ' . $percentage . '%');
+ print_r(' -> Pull Request Rejected');
+
+ throw new Exception('Code coverage is ' . round($coverage, 2) . '%, which is below the accepted ' . $percentage . '%');
}
-print_r('Code coverage is ' . round($coverage, 2) . '%, which is below the accepted ' . $percentage . '%');
-print_r(' -> Pull Request Rejected');
+function execute($argv) {
+ $branchName = $argv[3];
+ $cloverFile = $argv[1];
+ $percentage = min(100, max(0, (int) $argv[2]));
+ $pullRequestFiles = parse_pull_request_files($argv);
+
+ if (!is_hotfix_branch($branchName)) {
+ validate_clover_file($cloverFile);
+ validate_percentage_param($percentage);
+
+ $elements = get_elements($cloverFile, $pullRequestFiles);
+ $totalElements = $elements['totalElements'];
+ $checkedElements = $elements['checkedElements'];
+
+ if ($totalElements == 0 || $checkedElements == 0) {
+ if (count($pullRequestFiles) === 0) {
+ print_r('Pull request does not contain testable files');
+ return;
+ }
+
+ throw new Exception('Pull Request does not contain tested php files to check code coverage');
+ }
+
+ validate_pull_request_coverage($totalElements, $checkedElements, $percentage);
+
+ return;
+ }
+}
-throw new Exception('Code coverage is ' . round($coverage, 2) . '%, which is below the accepted ' . $percentage . '%');
+execute($argv);
From 85e53fd35fd7b9b29907dfc60e8ce80d69399028 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Wed, 10 Nov 2021 12:49:10 -0300
Subject: [PATCH 12/75] feat(PPWP-421): paycash front-end
---
src/MercadoPago/Core/Helper/Data.php | 13 +++++++++----
.../Core/view/frontend/web/css/MPv1.css | 2 +-
.../web/template/payment/custom_ticket.html | 15 ++++++++++++++-
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index d787911a..a9b1cd7f 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -355,24 +355,29 @@ protected function _getMultiCardValue($data, $field)
public function getMercadoPagoPaymentMethods($accessToken)
{
- $this->log('GET /v1/payment_methods', 'mercadopago', $accessToken);
+ $this->log('GET /v1/payment_methods', 'mercadopago');
try {
$mp = $this->getApiInstance($accessToken);
$payment_methods = $mp->get("/v1/payment_methods");
+ $treated_payments_methods = [];
foreach ($payment_methods['response'] as $payment_method) {
- if (!isset($payment_method['payment_places'])) {
+ if (!isset($payment_method['payment_places'])) {
$payment_method['payment_places'] = PaymentPlaces::getPaymentPlaces($payment_method['id']);
}
+
+ array_push($treated_payments_methods, $payment_method);
}
+ $payment_methods['response'] = $treated_payments_methods;
+
+ return $payment_methods;
+
} catch (Exception $e) {
return false;
}
-
- return $payment_methods;
}
/**
diff --git a/src/MercadoPago/Core/view/frontend/web/css/MPv1.css b/src/MercadoPago/Core/view/frontend/web/css/MPv1.css
index 9688f82c..ecaaf1c9 100644
--- a/src/MercadoPago/Core/view/frontend/web/css/MPv1.css
+++ b/src/MercadoPago/Core/view/frontend/web/css/MPv1.css
@@ -1,4 +1,4 @@
-#co-mercadopago-form, #co-mercadopago-form-ticket {
+#co-mercadopago-form {
max-width: 400px;
}
diff --git a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
index 383ffee2..0054ea9f 100644
--- a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
+++ b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
@@ -39,7 +39,8 @@
From 962bf10929e62863a8cd7d37cef10c92d4998d39 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Wed, 10 Nov 2021 15:39:45 -0300
Subject: [PATCH 13/75] feat(PPWP-422): paycash admin
---
.../PaymentMethods/PaymentMethodsTicket.php | 22 +++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsTicket.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsTicket.php
index 2d2c4e35..71615ee4 100644
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsTicket.php
+++ b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethods/PaymentMethodsTicket.php
@@ -21,8 +21,8 @@ public function toOptionArray()
if (isset($pm['id'], $pm['name'], $pm['payment_type_id'])
&& !empty($pm['payment_type_id'])
&& ($pm['payment_type_id'] === "ticket" || $pm['payment_type_id'] === "atm")
- ) {
- $methods[] = ['value' => $pm['id'], 'label' => __($pm['name'])];
+ ) {
+ $methods[] = ['value' => $pm['id'], 'label' => __($this->formatLabel($pm))];
}
}
}
@@ -31,4 +31,22 @@ public function toOptionArray()
return $methods;
}
+
+ /**
+ * @return string
+ */
+ public function formatLabel($pm)
+ {
+ $payment = '';
+ $concat = '';
+ if (!empty($pm['payment_places'])) {
+ foreach($pm['payment_places'] as $payment_place) {
+ $payment .= $concat . $payment_place['name'];
+ $concat = ', ';
+ }
+ $payment = " ($payment)";
+ }
+
+ return $pm['name'] . $payment;
+ }
}
From 0daf338070d33a3f29f8d66f49d365dd7861989b Mon Sep 17 00:00:00 2001
From: Fernando Lira
Date: Fri, 12 Nov 2021 13:44:47 -0300
Subject: [PATCH 14/75] =?UTF-8?q?fix(helper):=20=F0=9F=90=9B=20fixed=20flo?=
=?UTF-8?q?at=20to=20int=20convertion?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MercadoPago/Core/Helper/Round.php | 30 ++++---
.../Test/Unit/Helper/RoundTest.php | 86 +++++++++++++++++++
2 files changed, 104 insertions(+), 12 deletions(-)
create mode 100644 src/MercadoPago/Test/Unit/Helper/RoundTest.php
diff --git a/src/MercadoPago/Core/Helper/Round.php b/src/MercadoPago/Core/Helper/Round.php
index ec4ae3b2..2bef9b6c 100644
--- a/src/MercadoPago/Core/Helper/Round.php
+++ b/src/MercadoPago/Core/Helper/Round.php
@@ -11,46 +11,52 @@ class Round
*/
const COUNTRIES_WITH_INTEGER_PRICE = [
'MLC',
- 'MLO',
+ 'MCO',
];
+
/**
* Get rounded value with site id
*
- * @param float $value
+ * @param float $value
* @param string $siteId
* @return float|integer
*/
public static function roundWithSiteId($value, $siteId)
{
- $round = (float) number_format($value, 2, '.', '');
-
if (in_array($siteId, self::COUNTRIES_WITH_INTEGER_PRICE, true)) {
- return (int) $round;
+ return (int) number_format($value, 0, '.', '');
}
- return $round;
- }
+ return (float) number_format($value, 2, '.', '');
+
+ }//end roundWithSiteId()
+
/**
* Get rounded value with site id
*
- * @param float $value
+ * @param float $value
* @return float
*/
public static function roundWithoutSiteId($value)
{
return (float) number_format($value, 2, '.', '');
- }
+
+ }//end roundWithoutSiteId()
+
/**
* Get rounded value with site id
*
- * @param float $value
+ * @param float $value
* @return integer
*/
public static function roundInteger($value)
{
return (int) number_format($value, 0, '.', '');
- }
-}
+
+ }//end roundInteger()
+
+
+}//end class
diff --git a/src/MercadoPago/Test/Unit/Helper/RoundTest.php b/src/MercadoPago/Test/Unit/Helper/RoundTest.php
new file mode 100644
index 00000000..60c2cec3
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Helper/RoundTest.php
@@ -0,0 +1,86 @@
+assertEquals(2, $result);
+
+ $result = Round::roundInteger(1.5);
+ $this->assertEquals(2, $result);
+ }
+
+ public function testRoundIntToDown()
+ {
+ $result = Round::roundInteger(1.4);
+ $this->assertEquals(1, $result);
+
+ $result = Round::roundInteger(1.1);
+ $this->assertEquals(1, $result);
+ }
+
+ public function testRoundFloatToUp()
+ {
+ $result = Round::roundWithoutSiteId(99.4999);
+ $this->assertEquals(99.5, $result);
+
+ $result = Round::roundWithoutSiteId(55.999);
+ $this->assertEquals(56, $result);
+ }
+
+ public function testRoundFloatToDown()
+ {
+ $result = Round::roundWithoutSiteId(66.404444);
+ $this->assertEquals(66.40, $result);
+
+ $result = Round::roundWithoutSiteId(75.890000);
+ $this->assertEquals(75.89, $result);
+ }
+
+ public function testRoundWithSiteFloatToUp()
+ {
+ $result = Round::roundWithSiteId(142.87777, 'MLB');
+ $this->assertEquals(142.88, $result);
+
+ $result = Round::roundWithSiteId(545.999, 'MLA');
+ $this->assertEquals(546, $result);
+ }
+
+ public function testRoundWithSiteFloatToDown()
+ {
+ $result = Round::roundWithSiteId(66.672333, 'MLM');
+ $this->assertEquals(66.67, $result);
+
+ $result = Round::roundWithSiteId(755.890000, 'MLU');
+ $this->assertEquals(755.89, $result);
+ }
+
+ public function testRoundWithSiteIntToUp()
+ {
+ $result = Round::roundWithSiteId(142.87777, 'MLC');
+ $this->assertEquals(143, $result);
+
+ $result = Round::roundWithSiteId(545.999, 'MCO');
+ $this->assertEquals(546, $result);
+ }
+
+ public function testRoundWithSiteIntToDown()
+ {
+ $result = Round::roundWithSiteId(66.472333, 'MCO');
+ $this->assertEquals(66, $result);
+
+ $result = Round::roundWithSiteId(755.190000, 'MLC');
+ $this->assertEquals(755, $result);
+ }
+
+}//end class
From 3c8cfbcc073faff86f61aa6482eb8f49a5fc6470 Mon Sep 17 00:00:00 2001
From: Fernando Lira
Date: Fri, 12 Nov 2021 15:38:22 -0300
Subject: [PATCH 15/75] =?UTF-8?q?feat(bin):=20=E2=9C=A8=20new=20command=20?=
=?UTF-8?q?sync=20with=20container?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.editorconfig | 3 +++
Makefile | 5 ++++-
bin/run-linters.sh | 1 +
bin/run-sync-files.sh | 12 ++++++++++++
4 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 bin/run-sync-files.sh
diff --git a/.editorconfig b/.editorconfig
index a38c0db9..d8900f85 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -19,3 +19,6 @@ indent_size = 2
[{composer, auth}.json]
indent_size = 4
+
+[{Makefile,**.mk}]
+indent_style = tab
diff --git a/Makefile b/Makefile
index 87378e8f..b4826e2d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: help bash build linter phpcs phpmd phpstan test
+.PHONY: help bash build linter phpcs phpmd phpstan test sync-files
help:
@grep -E '^[a-zA-Z-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "[32m%-15s[0m %s\n", $$1, $$2}'
@@ -22,3 +22,6 @@ phpstan: ## Run and validate code standards with stan
test: ## Run and validate tests with phpunit
@sh bin/run-test.sh
+
+sync-files: ## Sync your local files to Magento 2 Container
+ @sh bin/run-sync-files.sh
diff --git a/bin/run-linters.sh b/bin/run-linters.sh
index de6d2e02..0844f834 100644
--- a/bin/run-linters.sh
+++ b/bin/run-linters.sh
@@ -1,5 +1,6 @@
#!/bin/bash
+sh bin/run-sync-files.sh
sh bin/run-phpcs.sh
sh bin/run-phpstan.sh
sh bin/run-phpmd.sh
diff --git a/bin/run-sync-files.sh b/bin/run-sync-files.sh
new file mode 100644
index 00000000..7c81dc47
--- /dev/null
+++ b/bin/run-sync-files.sh
@@ -0,0 +1,12 @@
+#!bin/bash
+echo "\n"
+echo 🐘🔍 '\033[01;33m RUNNING SYNC FILES TO MAGENTO 2 CONTAINER \033[0m'
+echo "\n"
+
+docker cp src/. magento-php:/var/www/html/magento2/app/code
+
+if [ $? -eq 0 ]; then
+ echo ✅ "\033[01;32m SYNC EXECUTED SUCCESSFULLY \n \033[0m"
+else
+ echo 🚫 "\033[01;31m SYNC FAILED \n \033[0m"
+fi
From ddb4b96077f80874ef559626d3604cf7e7ac7135 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Fri, 12 Nov 2021 17:47:07 -0300
Subject: [PATCH 16/75] improv: init tests
---
Dockerfile | 4 +-
src/MercadoPago/Core/Helper/Data.php | 104 ----
.../Test/Unit/Constants/Response.php | 564 ++++++++++++++++++
src/MercadoPago/Test/Unit/Helper/DataTest.php | 144 +++++
4 files changed, 711 insertions(+), 105 deletions(-)
create mode 100644 src/MercadoPago/Test/Unit/Constants/Response.php
create mode 100644 src/MercadoPago/Test/Unit/Helper/DataTest.php
diff --git a/Dockerfile b/Dockerfile
index 3b14986d..48132e89 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -41,4 +41,6 @@ COPY src magento2/app/code
COPY phpunit.xml phpunit.xml
# Fix permissions
-RUN chmod 777 -Rf magento2
+RUN cd magento2 && find var vendor generated pub/static pub/media app/etc -type f -print0 | xargs -0 chmod u+w
+RUN cd magento2 && find var vendor generated pub/static pub/media app/etc -type d -print0 | xargs -0 chmod u+w
+RUN chmod u+x magento2/bin/magento
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index a9b1cd7f..e4e178a6 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -212,27 +212,6 @@ public function isValidAccessToken($accessToken)
return true;
}
- /**
- * ClientId and Secret valid?
- *
- * @param $clientId
- * @param $clientSecret
- *
- * @return bool
- * @throws LocalizedException
- */
- public function isValidClientCredentials($clientId, $clientSecret)
- {
- $mp = $this->getApiInstance($clientId, $clientSecret);
- try {
- $mp->get_access_token();
- } catch (Exception $e) {
- return false;
- }
-
- return true;
- }
-
/**
* @param string $scopeCode
* @return bool|mixed
@@ -273,53 +252,6 @@ public function setOrderSubtotals($data, $order)
$order->save();
}
- /**
- * Modify payment array adding specific fields
- *
- * @param $payment
- *
- * @return mixed
- * @refactor
- */
- public function setPayerInfo(&$payment)
- {
- $this->log("setPayerInfo", 'mercadopago-custom.log', $payment);
-
- if ($payment['payment_method_id']) {
- $payment["payment_method"] = $payment['payment_method_id'];
- }
-
- if ($payment['installments']) {
- $payment["installments"] = $payment['installments'];
- }
- if ($payment['id']) {
- $payment["payment_id_detail"] = $payment['id'];
- }
- if (isset($payment['trunc_card'])) {
- $payment["trunc_card"] = $payment['trunc_card'];
- } elseif (isset($payment['card']) && isset($payment['card']['last_four_digits'])) {
- $payment["trunc_card"] = "xxxx xxxx xxxx " . $payment['card']["last_four_digits"];
- }
-
- if (isset($payment['card']["cardholder"]["name"])) {
- $payment["cardholder_name"] = $payment['card']["cardholder"]["name"];
- }
-
- if (isset($payment['payer']['first_name'])) {
- $payment['payer_first_name'] = $payment['payer']['first_name'];
- }
-
- if (isset($payment['payer']['last_name'])) {
- $payment['payer_last_name'] = $payment['payer']['last_name'];
- }
-
- if (isset($payment['payer']['email'])) {
- $payment['payer_email'] = $payment['payer']['email'];
- }
-
- return $payment;
- }
-
/**
* Return sum of fields separated with |
*
@@ -427,42 +359,6 @@ public function getModuleVersion()
return $this->_moduleResource->getDbVersion('MercadoPago_Core');
}
- /**
- * Summary: Get client id from access token.
- * Description: Get client id from access token.
- *
- * @param String $at
- *
- * @return String client id.
- */
- public static function getClientIdFromAccessToken($at)
- {
- $t = explode('-', $at);
-
- if (count($t) > 0) {
- return $t[1];
- }
-
- return '';
- }
-
- /**
- * @param $additionalInfo
- * @return string|null
- */
- public function getPaymentId($additionalInfo)
- {
- if (isset($additionalInfo['payment_id_detail']) && !empty($additionalInfo['payment_id_detail'])) {
- return $additionalInfo['payment_id_detail'];
- }
-
- if (isset($additionalInfo['paymentResponse']) && !empty($additionalInfo['paymentResponse'])) {
- return $additionalInfo['paymentResponse']['id'];
- }
-
- return null;
- }
-
/**
* Get modal link
*
diff --git a/src/MercadoPago/Test/Unit/Constants/Response.php b/src/MercadoPago/Test/Unit/Constants/Response.php
new file mode 100644
index 00000000..9ca8be35
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Constants/Response.php
@@ -0,0 +1,564 @@
+ [
+ 0 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'debmaster',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Mastercard Débito',
+ 'payment_type_id' => 'debit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debmaster.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(506302|506429)',
+ 'installments_pattern' => '',
+ 'pattern' => '^(506202|230868|506208|231018|542878|523595|506199|506305|506306|506307|506332|506333|588772|528430|551440|516016|524021|506269|535943|537030|526476|506323|551238|506259|529571|526354|539955|553467|516576|528074|534381|557604|506236|506257|532485|512280|516102|506250|506255|506304|526498|506212|539975|530113|506416|506414|550897|506392|506204|506249|529575|506201|506205|511265|538984|553800|554173|506275|557602|551515|523691|502275|506206|526194|526196|526197|551509|506415|511761|506383|506374|506402|506335|506265|535900|539944|506314|506411|506313|506245|506251|506386|526404|506274|506258|506353|506350|555924|506355|506410|506423|506424|506361|506247|506284|506352|506263|506432|506297|506287|506334|506364|506384|506320|506319|506344|506294|506283|506342|506282|506421|506393|506343|506439|506373|536783|549685|506367|506303|506254|506413|533922|516611|506337|506397|506398|506213|506277|506278|506279|506280|506377|511852|506422|506312|506441|506399|537938|506427|510586|538405|538088|506214|506215|506356|528480|506389|506351|506300|506354|506253|546378|516415|506309|533987|545290|545325|506311|506365|506380|506407|557920|557921|557922|557923|557924|506412|528598|531294|549672|506391|506428|511765|543924|506449|526400|551353|506405|506406|230884|230948|230951|557910|557909|557908|557907|557905|506217|545730|506218|589617|557906|517747|554628|504563|529093|517771|557991|551077|557561|550233|533609|551244|554627|504536|557875|557874|529028|525678|524711|520698|520694|520416|520116|517795|517721|517712|558426|554492|551081|517439|517440|549613|506228|557551|530686|518847|526424|516594|511114|506340|506270|506229|539177|559471|557671|511391|536324|543451|528514|538756|506458|555691)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debmaster.gif',
+ ],
+ 1 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'amex',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 1,
+ 'name' => 'American Express',
+ 'payment_type_id' => 'credit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/amex.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => '^(?!341595|3603(2|4)|360732|36075(5|6)|360935|37159(3|5)|3747((5(8|9))|(62))|3751(3([0-9])|7(7|8))|3764((0([0-9]))|(1([0-8]))|(2(2|8|9))|(3(6|7))|(4[0-9]|5[0-8])|(6([1-7])|7[0-8]|8[0-9]|9(1|3)))|37652(0|9)|37660((1|2)|[5-9])|376((6(2[0-9]|3[5-9]|8[5-8]))|71[0-4])|3771(69|74)|37779[0-8]|3778(0[2-6]|1[3-6]|20)|37782(5|6)|3799(6[6-8]|7(5|7)))',
+ 'pattern' => '^((34)|(37))',
+ ],
+ 'card_number' => [
+ 'length' => 15,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'front',
+ 'length' => 4,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/amex.gif',
+ ],
+ 2 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'master',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Mastercard',
+ 'payment_type_id' => 'credit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/master.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(506458|555691|231018|506208|541562|230868|506202|539177|531198|542878|506437|543691|506341|554964|527374|544505|589617|588772|559471|558426|557991|557924|557923|557922|557921|557920|557910|557909|557908|557907|557906|557905|557875|557874|557604|557602|557561|557551|555924|554964|554628|554627|554492|554173|553800|553467|551515|551509|551507|551440|551353|551244|551238|551081|551077|550897|550233|549685|549672|549613|546378|545730|545325|545290|543924|539978|539975|539955|539944|538984|538405|538088|537938|537030|536783|535943|535900|534926|534381|533987|533922|533609|532485|531294|530686|530113|529575|529571|529093|529028|528598|528480|528430|528074|526498|526476|526424|526404|526400|526354|526197|526196|526194|526192|525678|524711|524021|523691|523595|520698|520694|520416|520116|518847|517795|517771|517747|517721|517712|517440|517439|516611|516594|516576|516415|516102|516016|512280|511852|511765|511761|511265|511114|510586|506449|506441|506439|506432|506429|506428|506427|506424|506423|506422|506421|506416|506415|506414|506413|506412|506411|506410|506407|506406|506405|506402|506399|506398|506397|506393|506392|506391|506389|506386|506384|506383|506380|506377|506374|506373|506367|506365|506364|506361|506356|506355|506354|506353|506352|506351|506350|506344|506343|506342|506341|506340|506337|506336|506335|506334|506333|506332|506323|506320|506319|506314|506313|506312|506311|506309|506307|506306|506305|506304|506303|506302|506300|506297|506294|506287|506284|506283|506282|506280|506279|506278|506277|506275|506274|506273|506270|506269|506265|506263|506259|506258|506257|506255|506254|506253|506251|506250|506249|506247|506245|506236|506229|506228|506221|506218|506217|506215|506214|506213|506212|506206|506205|506204|506201|506199|504563|504536|502275|522312|522794|523013|577991|528877|601660|230884|230948|230951|557671|511391|557937|512422|539186|548843|536324|543451|528514|538756)',
+ 'installments_pattern' => '^(?!534548|511747|534629|506434|230958|558306|512912|545608|526777|526777|532794|529595|506445|506444|514065|506442|534548|519111|522618|(5(0(1105|2121|5861|67(2(6|7|8)|3(0|1)|4(1|8)|7(5|6|8))|90(5(1|9)|6[7-9]|91))|1(0(147|447|512|541)|1(623|708|7(39|40))|2(06(7|9)|107|267|3(3(1|2)|63|7(0|4)))|3(368|557)|4(0(0(4)|8(6|7))|322|8(68|95)|9(11|45|54))|5(073|11(7|8)|590|6(01|58)|7(67|87)|8(94))|6(0(64|70)|159|2(20|30|75|83|9(1|2))|376|478|585)|7(640|756|805|980)|8(148|2(77|94)|3(13|61)|4(54|82)|5(36|44)|664|7(59|6(1|7))|8(14|41|50)|9(14|50))|9(603|7(0(2|4)|1(0|4)|70)))|2(0(0(53|79)|1(32|56|84)|3(59|63)|4(0[0-3]|5)|898|9(77|95))|1(039|1(74|80)|3(12|7(0|3)|88|97)|5(09|2(3|4))|8(06|72|92))|2(073|135|273|4(46|99)|590|760|8(15|32|40)|97(2|8))|3(284|457|758|9(16|20|37))|4(003|348|70(2|3)|820)|5(320|4(25|8(6|9)|96)|6(31|40|6[2-4])|718|860|922)|6(396|549|7(69|78|8(7|8))|8(10|6(2|3)|92)|96(2|5|6|8))|7(4((05|06)|25|3(0|7)|6(2|8)|9[5-7])|5(15|33|72)|6(08|09|16|19|60|80|89|97))|8(052|209|392|400|5(87|99)|635|743|860)|9(053|2(05|85)|32(3|9)|86(1|7)|88(1|3|5)))|3(0(0(3(3|4|8)|58|7(2|3))|228|3(63|7(1|2|3))|452|57(4|5)|69(5|6)|780|841|99(4|8))|1(015|3(04|21)|448|6(54|6(3|4)|81)|705|966)|2(198|3(69|79|84|99)|473|817|9(24|30))|3(027|225|5(16|7(1|9))|728)|4(004|150|2(4|(6|9)|62)|447|5(03|1(3|6)|20|43|61|93))|5(0(16|8(1|5|8)|9(1|4|7))|106|32(3|7)|8(22|58|63|67|71))|6(087|143|2(33|69)|380|492|5(18|37)|650|805|969)|7(110|83(1|8))|8(8(07|18))|9(0(1(6|8)|2(8|9)|39|59|6(3|8)|73|83|9(0(0|1))|181|61(2|4)|9(09|19))))|4(0(0(64|78|84)|10(5|6)|168|47(6|7)|593|6(25|31|9(0|1|2|5))|782|9(05|19))|1(187|203|320|465|555|6(46|59|78|94)|7(19|59))|2(418|528|66(1|3)|7(02|19)|8(20|65)|9(74|76|91))|3(4(21|48)|565|696|8(06|55|85))|4(014|199|3(00|12|15)|5(40|70)|6(54|65)|7(31|64)|8(17|28|29|39|59|63|83|91)|9(08|15))|5(053|196|301|430|652|7(12|19|68)|8(10|32)|973)|6(056|4(52|79|99)|55(2|3)|6(16|24|38|89)|7(44|68)|852)|7(059|1(29|3(0|4)|4(1|2)|71)|369|408|874)|8(04(5|6)|166|2(62|93|95)|315|4(74|80)|5(73|9(0|1|5))|6(4(8|9)5(2|3))|7(2(3|4|9)|40|90)|8(2(4|6|7))|9(84|85|98))|9(0(12|20|51|70)|1(5(6|7|8|9)|6(2|3|7))|3(1(8|9)|2(8|9)|39|59|6(3|8)|83|9(0|1))|4(27|51)|585|828))|5(0(154|2(09|30)|568)|1000|2(072|1(28|67)|2(36|52|89|97)|3(0(0|5))|16|36|5(30|61)|6(40|68|93)|937)|3(0(07|96)|444|6(24|3(3|6|8|9)|4(3|5|6|8|9)|5(6|9)|6(5|8)|7(0|2|4)))|4(288|383|4(63|73|82)|61(0|2)|773|865|9(0(4|6)|17|27|3(2|3)|99))|5845|6615|7039|8(285|7(27|63))|9(198|202))|7(5809)|8(9(562|657|892|916))|9(0712))))',
+ 'pattern' => '^(5|(286900)|(627180)|(2(221|222|223|224|225|226|227|228|229|23|24|25|26|27|28|29|3|4|5|6|70|71|720)))',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/master.gif',
+ ],
+ 3 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'debvisa',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Visa Débito',
+ 'payment_type_id' => 'debit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(477130|400820|476684|476687|429522)',
+ 'installments_pattern' => '',
+ 'pattern' => '^(433126|411117|411673|451312|433194|405689|400819|480062|476840|474174|434798|422671|425983|433454|425984|491282|491089|483030|421316|474176|430967|480078|476588|491365|491580|491567|491566|442192|418928|490256|477961|477261|477177|476890|476687|446986|446985|490950|473993|469495|466397|467596|400889|441549|441545|429522|405930|449700|449187|408340|446115|441312|498587|455509|446117|446116|411808|408343|481517|446118|408341|481516|455537|455533|455510|410177|455511|441313|415231|409851|491566|416916|418914|407612|435769|428464|465762|413098|432049|446878|445016|445017|469693|460700|460766|400195|412432|415269|421364|402766|419821|480066|480076|457386|483104|483112|419822|419823|457249|408400|421003|426188|485043|485044|400443|410128|465828|465829|492143|407848|426808|465495|465496|465497|465498|444888|444889|491344|481279|405063|419334|419335|438099|459497|460068|474646|479303|422299|471239|457476|412294|420807|498588|498590|404313|420839|420831|412408)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 4 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'toka',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Toka',
+ 'payment_type_id' => 'debit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(420839|506302|506202|506429|506208|506316|230868|539177|420831)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 5 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'tengo',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Tengo',
+ 'payment_type_id' => 'debit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(506382|511747|534548)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 6 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'edenred',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Edenred',
+ 'payment_type_id' => 'debit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(636318|506303|636318|558306)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 7 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'sodexo',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Sodexo',
+ 'payment_type_id' => 'debit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(506444|506445|506365|230984|627535|506273|506336)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 8 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'carnet',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Carnet',
+ 'payment_type_id' => 'credit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
+ ],
+ 9 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'visa',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Visa',
+ 'payment_type_id' => 'credit_card',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/visa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(427295|411117|411673|428575|428574|474494|400820|498589|498590|498588|498587|492143|491580|491567|491566|491365|491344|491282|491089|490950|490256|485044|485043|483112|483104|483030|481517|481516|481279|480078|480076|480066|480062|479303|477961|477261|477177|477130|476890|476840|476687|476684|476588|474646|474176|474174|473993|471239|469693|469495|467596|466397|465829|465828|465762|465498|465497|465496|465495|462278|460766|460700|460068|459497|457476|457386|457249|455537|455533|455511|455510|455509|451312|449700|449187|446986|446985|446878|446118|446117|446116|446115|445017|445016|444889|444888|442192|441549|441545|441313|441312|438099|435769|434798|433454|433194|433126|432049|430967|429522|428464|426808|426188|425984|425983|422671|422299|421364|421316|421003|420807|419823|419822|419821|419335|419334|418928|418914|416916|415269|415231|413131|413098|412432|412294|411808|410177|410128|409851|408400|408343|408341|408340|407848|407612|405930|405689|405063|402766|400889|400820|400819|400443|400195|404313|420831|420839|443834|451015|440393|465283|412408)',
+ 'installments_pattern' => '^(?!(405067|426174|492144)|4(0(0(022|1(0(3|4)|63|7(6|8)|85|99)|2(17|25|4(7|8)|68)|344|4(3(7|9)|49|75|89)|6(34|47|54|89)|770|970)|1(093|178|200|370|684)|2(145|400|7(02|8[5-8]|9(1(7|8)|37|44)))|3(2(17|25|4(6|7)|54)|338|784)|4(024|280|370)|5(0(37|71)|6(43|9[3-5]))|6(1(6(6|8))|263|6(55|69)|897|997)|7(3(0(3|4))|4(09|38)|505|618)|9(152|308|6(0[1-3]|9(0|3))|744|9(21|8(3|4))))|1(0(0(39|84)|39[0-2]|4(07|2(4|5))|718|863)|1(0(5(0|4)|93)|759|8(0(1|4)|54))|2(1(77|87)|345|79(1|3))|4(7(09|20|40|91))|5(2(7(4|5)|8(1|3))|328)|6(0(23|94)|4(1[4-7]|2(4|5)))|7(9(5[3-5]|98))|8(0(4(4|7|8|9)|53)|668)|9(1(48|89|90)|590|6(19|2(0|3|5|8))|806))|2(0(061|3(12|3(8|9)|4(0|1)|767))|1(3(09|55|65|79)|4(01|10)|5(71|91)|644|84[3-8]|9(5(8|9)|6(0|2|4|5)))|2(0(0[4-6]|1(1|2)|23|53|61)|1(0(0|1|3)|85)|2(0(0|1)|74)|463|754)|3(669|808|9(25|44))|4(631|96(5|6))|5(8(2(1|2)|50)|944)|6(055|451|6(84|90))|7(16(4|7))|8(26[7-9]|304)|9768)|3(0(023|49(5|6|7)|535|963)|1307|2(03([0-2]|5)|72(8|9)|959)|3(4(41|60)|8(07|1(0|2|7)|2(2|6)|3(0|1|3)|47))|4(25[6-8]|639|769|9(49|56|95))|6618|7846|8(001|2(2(8|9)|30)|85(4|7)|935)|9(0(13|2(0|7))|14(0|4)|2(5(2|3)|67|76)|3(54|8(8|9)|90)))|4(0(066|69|(3|4))|1(080|1(20|74)|524)|2(01(4|5)|174|312|644|7(42|75))|4(054|4(34|5[6-9])|796)|5596|6(54(0|2)|690|867)|7(198|4(09|10))|8(165|459|502|7(33|99))|9(1(19|28|37|88)))|5(0(0(03|60)|40(7|8)|553|6(26|37|68)|75(0|1)|8(15|3(2|3|8)|4(3|4)|78)|9(10|7(2|9)|80|9(4|5)))|1(248|3(0[7-9]|42)|4(46|51|76)|786)|2(4(07|8(7|8)))|3(211|562)|4(07[3-5]|148|4(25|5(0|1))|6(00|4[0-2]|5[7-9])|8(12|32|45|5(0|1)))|5(1(03|7(0|5|9)|8([1-5]|[7-9])|9[6-9])|349|599|788|98(3|6))|6(137|4(60|7(3|7))|5(13|6[4-6]|8[2-4])|815)|7(0(21|55)|29(1|3)|305|5(09|15)|631|9(3(7|8)|43))|8919|9(0(2(0|3)|60|7(7|8)|80)|3(1[3-6]|56|60|8(0|[3-5]))|4(1(8|9)|26|50)|50(4|5)|918))|6(003(4|5)|1(046|202)|2(080|239|937)|3(158|312)|4(018|29[4-9]|30(0|1))|5(375|7(63|70))|6(0(57|69|7(0|9)))|7(1(12|4(8|9))|481|793)|8(201|531)|9(7(0(0|1)|2(4|5)|7(1|2))|8(70|93)))|7(0(455|598|653)|1(70(1|3))|2(81(1|3))|3(2(00|4[6-8])|702)|4(472|5(12|25|3(8|9))|638)|5(393|491|776)|6(002|33[1-3]|5(07|39|40)|60(4|5|6|8)|993)|7(1(28|57|76)|2(50|72))|9(3(52|7[5-8]|95)))|8(158(2|3)|2(108|4(25|69|7(0|6|9)|81))|3(0(42|66)|1(01|54|61)|3(1(2|6)))|4(1(32|9(3|8)))|5(0(11|29)|4(64|82)|904)|6(422|510)|9(070|167|3(21|89|91)|4(23|67|89)|9(11|25)))|9(0(071|172|225|69(6|8))|1(2(56|68)|41(1|2)|51(1|4)|6(17|4(6|7)|69|7(4|5))|956)|2(0(43|52)|1(37|69|80)|210|306|964)|3(1(0[0-3])|1(0|6)|49(3|4)|7(02|1(5|7|9)|6(2|3|8)|7(0|1)|81)|813)|4(0(16|78)|17(2|3)|611)|6(0(34|45|79|80)|210|6(17|7(0|2)))|8(4(0(1|4|[6-8])|2(3|4)|3(0|1|4|5)|4(2|9)|5(2|3)|84|96)|5(34|54|82)|8(11|58|61))|9847)))',
+ 'pattern' => '^4',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/visa.gif',
+ ],
+ 10 => [
+ 'accreditation_time' => 0,
+ 'additional_info_needed' => [
+ 0 => 'identification_type',
+ 1 => 'identification_number',
+ 2 => 'entity_type',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'paycash',
+ 'max_allowed_amount' => 60000,
+ 'min_allowed_amount' => 20,
+ 'name' => 'PayCash',
+ 'payment_places' => [
+ 0 => [
+ 'payment_option_id' => '7eleven',
+ 'name' => '7 Eleven',
+ 'status' => 'active',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/417ddb90-34ab-11e9-b8b8-15cad73057aa-s.png',
+ ],
+ 1 => [
+ 'payment_option_id' => 'circlek',
+ 'name' => 'Circle K',
+ 'status' => 'active',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/6f952c90-34ab-11e9-8357-f13e9b392369-s.png',
+ ],
+ 2 => [
+ 'payment_option_id' => 'soriana',
+ 'name' => 'Soriana',
+ 'status' => 'active',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/dac0bf10-01eb-11ec-ad92-052532916206-s.png',
+ ],
+ 3 => [
+ 'payment_option_id' => 'extra',
+ 'name' => 'Extra',
+ 'status' => 'active',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/9c8f26b0-34ab-11e9-b8b8-15cad73057aa-s.png',
+ ],
+ 4 => [
+ 'payment_option_id' => 'calimax',
+ 'name' => 'Calimax',
+ 'status' => 'active',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/52efa730-01ec-11ec-ba6b-c5f27048193b-s.png',
+ ],
+ ],
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
+ ],
+ 11 => [
+ 'accreditation_time' => 1,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ 0 => [
+ 'description' => 'SPEI',
+ 'id' => '1',
+ ],
+ ],
+ 'id' => 'clabe',
+ 'max_allowed_amount' => 5000,
+ 'min_allowed_amount' => 1,
+ 'name' => 'STP',
+ 'payment_type_id' => 'bank_transfer',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/clabe.gif',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/clabe.gif',
+ ],
+ 12 => [
+ 'accreditation_time' => 0,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'meliplace',
+ 'max_allowed_amount' => 10000,
+ 'min_allowed_amount' => 10,
+ 'name' => 'Meliplaces',
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/xxxxx.gif',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/xxxxx.gif',
+ ],
+ 13 => [
+ 'accreditation_time' => 60,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'banamex',
+ 'max_allowed_amount' => 40000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Citibanamex',
+ 'payment_type_id' => 'atm',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/banamex.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/banamex.gif',
+ ],
+ 14 => [
+ 'accreditation_time' => 60,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'bancomer',
+ 'max_allowed_amount' => 40000,
+ 'min_allowed_amount' => 10,
+ 'name' => 'BBVA Bancomer',
+ 'payment_type_id' => 'atm',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/bancomer.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/bancomer.gif',
+ ],
+ 15 => [
+ 'accreditation_time' => 60,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'serfin',
+ 'max_allowed_amount' => 40000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Santander',
+ 'payment_type_id' => 'atm',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/serfin.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/serfin.gif',
+ ],
+ 16 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'oxxo',
+ 'max_allowed_amount' => 10000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'OXXO',
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/oxxo.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/oxxo.gif',
+ ],
+ ],
+ 'status' => 200,
+ ];
+
+}
\ No newline at end of file
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
new file mode 100644
index 00000000..cb398df3
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -0,0 +1,144 @@
+getConstructArguments($className);
+ /** @var Context $context */
+ $context = $arguments['context'];
+ $this->scopeConfig = $context->getScopeConfig();
+ $this->layoutFactory = $arguments['layoutFactory'];
+
+ $this->messageInterface = $arguments['messageInterface'];
+ $this->mpCache = $arguments['mpCache'];
+
+ $this->paymentMethodFactory = $arguments['paymentMethodFactory'];
+ $this->appEmulation = $arguments['appEmulation'];
+ $this->paymentConfig = $arguments['paymentConfig'];
+ $this->initialConfig = $arguments['initialConfig'];
+ $this->logger = $arguments['logger'];
+ $this->statusFactory = $arguments['statusFactory'];
+ $this->orderFactory = $arguments['orderFactory'];
+ $this->switcher = $arguments['switcher'];
+ $this->composerInformation = $arguments['composerInformation'];
+ $this->moduleResource = $arguments['moduleResource'];
+
+
+ $this->helper = $objectManagerHelper->getObject($className, $arguments);
+ }
+
+ public function testGetMercadoPagoPaymentMethods(): void
+ {
+ list($accesstoken, $payment_methods, $uri) = [
+ 'APP-ACCESSTOKEN-TEST',
+ Response::RESPONSE_PAYMENT_METHODS_SUCCESS,
+ '/v1/payment_methods',
+ ];
+
+ $apiMock = $this->getMockBuilder(Api::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $apiMock
+ ->method(
+ 'get'
+ )->with(
+ $uri
+ )->willReturn(
+ $payment_methods
+ );
+
+ $this->assertEquals($payment_meethods, $this->helper->getMercadoPagoPaymentMethods($accesstoken));
+ }
+}
\ No newline at end of file
From 386f5b450c3aaac9fe2a76e0573e8f6fafe22822 Mon Sep 17 00:00:00 2001
From: Gustavo Brito
Date: Fri, 12 Nov 2021 17:59:59 -0300
Subject: [PATCH 17/75] improv: changing chmod command
---
Dockerfile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 3b14986d..48132e89 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -41,4 +41,6 @@ COPY src magento2/app/code
COPY phpunit.xml phpunit.xml
# Fix permissions
-RUN chmod 777 -Rf magento2
+RUN cd magento2 && find var vendor generated pub/static pub/media app/etc -type f -print0 | xargs -0 chmod u+w
+RUN cd magento2 && find var vendor generated pub/static pub/media app/etc -type d -print0 | xargs -0 chmod u+w
+RUN chmod u+x magento2/bin/magento
From e3d8b4e34cfed47626ec6e508a8de139d28690f4 Mon Sep 17 00:00:00 2001
From: Fernando Lira
Date: Tue, 16 Nov 2021 09:51:43 -0300
Subject: [PATCH 18/75] =?UTF-8?q?build:=20=F0=9F=93=A6=20new=20patch=20ver?=
=?UTF-8?q?sion=20of=20mercardo=20pago=20for=20magento=202=20v3.12.3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 6 ++++++
README.md | 2 +-
composer.json | 2 +-
src/MercadoPago/Core/composer.json | 2 +-
src/MercadoPago/Core/etc/module.xml | 2 +-
5 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55794ff2..8246f258 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [3.12.3] - 2021-11-16
+
+### Fixed
+
+- Fixed round method for integer currencies
+
## [3.12.2] - 2021-11-05
### Fixed
diff --git a/README.md b/README.md
index 030ea8ac..41772138 100755
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-# Magento 2 - Mercado Pago Module (v3.12.2)
+# Magento 2 - Mercado Pago Module (v3.12.3)
The Mercado Pago plugin for Magento 2 allows you to expand the functionalities of your online store and offer a unique payment experience for your customers.
diff --git a/composer.json b/composer.json
index d8efe2da..cce785c5 100755
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,7 @@
}
],
"type": "magento2-module",
- "version": "3.12.2",
+ "version": "3.12.3",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/src/MercadoPago/Core/composer.json b/src/MercadoPago/Core/composer.json
index f74ced0b..c3c77c78 100644
--- a/src/MercadoPago/Core/composer.json
+++ b/src/MercadoPago/Core/composer.json
@@ -2,7 +2,7 @@
"name": "mercadopago/core",
"description": "Mercado Pago Magento 2 Plugin",
"type": "magento2-module",
- "version": "3.12.2",
+ "version": "3.12.3",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/src/MercadoPago/Core/etc/module.xml b/src/MercadoPago/Core/etc/module.xml
index cc07878a..719d420c 100644
--- a/src/MercadoPago/Core/etc/module.xml
+++ b/src/MercadoPago/Core/etc/module.xml
@@ -1,6 +1,6 @@
-
+
From c91da2852d2b0ed16a59b4149418fec029a2cf9d Mon Sep 17 00:00:00 2001
From: Gustavo Brito
Date: Tue, 16 Nov 2021 11:38:00 -0300
Subject: [PATCH 19/75] getMercadoPagoPaymentMethods testing
---
src/MercadoPago/Core/Helper/Data.php | 18 +-
src/MercadoPago/Core/etc/di.xml | 1 +
.../Test/Unit/Constants/Response.php | 545 ++++++++++++++++++
src/MercadoPago/Test/Unit/Helper/DataTest.php | 48 +-
4 files changed, 591 insertions(+), 21 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index e4e178a6..68716e08 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -90,6 +90,11 @@ class Data extends \Magento\Payment\Helper\Data
*/
protected $_moduleResource;
+ /**
+ * @var Api $api
+ */
+ protected $_api;
+
/**
* Data constructor.
* @param Message\MessageInterface $messageInterface
@@ -106,6 +111,7 @@ class Data extends \Magento\Payment\Helper\Data
* @param Switcher $switcher
* @param ComposerInformation $composerInformation
* @param ResourceInterface $moduleResource
+ * @param Api $api
*/
public function __construct(
Message\MessageInterface $messageInterface,
@@ -121,7 +127,8 @@ public function __construct(
OrderFactory $orderFactory,
Switcher $switcher,
ComposerInformation $composerInformation,
- ResourceInterface $moduleResource
+ ResourceInterface $moduleResource,
+ Api $api
) {
parent::__construct($context, $layoutFactory, $paymentMethodFactory, $appEmulation, $paymentConfig, $initialConfig);
$this->_messageInterface = $messageInterface;
@@ -132,6 +139,7 @@ public function __construct(
$this->_switcher = $switcher;
$this->_composerInformation = $composerInformation;
$this->_moduleResource = $moduleResource;
+ $this->_api = $api;
}
/**
@@ -174,7 +182,8 @@ public function getApiInstance($accessToken = null)
throw new LocalizedException(__('The ACCESS_TOKEN has not been configured, without this credential the module will not work correctly.'));
}
- $api = new Api($accessToken);
+ //$api = new Api($accessToken);
+ $api = $this->_api;
$api->set_platform(self::PLATFORM_OPENPLATFORM);
$api->set_type(self::TYPE);
@@ -282,7 +291,7 @@ protected function _getMultiCardValue($data, $field)
*
* @param mixed|null $accessToken
*
- * @return mixed
+ * @return array
*/
public function getMercadoPagoPaymentMethods($accessToken)
{
@@ -293,6 +302,7 @@ public function getMercadoPagoPaymentMethods($accessToken)
$mp = $this->getApiInstance($accessToken);
$payment_methods = $mp->get("/v1/payment_methods");
+
$treated_payments_methods = [];
foreach ($payment_methods['response'] as $payment_method) {
@@ -308,7 +318,7 @@ public function getMercadoPagoPaymentMethods($accessToken)
return $payment_methods;
} catch (Exception $e) {
- return false;
+ return [];
}
}
diff --git a/src/MercadoPago/Core/etc/di.xml b/src/MercadoPago/Core/etc/di.xml
index 9220b9f9..a13c2d09 100644
--- a/src/MercadoPago/Core/etc/di.xml
+++ b/src/MercadoPago/Core/etc/di.xml
@@ -1,6 +1,7 @@
+
diff --git a/src/MercadoPago/Test/Unit/Constants/Response.php b/src/MercadoPago/Test/Unit/Constants/Response.php
index 9ca8be35..c19a40e6 100644
--- a/src/MercadoPago/Test/Unit/Constants/Response.php
+++ b/src/MercadoPago/Test/Unit/Constants/Response.php
@@ -371,6 +371,540 @@ class Response
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/visa.gif',
],
+ 10 => [
+ 'accreditation_time' => 0,
+ 'additional_info_needed' => [
+ 0 => 'identification_type',
+ 1 => 'identification_number',
+ 2 => 'entity_type',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'paycash',
+ 'max_allowed_amount' => 60000,
+ 'min_allowed_amount' => 20,
+ 'name' => 'PayCash',
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
+ ],
+ 11 => [
+ 'accreditation_time' => 1,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ 0 => [
+ 'description' => 'SPEI',
+ 'id' => '1',
+ ],
+ ],
+ 'id' => 'clabe',
+ 'max_allowed_amount' => 5000,
+ 'min_allowed_amount' => 1,
+ 'name' => 'STP',
+ 'payment_type_id' => 'bank_transfer',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/clabe.gif',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/clabe.gif',
+ ],
+ 12 => [
+ 'accreditation_time' => 0,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'meliplace',
+ 'max_allowed_amount' => 10000,
+ 'min_allowed_amount' => 10,
+ 'name' => 'Meliplaces',
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/xxxxx.gif',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/xxxxx.gif',
+ ],
+ 13 => [
+ 'accreditation_time' => 60,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'banamex',
+ 'max_allowed_amount' => 40000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Citibanamex',
+ 'payment_type_id' => 'atm',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/banamex.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/banamex.gif',
+ ],
+ 14 => [
+ 'accreditation_time' => 60,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'bancomer',
+ 'max_allowed_amount' => 40000,
+ 'min_allowed_amount' => 10,
+ 'name' => 'BBVA Bancomer',
+ 'payment_type_id' => 'atm',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/bancomer.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/bancomer.gif',
+ ],
+ 15 => [
+ 'accreditation_time' => 60,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'serfin',
+ 'max_allowed_amount' => 40000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Santander',
+ 'payment_type_id' => 'atm',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/serfin.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/serfin.gif',
+ ],
+ 16 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ ],
+ 'deferred_capture' => 'does_not_apply',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'oxxo',
+ 'max_allowed_amount' => 10000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'OXXO',
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/oxxo.gif',
+ 'settings' => [
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/oxxo.gif',
+ ],
+ ],
+ 'status' => 200,
+ ];
+
+ public const RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES = [
+ 'response' => [
+ 0 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'debmaster',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Mastercard Débito',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debmaster.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(506302|506429)',
+ 'installments_pattern' => '',
+ 'pattern' => '^(506202|230868|506208|231018|542878|523595|506199|506305|506306|506307|506332|506333|588772|528430|551440|516016|524021|506269|535943|537030|526476|506323|551238|506259|529571|526354|539955|553467|516576|528074|534381|557604|506236|506257|532485|512280|516102|506250|506255|506304|526498|506212|539975|530113|506416|506414|550897|506392|506204|506249|529575|506201|506205|511265|538984|553800|554173|506275|557602|551515|523691|502275|506206|526194|526196|526197|551509|506415|511761|506383|506374|506402|506335|506265|535900|539944|506314|506411|506313|506245|506251|506386|526404|506274|506258|506353|506350|555924|506355|506410|506423|506424|506361|506247|506284|506352|506263|506432|506297|506287|506334|506364|506384|506320|506319|506344|506294|506283|506342|506282|506421|506393|506343|506439|506373|536783|549685|506367|506303|506254|506413|533922|516611|506337|506397|506398|506213|506277|506278|506279|506280|506377|511852|506422|506312|506441|506399|537938|506427|510586|538405|538088|506214|506215|506356|528480|506389|506351|506300|506354|506253|546378|516415|506309|533987|545290|545325|506311|506365|506380|506407|557920|557921|557922|557923|557924|506412|528598|531294|549672|506391|506428|511765|543924|506449|526400|551353|506405|506406|230884|230948|230951|557910|557909|557908|557907|557905|506217|545730|506218|589617|557906|517747|554628|504563|529093|517771|557991|551077|557561|550233|533609|551244|554627|504536|557875|557874|529028|525678|524711|520698|520694|520416|520116|517795|517721|517712|558426|554492|551081|517439|517440|549613|506228|557551|530686|518847|526424|516594|511114|506340|506270|506229|539177|559471|557671|511391|536324|543451|528514|538756|506458|555691)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debmaster.gif',
+ ],
+ 1 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'amex',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 1,
+ 'name' => 'American Express',
+ 'payment_type_id' => 'credit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/amex.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => '^(?!341595|3603(2|4)|360732|36075(5|6)|360935|37159(3|5)|3747((5(8|9))|(62))|3751(3([0-9])|7(7|8))|3764((0([0-9]))|(1([0-8]))|(2(2|8|9))|(3(6|7))|(4[0-9]|5[0-8])|(6([1-7])|7[0-8]|8[0-9]|9(1|3)))|37652(0|9)|37660((1|2)|[5-9])|376((6(2[0-9]|3[5-9]|8[5-8]))|71[0-4])|3771(69|74)|37779[0-8]|3778(0[2-6]|1[3-6]|20)|37782(5|6)|3799(6[6-8]|7(5|7)))',
+ 'pattern' => '^((34)|(37))',
+ ],
+ 'card_number' => [
+ 'length' => 15,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'front',
+ 'length' => 4,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/amex.gif',
+ ],
+ 2 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'master',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Mastercard',
+ 'payment_type_id' => 'credit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/master.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(506458|555691|231018|506208|541562|230868|506202|539177|531198|542878|506437|543691|506341|554964|527374|544505|589617|588772|559471|558426|557991|557924|557923|557922|557921|557920|557910|557909|557908|557907|557906|557905|557875|557874|557604|557602|557561|557551|555924|554964|554628|554627|554492|554173|553800|553467|551515|551509|551507|551440|551353|551244|551238|551081|551077|550897|550233|549685|549672|549613|546378|545730|545325|545290|543924|539978|539975|539955|539944|538984|538405|538088|537938|537030|536783|535943|535900|534926|534381|533987|533922|533609|532485|531294|530686|530113|529575|529571|529093|529028|528598|528480|528430|528074|526498|526476|526424|526404|526400|526354|526197|526196|526194|526192|525678|524711|524021|523691|523595|520698|520694|520416|520116|518847|517795|517771|517747|517721|517712|517440|517439|516611|516594|516576|516415|516102|516016|512280|511852|511765|511761|511265|511114|510586|506449|506441|506439|506432|506429|506428|506427|506424|506423|506422|506421|506416|506415|506414|506413|506412|506411|506410|506407|506406|506405|506402|506399|506398|506397|506393|506392|506391|506389|506386|506384|506383|506380|506377|506374|506373|506367|506365|506364|506361|506356|506355|506354|506353|506352|506351|506350|506344|506343|506342|506341|506340|506337|506336|506335|506334|506333|506332|506323|506320|506319|506314|506313|506312|506311|506309|506307|506306|506305|506304|506303|506302|506300|506297|506294|506287|506284|506283|506282|506280|506279|506278|506277|506275|506274|506273|506270|506269|506265|506263|506259|506258|506257|506255|506254|506253|506251|506250|506249|506247|506245|506236|506229|506228|506221|506218|506217|506215|506214|506213|506212|506206|506205|506204|506201|506199|504563|504536|502275|522312|522794|523013|577991|528877|601660|230884|230948|230951|557671|511391|557937|512422|539186|548843|536324|543451|528514|538756)',
+ 'installments_pattern' => '^(?!534548|511747|534629|506434|230958|558306|512912|545608|526777|526777|532794|529595|506445|506444|514065|506442|534548|519111|522618|(5(0(1105|2121|5861|67(2(6|7|8)|3(0|1)|4(1|8)|7(5|6|8))|90(5(1|9)|6[7-9]|91))|1(0(147|447|512|541)|1(623|708|7(39|40))|2(06(7|9)|107|267|3(3(1|2)|63|7(0|4)))|3(368|557)|4(0(0(4)|8(6|7))|322|8(68|95)|9(11|45|54))|5(073|11(7|8)|590|6(01|58)|7(67|87)|8(94))|6(0(64|70)|159|2(20|30|75|83|9(1|2))|376|478|585)|7(640|756|805|980)|8(148|2(77|94)|3(13|61)|4(54|82)|5(36|44)|664|7(59|6(1|7))|8(14|41|50)|9(14|50))|9(603|7(0(2|4)|1(0|4)|70)))|2(0(0(53|79)|1(32|56|84)|3(59|63)|4(0[0-3]|5)|898|9(77|95))|1(039|1(74|80)|3(12|7(0|3)|88|97)|5(09|2(3|4))|8(06|72|92))|2(073|135|273|4(46|99)|590|760|8(15|32|40)|97(2|8))|3(284|457|758|9(16|20|37))|4(003|348|70(2|3)|820)|5(320|4(25|8(6|9)|96)|6(31|40|6[2-4])|718|860|922)|6(396|549|7(69|78|8(7|8))|8(10|6(2|3)|92)|96(2|5|6|8))|7(4((05|06)|25|3(0|7)|6(2|8)|9[5-7])|5(15|33|72)|6(08|09|16|19|60|80|89|97))|8(052|209|392|400|5(87|99)|635|743|860)|9(053|2(05|85)|32(3|9)|86(1|7)|88(1|3|5)))|3(0(0(3(3|4|8)|58|7(2|3))|228|3(63|7(1|2|3))|452|57(4|5)|69(5|6)|780|841|99(4|8))|1(015|3(04|21)|448|6(54|6(3|4)|81)|705|966)|2(198|3(69|79|84|99)|473|817|9(24|30))|3(027|225|5(16|7(1|9))|728)|4(004|150|2(4|(6|9)|62)|447|5(03|1(3|6)|20|43|61|93))|5(0(16|8(1|5|8)|9(1|4|7))|106|32(3|7)|8(22|58|63|67|71))|6(087|143|2(33|69)|380|492|5(18|37)|650|805|969)|7(110|83(1|8))|8(8(07|18))|9(0(1(6|8)|2(8|9)|39|59|6(3|8)|73|83|9(0(0|1))|181|61(2|4)|9(09|19))))|4(0(0(64|78|84)|10(5|6)|168|47(6|7)|593|6(25|31|9(0|1|2|5))|782|9(05|19))|1(187|203|320|465|555|6(46|59|78|94)|7(19|59))|2(418|528|66(1|3)|7(02|19)|8(20|65)|9(74|76|91))|3(4(21|48)|565|696|8(06|55|85))|4(014|199|3(00|12|15)|5(40|70)|6(54|65)|7(31|64)|8(17|28|29|39|59|63|83|91)|9(08|15))|5(053|196|301|430|652|7(12|19|68)|8(10|32)|973)|6(056|4(52|79|99)|55(2|3)|6(16|24|38|89)|7(44|68)|852)|7(059|1(29|3(0|4)|4(1|2)|71)|369|408|874)|8(04(5|6)|166|2(62|93|95)|315|4(74|80)|5(73|9(0|1|5))|6(4(8|9)5(2|3))|7(2(3|4|9)|40|90)|8(2(4|6|7))|9(84|85|98))|9(0(12|20|51|70)|1(5(6|7|8|9)|6(2|3|7))|3(1(8|9)|2(8|9)|39|59|6(3|8)|83|9(0|1))|4(27|51)|585|828))|5(0(154|2(09|30)|568)|1000|2(072|1(28|67)|2(36|52|89|97)|3(0(0|5))|16|36|5(30|61)|6(40|68|93)|937)|3(0(07|96)|444|6(24|3(3|6|8|9)|4(3|5|6|8|9)|5(6|9)|6(5|8)|7(0|2|4)))|4(288|383|4(63|73|82)|61(0|2)|773|865|9(0(4|6)|17|27|3(2|3)|99))|5845|6615|7039|8(285|7(27|63))|9(198|202))|7(5809)|8(9(562|657|892|916))|9(0712))))',
+ 'pattern' => '^(5|(286900)|(627180)|(2(221|222|223|224|225|226|227|228|229|23|24|25|26|27|28|29|3|4|5|6|70|71|720)))',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/master.gif',
+ ],
+ 3 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'debvisa',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Visa Débito',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(477130|400820|476684|476687|429522)',
+ 'installments_pattern' => '',
+ 'pattern' => '^(433126|411117|411673|451312|433194|405689|400819|480062|476840|474174|434798|422671|425983|433454|425984|491282|491089|483030|421316|474176|430967|480078|476588|491365|491580|491567|491566|442192|418928|490256|477961|477261|477177|476890|476687|446986|446985|490950|473993|469495|466397|467596|400889|441549|441545|429522|405930|449700|449187|408340|446115|441312|498587|455509|446117|446116|411808|408343|481517|446118|408341|481516|455537|455533|455510|410177|455511|441313|415231|409851|491566|416916|418914|407612|435769|428464|465762|413098|432049|446878|445016|445017|469693|460700|460766|400195|412432|415269|421364|402766|419821|480066|480076|457386|483104|483112|419822|419823|457249|408400|421003|426188|485043|485044|400443|410128|465828|465829|492143|407848|426808|465495|465496|465497|465498|444888|444889|491344|481279|405063|419334|419335|438099|459497|460068|474646|479303|422299|471239|457476|412294|420807|498588|498590|404313|420839|420831|412408)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 4 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'toka',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Toka',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(420839|506302|506202|506429|506208|506316|230868|539177|420831)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 5 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'tengo',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Tengo',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(506382|511747|534548)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 6 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'edenred',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Edenred',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(636318|506303|636318|558306)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 7 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'sodexo',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Sodexo',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debvisa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => NULL,
+ 'pattern' => '^(506444|506445|506365|230984|627535|506273|506336)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/debvisa.gif',
+ ],
+ 8 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'carnet',
+ 'max_allowed_amount' => 200000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Carnet',
+ 'payment_type_id' => 'credit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
+ 'settings' => [
+ ],
+ 'status' => 'testing',
+ 'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
+ ],
+ 9 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [
+ ],
+ 'id' => 'visa',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Visa',
+ 'payment_type_id' => 'credit_card',
+ 'payment_places' => [ ],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/visa.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(427295|411117|411673|428575|428574|474494|400820|498589|498590|498588|498587|492143|491580|491567|491566|491365|491344|491282|491089|490950|490256|485044|485043|483112|483104|483030|481517|481516|481279|480078|480076|480066|480062|479303|477961|477261|477177|477130|476890|476840|476687|476684|476588|474646|474176|474174|473993|471239|469693|469495|467596|466397|465829|465828|465762|465498|465497|465496|465495|462278|460766|460700|460068|459497|457476|457386|457249|455537|455533|455511|455510|455509|451312|449700|449187|446986|446985|446878|446118|446117|446116|446115|445017|445016|444889|444888|442192|441549|441545|441313|441312|438099|435769|434798|433454|433194|433126|432049|430967|429522|428464|426808|426188|425984|425983|422671|422299|421364|421316|421003|420807|419823|419822|419821|419335|419334|418928|418914|416916|415269|415231|413131|413098|412432|412294|411808|410177|410128|409851|408400|408343|408341|408340|407848|407612|405930|405689|405063|402766|400889|400820|400819|400443|400195|404313|420831|420839|443834|451015|440393|465283|412408)',
+ 'installments_pattern' => '^(?!(405067|426174|492144)|4(0(0(022|1(0(3|4)|63|7(6|8)|85|99)|2(17|25|4(7|8)|68)|344|4(3(7|9)|49|75|89)|6(34|47|54|89)|770|970)|1(093|178|200|370|684)|2(145|400|7(02|8[5-8]|9(1(7|8)|37|44)))|3(2(17|25|4(6|7)|54)|338|784)|4(024|280|370)|5(0(37|71)|6(43|9[3-5]))|6(1(6(6|8))|263|6(55|69)|897|997)|7(3(0(3|4))|4(09|38)|505|618)|9(152|308|6(0[1-3]|9(0|3))|744|9(21|8(3|4))))|1(0(0(39|84)|39[0-2]|4(07|2(4|5))|718|863)|1(0(5(0|4)|93)|759|8(0(1|4)|54))|2(1(77|87)|345|79(1|3))|4(7(09|20|40|91))|5(2(7(4|5)|8(1|3))|328)|6(0(23|94)|4(1[4-7]|2(4|5)))|7(9(5[3-5]|98))|8(0(4(4|7|8|9)|53)|668)|9(1(48|89|90)|590|6(19|2(0|3|5|8))|806))|2(0(061|3(12|3(8|9)|4(0|1)|767))|1(3(09|55|65|79)|4(01|10)|5(71|91)|644|84[3-8]|9(5(8|9)|6(0|2|4|5)))|2(0(0[4-6]|1(1|2)|23|53|61)|1(0(0|1|3)|85)|2(0(0|1)|74)|463|754)|3(669|808|9(25|44))|4(631|96(5|6))|5(8(2(1|2)|50)|944)|6(055|451|6(84|90))|7(16(4|7))|8(26[7-9]|304)|9768)|3(0(023|49(5|6|7)|535|963)|1307|2(03([0-2]|5)|72(8|9)|959)|3(4(41|60)|8(07|1(0|2|7)|2(2|6)|3(0|1|3)|47))|4(25[6-8]|639|769|9(49|56|95))|6618|7846|8(001|2(2(8|9)|30)|85(4|7)|935)|9(0(13|2(0|7))|14(0|4)|2(5(2|3)|67|76)|3(54|8(8|9)|90)))|4(0(066|69|(3|4))|1(080|1(20|74)|524)|2(01(4|5)|174|312|644|7(42|75))|4(054|4(34|5[6-9])|796)|5596|6(54(0|2)|690|867)|7(198|4(09|10))|8(165|459|502|7(33|99))|9(1(19|28|37|88)))|5(0(0(03|60)|40(7|8)|553|6(26|37|68)|75(0|1)|8(15|3(2|3|8)|4(3|4)|78)|9(10|7(2|9)|80|9(4|5)))|1(248|3(0[7-9]|42)|4(46|51|76)|786)|2(4(07|8(7|8)))|3(211|562)|4(07[3-5]|148|4(25|5(0|1))|6(00|4[0-2]|5[7-9])|8(12|32|45|5(0|1)))|5(1(03|7(0|5|9)|8([1-5]|[7-9])|9[6-9])|349|599|788|98(3|6))|6(137|4(60|7(3|7))|5(13|6[4-6]|8[2-4])|815)|7(0(21|55)|29(1|3)|305|5(09|15)|631|9(3(7|8)|43))|8919|9(0(2(0|3)|60|7(7|8)|80)|3(1[3-6]|56|60|8(0|[3-5]))|4(1(8|9)|26|50)|50(4|5)|918))|6(003(4|5)|1(046|202)|2(080|239|937)|3(158|312)|4(018|29[4-9]|30(0|1))|5(375|7(63|70))|6(0(57|69|7(0|9)))|7(1(12|4(8|9))|481|793)|8(201|531)|9(7(0(0|1)|2(4|5)|7(1|2))|8(70|93)))|7(0(455|598|653)|1(70(1|3))|2(81(1|3))|3(2(00|4[6-8])|702)|4(472|5(12|25|3(8|9))|638)|5(393|491|776)|6(002|33[1-3]|5(07|39|40)|60(4|5|6|8)|993)|7(1(28|57|76)|2(50|72))|9(3(52|7[5-8]|95)))|8(158(2|3)|2(108|4(25|69|7(0|6|9)|81))|3(0(42|66)|1(01|54|61)|3(1(2|6)))|4(1(32|9(3|8)))|5(0(11|29)|4(64|82)|904)|6(422|510)|9(070|167|3(21|89|91)|4(23|67|89)|9(11|25)))|9(0(071|172|225|69(6|8))|1(2(56|68)|41(1|2)|51(1|4)|6(17|4(6|7)|69|7(4|5))|956)|2(0(43|52)|1(37|69|80)|210|306|964)|3(1(0[0-3])|1(0|6)|49(3|4)|7(02|1(5|7|9)|6(2|3|8)|7(0|1)|81)|813)|4(0(16|78)|17(2|3)|611)|6(0(34|45|79|80)|210|6(17|7(0|2)))|8(4(0(1|4|[6-8])|2(3|4)|3(0|1|4|5)|4(2|9)|5(2|3)|84|96)|5(34|54|82)|8(11|58|61))|9847)))',
+ 'pattern' => '^4',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/visa.gif',
+ ],
10 => [
'accreditation_time' => 0,
'additional_info_needed' => [
@@ -443,6 +977,7 @@ class Response
'min_allowed_amount' => 1,
'name' => 'STP',
'payment_type_id' => 'bank_transfer',
+ 'payment_places' => [ ],
'processing_modes' => [
0 => 'aggregator',
],
@@ -464,6 +999,7 @@ class Response
'min_allowed_amount' => 10,
'name' => 'Meliplaces',
'payment_type_id' => 'ticket',
+ 'payment_places' => [ ],
'processing_modes' => [
0 => 'aggregator',
],
@@ -485,6 +1021,7 @@ class Response
'min_allowed_amount' => 5,
'name' => 'Citibanamex',
'payment_type_id' => 'atm',
+ 'payment_places' => [ ],
'processing_modes' => [
0 => 'aggregator',
],
@@ -506,6 +1043,7 @@ class Response
'min_allowed_amount' => 10,
'name' => 'BBVA Bancomer',
'payment_type_id' => 'atm',
+ 'payment_places' => [ ],
'processing_modes' => [
0 => 'aggregator',
],
@@ -527,6 +1065,7 @@ class Response
'min_allowed_amount' => 5,
'name' => 'Santander',
'payment_type_id' => 'atm',
+ 'payment_places' => [ ],
'processing_modes' => [
0 => 'aggregator',
],
@@ -548,6 +1087,7 @@ class Response
'min_allowed_amount' => 5,
'name' => 'OXXO',
'payment_type_id' => 'ticket',
+ 'payment_places' => [ ],
'processing_modes' => [
0 => 'aggregator',
],
@@ -561,4 +1101,9 @@ class Response
'status' => 200,
];
+ public const RESPONSE_PAYMENT_METHODS_FAILURE = [
+ 'response' => [ ],
+ 'status' => 401,
+ ];
+
}
\ No newline at end of file
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
index cb398df3..62a11957 100644
--- a/src/MercadoPago/Test/Unit/Helper/DataTest.php
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -87,6 +87,11 @@ class DataTest extends TestCase
*/
private $moduleResource;
+ /**
+ * @var MockObject
+ */
+ private $api;
+
/**
* @inheritdoc
*/
@@ -113,32 +118,41 @@ protected function setUp(): void
$this->switcher = $arguments['switcher'];
$this->composerInformation = $arguments['composerInformation'];
$this->moduleResource = $arguments['moduleResource'];
-
-
+ $this->api = $arguments['api'];
+
$this->helper = $objectManagerHelper->getObject($className, $arguments);
}
- public function testGetMercadoPagoPaymentMethods(): void
+ public function testGetMercadoPagoPaymentMethods_successResponse_returnArrayWithPaymentPlaces(): void
{
- list($accesstoken, $payment_methods, $uri) = [
- 'APP-ACCESSTOKEN-TEST',
+ list($accesstoken, $payment_methods, $expected_payment_methods, $uri) = [
+ 'APP_USR-00000000000-000000-000000-0000000000',
Response::RESPONSE_PAYMENT_METHODS_SUCCESS,
+ Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES,
'/v1/payment_methods',
];
- $apiMock = $this->getMockBuilder(Api::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->api->expects($this->once())
+ ->method('get')
+ ->with($uri)
+ ->willReturn($payment_methods);
+
+ $this->assertEquals($expected_payment_methods, $this->helper->getMercadoPagoPaymentMethods($accesstoken));
+ }
+
+ public function testGetMercadoPagoPaymentMethods_exception_returnEmpty(): void
+ {
+ list($accesstoken, $uri) = [
+ 'APP-ACCESSTOKEN-TEST',
+ '/v1/payment_methods',
+ ];
- $apiMock
- ->method(
- 'get'
- )->with(
- $uri
- )->willReturn(
- $payment_methods
- );
+ $this->api->expects($this->once())
+ ->method('get')
+ ->with($uri)
+ ->willReturn(null);
- $this->assertEquals($payment_meethods, $this->helper->getMercadoPagoPaymentMethods($accesstoken));
+ $this->expectException(Exception::class);
+ $response = $this->helper->getMercadoPagoPaymentMethods($accesstoken);
}
}
\ No newline at end of file
From 2e9974da21dac381874268e55e0894a1735b119d Mon Sep 17 00:00:00 2001
From: Gustavo Brito
Date: Wed, 17 Nov 2021 07:29:54 -0300
Subject: [PATCH 20/75] fix(ppwp-337): fixing exception testing
---
src/MercadoPago/Test/Unit/Helper/DataTest.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
index 62a11957..01912951 100644
--- a/src/MercadoPago/Test/Unit/Helper/DataTest.php
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -152,7 +152,6 @@ public function testGetMercadoPagoPaymentMethods_exception_returnEmpty(): void
->with($uri)
->willReturn(null);
- $this->expectException(Exception::class);
- $response = $this->helper->getMercadoPagoPaymentMethods($accesstoken);
+ $this->assertEquals([], $this->helper->getMercadoPagoPaymentMethods($accesstoken));
}
}
\ No newline at end of file
From 9ebcb6413e6a1d8b9285b7f0b712e571978d2af4 Mon Sep 17 00:00:00 2001
From: Gustavo Brito
Date: Thu, 18 Nov 2021 18:55:45 -0300
Subject: [PATCH 21/75] testing config provider and api
---
.../Constants/ConfigProviderConstants.php | 111 +++++++++
.../Test/Unit/Constants/Response.php | 219 ++++++----------
src/MercadoPago/Test/Unit/Helper/DataTest.php | 24 +-
src/MercadoPago/Test/Unit/Lib/ApiTest.php | 47 ++++
.../Unit/Model/BasicConfigProviderTest.php | 235 ++++++++++++++++++
5 files changed, 484 insertions(+), 152 deletions(-)
create mode 100644 src/MercadoPago/Test/Unit/Constants/ConfigProviderConstants.php
create mode 100644 src/MercadoPago/Test/Unit/Lib/ApiTest.php
create mode 100644 src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
diff --git a/src/MercadoPago/Test/Unit/Constants/ConfigProviderConstants.php b/src/MercadoPago/Test/Unit/Constants/ConfigProviderConstants.php
new file mode 100644
index 00000000..be576a8e
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Constants/ConfigProviderConstants.php
@@ -0,0 +1,111 @@
+ [
+ 0 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [],
+ 'id' => 'debmaster',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 5,
+ 'name' => 'Mastercard Débito',
+ 'payment_type_id' => 'debit_card',
+ 'payment_places' => [],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debmaster.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => '^(506302|506429)',
+ 'installments_pattern' => '',
+ 'pattern' => '^(506202|230868|506208|231018|542878|523595|506199|506305|506306|506307|506332|506333|588772|528430|551440|516016|524021|506269|535943|537030|526476|506323|551238|506259|529571|526354|539955|553467|516576|528074|534381|557604|506236|506257|532485|512280|516102|506250|506255|506304|526498|506212|539975|530113|506416|506414|550897|506392|506204|506249|529575|506201|506205|511265|538984|553800|554173|506275|557602|551515|523691|502275|506206|526194|526196|526197|551509|506415|511761|506383|506374|506402|506335|506265|535900|539944|506314|506411|506313|506245|506251|506386|526404|506274|506258|506353|506350|555924|506355|506410|506423|506424|506361|506247|506284|506352|506263|506432|506297|506287|506334|506364|506384|506320|506319|506344|506294|506283|506342|506282|506421|506393|506343|506439|506373|536783|549685|506367|506303|506254|506413|533922|516611|506337|506397|506398|506213|506277|506278|506279|506280|506377|511852|506422|506312|506441|506399|537938|506427|510586|538405|538088|506214|506215|506356|528480|506389|506351|506300|506354|506253|546378|516415|506309|533987|545290|545325|506311|506365|506380|506407|557920|557921|557922|557923|557924|506412|528598|531294|549672|506391|506428|511765|543924|506449|526400|551353|506405|506406|230884|230948|230951|557910|557909|557908|557907|557905|506217|545730|506218|589617|557906|517747|554628|504563|529093|517771|557991|551077|557561|550233|533609|551244|554627|504536|557875|557874|529028|525678|524711|520698|520694|520416|520116|517795|517721|517712|558426|554492|551081|517439|517440|549613|506228|557551|530686|518847|526424|516594|511114|506340|506270|506229|539177|559471|557671|511391|536324|543451|528514|538756|506458|555691)',
+ ],
+ 'card_number' => [
+ 'length' => 16,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'back',
+ 'length' => 3,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/debmaster.gif',
+ ],
+ 1 => [
+ 'accreditation_time' => 2880,
+ 'additional_info_needed' => [
+ 0 => 'cardholder_name',
+ ],
+ 'deferred_capture' => 'supported',
+ 'financial_institutions' => [],
+ 'id' => 'amex',
+ 'max_allowed_amount' => 300000,
+ 'min_allowed_amount' => 1,
+ 'name' => 'American Express',
+ 'payment_type_id' => 'credit_card',
+ 'payment_places' => [],
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/amex.gif',
+ 'settings' => [
+ 0 => [
+ 'bin' => [
+ 'exclusion_pattern' => NULL,
+ 'installments_pattern' => '^(?!341595|3603(2|4)|360732|36075(5|6)|360935|37159(3|5)|3747((5(8|9))|(62))|3751(3([0-9])|7(7|8))|3764((0([0-9]))|(1([0-8]))|(2(2|8|9))|(3(6|7))|(4[0-9]|5[0-8])|(6([1-7])|7[0-8]|8[0-9]|9(1|3)))|37652(0|9)|37660((1|2)|[5-9])|376((6(2[0-9]|3[5-9]|8[5-8]))|71[0-4])|3771(69|74)|37779[0-8]|3778(0[2-6]|1[3-6]|20)|37782(5|6)|3799(6[6-8]|7(5|7)))',
+ 'pattern' => '^((34)|(37))',
+ ],
+ 'card_number' => [
+ 'length' => 15,
+ 'validation' => 'standard',
+ ],
+ 'security_code' => [
+ 'card_location' => 'front',
+ 'length' => 4,
+ 'mode' => 'mandatory',
+ ],
+ ],
+ ],
+ 'status' => 'active',
+ 'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/amex.gif',
+ ],
+ 2 => [
+ 'accreditation_time' => 0,
+ 'additional_info_needed' => [
+ 0 => 'identification_type',
+ 1 => 'identification_number',
+ 2 => 'entity_type',
+ ],
+ 'deferred_capture' => 'unsupported',
+ 'financial_institutions' => [],
+ 'id' => 'paycash',
+ 'max_allowed_amount' => 60000,
+ 'min_allowed_amount' => 20,
+ 'name' => 'PayCash',
+ 'payment_type_id' => 'ticket',
+ 'processing_modes' => [
+ 0 => 'aggregator',
+ ],
+ 'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
+ 'settings' => [],
+ 'status' => 'testing',
+ 'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
+ ],
+ ],
+ 'status' => 200,
+ ];
+}
diff --git a/src/MercadoPago/Test/Unit/Constants/Response.php b/src/MercadoPago/Test/Unit/Constants/Response.php
index c19a40e6..46cea22b 100644
--- a/src/MercadoPago/Test/Unit/Constants/Response.php
+++ b/src/MercadoPago/Test/Unit/Constants/Response.php
@@ -2,7 +2,7 @@
namespace MercadoPago\Test\Unit\Constants;
-class Response
+class Response
{
public const RESPONSE_PAYMENT_METHODS_SUCCESS = [
@@ -13,8 +13,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'debmaster',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
@@ -51,8 +50,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'amex',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 1,
@@ -89,8 +87,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'master',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
@@ -127,8 +124,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'debvisa',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
@@ -165,8 +161,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'toka',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
@@ -203,8 +198,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'tengo',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
@@ -241,8 +235,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'edenred',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
@@ -279,8 +272,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'sodexo',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
@@ -317,8 +309,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'carnet',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
@@ -328,8 +319,7 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
],
@@ -339,8 +329,7 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'visa',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
@@ -379,8 +368,7 @@ class Response
2 => 'entity_type',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'paycash',
'max_allowed_amount' => 60000,
'min_allowed_amount' => 20,
@@ -390,15 +378,13 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
],
11 => [
'accreditation_time' => 1,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
'financial_institutions' => [
0 => [
@@ -415,18 +401,15 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/clabe.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/clabe.gif',
],
12 => [
'accreditation_time' => 0,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'meliplace',
'max_allowed_amount' => 10000,
'min_allowed_amount' => 10,
@@ -436,18 +419,15 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/xxxxx.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/xxxxx.gif',
],
13 => [
'accreditation_time' => 60,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'banamex',
'max_allowed_amount' => 40000,
'min_allowed_amount' => 5,
@@ -457,18 +437,15 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/banamex.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/banamex.gif',
],
14 => [
'accreditation_time' => 60,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'bancomer',
'max_allowed_amount' => 40000,
'min_allowed_amount' => 10,
@@ -478,18 +455,15 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/bancomer.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/bancomer.gif',
],
15 => [
'accreditation_time' => 60,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'serfin',
'max_allowed_amount' => 40000,
'min_allowed_amount' => 5,
@@ -499,18 +473,15 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/serfin.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/serfin.gif',
],
16 => [
'accreditation_time' => 2880,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'oxxo',
'max_allowed_amount' => 10000,
'min_allowed_amount' => 5,
@@ -520,8 +491,7 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/oxxo.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/oxxo.gif',
],
@@ -537,14 +507,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'debmaster',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
'name' => 'Mastercard Débito',
'payment_type_id' => 'debit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -576,14 +545,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'amex',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 1,
'name' => 'American Express',
'payment_type_id' => 'credit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -615,14 +583,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'master',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
'name' => 'Mastercard',
'payment_type_id' => 'credit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -654,14 +621,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'debvisa',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
'name' => 'Visa Débito',
'payment_type_id' => 'debit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -693,14 +659,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'toka',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
'name' => 'Toka',
'payment_type_id' => 'debit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -732,14 +697,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'tengo',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
'name' => 'Tengo',
'payment_type_id' => 'debit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -771,14 +735,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'edenred',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
'name' => 'Edenred',
'payment_type_id' => 'debit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -810,14 +773,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'sodexo',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
'name' => 'Sodexo',
'payment_type_id' => 'debit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -849,20 +811,18 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'carnet',
'max_allowed_amount' => 200000,
'min_allowed_amount' => 5,
'name' => 'Carnet',
'payment_type_id' => 'credit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'https://http2.mlstatic.com/storage/logos-api-admin/14b2cb40-e3bc-11ea-a26c-a3e05eb53570-m@2x.png',
],
@@ -872,14 +832,13 @@ class Response
0 => 'cardholder_name',
],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'visa',
'max_allowed_amount' => 300000,
'min_allowed_amount' => 5,
'name' => 'Visa',
'payment_type_id' => 'credit_card',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
@@ -913,8 +872,7 @@ class Response
2 => 'entity_type',
],
'deferred_capture' => 'unsupported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'paycash',
'max_allowed_amount' => 60000,
'min_allowed_amount' => 20,
@@ -956,15 +914,13 @@ class Response
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/paycash.gif',
],
11 => [
'accreditation_time' => 1,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
'financial_institutions' => [
0 => [
@@ -977,123 +933,107 @@ class Response
'min_allowed_amount' => 1,
'name' => 'STP',
'payment_type_id' => 'bank_transfer',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/clabe.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/clabe.gif',
],
12 => [
'accreditation_time' => 0,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'supported',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'meliplace',
'max_allowed_amount' => 10000,
'min_allowed_amount' => 10,
'name' => 'Meliplaces',
'payment_type_id' => 'ticket',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/xxxxx.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'testing',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/xxxxx.gif',
],
13 => [
'accreditation_time' => 60,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'banamex',
'max_allowed_amount' => 40000,
'min_allowed_amount' => 5,
'name' => 'Citibanamex',
'payment_type_id' => 'atm',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/banamex.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/banamex.gif',
],
14 => [
'accreditation_time' => 60,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'bancomer',
'max_allowed_amount' => 40000,
'min_allowed_amount' => 10,
'name' => 'BBVA Bancomer',
'payment_type_id' => 'atm',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/bancomer.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/bancomer.gif',
],
15 => [
'accreditation_time' => 60,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'serfin',
'max_allowed_amount' => 40000,
'min_allowed_amount' => 5,
'name' => 'Santander',
'payment_type_id' => 'atm',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/serfin.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/serfin.gif',
],
16 => [
'accreditation_time' => 2880,
- 'additional_info_needed' => [
- ],
+ 'additional_info_needed' => [],
'deferred_capture' => 'does_not_apply',
- 'financial_institutions' => [
- ],
+ 'financial_institutions' => [],
'id' => 'oxxo',
'max_allowed_amount' => 10000,
'min_allowed_amount' => 5,
'name' => 'OXXO',
'payment_type_id' => 'ticket',
- 'payment_places' => [ ],
+ 'payment_places' => [],
'processing_modes' => [
0 => 'aggregator',
],
'secure_thumbnail' => 'https://www.mercadopago.com/org-img/MP3/API/logos/oxxo.gif',
- 'settings' => [
- ],
+ 'settings' => [],
'status' => 'active',
'thumbnail' => 'http://img.mlstatic.com/org-img/MP3/API/logos/oxxo.gif',
],
@@ -1102,8 +1042,7 @@ class Response
];
public const RESPONSE_PAYMENT_METHODS_FAILURE = [
- 'response' => [ ],
+ 'response' => [],
'status' => 401,
];
-
-}
\ No newline at end of file
+}
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
index 01912951..8ef21f7b 100644
--- a/src/MercadoPago/Test/Unit/Helper/DataTest.php
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -41,12 +41,12 @@ class DataTest extends TestCase
* @var MockObject
*/
private $paymentMethodFactory;
-
+
/**
* @var MockObject
*/
private $appEmulation;
-
+
/**
* @var MockObject
*/
@@ -76,12 +76,12 @@ class DataTest extends TestCase
* @var MockObject
*/
private $switcher;
-
+
/**
* @var MockObject
*/
private $composerInformation;
-
+
/**
* @var MockObject
*/
@@ -104,7 +104,7 @@ protected function setUp(): void
$context = $arguments['context'];
$this->scopeConfig = $context->getScopeConfig();
$this->layoutFactory = $arguments['layoutFactory'];
-
+
$this->messageInterface = $arguments['messageInterface'];
$this->mpCache = $arguments['mpCache'];
@@ -133,9 +133,9 @@ public function testGetMercadoPagoPaymentMethods_successResponse_returnArrayWith
];
$this->api->expects($this->once())
- ->method('get')
- ->with($uri)
- ->willReturn($payment_methods);
+ ->method('get')
+ ->with($uri)
+ ->willReturn($payment_methods);
$this->assertEquals($expected_payment_methods, $this->helper->getMercadoPagoPaymentMethods($accesstoken));
}
@@ -148,10 +148,10 @@ public function testGetMercadoPagoPaymentMethods_exception_returnEmpty(): void
];
$this->api->expects($this->once())
- ->method('get')
- ->with($uri)
- ->willReturn(null);
+ ->method('get')
+ ->with($uri)
+ ->willReturn(null);
$this->assertEquals([], $this->helper->getMercadoPagoPaymentMethods($accesstoken));
}
-}
\ No newline at end of file
+}
diff --git a/src/MercadoPago/Test/Unit/Lib/ApiTest.php b/src/MercadoPago/Test/Unit/Lib/ApiTest.php
new file mode 100644
index 00000000..86f110ce
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Lib/ApiTest.php
@@ -0,0 +1,47 @@
+api = $this->getMockBuilder(Api::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ /**
+ * @dataProvider sandboxProvider
+ */
+ public function testSandboxMode($functionParam, $expected): void
+ {
+ $this->assertEquals($expected, $this->api->sandbox_mode($functionParam));
+ }
+
+ public function sandboxProvider(): array
+ {
+ return [
+ [false, false],
+ [null, false],
+ [true, true],
+ ];
+ }
+
+}
diff --git a/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php b/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
new file mode 100644
index 00000000..248aa4ad
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
@@ -0,0 +1,235 @@
+getConstructArguments($className);
+
+ $this->context = $arguments['context'];
+ $this->coreHelper = $arguments['coreHelper'];
+ $this->assetRepo = $arguments['assetRepo'];
+ $this->checkoutSession = $arguments['checkoutSession'];
+ $this->paymentHelper = $arguments['paymentHelper'];
+ $this->scopeConfig = $arguments['scopeConfig'];
+ $this->productMetadata = $arguments['productMetadata'];
+
+ $this->abstractMethodMock = $this->getMockBuilder(AbstractMethod::class)
+ ->setMethods(['isAvailable'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->paymentHelper
+ ->expects($this->any())
+ ->method('getMethodInstance')
+ ->willReturn($this->abstractMethodMock);
+
+ $this->basicConfigProvider = $objectManagerHelper->getObject($className, $arguments);
+ }
+
+ public function testGetConfig_successfulExecution_returnArray(): void
+ {
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(true);
+
+ $this->scopeConfig->expects($this->any())
+ ->method('getValue')
+ ->willReturnArgument(0);
+
+ $this->assetRepo->expects($this->any())
+ ->method('getUrl')
+ ->willReturnArgument(0);
+
+ $this->coreHelper->expects($this->once())
+ ->method('getModuleversion')
+ ->willReturn('module_version');
+
+ $this->coreHelper->expects($this->once())
+ ->method('getFingerPrintLink')
+ ->willReturn('fingerprint_link');
+
+ $this->productMetadata->expects($this->once())
+ ->method('getVersion')
+ ->willReturn('magento2');
+
+ $expectedReturn = [
+ 'payment' => [
+ \MercadoPago\Core\Model\Basic\Payment::CODE => [
+ 'active' => 'payment/mercadopago_basic/active',
+ 'logEnabled' => 'payment/mercadopago/logs',
+ 'max_installments' => 'payment/mercadopago_basic/max_installments',
+ 'auto_return' => 'payment/mercadopago_basic/auto_return',
+ 'exclude_payments' => 'payment/mercadopago_basic/excluded_payment_methods',
+ 'order_status' => 'payment/mercadopago_basic/order_status',
+ 'logoUrl' => 'MercadoPago_Core::images/mp_logo.png',
+ 'actionUrl' => null,
+ 'banner_info' => null,
+ 'loading_gif' => 'MercadoPago_Core::images/loading.gif',
+ 'redirect_image' => 'MercadoPago_Core::images/redirect_checkout.png',
+ 'module_version' => 'module_version',
+ 'platform_version' => 'magento2',
+ 'mercadopago_mini' => 'MercadoPago_Core::images/mercado-pago-mini.png',
+ 'fingerprint_link' => 'fingerprint_link',
+ ],
+ ],
+ ];
+
+ $this->assertEquals($expectedReturn, $this->basicConfigProvider->getConfig());
+ }
+
+ public function testGetConfig_exceptionExecution_returnEmpty(): void
+ {
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->will($this->throwException(new \Exception()));
+
+ $this->assertEquals([], $this->basicConfigProvider->getConfig());
+ }
+
+ public function testGetConfig_methodInstanceNotAvailable_returnEmpty(): void
+ {
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(false);
+
+ $this->assertEquals([], $this->basicConfigProvider->getConfig());
+ }
+
+ public function testMakeBannerCheckout_successExecution_returnArray(): void
+ {
+ $valueMap = [
+ [ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_STORE, null, 'some_access_token'],
+ [ConfigData::PATH_BASIC_MAX_INSTALLMENTS, ScopeInterface::SCOPE_STORE, null, 2],
+ [ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE, null, '']
+ ];
+
+ $this->scopeConfig
+ ->method('getValue')
+ ->will($this->returnValueMap($valueMap));
+
+ $this->coreHelper->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
+
+ $expectedOutput = [
+ "debit" => 1,
+ "credit" => 1,
+ "ticket" => 1,
+ "installments" => 2,
+ "checkout_methods" => ConfigProviderConstants::PAYMENT_METHODS['response'],
+ ];
+
+ $this->assertEquals($expectedOutput, $this->basicConfigProvider->makeBannerCheckout());
+ }
+
+ public function testMakeBannerCheckout_successExcludeMethod_returnArray(): void
+ {
+ $valueMap = [
+ [ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_STORE, null, 'some_access_token'],
+ [ConfigData::PATH_BASIC_MAX_INSTALLMENTS, ScopeInterface::SCOPE_STORE, null, 1],
+ [ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE, null, 'paycash,amex']
+ ];
+
+
+ $this->scopeConfig
+ ->method('getValue')
+ ->will($this->returnValueMap($valueMap));
+
+ echo "\n";
+ echo $this->scopeConfig->getValue(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_STORE);
+ echo "\n";
+ echo $this->scopeConfig->getValue(ConfigData::PATH_BASIC_MAX_INSTALLMENTS, ScopeInterface::SCOPE_STORE);
+ echo "\n";
+ echo $this->scopeConfig->getValue(ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE);
+ echo "\n";
+
+ $this->coreHelper->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
+
+ $expectedOutput = [
+ "debit" => 1,
+ "credit" => 0,
+ "ticket" => 0,
+ "installments" => 1,
+ "checkout_methods" => [
+ 0 => ConfigProviderConstants::PAYMENT_METHODS['response'][0]
+ ],
+ ];
+
+ $this->assertEquals($expectedOutput, $this->basicConfigProvider->makeBannerCheckout());
+ }
+
+ public function testMakeBannerCheckout_exceptionExecution_returnNull(): void
+ {
+ $this->coreHelper->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->will($this->throwException(new \Exception()));
+
+ $this->assertEquals(null, $this->basicConfigProvider->makeBannerCheckout());
+ }
+}
From 5ac3e9b7318dbe82a386fa09cd7509c0cf395995 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Mon, 22 Nov 2021 13:54:17 -0300
Subject: [PATCH 22/75] testing PaymentMethodsTicket
---
.../Config/Source/PaymentMethodsTicket.php | 99 -------------------
.../Test/Unit/Constants/Config.php | 8 ++
.../Test/Unit/Constants/PaymentMethods.php | 47 +++++++++
src/MercadoPago/Test/Unit/Helper/DataTest.php | 25 ++---
src/MercadoPago/Test/Unit/Model/CoreTest.php | 41 ++++++++
.../Unit/Model/PaymentMethodsTicketTest.php | 74 ++++++++++++++
6 files changed, 177 insertions(+), 117 deletions(-)
delete mode 100644 src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
create mode 100644 src/MercadoPago/Test/Unit/Constants/Config.php
create mode 100644 src/MercadoPago/Test/Unit/Constants/PaymentMethods.php
create mode 100644 src/MercadoPago/Test/Unit/Model/CoreTest.php
create mode 100644 src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php
diff --git a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php b/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
deleted file mode 100644
index 526a14e0..00000000
--- a/src/MercadoPago/Core/Model/System/Config/Source/PaymentMethodsTicket.php
+++ /dev/null
@@ -1,99 +0,0 @@
-scopeConfig = $scopeConfig;
- $this->coreHelper = $coreHelper;
- $this->_switcher = $switcher;
- } //end __construct()
-
-
- /**
- * Return available payment methods
- *
- * @return array
- */
- public function toOptionArray()
- {
- $methods = [];
-
- // default empty value
- $methods[] = [
- 'value' => '',
- 'label' => __('Accept all payment methods'),
- ];
- $accessToken = $this->scopeConfig->getValue(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_WEBSITE, $this->_switcher->getWebsiteId());
-
- if (empty($accessToken)) {
- return $methods;
- }
-
- try {
- $response = $this->coreHelper->getMercadoPagoPaymentMethods($accessToken);
- } catch (Exception $e) {
- $this->coreHelper->log('PaymentMethodsTicket:: An error occurred at the time of obtaining the ticket payment methods: ' . $e);
- return [];
- }
-
- if (isset($response['error']) || (isset($response['status']) && ($response['status'] != '200' && $response['status'] != '201'))) {
- return $methods;
- }
-
- $response = $response['response'];
-
- foreach ($response as $pm) {
- if ((isset($pm['payment_type_id']) && $pm['payment_type_id'] == 'ticket') || $pm['payment_type_id'] == 'atm') {
- $methods[] = [
- 'value' => $pm['id'],
- 'label' => __($pm['name']),
- ];
- }
- }
-
- $this->coreHelper->log('PaymentMethodsTicket:: Displayed', 'mercadopago', $methods);
-
- return $methods;
- } //end toOptionArray()
-}//end class
diff --git a/src/MercadoPago/Test/Unit/Constants/Config.php b/src/MercadoPago/Test/Unit/Constants/Config.php
new file mode 100644
index 00000000..fe95fd26
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Constants/Config.php
@@ -0,0 +1,8 @@
+ '',
+ 'label' => 'Accept all payment methods',
+ ],
+ [
+ 'value' => 'paycash',
+ 'label' => 'PayCash (7 Eleven, Circle K, Soriana, Extra, Calimax)',
+ ],
+ [
+ 'value' => 'meliplace',
+ 'label' => 'Meliplaces',
+ ],
+ [
+ 'value' => 'banamex',
+ 'label' => 'Citibanamex',
+ ],
+ [
+ 'value' => 'bancomer',
+ 'label' => 'BBVA Bancomer',
+ ],
+ [
+ 'value' => 'serfin',
+ 'label' => 'Santander',
+ ],
+ [
+ 'value' => 'oxxo',
+ 'label' => 'OXXO',
+ ],
+ ];
+
+ public const EMPTY_PAYMENT_METHODS = [
+ 0 => [
+ 'value' => '',
+ 'label' => 'Accept all payment methods',
+ ]
+ ];
+
+ public const PAYMENT_METHODS_URI = '/v1/payment_methods';
+}
\ No newline at end of file
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
index 62a11957..6efb7ea6 100644
--- a/src/MercadoPago/Test/Unit/Helper/DataTest.php
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -4,7 +4,9 @@
use MercadoPago\Core\Helper\Data;
use MercadoPago\Core\Lib\Api;
+use MercadoPago\Test\Unit\Constants\Config;
use MercadoPago\Test\Unit\Constants\Response;
+use MercadoPago\Test\Unit\Constants\PaymentMethods;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\TestCase;
@@ -125,34 +127,21 @@ protected function setUp(): void
public function testGetMercadoPagoPaymentMethods_successResponse_returnArrayWithPaymentPlaces(): void
{
- list($accesstoken, $payment_methods, $expected_payment_methods, $uri) = [
- 'APP_USR-00000000000-000000-000000-0000000000',
- Response::RESPONSE_PAYMENT_METHODS_SUCCESS,
- Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES,
- '/v1/payment_methods',
- ];
-
$this->api->expects($this->once())
->method('get')
- ->with($uri)
- ->willReturn($payment_methods);
+ ->with(PaymentMethods::PAYMENT_METHODS_URI)
+ ->willReturn(Response::RESPONSE_PAYMENT_METHODS_SUCCESS);
- $this->assertEquals($expected_payment_methods, $this->helper->getMercadoPagoPaymentMethods($accesstoken));
+ $this->assertEquals(Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES, $this->helper->getMercadoPagoPaymentMethods(Config::ACCESS_TOKEN));
}
public function testGetMercadoPagoPaymentMethods_exception_returnEmpty(): void
{
- list($accesstoken, $uri) = [
- 'APP-ACCESSTOKEN-TEST',
- '/v1/payment_methods',
- ];
-
$this->api->expects($this->once())
->method('get')
- ->with($uri)
+ ->with(PaymentMethods::PAYMENT_METHODS_URI)
->willReturn(null);
- $this->expectException(Exception::class);
- $response = $this->helper->getMercadoPagoPaymentMethods($accesstoken);
+ $this->assertEquals([], $this->helper->getMercadoPagoPaymentMethods(Config::ACCESS_TOKEN));
}
}
\ No newline at end of file
diff --git a/src/MercadoPago/Test/Unit/Model/CoreTest.php b/src/MercadoPago/Test/Unit/Model/CoreTest.php
new file mode 100644
index 00000000..a61486c6
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Model/CoreTest.php
@@ -0,0 +1,41 @@
+getConstructArguments($className);
+ $this->scopeConfig = $arguments['scopeConfig'];
+ $this->coreHelper = $arguments['coreHelper'];
+ $this->switcher = $arguments['switcher'];
+
+ $this->helper = $objectManagerHelper->getObject($className, $arguments);
+ }
+}
\ No newline at end of file
diff --git a/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php b/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php
new file mode 100644
index 00000000..baf07bd8
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php
@@ -0,0 +1,74 @@
+getConstructArguments($className);
+ $this->scopeConfig = $arguments['scopeConfig'];
+ $this->coreHelper = $arguments['coreHelper'];
+ $this->switcher = $arguments['switcher'];
+
+ $this->helper = $objectManagerHelper->getObject($className, $arguments);
+ }
+
+ public function testToOptionArray_success_returnArrayWithoutMethods(): void
+ {
+ $this->scopeConfig->expects(self::any())->method('getValue')
+ ->with(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_WEBSITE, $this->switcher->getWebsiteId())
+ ->willReturn('');
+
+ $this->assertEquals(PaymentMethods::EMPTY_PAYMENT_METHODS, $this->helper->toOptionArray());
+ }
+
+ public function testToOptionArray_success_returnArrayWithMethods(): void
+ {
+ $this->scopeConfig->expects(self::any())->method('getValue')
+ ->with(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_WEBSITE, $this->switcher->getWebsiteId())
+ ->willReturn(Config::ACCESS_TOKEN);
+
+ $this->coreHelper->expects(self::any())->method('getMercadoPagoPaymentMethods')
+ ->with(Config::ACCESS_TOKEN)
+ ->willReturn(Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES);
+
+ $this->assertEquals(PaymentMethods::PAYMENT_METHODS_SUCCESS, $this->helper->toOptionArray());
+ }
+}
\ No newline at end of file
From 87433e09346f1e97e2f3cfcd0bd8d175d390268b Mon Sep 17 00:00:00 2001
From: Gustavo Brito
Date: Tue, 23 Nov 2021 10:53:23 -0300
Subject: [PATCH 23/75] feat(ppwp-377): testing custom config provider
---
src/MercadoPago/Test/Unit/Lib/ApiTest.php | 4 +-
.../Unit/Model/BasicConfigProviderTest.php | 66 +++--
.../Unit/Model/CustomConfigProviderTest.php | 261 ++++++++++++++++++
3 files changed, 303 insertions(+), 28 deletions(-)
create mode 100644 src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php
diff --git a/src/MercadoPago/Test/Unit/Lib/ApiTest.php b/src/MercadoPago/Test/Unit/Lib/ApiTest.php
index 86f110ce..e900db17 100644
--- a/src/MercadoPago/Test/Unit/Lib/ApiTest.php
+++ b/src/MercadoPago/Test/Unit/Lib/ApiTest.php
@@ -22,9 +22,7 @@ class ApiTest extends TestCase
*/
protected function setUp(): void
{
- $this->api = $this->getMockBuilder(Api::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->api = new Api($default_access_token);
}
/**
diff --git a/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php b/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
index 248aa4ad..f2270aa7 100644
--- a/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
+++ b/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
@@ -1,17 +1,18 @@
scopeConfig = $arguments['scopeConfig'];
$this->productMetadata = $arguments['productMetadata'];
- $this->abstractMethodMock = $this->getMockBuilder(AbstractMethod::class)
+ $this->abstractMethod = $this->getMockBuilder(AbstractMethod::class)
->setMethods(['isAvailable'])
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -85,14 +91,29 @@ protected function setUp(): void
$this->paymentHelper
->expects($this->any())
->method('getMethodInstance')
- ->willReturn($this->abstractMethodMock);
+ ->willReturn($this->abstractMethod);
+
+ $this->url = $this->getMockBuilder(UrlInterface::class)
+ ->setMethods(['getUrl'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->context = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $arguments['context'] = $this->context;
+
+ $this->context->expects($this->any())
+ ->method('getUrl')
+ ->willReturn($this->url);
$this->basicConfigProvider = $objectManagerHelper->getObject($className, $arguments);
}
public function testGetConfig_successfulExecution_returnArray(): void
{
- $this->abstractMethodMock->expects($this->once())
+ $this->abstractMethod->expects($this->once())
->method('isAvailable')
->willReturn(true);
@@ -104,6 +125,10 @@ public function testGetConfig_successfulExecution_returnArray(): void
->method('getUrl')
->willReturnArgument(0);
+ $this->url->expects($this->once())
+ ->method('getUrl')
+ ->willReturn('action_url');
+
$this->coreHelper->expects($this->once())
->method('getModuleversion')
->willReturn('module_version');
@@ -119,14 +144,14 @@ public function testGetConfig_successfulExecution_returnArray(): void
$expectedReturn = [
'payment' => [
\MercadoPago\Core\Model\Basic\Payment::CODE => [
- 'active' => 'payment/mercadopago_basic/active',
- 'logEnabled' => 'payment/mercadopago/logs',
- 'max_installments' => 'payment/mercadopago_basic/max_installments',
- 'auto_return' => 'payment/mercadopago_basic/auto_return',
- 'exclude_payments' => 'payment/mercadopago_basic/excluded_payment_methods',
- 'order_status' => 'payment/mercadopago_basic/order_status',
+ 'active' => ConfigData::PATH_BASIC_ACTIVE,
+ 'logEnabled' => ConfigData::PATH_ADVANCED_LOG,
+ 'max_installments' => ConfigData::PATH_BASIC_MAX_INSTALLMENTS,
+ 'auto_return' => ConfigData::PATH_BASIC_AUTO_RETURN,
+ 'exclude_payments' => ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS,
+ 'order_status' => ConfigData::PATH_BASIC_ORDER_STATUS,
'logoUrl' => 'MercadoPago_Core::images/mp_logo.png',
- 'actionUrl' => null,
+ 'actionUrl' => 'action_url',
'banner_info' => null,
'loading_gif' => 'MercadoPago_Core::images/loading.gif',
'redirect_image' => 'MercadoPago_Core::images/redirect_checkout.png',
@@ -143,7 +168,7 @@ public function testGetConfig_successfulExecution_returnArray(): void
public function testGetConfig_exceptionExecution_returnEmpty(): void
{
- $this->abstractMethodMock->expects($this->once())
+ $this->abstractMethod->expects($this->once())
->method('isAvailable')
->will($this->throwException(new \Exception()));
@@ -152,7 +177,7 @@ public function testGetConfig_exceptionExecution_returnEmpty(): void
public function testGetConfig_methodInstanceNotAvailable_returnEmpty(): void
{
- $this->abstractMethodMock->expects($this->once())
+ $this->abstractMethod->expects($this->once())
->method('isAvailable')
->willReturn(false);
@@ -194,18 +219,9 @@ public function testMakeBannerCheckout_successExcludeMethod_returnArray(): void
[ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE, null, 'paycash,amex']
];
-
$this->scopeConfig
->method('getValue')
->will($this->returnValueMap($valueMap));
-
- echo "\n";
- echo $this->scopeConfig->getValue(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_STORE);
- echo "\n";
- echo $this->scopeConfig->getValue(ConfigData::PATH_BASIC_MAX_INSTALLMENTS, ScopeInterface::SCOPE_STORE);
- echo "\n";
- echo $this->scopeConfig->getValue(ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE);
- echo "\n";
$this->coreHelper->expects($this->once())
->method('getMercadoPagoPaymentMethods')
@@ -230,6 +246,6 @@ public function testMakeBannerCheckout_exceptionExecution_returnNull(): void
->method('getMercadoPagoPaymentMethods')
->will($this->throwException(new \Exception()));
- $this->assertEquals(null, $this->basicConfigProvider->makeBannerCheckout());
+ $this->assertEquals(null, $this->basicConfigProvider->makeBannerCheckout());
}
}
diff --git a/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php b/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php
new file mode 100644
index 00000000..dc625d1e
--- /dev/null
+++ b/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php
@@ -0,0 +1,261 @@
+getConstructArguments($className);
+
+ $this->paymentHelper = $arguments['paymentHelper'];
+ $this->coreHelper = $arguments['coreHelper'];
+ $this->checkoutSession = $arguments['checkoutSession'];
+ $this->assetRepo = $arguments['assetRepo'];
+ $this->storeManager = $arguments['storeManager'];
+ $this->scopeConfig = $arguments['scopeConfig'];
+ $this->productMetadata = $arguments['productMetadata'];
+
+ $this->abstractMethod = $this->getMockBuilder(AbstractMethod::class)
+ ->setMethods(['isAvailable', 'getCustomerAndCards', 'getConfigData'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->paymentHelper->expects($this->any())
+ ->method('getMethodInstance')
+ ->willReturn($this->abstractMethod);
+
+ $this->storeInterface = $this->getMockBuilder(StoreInterface::class)
+ ->setMethods(['getBaseUrl'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->storeManager->expects($this->any())
+ ->method('getStore')
+ ->willReturn($this->storeInterface);
+
+ $this->quote = $this->getMockBuilder(Quote::class)
+ ->setMethods(['getGrandTotal'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->checkoutSession->expects($this->any())
+ ->method('getQuote')
+ ->willReturn($this->quote);
+
+ $this->request = $this->getMockBuilder(RequestInterface::class)
+ ->setMethods(['getRouteName'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->context = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $arguments['context'] = $this->context;
+
+ $this->context->expects($this->any())
+ ->method('getRequest')
+ ->willReturn($this->request);
+
+ $this->customConfigProvider = $objectManagerHelper->getObject($className, $arguments);
+ }
+
+ public function testGetConfig_successfulExecution_returnArray(): void
+ {
+ $this->abstractMethod->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(true);
+
+ $this->abstractMethod->expects($this->once())
+ ->method('getCustomerAndCards')
+ ->willReturn('customer_and_cards');
+
+ $this->abstractMethod->expects($this->once())
+ ->method('getConfigData')
+ ->willReturn('success_url');
+
+ $this->scopeConfig->expects($this->any())
+ ->method('getValue')
+ ->willReturnArgument(0);
+
+ $this->assetRepo->expects($this->any())
+ ->method('getUrl')
+ ->willReturnArgument(0);
+
+ $this->storeInterface->expects($this->any())
+ ->method('getBaseUrl')
+ ->willReturn('base_url');
+
+ $this->quote->expects($this->any())
+ ->method('getGrandTotal')
+ ->willReturn('grand_total');
+
+ $this->request->expects($this->once())
+ ->method('getRouteName')
+ ->willReturn('route_name');
+
+ $this->coreHelper->expects($this->once())
+ ->method('getModuleversion')
+ ->willReturn('module_version');
+
+ $this->coreHelper->expects($this->once())
+ ->method('getWalletButtonLink')
+ ->willReturn('wallet_button_link');
+
+ $this->coreHelper->expects($this->once())
+ ->method('getFingerPrintLink')
+ ->willReturn('fingerprint_link');
+
+ $this->coreHelper->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(null);
+
+ $this->productMetadata->expects($this->once())
+ ->method('getVersion')
+ ->willReturn('magento2');
+
+ $expectedReturn = [
+ 'payment' => [
+ \MercadoPago\Core\Model\Custom\Payment::CODE => [
+ 'bannerUrl' => ConfigData::PATH_CUSTOM_BANNER,
+ 'public_key' => ConfigData::PATH_PUBLIC_KEY,
+ 'logEnabled' => ConfigData::PATH_ADVANCED_LOG,
+ 'mp_gateway_mode' => ConfigData::PATH_CUSTOM_GATEWAY_MODE,
+ 'mp_wallet_button' => ConfigData::PATH_CUSTOM_WALLET_BUTTON,
+ 'country' => strtoupper(ConfigData::PATH_SITE_ID),
+ 'route' => "route_name",
+ 'logoUrl' => "MercadoPago_Core::images/mp_logo.png",
+ 'minilogo' => "MercadoPago_Core::images/minilogo.png",
+ 'gray_minilogo' => "MercadoPago_Core::images/gray_minilogo.png",
+ 'base_url' => 'base_url',
+ 'customer' => "customer_and_cards",
+ 'grand_total' => 'grand_total',
+ 'success_url' => "success_url",
+ 'loading_gif' => 'MercadoPago_Core::images/loading.gif',
+ 'text-choice' => __('Select'),
+ 'text-currency' => __('$'),
+ 'default-issuer' => __('Default issuer'),
+ 'module_version' => "module_version",
+ 'platform_version' => "magento2",
+ 'text-installment' => __('Enter the card number'),
+ 'wallet_button_link' => "wallet_button_link",
+ 'payment_methods' => null,
+ 'creditcard_mini' => "MercadoPago_Core::images/creditcard-mini.png",
+ 'fingerprint_link' => 'fingerprint_link',
+ ],
+ ],
+ ];
+
+ $this->assertEquals($expectedReturn, $this->customConfigProvider->getConfig());
+ }
+
+ public function testGetConfig_methodInstanceNotAvailable_returnEmpty(): void
+ {
+ $this->abstractMethod->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(false);
+
+ $this->assertEquals([], $this->customConfigProvider->getConfig());
+ }
+
+ public function testGetPaymentMethods_successExecution_returnCards(): void
+ {
+ $this->scopeConfig->expects($this->any())
+ ->method('getValue')
+ ->willReturnArgument(0);
+
+ $this->coreHelper->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
+
+ $expectedOutput = [
+ 0 => ConfigProviderConstants::PAYMENT_METHODS['response'][0],
+ 1 => ConfigProviderConstants::PAYMENT_METHODS['response'][1]
+ ];
+
+ $this->assertEquals($expectedOutput, $this->customConfigProvider->getPaymentMethods());
+ }
+}
From d7da28d7ba2311a96e9952855bc761c42071a5d5 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 23 Nov 2021 16:35:49 -0300
Subject: [PATCH 24/75] refactored constants
---
src/MercadoPago/Test/Unit/Constants/Config.php | 8 --------
src/MercadoPago/Test/Unit/Constants/PaymentMethods.php | 2 +-
2 files changed, 1 insertion(+), 9 deletions(-)
delete mode 100644 src/MercadoPago/Test/Unit/Constants/Config.php
diff --git a/src/MercadoPago/Test/Unit/Constants/Config.php b/src/MercadoPago/Test/Unit/Constants/Config.php
deleted file mode 100644
index fe95fd26..00000000
--- a/src/MercadoPago/Test/Unit/Constants/Config.php
+++ /dev/null
@@ -1,8 +0,0 @@
- [
+ [
'value' => '',
'label' => 'Accept all payment methods',
]
From 6d893f3d085d592c51479c5d7574987b8d13010b Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 23 Nov 2021 16:38:11 -0300
Subject: [PATCH 25/75] refactored model test classes
---
.../Unit/Model/BasicConfigProviderTest.php | 158 +++++++-------
src/MercadoPago/Test/Unit/Model/CoreTest.php | 41 ----
.../Unit/Model/CustomConfigProviderTest.php | 202 +++++++++---------
.../Unit/Model/PaymentMethodsTicketTest.php | 35 +--
4 files changed, 198 insertions(+), 238 deletions(-)
delete mode 100644 src/MercadoPago/Test/Unit/Model/CoreTest.php
diff --git a/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php b/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
index f2270aa7..29d14b21 100644
--- a/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
+++ b/src/MercadoPago/Test/Unit/Model/BasicConfigProviderTest.php
@@ -24,47 +24,47 @@ class BasicConfigProviderTest extends TestCase
/**
* @var MockObject
*/
- private $coreHelper;
+ private $coreHelperMock;
/**
* @var MockObject
*/
- private $context;
+ private $contextMock;
/**
* @var MockObject
*/
- private $assetRepo;
+ private $assetRepoMock;
/**
* @var MockObject
*/
- private $checkoutSession;
+ private $checkoutSessionMock;
/**
* @var MockObject
*/
- private $paymentHelper;
+ private $paymentHelperMock;
/**
* @var MockObject
*/
- private $scopeConfig;
+ private $scopeConfigMock;
/**
* @var MockObject
*/
- private $productMetadata;
+ private $productMetadataMock;
/**
* @var MockObject
*/
- private $abstractMethod;
+ private $abstractMethodMock;
/**
* @var MockObject
*/
- private $url;
+ private $urlMock;
/**
* @inheritdoc
@@ -75,71 +75,71 @@ protected function setUp(): void
$className = BasicConfigProvider::class;
$arguments = $objectManagerHelper->getConstructArguments($className);
- $this->context = $arguments['context'];
- $this->coreHelper = $arguments['coreHelper'];
- $this->assetRepo = $arguments['assetRepo'];
- $this->checkoutSession = $arguments['checkoutSession'];
- $this->paymentHelper = $arguments['paymentHelper'];
- $this->scopeConfig = $arguments['scopeConfig'];
- $this->productMetadata = $arguments['productMetadata'];
-
- $this->abstractMethod = $this->getMockBuilder(AbstractMethod::class)
- ->setMethods(['isAvailable'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
-
- $this->paymentHelper
- ->expects($this->any())
- ->method('getMethodInstance')
- ->willReturn($this->abstractMethod);
+ $this->contextMock = $arguments['context'];
+ $this->coreHelperMock = $arguments['coreHelper'];
+ $this->assetRepoMock = $arguments['assetRepo'];
+ $this->checkoutSessionMock = $arguments['checkoutSession'];
+ $this->paymentHelperMock = $arguments['paymentHelper'];
+ $this->scopeConfigMock = $arguments['scopeConfig'];
+ $this->productMetadataMock = $arguments['productMetadata'];
+
+ $this->abstractMethodMock = $this->getMockBuilder(AbstractMethod::class)
+ ->setMethods(['isAvailable'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->paymentHelperMock
+ ->expects($this->any())
+ ->method('getMethodInstance')
+ ->willReturn($this->abstractMethodMock);
- $this->url = $this->getMockBuilder(UrlInterface::class)
- ->setMethods(['getUrl'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
+ $this->urlMock = $this->getMockBuilder(UrlInterface::class)
+ ->setMethods(['getUrl'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
- $this->context = $this->getMockBuilder(Context::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->contextMock = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
- $arguments['context'] = $this->context;
+ $arguments['context'] = $this->contextMock;
- $this->context->expects($this->any())
- ->method('getUrl')
- ->willReturn($this->url);
+ $this->contextMock->expects($this->any())
+ ->method('getUrl')
+ ->willReturn($this->urlMock);
$this->basicConfigProvider = $objectManagerHelper->getObject($className, $arguments);
}
public function testGetConfig_successfulExecution_returnArray(): void
{
- $this->abstractMethod->expects($this->once())
- ->method('isAvailable')
- ->willReturn(true);
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(true);
- $this->scopeConfig->expects($this->any())
- ->method('getValue')
- ->willReturnArgument(0);
+ $this->scopeConfigMock->expects($this->any())
+ ->method('getValue')
+ ->willReturnArgument(0);
- $this->assetRepo->expects($this->any())
- ->method('getUrl')
- ->willReturnArgument(0);
+ $this->assetRepoMock->expects($this->any())
+ ->method('getUrl')
+ ->willReturnArgument(0);
- $this->url->expects($this->once())
- ->method('getUrl')
- ->willReturn('action_url');
+ $this->urlMock->expects($this->once())
+ ->method('getUrl')
+ ->willReturn('action_url');
- $this->coreHelper->expects($this->once())
- ->method('getModuleversion')
- ->willReturn('module_version');
+ $this->coreHelperMock->expects($this->once())
+ ->method('getModuleversion')
+ ->willReturn('module_version');
- $this->coreHelper->expects($this->once())
- ->method('getFingerPrintLink')
- ->willReturn('fingerprint_link');
+ $this->coreHelperMock->expects($this->once())
+ ->method('getFingerPrintLink')
+ ->willReturn('fingerprint_link');
- $this->productMetadata->expects($this->once())
- ->method('getVersion')
- ->willReturn('magento2');
+ $this->productMetadataMock->expects($this->once())
+ ->method('getVersion')
+ ->willReturn('magento2');
$expectedReturn = [
'payment' => [
@@ -168,18 +168,18 @@ public function testGetConfig_successfulExecution_returnArray(): void
public function testGetConfig_exceptionExecution_returnEmpty(): void
{
- $this->abstractMethod->expects($this->once())
- ->method('isAvailable')
- ->will($this->throwException(new \Exception()));
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->will($this->throwException(new \Exception()));
$this->assertEquals([], $this->basicConfigProvider->getConfig());
}
public function testGetConfig_methodInstanceNotAvailable_returnEmpty(): void
{
- $this->abstractMethod->expects($this->once())
- ->method('isAvailable')
- ->willReturn(false);
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(false);
$this->assertEquals([], $this->basicConfigProvider->getConfig());
}
@@ -192,13 +192,13 @@ public function testMakeBannerCheckout_successExecution_returnArray(): void
[ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE, null, '']
];
- $this->scopeConfig
- ->method('getValue')
- ->will($this->returnValueMap($valueMap));
+ $this->scopeConfigMock
+ ->method('getValue')
+ ->will($this->returnValueMap($valueMap));
- $this->coreHelper->expects($this->once())
- ->method('getMercadoPagoPaymentMethods')
- ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
+ $this->coreHelperMock->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
$expectedOutput = [
"debit" => 1,
@@ -219,13 +219,13 @@ public function testMakeBannerCheckout_successExcludeMethod_returnArray(): void
[ConfigData::PATH_BASIC_EXCLUDE_PAYMENT_METHODS, ScopeInterface::SCOPE_STORE, null, 'paycash,amex']
];
- $this->scopeConfig
- ->method('getValue')
- ->will($this->returnValueMap($valueMap));
+ $this->scopeConfigMock
+ ->method('getValue')
+ ->will($this->returnValueMap($valueMap));
- $this->coreHelper->expects($this->once())
- ->method('getMercadoPagoPaymentMethods')
- ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
+ $this->coreHelperMock->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
$expectedOutput = [
"debit" => 1,
@@ -242,9 +242,9 @@ public function testMakeBannerCheckout_successExcludeMethod_returnArray(): void
public function testMakeBannerCheckout_exceptionExecution_returnNull(): void
{
- $this->coreHelper->expects($this->once())
- ->method('getMercadoPagoPaymentMethods')
- ->will($this->throwException(new \Exception()));
+ $this->coreHelperMock->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->will($this->throwException(new \Exception()));
$this->assertEquals(null, $this->basicConfigProvider->makeBannerCheckout());
}
diff --git a/src/MercadoPago/Test/Unit/Model/CoreTest.php b/src/MercadoPago/Test/Unit/Model/CoreTest.php
deleted file mode 100644
index a61486c6..00000000
--- a/src/MercadoPago/Test/Unit/Model/CoreTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-getConstructArguments($className);
- $this->scopeConfig = $arguments['scopeConfig'];
- $this->coreHelper = $arguments['coreHelper'];
- $this->switcher = $arguments['switcher'];
-
- $this->helper = $objectManagerHelper->getObject($className, $arguments);
- }
-}
\ No newline at end of file
diff --git a/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php b/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php
index dc625d1e..919128ad 100644
--- a/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php
+++ b/src/MercadoPago/Test/Unit/Model/CustomConfigProviderTest.php
@@ -25,61 +25,61 @@ class CustomConfigProviderTest extends TestCase
/**
* @var MockObject
*/
- private $coreHelper;
+ private $coreHelperMock;
/**
* @var MockObject
*/
- private $request;
+ private $requestMock;
/**
* @var MockObject
*/
- private $context;
+ private $contextMock;
/**
* @var MockObject
*/
- private $assetRepo;
+ private $assetRepoMock;
/**
* @var MockObject
*/
- private $storeManager;
+ private $storeManagerMock;
/**
* @var MockObject
*/
- private $checkoutSession;
+ private $checkoutSessionMock;
/**
* @var MockObject
*/
- private $paymentHelper;
+ private $paymentHelperMock;
/**
* @var MockObject
*/
- private $scopeConfig;
+ private $scopeConfigMock;
/**
* @var MockObject
*/
- private $productMetadata;
+ private $productMetadataMock;
/**
* @var MockObject
*/
- private $abstractMethod;
+ private $abstractMethodMock;
/**
* @var MockObject
*/
- private $storeInterface;
+ private $storeInterfaceMock;
/**
* @var MockObject
*/
- private $quote;
+ private $quoteMock;
/**
* @inheritdoc
@@ -90,112 +90,112 @@ protected function setUp(): void
$className = CustomConfigProvider::class;
$arguments = $objectManagerHelper->getConstructArguments($className);
- $this->paymentHelper = $arguments['paymentHelper'];
- $this->coreHelper = $arguments['coreHelper'];
- $this->checkoutSession = $arguments['checkoutSession'];
- $this->assetRepo = $arguments['assetRepo'];
- $this->storeManager = $arguments['storeManager'];
- $this->scopeConfig = $arguments['scopeConfig'];
- $this->productMetadata = $arguments['productMetadata'];
+ $this->paymentHelperMock = $arguments['paymentHelper'];
+ $this->coreHelperMock = $arguments['coreHelper'];
+ $this->checkoutSessionMock = $arguments['checkoutSession'];
+ $this->assetRepoMock = $arguments['assetRepo'];
+ $this->storeManagerMock = $arguments['storeManager'];
+ $this->scopeConfigMock = $arguments['scopeConfig'];
+ $this->productMetadataMock = $arguments['productMetadata'];
- $this->abstractMethod = $this->getMockBuilder(AbstractMethod::class)
- ->setMethods(['isAvailable', 'getCustomerAndCards', 'getConfigData'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
+ $this->abstractMethodMock = $this->getMockBuilder(AbstractMethod::class)
+ ->setMethods(['isAvailable', 'getCustomerAndCards', 'getConfigData'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
- $this->paymentHelper->expects($this->any())
- ->method('getMethodInstance')
- ->willReturn($this->abstractMethod);
+ $this->paymentHelperMock->expects($this->any())
+ ->method('getMethodInstance')
+ ->willReturn($this->abstractMethodMock);
- $this->storeInterface = $this->getMockBuilder(StoreInterface::class)
- ->setMethods(['getBaseUrl'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
-
- $this->storeManager->expects($this->any())
- ->method('getStore')
- ->willReturn($this->storeInterface);
+ $this->storeInterfaceMock = $this->getMockBuilder(StoreInterface::class)
+ ->setMethods(['getBaseUrl'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->storeManagerMock->expects($this->any())
+ ->method('getStore')
+ ->willReturn($this->storeInterfaceMock);
- $this->quote = $this->getMockBuilder(Quote::class)
- ->setMethods(['getGrandTotal'])
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->checkoutSession->expects($this->any())
- ->method('getQuote')
- ->willReturn($this->quote);
+ $this->quoteMock = $this->getMockBuilder(Quote::class)
+ ->setMethods(['getGrandTotal'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->checkoutSessionMock->expects($this->any())
+ ->method('getQuote')
+ ->willReturn($this->quoteMock);
- $this->request = $this->getMockBuilder(RequestInterface::class)
- ->setMethods(['getRouteName'])
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
+ $this->requestMock = $this->getMockBuilder(RequestInterface::class)
+ ->setMethods(['getRouteName'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
- $this->context = $this->getMockBuilder(Context::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->contextMock = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
- $arguments['context'] = $this->context;
+ $arguments['context'] = $this->contextMock;
- $this->context->expects($this->any())
- ->method('getRequest')
- ->willReturn($this->request);
+ $this->contextMock->expects($this->any())
+ ->method('getRequest')
+ ->willReturn($this->requestMock);
$this->customConfigProvider = $objectManagerHelper->getObject($className, $arguments);
}
public function testGetConfig_successfulExecution_returnArray(): void
{
- $this->abstractMethod->expects($this->once())
- ->method('isAvailable')
- ->willReturn(true);
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(true);
- $this->abstractMethod->expects($this->once())
- ->method('getCustomerAndCards')
- ->willReturn('customer_and_cards');
+ $this->abstractMethodMock->expects($this->once())
+ ->method('getCustomerAndCards')
+ ->willReturn('customer_and_cards');
- $this->abstractMethod->expects($this->once())
- ->method('getConfigData')
- ->willReturn('success_url');
+ $this->abstractMethodMock->expects($this->once())
+ ->method('getConfigData')
+ ->willReturn('success_url');
- $this->scopeConfig->expects($this->any())
- ->method('getValue')
- ->willReturnArgument(0);
+ $this->scopeConfigMock->expects($this->any())
+ ->method('getValue')
+ ->willReturnArgument(0);
- $this->assetRepo->expects($this->any())
- ->method('getUrl')
- ->willReturnArgument(0);
+ $this->assetRepoMock->expects($this->any())
+ ->method('getUrl')
+ ->willReturnArgument(0);
- $this->storeInterface->expects($this->any())
- ->method('getBaseUrl')
- ->willReturn('base_url');
+ $this->storeInterfaceMock->expects($this->any())
+ ->method('getBaseUrl')
+ ->willReturn('base_url');
- $this->quote->expects($this->any())
- ->method('getGrandTotal')
- ->willReturn('grand_total');
+ $this->quoteMock->expects($this->any())
+ ->method('getGrandTotal')
+ ->willReturn('grand_total');
- $this->request->expects($this->once())
- ->method('getRouteName')
- ->willReturn('route_name');
+ $this->requestMock->expects($this->once())
+ ->method('getRouteName')
+ ->willReturn('route_name');
- $this->coreHelper->expects($this->once())
- ->method('getModuleversion')
- ->willReturn('module_version');
+ $this->coreHelperMock->expects($this->once())
+ ->method('getModuleversion')
+ ->willReturn('module_version');
- $this->coreHelper->expects($this->once())
- ->method('getWalletButtonLink')
- ->willReturn('wallet_button_link');
+ $this->coreHelperMock->expects($this->once())
+ ->method('getWalletButtonLink')
+ ->willReturn('wallet_button_link');
- $this->coreHelper->expects($this->once())
- ->method('getFingerPrintLink')
- ->willReturn('fingerprint_link');
+ $this->coreHelperMock->expects($this->once())
+ ->method('getFingerPrintLink')
+ ->willReturn('fingerprint_link');
- $this->coreHelper->expects($this->once())
- ->method('getMercadoPagoPaymentMethods')
- ->willReturn(null);
+ $this->coreHelperMock->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(null);
- $this->productMetadata->expects($this->once())
- ->method('getVersion')
- ->willReturn('magento2');
+ $this->productMetadataMock->expects($this->once())
+ ->method('getVersion')
+ ->willReturn('magento2');
$expectedReturn = [
'payment' => [
@@ -234,22 +234,22 @@ public function testGetConfig_successfulExecution_returnArray(): void
public function testGetConfig_methodInstanceNotAvailable_returnEmpty(): void
{
- $this->abstractMethod->expects($this->once())
- ->method('isAvailable')
- ->willReturn(false);
+ $this->abstractMethodMock->expects($this->once())
+ ->method('isAvailable')
+ ->willReturn(false);
$this->assertEquals([], $this->customConfigProvider->getConfig());
}
public function testGetPaymentMethods_successExecution_returnCards(): void
{
- $this->scopeConfig->expects($this->any())
- ->method('getValue')
- ->willReturnArgument(0);
+ $this->scopeConfigMock->expects($this->any())
+ ->method('getValue')
+ ->willReturnArgument(0);
- $this->coreHelper->expects($this->once())
- ->method('getMercadoPagoPaymentMethods')
- ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
+ $this->coreHelperMock->expects($this->once())
+ ->method('getMercadoPagoPaymentMethods')
+ ->willReturn(ConfigProviderConstants::PAYMENT_METHODS);
$expectedOutput = [
0 => ConfigProviderConstants::PAYMENT_METHODS['response'][0],
diff --git a/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php b/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php
index baf07bd8..21536240 100644
--- a/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php
+++ b/src/MercadoPago/Test/Unit/Model/PaymentMethodsTicketTest.php
@@ -18,22 +18,22 @@ class PaymentMethodsTicketTest extends TestCase
/**
* @var PaymentMethodsTicket
*/
- private $helper;
+ private $paymentMethodsTicket;
/**
* @var MockObject
*/
- private $scopeConfig;
+ private $scopeConfigMock;
/**
* @var MockObject
*/
- private $coreHelper;
+ private $coreHelperMock;
/**
* @var MockObject
*/
- private $switcher;
+ private $switcherMock;
/**
* @inheritdoc
@@ -43,32 +43,33 @@ protected function setUp(): void
$objectManagerHelper = new ObjectManager($this);
$className = PaymentMethodsTicket::class;
$arguments = $objectManagerHelper->getConstructArguments($className);
- $this->scopeConfig = $arguments['scopeConfig'];
- $this->coreHelper = $arguments['coreHelper'];
- $this->switcher = $arguments['switcher'];
+ $this->scopeConfigMock = $arguments['scopeConfig'];
+ $this->coreHelperMock = $arguments['coreHelper'];
+ $this->switcherMock = $arguments['switcher'];
- $this->helper = $objectManagerHelper->getObject($className, $arguments);
+ $this->paymentMethodsTicket = $objectManagerHelper->getObject($className, $arguments);
}
public function testToOptionArray_success_returnArrayWithoutMethods(): void
{
- $this->scopeConfig->expects(self::any())->method('getValue')
- ->with(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_WEBSITE, $this->switcher->getWebsiteId())
+ $this->scopeConfigMock->expects(self::any())
+ ->method('getValue')
->willReturn('');
- $this->assertEquals(PaymentMethods::EMPTY_PAYMENT_METHODS, $this->helper->toOptionArray());
+ $this->assertEquals(PaymentMethods::EMPTY_PAYMENT_METHODS, $this->paymentMethodsTicket->toOptionArray());
}
public function testToOptionArray_success_returnArrayWithMethods(): void
{
- $this->scopeConfig->expects(self::any())->method('getValue')
- ->with(ConfigData::PATH_ACCESS_TOKEN, ScopeInterface::SCOPE_WEBSITE, $this->switcher->getWebsiteId())
- ->willReturn(Config::ACCESS_TOKEN);
+ $this->scopeConfigMock->expects(self::any())
+ ->method('getValue')
+ ->willReturn('APP_USR-00000000000-000000-000000-0000000000');
- $this->coreHelper->expects(self::any())->method('getMercadoPagoPaymentMethods')
- ->with(Config::ACCESS_TOKEN)
+ $this->coreHelperMock->expects(self::any())
+ ->method('getMercadoPagoPaymentMethods')
+ ->with('APP_USR-00000000000-000000-000000-0000000000')
->willReturn(Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES);
- $this->assertEquals(PaymentMethods::PAYMENT_METHODS_SUCCESS, $this->helper->toOptionArray());
+ $this->assertEquals(PaymentMethods::PAYMENT_METHODS_SUCCESS, $this->paymentMethodsTicket->toOptionArray());
}
}
\ No newline at end of file
From b915209c3008013498bdf9ad79954e68235640c7 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 23 Nov 2021 16:38:59 -0300
Subject: [PATCH 26/75] refactored helper test classes
---
src/MercadoPago/Test/Unit/Helper/DataTest.php | 85 ++++++++++---------
1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
index a9f36d36..8c2bdd9e 100644
--- a/src/MercadoPago/Test/Unit/Helper/DataTest.php
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -4,7 +4,6 @@
use MercadoPago\Core\Helper\Data;
use MercadoPago\Core\Lib\Api;
-use MercadoPago\Test\Unit\Constants\Config;
use MercadoPago\Test\Unit\Constants\Response;
use MercadoPago\Test\Unit\Constants\PaymentMethods;
use Magento\Framework\App\Helper\Context;
@@ -17,82 +16,82 @@ class DataTest extends TestCase
/**
* @var Data
*/
- private $helper;
+ private $data;
/**
* @var MockObject
*/
- private $messageInterface;
+ private $messageInterfaceMock;
/**
* @var MockObject
*/
- private $mpCache;
+ private $mpCacheMock;
/**
* @var MockObject
*/
- private $context;
+ private $contextMock;
/**
* @var LayoutFactory|MockObject
*/
- private $layoutFactory;
+ private $layoutFactoryMock;
/**
* @var MockObject
*/
- private $paymentMethodFactory;
+ private $paymentMethodFactoryMock;
/**
* @var MockObject
*/
- private $appEmulation;
+ private $appEmulationMock;
/**
* @var MockObject
*/
- private $paymentConfig;
+ private $paymentConfigMock;
/**
* @var MockObject
*/
- private $initialConfig;
+ private $initialConfigMock;
/**
* @var MockObject
*/
- private $logger;
+ private $loggerMock;
/**
* @var MockObject
*/
- private $statusFactory;
+ private $statusFactoryMock;
/**
* @var MockObject
*/
- private $orderFactory;
+ private $orderFactoryMock;
/**
* @var MockObject
*/
- private $switcher;
+ private $switcherMock;
/**
* @var MockObject
*/
- private $composerInformation;
+ private $composerInformationMock;
/**
* @var MockObject
*/
- private $moduleResource;
+ private $moduleResourceMock;
/**
* @var MockObject
*/
- private $api;
+ private $apiMock;
/**
* @inheritdoc
@@ -102,46 +101,48 @@ protected function setUp(): void
$objectManagerHelper = new ObjectManager($this);
$className = Data::class;
$arguments = $objectManagerHelper->getConstructArguments($className);
- /** @var Context $context */
- $context = $arguments['context'];
- $this->scopeConfig = $context->getScopeConfig();
- $this->layoutFactory = $arguments['layoutFactory'];
-
- $this->messageInterface = $arguments['messageInterface'];
- $this->mpCache = $arguments['mpCache'];
-
- $this->paymentMethodFactory = $arguments['paymentMethodFactory'];
- $this->appEmulation = $arguments['appEmulation'];
- $this->paymentConfig = $arguments['paymentConfig'];
- $this->initialConfig = $arguments['initialConfig'];
- $this->logger = $arguments['logger'];
- $this->statusFactory = $arguments['statusFactory'];
- $this->orderFactory = $arguments['orderFactory'];
- $this->switcher = $arguments['switcher'];
- $this->composerInformation = $arguments['composerInformation'];
- $this->moduleResource = $arguments['moduleResource'];
- $this->api = $arguments['api'];
-
- $this->helper = $objectManagerHelper->getObject($className, $arguments);
+
+ $this->contextMock = $arguments['context'];
+ $this->scopeConfigMock = $arguments['scopeConfig'];
+ $this->layoutFactoryMock = $arguments['layoutFactory'];
+ $this->messageInterfaceMock = $arguments['messageInterface'];
+ $this->mpCacheMock = $arguments['mpCache'];
+ $this->paymentMethodFactoryMock = $arguments['paymentMethodFactory'];
+ $this->appEmulationMock = $arguments['appEmulation'];
+ $this->paymentConfigMock = $arguments['paymentConfig'];
+ $this->initialConfigMock = $arguments['initialConfig'];
+ $this->loggerMock = $arguments['logger'];
+ $this->statusFactoryMock = $arguments['statusFactory'];
+ $this->orderFactoryMock = $arguments['orderFactory'];
+ $this->switcherMock = $arguments['switcher'];
+ $this->composerInformationMock = $arguments['composerInformation'];
+ $this->moduleResourceMock = $arguments['moduleResource'];
+ $this->apiMock = $arguments['api'];
+
+ $this->contextMock = $this->getMockBuilder(Api::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->data = $objectManagerHelper->getObject($className, $arguments);
}
public function testGetMercadoPagoPaymentMethods_successResponse_returnArrayWithPaymentPlaces(): void
{
- $this->api->expects($this->once())
+ $this->apiMock->expects($this->once())
->method('get')
->with(PaymentMethods::PAYMENT_METHODS_URI)
->willReturn(Response::RESPONSE_PAYMENT_METHODS_SUCCESS);
- $this->assertEquals(Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES, $this->helper->getMercadoPagoPaymentMethods(Config::ACCESS_TOKEN));
+ $this->assertEquals(Response::RESPONSE_PAYMENT_METHODS_SUCCESS_WITH_PAY_PLACES, $this->data->getMercadoPagoPaymentMethods('APP_USR-00000000000-000000-000000-0000000000'));
}
public function testGetMercadoPagoPaymentMethods_exception_returnEmpty(): void
{
- $this->api->expects($this->once())
+ $this->apiMock->expects($this->once())
->method('get')
->with(PaymentMethods::PAYMENT_METHODS_URI)
->willReturn(null);
- $this->assertEquals([], $this->helper->getMercadoPagoPaymentMethods(Config::ACCESS_TOKEN));
+ $this->assertEquals([], $this->data->getMercadoPagoPaymentMethods('APP_USR-00000000000-000000-000000-0000000000'));
}
}
From f5068da85a2d27b85bba0613fde9bc9a139075fc Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 23 Nov 2021 16:41:51 -0300
Subject: [PATCH 27/75] added annotation for Code Coverage Ignore
---
src/MercadoPago/Core/Lib/Api.php | 2 ++
src/MercadoPago/Core/Lib/RestClient.php | 2 ++
src/MercadoPago/Core/Model/Core.php | 2 ++
3 files changed, 6 insertions(+)
diff --git a/src/MercadoPago/Core/Lib/Api.php b/src/MercadoPago/Core/Lib/Api.php
index 49154028..83485c7e 100644
--- a/src/MercadoPago/Core/Lib/Api.php
+++ b/src/MercadoPago/Core/Lib/Api.php
@@ -7,6 +7,8 @@
* Access MercadoPago for payments integration
*
* @author hcasatti
+ *
+ * @codeCoverageIgnore
*
*/
class Api
diff --git a/src/MercadoPago/Core/Lib/RestClient.php b/src/MercadoPago/Core/Lib/RestClient.php
index 723ff43b..5ff20516 100644
--- a/src/MercadoPago/Core/Lib/RestClient.php
+++ b/src/MercadoPago/Core/Lib/RestClient.php
@@ -7,6 +7,8 @@
/**
* MercadoPago cURL RestClient
+ *
+ * @codeCoverageIgnore
*/
class RestClient
{
diff --git a/src/MercadoPago/Core/Model/Core.php b/src/MercadoPago/Core/Model/Core.php
index daa00570..49aef2d6 100644
--- a/src/MercadoPago/Core/Model/Core.php
+++ b/src/MercadoPago/Core/Model/Core.php
@@ -35,6 +35,8 @@
* Class Core
*
* @package MercadoPago\Core\Model
+ *
+ * @codeCoverageIgnore
*/
class Core extends \Magento\Payment\Model\Method\AbstractMethod
{
From 107bf2525ea6f886224f68210e685405c7bf3440 Mon Sep 17 00:00:00 2001
From: sleaof
Date: Tue, 23 Nov 2021 16:54:29 -0300
Subject: [PATCH 28/75] fixed test variables
---
src/MercadoPago/Test/Unit/Helper/DataTest.php | 1 -
src/MercadoPago/Test/Unit/Lib/ApiTest.php | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/MercadoPago/Test/Unit/Helper/DataTest.php b/src/MercadoPago/Test/Unit/Helper/DataTest.php
index 8c2bdd9e..2395629c 100644
--- a/src/MercadoPago/Test/Unit/Helper/DataTest.php
+++ b/src/MercadoPago/Test/Unit/Helper/DataTest.php
@@ -103,7 +103,6 @@ protected function setUp(): void
$arguments = $objectManagerHelper->getConstructArguments($className);
$this->contextMock = $arguments['context'];
- $this->scopeConfigMock = $arguments['scopeConfig'];
$this->layoutFactoryMock = $arguments['layoutFactory'];
$this->messageInterfaceMock = $arguments['messageInterface'];
$this->mpCacheMock = $arguments['mpCache'];
diff --git a/src/MercadoPago/Test/Unit/Lib/ApiTest.php b/src/MercadoPago/Test/Unit/Lib/ApiTest.php
index e900db17..53aa4403 100644
--- a/src/MercadoPago/Test/Unit/Lib/ApiTest.php
+++ b/src/MercadoPago/Test/Unit/Lib/ApiTest.php
@@ -22,7 +22,7 @@ class ApiTest extends TestCase
*/
protected function setUp(): void
{
- $this->api = new Api($default_access_token);
+ $this->api = new Api($this->default_access_token);
}
/**
From 1bd7f452a56bb283a38bee9a40049764d712e61c Mon Sep 17 00:00:00 2001
From: sleaof
Date: Wed, 24 Nov 2021 16:04:17 -0300
Subject: [PATCH 29/75] fixed html structure of ticket
---
src/MercadoPago/Core/Helper/Data.php | 13 +-
src/MercadoPago/Core/etc/di.xml | 1 -
.../Core/view/frontend/web/css/MPv1.css | 4 +
.../web/template/payment/custom_ticket.html | 222 +++++++++---------
4 files changed, 118 insertions(+), 122 deletions(-)
diff --git a/src/MercadoPago/Core/Helper/Data.php b/src/MercadoPago/Core/Helper/Data.php
index 68716e08..10faeea9 100644
--- a/src/MercadoPago/Core/Helper/Data.php
+++ b/src/MercadoPago/Core/Helper/Data.php
@@ -90,11 +90,6 @@ class Data extends \Magento\Payment\Helper\Data
*/
protected $_moduleResource;
- /**
- * @var Api $api
- */
- protected $_api;
-
/**
* Data constructor.
* @param Message\MessageInterface $messageInterface
@@ -111,7 +106,6 @@ class Data extends \Magento\Payment\Helper\Data
* @param Switcher $switcher
* @param ComposerInformation $composerInformation
* @param ResourceInterface $moduleResource
- * @param Api $api
*/
public function __construct(
Message\MessageInterface $messageInterface,
@@ -127,8 +121,7 @@ public function __construct(
OrderFactory $orderFactory,
Switcher $switcher,
ComposerInformation $composerInformation,
- ResourceInterface $moduleResource,
- Api $api
+ ResourceInterface $moduleResource
) {
parent::__construct($context, $layoutFactory, $paymentMethodFactory, $appEmulation, $paymentConfig, $initialConfig);
$this->_messageInterface = $messageInterface;
@@ -139,7 +132,6 @@ public function __construct(
$this->_switcher = $switcher;
$this->_composerInformation = $composerInformation;
$this->_moduleResource = $moduleResource;
- $this->_api = $api;
}
/**
@@ -182,8 +174,7 @@ public function getApiInstance($accessToken = null)
throw new LocalizedException(__('The ACCESS_TOKEN has not been configured, without this credential the module will not work correctly.'));
}
- //$api = new Api($accessToken);
- $api = $this->_api;
+ $api = new Api($accessToken);
$api->set_platform(self::PLATFORM_OPENPLATFORM);
$api->set_type(self::TYPE);
diff --git a/src/MercadoPago/Core/etc/di.xml b/src/MercadoPago/Core/etc/di.xml
index a13c2d09..9220b9f9 100644
--- a/src/MercadoPago/Core/etc/di.xml
+++ b/src/MercadoPago/Core/etc/di.xml
@@ -1,7 +1,6 @@
-
diff --git a/src/MercadoPago/Core/view/frontend/web/css/MPv1.css b/src/MercadoPago/Core/view/frontend/web/css/MPv1.css
index ecaaf1c9..5d596164 100644
--- a/src/MercadoPago/Core/view/frontend/web/css/MPv1.css
+++ b/src/MercadoPago/Core/view/frontend/web/css/MPv1.css
@@ -2,6 +2,10 @@
max-width: 400px;
}
+#co-mercadopago-form-mlb {
+ display: inline-block;
+}
+
#mp-box-form {
width: 100%;
max-width: 375px;
diff --git a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
index 0054ea9f..20788c63 100644
--- a/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
+++ b/src/MercadoPago/Core/view/frontend/web/template/payment/custom_ticket.html
@@ -40,7 +40,7 @@