Skip to content

Commit 7cccb38

Browse files
committed
🐛 Fix payment method labels an add payment data in additional information.
1 parent dc43c59 commit 7cccb38

File tree

33 files changed

+248
-40
lines changed

33 files changed

+248
-40
lines changed

Gateway/Transaction/Billet/Config/Config.php

+14
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,18 @@ public function getCustomerAddressDistrict()
7979
{
8080
return $this->getConfig(static::PATH_CUSTOMER_DISTRICT);
8181
}
82+
83+
/**
84+
* @return string
85+
*/
86+
public function getTitle()
87+
{
88+
$title = $this->getConfig(static::PATH_TITLE);
89+
90+
if(empty($title)){
91+
return __('MundiPagg Billet');
92+
}
93+
94+
return $title;
95+
}
8296
}

Gateway/Transaction/Billet/Config/ConfigInterface.php

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface ConfigInterface
2222
const PATH_CUSTOMER_NUMBER = 'payment/mundipagg_customer_address/number_attribute';
2323
const PATH_CUSTOMER_COMPLEMENT = 'payment/mundipagg_customer_address/complement_attribute';
2424
const PATH_CUSTOMER_DISTRICT = 'payment/mundipagg_customer_address/district_attribute';
25+
const PATH_TITLE = 'payment/mundipagg_billet/title';
2526

2627
/**
2728
* @return string
@@ -62,4 +63,10 @@ public function getCustomerAddressComplement();
6263
* @return string
6364
*/
6465
public function getCustomerAddressDistrict();
66+
67+
/**
68+
* @return string
69+
*/
70+
public function getTitle();
71+
6572
}

Gateway/Transaction/BilletCreditCard/Config/Config.php

+14
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,18 @@ public function getCustomerAddressDistrict()
8888
{
8989
return $this->getConfig(static::PATH_CUSTOMER_DISTRICT);
9090
}
91+
92+
/**
93+
* @return string
94+
*/
95+
public function getTitle()
96+
{
97+
$title = $this->getConfig(static::PATH_TITLE);
98+
99+
if(empty($title)){
100+
return __('MundiPagg Billet Credit Card');
101+
}
102+
103+
return $title;
104+
}
91105
}

Gateway/Transaction/BilletCreditCard/Config/ConfigInterface.php

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ConfigInterface
2323
const PATH_CUSTOMER_NUMBER = 'payment/mundipagg_customer_address/number_attribute';
2424
const PATH_CUSTOMER_COMPLEMENT = 'payment/mundipagg_customer_address/complement_attribute';
2525
const PATH_CUSTOMER_DISTRICT = 'payment/mundipagg_customer_address/district_attribute';
26+
const PATH_TITLE = 'payment/mundipagg_billet_creditcard/title';
2627

2728
/**
2829
* @return bool
@@ -68,4 +69,9 @@ public function getCustomerAddressComplement();
6869
* @return string
6970
*/
7071
public function getCustomerAddressDistrict();
72+
73+
/**
74+
* @return string
75+
*/
76+
public function getTitle();
7177
}

Gateway/Transaction/BilletCreditCard/ResourceGateway/Create/RequestBuilder.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,10 @@ protected function createNewRequest($requestDataProvider)
546546
}
547547

548548
if($hasOnlyVirtual){
549-
550-
$order->shipping['address'] = $order->customer['address'];
549+
$address = $order->payments[0]['credit_card']['card']['billing_address'];
550+
$order->shipping['address'] = $address;
551+
$order->customer['address'] = $address;
551552
$order->shipping['description'] = __('Product_Virtual');
552-
553553
}else{
554554
$order->shipping['description'] = '.';
555555
}
@@ -565,17 +565,15 @@ protected function createNewRequest($requestDataProvider)
565565
$response = $this->getApi()->getOrders()->createOrder($order);
566566

567567
if($response->charges[0]->status == 'failed'){
568-
568+
$responseCancel = $this->getApi()->getCharges()->cancelCharge($response->charges[1]->id);
569569
$messageError = __('Your transaction was processed with failure');
570570
throw new \InvalidArgumentException($messageError);
571-
572571
}
573572

574573
if($response->charges[1]->status == 'failed'){
575-
574+
$responseCancel = $this->getApi()->getCharges()->cancelCharge($response->charges[0]->id);
576575
$messageError = __('Your transaction was processed with failure');
577576
throw new \InvalidArgumentException($messageError);
578-
579577
}
580578

581579

Gateway/Transaction/BilletCreditCard/ResourceGateway/Create/Response/GeneralHandler.php

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ protected function _handle($payment, $response)
5656
$payment->setAdditionalInformation('billet_url', $boletoUrl);
5757

5858
$payment->setTransactionId($response->id);
59+
$charges = $response->charges[0];
60+
$payment->setTransactionAdditionalInfo('bcc_acquirer_tid',$charges->lastTransaction->acquirerTid);
61+
$payment->setTransactionAdditionalInfo('bcc_acquirer_nsu',$charges->lastTransaction->acquirerNsu);
5962
$payment->setIsTransactionClosed(false);
6063

6164
foreach($response->charges as $charge)

Gateway/Transaction/CreditCard/Config/Config.php

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ public function getActive()
2424
return (bool) $this->getConfig(static::PATH_ACTIVE);
2525
}
2626

27+
/**
28+
* @return string
29+
*/
30+
public function getTitle()
31+
{
32+
$title = $this->getConfig(static::PATH_TITLE);
33+
34+
if(empty($title)){
35+
return __('MundiPagg Credit Card');
36+
}
37+
38+
return $title;
39+
}
40+
2741
/**
2842
* {@inheritdoc}
2943
*/

Gateway/Transaction/CreditCard/Config/ConfigInterface.php

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ConfigInterface
2323
const PATH_CUSTOMER_NUMBER = 'payment/mundipagg_customer_address/number_attribute';
2424
const PATH_CUSTOMER_COMPLEMENT = 'payment/mundipagg_customer_address/complement_attribute';
2525
const PATH_CUSTOMER_DISTRICT = 'payment/mundipagg_customer_address/district_attribute';
26+
const PATH_TITLE = 'payment/mundipagg_creditcard/title';
2627

2728
/**
2829
* @return bool
@@ -68,4 +69,10 @@ public function getCustomerAddressComplement();
6869
* @return string
6970
*/
7071
public function getCustomerAddressDistrict();
72+
73+
/**
74+
* @return string
75+
*/
76+
public function getTitle();
77+
7178
}

Gateway/Transaction/CreditCard/ResourceGateway/Create/RequestBuilder.php

+1
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ protected function createNewRequest($requestDataProvider)
491491

492492
if($response->charges[0]->status == 'failed'){
493493

494+
494495
$messageError = __('Your transaction was processed with failure');
495496
throw new \InvalidArgumentException($messageError);
496497

Gateway/Transaction/CreditCard/ResourceGateway/Create/Response/GeneralHandler.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ protected function _handle($payment, $response)
5656
{
5757
$this->logger->logger(json_encode($response));
5858
$payment->setTransactionId($response->id);
59-
6059
$this->setPaymentStateCreditCard($payment, $response);
6160

61+
$charges = $response->charges[0];
62+
$payment->setTransactionAdditionalInfo('cc_acquirer_tid',$charges->lastTransaction->acquirerTid);
63+
$payment->setTransactionAdditionalInfo('cc_acquirer_nsu',$charges->lastTransaction->acquirerNsu);
64+
6265
$payment->setIsTransactionClosed(false);
6366
if($this->configCreditCard->getPaymentAction() == 'authorize_capture') {
6467
$payment->setIsTransactionClosed(true);

Gateway/Transaction/TwoCreditCard/Config/Config.php

+14
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,18 @@ public function getCustomerAddressDistrict()
8787
{
8888
return $this->getConfig(static::PATH_CUSTOMER_DISTRICT);
8989
}
90+
91+
/**
92+
* @return string
93+
*/
94+
public function getTitle()
95+
{
96+
$title = $this->getConfig(static::PATH_TITLE);
97+
98+
if(empty($title)){
99+
return __('MundiPagg Two Credit Cards');
100+
}
101+
102+
return $title;
103+
}
90104
}

Gateway/Transaction/TwoCreditCard/Config/ConfigInterface.php

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ConfigInterface
2323
const PATH_CUSTOMER_NUMBER = 'payment/mundipagg_customer_address/number_attribute';
2424
const PATH_CUSTOMER_COMPLEMENT = 'payment/mundipagg_customer_address/complement_attribute';
2525
const PATH_CUSTOMER_DISTRICT = 'payment/mundipagg_customer_address/district_attribute';
26+
const PATH_TITLE = 'payment/mundipagg_two_creditcard/title';
2627

2728
/**
2829
* @return bool
@@ -48,4 +49,9 @@ public function getAntifraudMinAmount();
4849
* @return string
4950
*/
5051
public function getSoftDescription();
52+
53+
/**
54+
* @return string
55+
*/
56+
public function getTitle();
5157
}

Gateway/Transaction/TwoCreditCard/ResourceGateway/Create/RequestBuilder.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ protected function createNewRequest($requestDataProvider)
511511
if(($response->charges[0]->status == 'failed')) {
512512

513513
if (!empty($response->charges[0]->lastTransaction->acquirerMessage)) {
514-
514+
$responseCancel = $this->getApi()->getCharges()->cancelCharge($response->charges[1]->id);
515515
$messageError = __('Your transaction was processed with failure') . __(' first card');
516516
throw new \InvalidArgumentException($messageError);
517517

@@ -521,15 +521,14 @@ protected function createNewRequest($requestDataProvider)
521521

522522
if(($response->charges[1]->status == 'failed')){
523523
if(!empty($response->charges[1]->lastTransaction->acquirerMessage)){
524-
524+
$responseCancel = $this->getApi()->getCharges()->cancelCharge($response->charges[0]->id);
525525
$messageError = __('Your transaction was processed with failure').__(' secound card');
526526
throw new \InvalidArgumentException($messageError);
527527

528528
}
529529

530530
}
531531

532-
533532
if ($payment->getAdditionalInformation('cc_savecard_first') == '1' && empty($payment->getAdditionalInformation('cc_saved_card_first'))) {
534533
$this->getCreateCardHelper()->createCard($response->charges[0]->lastTransaction->card, $response->charges[0]->customer, $quote);
535534
}

Gateway/Transaction/TwoCreditCard/ResourceGateway/Create/Response/GeneralHandler.php

+9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ protected function _handle($payment, $response)
5858

5959
$this->setPaymentStateTwoCreditCards($payment, $response);
6060

61+
$charges1 = $response->charges[0];
62+
$charges2 = $response->charges[1];
63+
64+
$payment->setTransactionAdditionalInfo('two_cc_first_acquirer_tid',$charges1->lastTransaction->acquirerTid);
65+
$payment->setTransactionAdditionalInfo('two_cc_first_acquirer_nsu',$charges1->lastTransaction->acquirerNsu);
66+
67+
$payment->setTransactionAdditionalInfo('two_cc_second_acquirer_tid',$charges2->lastTransaction->acquirerTid);
68+
$payment->setTransactionAdditionalInfo('two_cc_second_acquirer_nsu',$charges2->lastTransaction->acquirerNsu);
69+
6170
$payment->setIsTransactionClosed(false);
6271
if($this->configCreditCard->getPaymentAction() == 'authorize_capture') {
6372
$payment->setIsTransactionClosed(true);

Gateway/Transaction/TwoCreditCard/ResourceGateway/Refund/RequestBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @link http://www.mundipagg.com
1010
*/
1111

12-
namespace MundiPagg\MundiPagg\Gateway\Transaction\TwoCreditCard\Resource\Refund;
12+
namespace MundiPagg\MundiPagg\Gateway\Transaction\TwoCreditCard\ResourceGateway\Refund;
1313

1414
use Magento\Payment\Gateway\Data\OrderAdapterInterface;
1515
use Magento\Payment\Model\InfoInterface;

Model/Ui/Billet/ConfigProvider.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public function getConfig()
3737
return [
3838
'payment' => [
3939
self::CODE =>[
40-
'text' => $this->getBilletConfig()->getText()
40+
'text' => $this->getBilletConfig()->getText(),
41+
'title' => $this->getBilletConfig()->getTitle(),
4142
]
4243
]
4344
];

Model/Ui/BilletCreditCard/ConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getConfig()
7474
'payment' => [
7575
self::CODE =>[
7676
'active' => $this->getBilletCreditCardConfig()->getActive(),
77+
'title' => $this->getBilletCreditCardConfig()->getTitle(),
7778
'is_saved_card' => $is_saved_card,
7879
'cards' => $cards,
7980
'selected_card' => $selectedCard

Model/Ui/CreditCard/ConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function getConfig()
7171
'payment' => [
7272
self::CODE =>[
7373
'active' => $this->getCreditCardConfig()->getActive(),
74+
'title' => $this->getCreditCardConfig()->getTitle(),
7475
'is_saved_card' => $is_saved_card,
7576
'cards' => $cards,
7677
'selected_card' => $selectedCard,

Model/Ui/TwoCreditCard/ConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getConfig()
7474
'payment' => [
7575
self::CODE =>[
7676
'active' => $this->getCreditCardConfig()->getActive(),
77+
'title' => $this->getCreditCardConfig()->getTitle(),
7778
'is_saved_card' => $is_saved_card,
7879
'cards' => $cards,
7980
'selected_card' => $selectedCard

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mundipagg/mundipagg-magento2-module",
33
"license": "MIT",
4-
"version": "1.2.27",
4+
"version": "1.2.39",
55
"type": "magento2-module",
66
"description": "Magento 2 Module Mundipagg",
77
"require": {

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
-->
1111
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
12-
<module name="MundiPagg_MundiPagg" setup_version="1.2.27">
12+
<module name="MundiPagg_MundiPagg" setup_version="1.2.38">
1313
<sequence>
1414
<module name="Magento_Sales" />
1515
<module name="Magento_Payment" />

i18n/pt_BR.csv

+7-6
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@
277277
"Brand","Tipo"
278278
"Error to save MundiPagg Soft Description Credit Card, size too big max 22 character.","Erro para salvar MundiPagg Soft Descrição Cartão de crédito, tamanho muito grande máximo 22 caracteres."
279279
"Max size 22.","Tamanho máximo 22."
280-
"Please check your address. First field of Street Address (Street) is required.","Por favor, verifique seu endereço. O primeiro campo do Street Address (Street) é obrigatório."
281-
"Please check your address. Second field of Street Address (Number) is required.","Por favor, verifique seu endereço. O segundo campo do Street Address (Number) é obrigatório."
282-
"Please check your address. Fourth field of Street Address (Neighborhood) is required.","Por favor, verifique seu endereço. O quarto campo do Street Address (Bairro) é obrigatório."
280+
"Please check your address. First field of Street Address (Street) is required.","Por favor, verifique seu endereço. O campo (Endereço) é obrigatório."
281+
"Please check your address. Second field of Street Address (Number) is required.","Por favor, verifique seu endereço. O campo (Número) é obrigatório."
282+
"Please check your address. Fourth field of Street Address (Neighborhood) is required.","Por favor, verifique seu endereço. O campo (Bairro) é obrigatório."
283283
"Brand not exists.","Bandeira não existe."
284284
"Name not informed.","Nome não informado."
285285
"Month not informed.","Mês não informado."
@@ -289,6 +289,9 @@
289289
"Total of the second card not informed.","Total do segundo cartão não informado."
290290
"First Card","Primeiro cartão"
291291
"Second Card","Segundo cartão"
292+
"Installments not informed.","Número de parcelas não informado."
293+
"Installments first card not informed.","Número de parcelas do primeiro cartão não informado."
294+
"Installments secund card not informed.","Número de parcelas do segundo cartão não informado."
292295
"First Card Amount","Total primeiro cartão"
293296
"Second Card Amount","Total segundo cartão"
294297
"Brand first credit card not exists.","O primeiro cartão a bandeira não existe."
@@ -323,6 +326,4 @@
323326
"My Cards MundiPagg","Meus Cartões MundiPagg"
324327
"Your transaction was processed with failure","Sua transação foi processada com falha"
325328
" first card"," primeiro cartão"
326-
" secound card"," segundo cartão"
327-
328-
329+
" secound card"," segundo cartão"

patches/0001-issues-18195.patch

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/vendor/magento/module-checkout/view/frontend/web/js/model/new-customer-address.js b/vendor/magento/module-checkout/view/frontend/web/js/model/new-customer-address.js
2+
index a880bd4..9afd6c4 100644
3+
--- a/vendor/magento/module-checkout/view/frontend/web/js/model/new-customer-address.js
4+
+++ b/vendor/magento/module-checkout/view/frontend/web/js/model/new-customer-address.js
5+
@@ -38,7 +38,7 @@ define([
6+
regionCode: addressData.region ? addressData.region['region_code'] : null,
7+
region: addressData.region ? addressData.region.region : null,
8+
customerId: addressData['customer_id'] || addressData.customerId,
9+
- street: addressData.street ? _.compact(addressData.street) : addressData.street,
10+
+ street: addressData.street,
11+
company: addressData.company,
12+
telephone: addressData.telephone,
13+
fax: addressData.fax,
14+
--
15+
2.7.4
16+

view/frontend/web/js/view/payment/method-renderer/billet.js

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ define(
7171
'additional_data': null
7272
};
7373
},
74+
getTitle: function () {
75+
return window.checkoutConfig.payment.mundipagg_billet.title;
76+
},
7477
});
7578
}
7679
);

0 commit comments

Comments
 (0)