Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #97 from gmatsuoka/master
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
falehenrique authored Aug 3, 2018
2 parents 81e7ac3 + d280c5b commit 5a4db4d
Show file tree
Hide file tree
Showing 263 changed files with 212 additions and 263 deletions.
Empty file modified README.img/logo_mp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified README.img/mercadoenvios.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified README.img/mercadopago_custom_checkout_cc.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified README.img/mercadopago_custom_checkout_configuration.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified README.img/mercadopago_custom_checkout_ticket.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified README.img/mercadopago_global_configuration.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified Test/.gitignore
100644 → 100755
Empty file.
Empty file modified Test/behat.yml.dist
100644 → 100755
Empty file.
Empty file modified Test/composer.json
100644 → 100755
Empty file.
Empty file modified Test/functional/features/MercadoPago/CouponDiscount.feature
100644 → 100755
Empty file.
Empty file modified Test/functional/features/MercadoPago/CreditCards.feature
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/functional/features/MercadoPago/CustomCheckout.feature
100644 → 100755
Empty file.
Empty file modified Test/functional/features/MercadoPago/CustomForm.feature
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified Test/functional/features/MercadoPago/StandardCheckout.feature
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/functional/features/bootstrap/FeatureContext.php
100644 → 100755
Empty file.
Empty file modified Test/functional/features/fixture/MercadoPagoFixture.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/LICENSE
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/README.md
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Classes/Mysql4Sniff.php
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/PHP/GotoSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/PHP/VarSniff.php
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Performance/FetchAllSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Performance/GetFirstItemSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Performance/LoopSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Security/AclSniff.php
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Security/IncludeFileSniff.php
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Security/SuperglobalSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Sql/RawQuerySniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Sql/SlowQuerySniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Strings/RegExSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Strings/StringConcatSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Sniffs/Strings/StringPositionSniff.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Classes/Mysql4UnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Classes/Mysql4UnitTest.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/PHP/GotoUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/PHP/GotoUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/PHP/VarUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/PHP/VarUnitTest.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Performance/FetchAllUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Performance/FetchAllUnitTest.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Performance/LoopUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Performance/LoopUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Security/AclUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Security/AclUnitTest.php
100644 → 100755
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Security/IncludeFileUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Security/IncludeFileUnitTest.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Security/SuperglobalUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Security/SuperglobalUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Sql/RawQueryUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Sql/RawQueryUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Sql/SlowQueryUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Sql/SlowQueryUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Strings/RegExUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Strings/RegExUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Strings/StringConcatUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Strings/StringConcatUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Strings/StringPositionUnitTest.inc
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/Tests/Strings/StringPositionUnitTest.php
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/composer.json
100644 → 100755
Empty file.
Empty file modified Test/static/phpcs/Ecg/ruleset.xml
100644 → 100755
Empty file.
Empty file modified Test/static/phpmd/ruleset.xml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"type": "magento2-component",
"version": "2.1.4",
"version": "2.2.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
Empty file modified src/MercadoPago/Core/Block/AbstractSuccess.php
100755 → 100644
Empty file.
Empty file.
Empty file modified src/MercadoPago/Core/Block/Analytics/AfterCheckout.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/Calculator/CalculatorForm.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/Calculator/CalculatorLink.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/Custom/Success.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/CustomTicket/Success.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/Info.php
100755 → 100644
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion src/MercadoPago/Core/Block/Sales/Order/Totals/FinanceCost.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public function getSource()
*/
public function initTotals()
{
if ((float)$this->getSource()->getFinanceCostAmount() == 0) {
if ((float)$this->getSource()->getFinanceCostAmount() == 0
|| !$this->_scopeConfig->isSetFlag('payment/mercadopago/financing_cost',\Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return $this;
}
$total = new \Magento\Framework\DataObject([
Expand Down
Empty file modified src/MercadoPago/Core/Block/Standard/Failure.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/Standard/FailureRedirect.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Block/Standard/Success.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Api/Coupon.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Api/Subtotals.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Calculator/Popup.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Checkout/Page.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Customticket/Success.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Notifications/Custom.php
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions src/MercadoPago/Core/Controller/Notifications/Standard.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function _responseLog()
protected function _getFormattedPaymentData($paymentId, $data = [])
{
$response = $this->coreModel->getPayment($paymentId);
$payment = $response['response']['collection'];
$payment = $response['response'];

return $this->_statusHelper->formatArrayPayment($data, $payment, self::LOG_NAME);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ protected function _getDataPayments($merchantOrder)
$data = array();
foreach ($merchantOrder['payments'] as $payment) {
$response = $this->coreModel->getPayment($payment['id']);
$payment = $response['response']['collection'];
$payment = $response['response'];
$data = $this->_statusHelper->formatArrayPayment($data, $payment, self::LOG_NAME);
}
return $data;
Expand Down
Empty file modified src/MercadoPago/Core/Controller/Standard/Failure.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Standard/FailureRedirect.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Controller/Standard/Pay.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Cron/OrderUpdate.php
100755 → 100644
Empty file.
4 changes: 3 additions & 1 deletion src/MercadoPago/Core/Helper/Data.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class Data
const XML_PATH_SPONSOR_ID = 'payment/mercadopago/sponsor_id';

const XML_PATH_CONSIDER_DISCOUNT = 'payment/mercadopago/consider_discount';

const XML_PATH_CONSIDER_FINANCING_COST = 'payment/mercadopago/financing_cost';


/**
Expand Down Expand Up @@ -354,7 +356,7 @@ public function setOrderSubtotals($data, $order)
}


if (\Zend_Locale_Math::round($financingCost, 4) > 0) {
if (\Zend_Locale_Math::round($financingCost, 4) > 0 && $this->scopeConfig->isSetFlag(self::XML_PATH_CONSIDER_FINANCING_COST,\Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
$order->setFinanceCostAmount($financingCost);
$order->setBaseFinanceCostAmount($financingCost);
}
Expand Down
Empty file modified src/MercadoPago/Core/Helper/Message/AbstractMessage.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Helper/Message/MessageInterface.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Helper/Message/StatusDetailMessage.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Helper/Message/StatusMessage.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Helper/Message/StatusOrderMessage.php
100755 → 100644
Empty file.
Empty file modified src/MercadoPago/Core/Helper/Response.php
100755 → 100644
Empty file.
122 changes: 63 additions & 59 deletions src/MercadoPago/Core/Helper/StatusUpdate.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -370,88 +370,92 @@ protected function _createCreditmemo($order, $data)
*/
public function formatArrayPayment($data, $payment, $logName)
{
$this->_dataHelper->log("Format Array", $logName);

$fields = [
"status",
"status_detail",
"order_id",
"id",
"payment_method_id",
"transaction_amount",
"total_paid_amount",
"coupon_amount",
"installments",
"shipping_cost",
"amount_refunded"
];

foreach ($fields as $field) {
if (isset($payment[$field])) {
if (isset($data[$field])) {
$data[$field] .= " | " . $payment[$field];
} else {
$data[$field] = $payment[$field];
}
}
$this->_dataHelper->log("Format Array", $logName);

$fields = [
"status",
"status_detail",
"id",
"payment_method_id",
"transaction_amount",
"coupon_amount",
"installments",
"amount_refunded"
];

foreach ($fields as $field) {
if (isset($payment[$field])) {
if (isset($data[$field])) {
$data[$field] .= " | " . $payment[$field];
} else {
$data[$field] = $payment[$field];
}
}

if (isset($payment['refunds'])) {
foreach ($payment['refunds'] as $refund) {
if (isset($data['refunds'])) {
$data['refunds'] .= " | " . $refund['id'];
} else {
$data['refunds'] = $refund['id'];
}
}
}

if (isset($payment['refunds'])) {
foreach ($payment['refunds'] as $refund) {
if (isset($data['refunds'])) {
$data['refunds'] .= " | " . $refund['id'];
} else {
$data['refunds'] = $refund['id'];
}
}

$data = $this->_updateAtributesData($data, $payment);

$data['external_reference'] = $payment['external_reference'];
$data['payer_first_name'] = $payment['payer']['first_name'];
$data['payer_last_name'] = $payment['payer']['last_name'];
$data['payer_email'] = $payment['payer']['email'];

if (isset($data['payer_identification_type'])) {
$data['payer_identification_type'] .= " | " . $payment['payer']['identification']['type'];
} else {
$data['payer_identification_type'] = $payment['payer']['identification']['type'];
}

$data = $this->_updateAtributesData($data, $payment);

$data['external_reference'] = $payment['external_reference'];
$data['order_id'] = $payment['external_reference'];
$data['payer_first_name'] = $payment['payer']['first_name'];
$data['payer_last_name'] = $payment['payer']['last_name'];
$data['payer_email'] = $payment['payer']['email'];
$data['total_paid_amount'] = $payment['transaction_details']['total_paid_amount'];
$data['shipping_cost'] = isset($payment['shipping_amount']) ? $payment['shipping_amount'] : "0";

if (isset($data['payer_identification_type'])) {
$data['payer_identification_type'] .= " | " . $payment['payer']['identification']['type'];
} else {
if (isset($payment['payer']) && isset($payment['payer']['identification']) && isset($payment['payer']['identification']['type'])) {
$data['payer_identification_type'] = $payment['payer']['identification']['type'];
}

if (isset($data['payer_identification_number'])) {
$data['payer_identification_number'] .= " | " . $payment['payer']['identification']['number'];
} else {
$data['payer_identification_number'] = $payment['payer']['identification']['number'];
}

if (isset($data['payer_identification_number'])) {
$data['payer_identification_number'] .= " | " . $payment['payer']['identification']['number'];
} else {
if (isset($payment['payer']) && isset($payment['payer']['identification']) && isset($payment['payer']['identification']['number'])) {
$data['payer_identification_number'] = $payment['payer']['identification']['number'];
}
}

return $data;
return $data;
}

protected function _updateAtributesData($data, $payment)
{
if (isset($payment["last_four_digits"])) {
if (isset($payment['card']) && isset($payment['card']["last_four_digits"])) {
if (isset($data["trunc_card"])) {
$data["trunc_card"] .= " | " . "xxxx xxxx xxxx " . $payment["last_four_digits"];
$data["trunc_card"] .= " | " . "xxxx xxxx xxxx " . $payment['card']["last_four_digits"];
} else {
$data["trunc_card"] = "xxxx xxxx xxxx " . $payment["last_four_digits"];
$data["trunc_card"] = "xxxx xxxx xxxx " . $payment['card']["last_four_digits"];
}
}

if (isset($payment['cardholder']['name'])) {
if (isset($payment['card']) && isset($payment['card']['cardholder']) && isset($payment['card']['cardholder']['name'])) {
if (isset($data["cardholder_name"])) {
$data["cardholder_name"] .= " | " . $payment["cardholder"]["name"];
$data["cardholder_name"] .= " | " . $payment['card']["cardholder"]["name"];
} else {
$data["cardholder_name"] = $payment["cardholder"]["name"];
$data["cardholder_name"] = $payment['card']["cardholder"]["name"];
}
}

if (isset($payment['statement_descriptor'])) {
$data['statement_descriptor'] = $payment['statement_descriptor'];
}

if (isset($payment['merchant_order_id'])) {
$data['merchant_order_id'] = $payment['merchant_order_id'];
if (isset($payment['order']) && isset($payment['order']['type']) && $payment['order']['type'] == "mercadopago") {
$data['merchant_order_id'] = $payment['order']['id'] ;
}

return $data;
Expand Down
66 changes: 1 addition & 65 deletions src/MercadoPago/Core/Lib/Api.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,6 @@ public function get_access_token() {
return $this->access_data['access_token'];
}

/**
* Get information for specific payment
* @param int $id
* @return array(json)
*/
public function get_payment($id) {
$access_token = $this->get_access_token();

$uri_prefix = $this->sandbox ? "/sandbox" : "";

$payment_info = \MercadoPago\Core\Lib\RestClient::get($uri_prefix."/collections/notifications/" . $id . "?access_token=" . $access_token);
return $payment_info;
}

/**
* @param $id
*
* @return array
*/
public function get_payment_info($id) {
return $this->get_payment($id);
}

/**
* Get information for specific authorized payment
* @param id
Expand All @@ -152,27 +129,7 @@ public function get_authorized_payment($id) {
public function refund_payment($id) {
$access_token = $this->get_access_token();

$refund_status = array(
"status" => "refunded"
);

$response = \MercadoPago\Core\Lib\RestClient::put("/collections/" . $id . "?access_token=" . $access_token, $refund_status);
return $response;
}

/**
* Cancel pending payment
* @param int $id
* @return array(json)
*/
public function cancel_payment($id) {
$access_token = $this->get_access_token();

$cancel_status = array(
"status" => "cancelled"
);

$response = \MercadoPago\Core\Lib\RestClient::put("/collections/" . $id . "?access_token=" . $access_token, $cancel_status);
$response = \MercadoPago\Core\Lib\RestClient::post("/v1/payments/$id/refunds?access_token=$access_token", array());
return $response;
}

Expand All @@ -192,27 +149,6 @@ public function cancel_preapproval_payment($id) {
return $response;
}

/**
* Search payments according to filters, with pagination
* @param array $filters
* @param int $offset
* @param int $limit
* @return array(json)
*/
public function search_payment($filters, $offset = 0, $limit = 0) {
$access_token = $this->get_access_token();

$filters["offset"] = $offset;
$filters["limit"] = $limit;

$filters = $this->build_query($filters);

$uri_prefix = $this->sandbox ? "/sandbox" : "";

$collection_result = \MercadoPago\Core\Lib\RestClient::get($uri_prefix."/collections/search?" . $filters . "&access_token=" . $access_token);
return $collection_result;
}

/**
* Create a checkout preference
* @param array $preference
Expand Down
Loading

0 comments on commit 5a4db4d

Please sign in to comment.