Skip to content

Commit 81d0bd2

Browse files
committed
v1.8.5
1 parent 26ced1f commit 81d0bd2

37 files changed

+493
-145
lines changed

Block/MpDeviceSessionId.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class MpDeviceSessionId extends Template
1414

1515
private DynamicCollector $dynamicCollector;
1616
private Random $random;
17-
18-
/**
17+
18+
/**
1919
* @param Context $context
2020
* @param DynamicCollector $dynamicCollector
2121
* @param Random $random

Block/Sales/Info/Info.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ public function date($date)
7171
* Function getFormatedPrice
7272
*
7373
* @param float $price
74+
* @param bool $includeContainer
7475
*
7576
* @return string
7677
*/
77-
public function getFormatedPrice($amount)
78+
public function getFormatedPrice($amount, $includeContainer = true)
7879
{
79-
return $this->priceCurrency->convertAndFormat($amount);
80+
return $this->priceCurrency->convertAndFormat($amount, $includeContainer);
8081
}
8182
}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.8.5] - 2024-10-30
9+
### Changed
10+
- Adjustments on maximum order amount when payment has financial cost
11+
- Adjustments on partial refund
12+
- Update binary mode default value
13+
- Fixed financial cost amount exhibition on order view and success page with cards payment
14+
- Improved logs on cancel orders with expirated preferences cron
15+
- Updated text for congrats page on MLB "Lotérica" payment
16+
817
## [1.8.4] - 2024-09-23
918
### Changed
1019
- Rebranding of Mercado Credits

Cron/CancelCheckoutPro.php

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,80 @@ public function execute()
9393
->join(
9494
['sop' => $this->getSalesOrderPaymentTableName()],
9595
'main_table.entity_id = sop.parent_id',
96-
['method']
96+
['method', 'additional_information']
9797
)
9898
->where(new \Zend_Db_Expr(
9999
"sop.method = ? AND TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, CAST(JSON_EXTRACT(sop.additional_information, '$.date_of_expiration') AS DATETIME))) >= 0 "
100100
), ConfigCheckoutPro::METHOD);
101101

102-
foreach ($orders as $order) {
103-
$orderId = $order->getEntityId();
104-
$amount = $order->getTotalDue();
105-
$baseAmount = $order->getBaseTotalDue();
106-
$payment = $order->getPayment();
107-
$payment->setPreparedMessage(__('Order Canceled.'));
108-
$payment->registerVoidNotification($amount);
109-
$payment->setIsTransactionApproved(false);
110-
$payment->setIsTransactionDenied(true);
111-
$payment->setIsTransactionPending(false);
112-
$payment->setIsInProcess(true);
113-
$payment->setIsTransactionClosed(true);
114-
$payment->setShouldCloseParentTransaction(true);
115-
$payment->setAmountCanceled($amount);
116-
$payment->setBaseAmountCanceled($baseAmount);
117-
$order->cancel();
118-
$order->save();
102+
103+
$this->logger->debug([
104+
'Total orders to cancel: ' => $orders->count()
105+
]);
106+
107+
$dateRange = [];
108+
$orderId = null;
109+
110+
try {
111+
$this->logger->debug([
112+
'Cancel Start'
113+
]);
114+
foreach ($orders as $order) {
115+
$orderAdditionalInformation = json_decode($order->getData('additional_information'));
116+
$orderId = $order->getEntityId();
117+
$amount = $order->getTotalDue();
118+
$baseAmount = $order->getBaseTotalDue();
119+
$payment = $order->getPayment();
120+
$payment->setPreparedMessage(__('Order Canceled.'));
121+
$payment->registerVoidNotification($amount);
122+
$payment->setIsTransactionApproved(false);
123+
$payment->setIsTransactionDenied(true);
124+
$payment->setIsTransactionPending(false);
125+
$payment->setIsInProcess(true);
126+
$payment->setIsTransactionClosed(true);
127+
$payment->setShouldCloseParentTransaction(true);
128+
$payment->setAmountCanceled($amount);
129+
$payment->setBaseAmountCanceled($baseAmount);
130+
$order->cancel();
131+
$order->save();
132+
133+
$dateRange[] = $orderAdditionalInformation->date_of_expiration;
134+
$this->logger->debug([
135+
'fetch' => 'Cancel Order Id ' . $orderId . ' successfully',
136+
'order_date_of_expiration' => $orderAdditionalInformation->date_of_expiration
137+
]);
138+
}
139+
140+
$this->calculateExpirationRange($dateRange);
141+
$this->logger->debug([
142+
'Cancel Finish'
143+
]);
144+
145+
} catch (\Exception $e) {
119146
$this->logger->debug([
120-
'fetch' => 'Cancel Order Id ' . $orderId,
147+
'Cancel order execution error' => $e->getMessage(),
148+
'Order Id' => $orderId
121149
]);
122150
}
123151
}
152+
153+
/**
154+
* Calculate expiration range date
155+
*
156+
* @param array $dateRange
157+
* @return void
158+
*/
159+
private function calculateExpirationRange(array $dateRange): void
160+
{
161+
usort($dateRange, function ($a, $b) {
162+
return strtotime($a) - strtotime($b);
163+
});
164+
165+
$initialDate = reset($dateRange);
166+
$endDate = end($dateRange);
167+
168+
$this->logger->debug([
169+
'Orders expiration range: ' => "from: $initialDate to: $endDate"
170+
]);
171+
}
124172
}

Gateway/Config/ConfigCc.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class ConfigCc extends PaymentConfig
6969
*/
7070
public const PAYMENT_ACTION = 'payment_action';
7171

72+
/**
73+
* Maximum Order Amount Total.
74+
*/
75+
public const MAX_ORDER_TOTAL = 'max_order_total';
76+
7277
/**
7378
* @var Config
7479
*/
@@ -329,4 +334,22 @@ public function getFingerPrintLink($storeId = null): string
329334

330335
return $this->fingerprint->getFingerPrintLink($mpSiteId);
331336
}
337+
338+
/**
339+
* Get Maximum order total
340+
*
341+
* @param int|null $storeId
342+
*
343+
* @return float
344+
*/
345+
public function getMaximumOrderTotal($storeId = null): float
346+
{
347+
$pathPattern = 'payment/%s/%s';
348+
349+
return (float)$this->scopeConfig->getValue(
350+
sprintf($pathPattern, self::METHOD, self::MAX_ORDER_TOTAL),
351+
ScopeInterface::SCOPE_STORE,
352+
$storeId
353+
);
354+
}
332355
}

Gateway/Config/ConfigCheckoutCredits.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class ConfigCheckoutCredits extends ConfigPro
2525
*/
2626
public const METHOD = 'mercadopago_adbpayment_checkout_credits';
2727

28+
/**
29+
* Maximum Order Amount Total.
30+
*/
31+
public const MAX_ORDER_TOTAL = 'max_order_total';
32+
2833
/**
2934
* @param ScopeConfigInterface $scopeConfig
3035
* @param DateTime $date
@@ -58,4 +63,22 @@ public function getBannerText($textId, $storeId = null): string
5863
$storeId
5964
);
6065
}
66+
67+
/**
68+
* Get Maximum order total
69+
*
70+
* @param int|null $storeId
71+
*
72+
* @return float
73+
*/
74+
public function getMaximumOrderTotal($storeId = null): float
75+
{
76+
$pathPattern = 'payment/%s/%s';
77+
78+
return (float)$this->scopeConfig->getValue(
79+
sprintf($pathPattern, self::METHOD, self::MAX_ORDER_TOTAL),
80+
ScopeInterface::SCOPE_STORE,
81+
$storeId
82+
);
83+
}
6184
}

Gateway/Config/ConfigTwoCc.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class ConfigTwoCc extends PaymentConfig
6767
*/
6868
public const PAYMENT_ACTION = 'payment_action';
6969

70+
/**
71+
* Maximum Order Amount Total.
72+
*/
73+
public const MAX_ORDER_TOTAL = 'max_order_total';
74+
7075
/**
7176
* @var Config
7277
*/
@@ -330,4 +335,21 @@ public function getFingerPrintLink($storeId = null): string
330335
return $this->fingerprint->getFingerPrintLink($mpSiteId);
331336
}
332337

338+
/**
339+
* Get Maximum order total
340+
*
341+
* @param int|null $storeId
342+
*
343+
* @return float
344+
*/
345+
public function getMaximumOrderTotal($storeId = null): float
346+
{
347+
$pathPattern = 'payment/%s/%s';
348+
349+
return (float)$this->scopeConfig->getValue(
350+
sprintf($pathPattern, self::METHOD, self::MAX_ORDER_TOTAL),
351+
ScopeInterface::SCOPE_STORE,
352+
$storeId
353+
);
354+
}
333355
}

Gateway/Http/Client/CreateOrderPaymentCustomClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ public function placeRequest(TransferInterface $transferObject)
229229
unset($request[CaptureAmountRequest::AMOUNT_TO_CAPTURE]);
230230

231231
$paymentInstance->setEntity($request);
232-
232+
233233

234234
if(isset($paymentInstance->payer->id)) {
235235
$customHeaders[] = self::HEADER_CUSTOMER_ID . $paymentInstance->payer->id;
236236
}
237-
237+
238238
$paymentInstance->setCustomHeaders($customHeaders);
239239

240240
$clientHeaders = $paymentInstance->getLastHeaders();
@@ -313,4 +313,4 @@ public function placeRequest(TransferInterface $transferObject)
313313

314314
return $response;
315315
}
316-
}
316+
}

Gateway/Response/TxnIdPaymentMethodsOffHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ public function setAddtionalInformationMLB($payment, $response) {
289289
self::MESSAGE_DOCUMENT,
290290
'Enter the ID Document you used in the purchase'
291291
);
292+
293+
$payment->setAdditionalInformation(
294+
self::MESSAGE_INFO,
295+
'To pay, please go to any lotérica or "Correspondente Caixa" branch. You will need the following code and the ID number used in the purchase.'
296+
);
292297
}
293298
}
294299
}

Model/Adminhtml/Source/IsBinaryMode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public function toOptionArray(): array
2323
return [
2424
[
2525
'value' => 0,
26-
'label' => __('Yes, Processed Order Synchronous'),
26+
'label' => __('No, Processed Order Asynchronous'),
2727
],
2828
[
2929
'value' => 1,
30-
'label' => __('No, Processed Order Asynchronous'),
30+
'label' => __('Yes, Processed Order Synchronous'),
3131
],
3232
];
3333
}

0 commit comments

Comments
 (0)