Skip to content

Commit 97c699e

Browse files
thalita-nascimento-vindithais-kusuki-vindicedrandevbizcommercecontardi
authored
Versão 2.2.0 (#140)
* Versionamento da 2.1.0 (#134) * Link de Pagamento - Cancelamento de Pedido (#136) * fix: add 'view/base/web/images/cc' images * feat: adding information message when deleting credit card * feat: add translate payment * feat: committing the features of the functionality in general * fix: error with null * fix: unify settings on menu * fix: unify settings on menu * feat: Adding validation on the card success page * feat: add delete payment link cron * fix: returning composer to version '1.4.0' * fix: delete payment link argument * fix: correction of method names in the template * fix: adjusting BillPaid webhook flow for when it is subscription and when it is not * fix: correction when searching for customer data in purchases with pix in Model/Payment/Customer.php * fix: PLANOS (1) * fix: PLANOS (1) - quantidade de periodos vazio * fix: PLANOS (2) - correcao de labels e quantidade de ate 31 dias * fix: PLANOS (3) e (4) - ajuste na edicao de planos importados * fix: PRODUTOS (1) e (2) - ajuste de cadastro de planos ao salvar produtos * fix: - PRODUTOS (3) - removendo cache do campo observacoes * fix: ASSINATURAS (2) - ajuste ao refazer pedidos de assinatura * fix: ASSINATURAS (1) - correcao na aplicacao de descontos * fix 2: PLANOS (3) e (4) - ajuste na edicao de planos importados * fix: PLANOS - ajustes ao salvar configuracao da cobranca * fix 2: PLANOS (1) - quantidade de periodos vazio * fix: METODOS DE PAGAMENTO - correcao ao habilitar/desabilitar compras com recorrencia * fix: CHECKOUT - duplicacao de mensagens * fix: PLANOS adicionando ID ao code * fix: PRODUTO - adicionando filtro no preco para valores maiores que zero * fix: PLANOS - ajuste no code * fix: CHECKOUT - compra como convidado * fix: ASSINATURAS - ajuste na exibicao dos detalhes da assinatura * fix: LOGS - aplicacao de mascara no CVV e no registry_code * fix: PRODUTOS - exibicao de mensagem no carrinho * feat: show discount at checkout and redirect customer to home page if link expires * fix: LOG - refatoracao nas expressoes regulares * fix: CHECKOUT - ajuste na url do boleto na renovacao de ciclo de assinatura * fix: ajuste da label do botao de criar e enviar novo link de pagamento * refactor: ajustando codigo para validacao do PHPStan * VINDI-158: estilizacao paginas link de pagamento e sucesso * Retorna arquivos comitados por engano * feat: vindi payment link module * fix: remove delete payment link after first access * feat: frontend development * fix: fix error Block/InfoTrait.php * fix: pay now color * feat: login is required, columns in the grid in the admin and frontend * feat: mass action send payment link email * feat: create payment link status * fix: add status validation in mass payment link send * fix: change link payment expiration time for 20 days * fix: update expired link * fix: change paid to processed status * fix: creating email trigger config * fix: changing the instruction label on the payment link success page * fix: setting a default template if none is selected * fix: name in from customer template * feat: add transtale * feat: adding access to the payment link also within the order * fix: change the link status if the order is canceled and it has not yet been changed * refactor: readjusting features to test them better * changing the version to 2.1.0 * feat: mass sending of emails in the order grid * feat: cancel order if payment link not processed * fix: save payment additionoal information in saved card * fix: version * refactor: change translate * fix: remove version in composer.json * feat: when invoicing orders, payments are processed * refactor: line comment * fix: plan form format --------- Co-authored-by: Iago Cedran <[email protected]> Co-authored-by: Thiago Contardi <[email protected]> Co-authored-by: Caroline Esteves <[email protected]> * Link de Pagamento - Template de Email (#137) * feat: adding information message when deleting credit card * feat: add translation * feat: add translate payment * feat: committing the features of the functionality in general * fix: error with null * fix: unify settings on menu * fix: unify settings on menu * feat: Adding validation on the card success page * feat: add delete payment link cron * fix: returning composer to version '1.4.0' * fix: delete payment link argument * fix: correction of method names in the template * fix: adjusting BillPaid webhook flow for when it is subscription and when it is not * fix: correction when searching for customer data in purchases with pix in Model/Payment/Customer.php * fix: PLANOS (1) * fix: PLANOS (1) - quantidade de periodos vazio * fix: PLANOS (2) - correcao de labels e quantidade de ate 31 dias * fix: PLANOS (3) e (4) - ajuste na edicao de planos importados * fix: PRODUTOS (1) e (2) - ajuste de cadastro de planos ao salvar produtos * fix: - PRODUTOS (3) - removendo cache do campo observacoes * fix: ASSINATURAS (2) - ajuste ao refazer pedidos de assinatura * fix: ASSINATURAS (1) - correcao na aplicacao de descontos * fix 2: PLANOS (3) e (4) - ajuste na edicao de planos importados * fix: PLANOS - ajustes ao salvar configuracao da cobranca * fix 2: PLANOS (1) - quantidade de periodos vazio * fix: METODOS DE PAGAMENTO - correcao ao habilitar/desabilitar compras com recorrencia * fix: CHECKOUT - duplicacao de mensagens * fix: PLANOS adicionando ID ao code * fix: PRODUTO - adicionando filtro no preco para valores maiores que zero * fix: PLANOS - ajuste no code * fix: CHECKOUT - compra como convidado * fix: ASSINATURAS - ajuste na exibicao dos detalhes da assinatura * fix: LOGS - aplicacao de mascara no CVV e no registry_code * fix: PRODUTOS - exibicao de mensagem no carrinho * feat: show discount at checkout and redirect customer to home page if link expires * fix: LOG - refatoracao nas expressoes regulares * fix: CHECKOUT - ajuste na url do boleto na renovacao de ciclo de assinatura * fix: ajuste da label do botao de criar e enviar novo link de pagamento * refactor: ajustando codigo para validacao do PHPStan * VINDI-158: estilizacao paginas link de pagamento e sucesso * Retorna arquivos comitados por engano * feat: vindi payment link module * fix: remove delete payment link after first access * feat: frontend development * fix: fix error Block/InfoTrait.php * fix: pay now color * feat: login is required, columns in the grid in the admin and frontend * feat: mass action send payment link email * feat: create payment link status * fix: add status validation in mass payment link send * fix: change link payment expiration time for 20 days * fix: update expired link * fix: change paid to processed status * fix: creating email trigger config * fix: changing the instruction label on the payment link success page * fix: setting a default template if none is selected * fix: name in from customer template * feat: add transtale * feat: adding access to the payment link also within the order * fix: change the link status if the order is canceled and it has not yet been changed * refactor: readjusting features to test them better * changing the version to 2.1.0 * feat: mass sending of emails in the order grid * feat: cancel order if payment link not processed * feat: add template email by config * fix: save payment additionoal information in saved card * fix: version * fix: adjusting link access correction * refactor: change translate * fix: remove version in composer.json * feat: when invoicing orders, payments are processed * fix: correcting to pick up emails, either the default, or those created from the default * feat: changing the display of labels in the admin * feat: adding expiration validation to access payment link success page * fix: only 'vindi_vr_payment_link_template' custom email template * fix: change form with get status * feat: implementing single view system on success page * refactor: line comment * fix: plan form format --------- Co-authored-by: Iago Cedran <[email protected]> Co-authored-by: Thiago Contardi <[email protected]> Co-authored-by: Caroline Esteves <[email protected]> * Novo layout do cartão de crédito na página de checkout (#138) * feat: removed deprecated magento 2 classes * feat: removed deprecated magento 2 classes * fix: remove unused patch * fix: call non existing class * fix: return composer version * Versionamento da 2.1.0 * feat: new card layout * fix: same input id for different fields * fix: cacheable false for product view * fix: add cache key info product block * feat: added all available brands --------- Co-authored-by: Iago Cedran <[email protected]> Co-authored-by: Thiago Contardi <[email protected]> Co-authored-by: Thais Kusuki <[email protected]> Co-authored-by: Thais Kusuki <[email protected]> * inserindo as outras alterações no merge --------- Co-authored-by: Thais Kusuki <[email protected]> Co-authored-by: Iago Cedran <[email protected]> Co-authored-by: Iago Cedran <[email protected]> Co-authored-by: Thiago Contardi <[email protected]> Co-authored-by: Caroline Esteves <[email protected]> Co-authored-by: Contardi <[email protected]> Co-authored-by: Thiago Contardi <[email protected]> Co-authored-by: Thais Kusuki <[email protected]>
1 parent 62ae174 commit 97c699e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+5290
-717
lines changed

Api/Data/PaymentLinkInterface.php

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
declare(strict_types=1);
44

5-
/**
6-
* DISCLAIMER
7-
*
8-
* Do not edit or add to this file if you wish to upgrade this extension to newer
9-
* version in the future.
10-
*
11-
* @category Vindi
12-
* @package Vindi_Payment
13-
*/
14-
155
namespace Vindi\Payment\Api\Data;
166

177
use Magento\Framework\Api\ExtensibleDataInterface;
@@ -25,14 +15,16 @@ interface PaymentLinkInterface extends ExtensibleDataInterface
2515
const CUSTOMER_ID = 'customer_id';
2616
const CREATED_AT = 'created_at';
2717
const STATUS = 'status';
18+
const EXPIRED_AT = 'expired_at';
19+
const SUCCESS_PAGE_ACCESSED = 'success_page_accessed';
2820

2921
/**
3022
* @return int
3123
*/
3224
public function getEntityId();
3325

3426
/**
35-
* @param int $id
27+
* @param int $entityId
3628
*/
3729
public function setEntityId(int $entityId);
3830

@@ -95,4 +87,32 @@ public function getStatus();
9587
* @param string $status
9688
*/
9789
public function setStatus(string $status);
90+
91+
/**
92+
* Get the expiration date of the payment link
93+
*
94+
* @return string|null
95+
*/
96+
public function getExpiredAt();
97+
98+
/**
99+
* Set the expiration date of the payment link
100+
*
101+
* @param string|null $expiredAt
102+
*/
103+
public function setExpiredAt($expiredAt);
104+
105+
/**
106+
* Check if the success page has been accessed
107+
*
108+
* @return bool
109+
*/
110+
public function getSuccessPageAccessed();
111+
112+
/**
113+
* Set the success page accessed flag
114+
*
115+
* @param bool $successPageAccessed
116+
*/
117+
public function setSuccessPageAccessed(bool $successPageAccessed);
98118
}

Block/InfoTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getCcValue($totalQtyCard = 1, $cardPosition = 1)
6969
*/
7070
public function getCcBrand()
7171
{
72-
$brands = $this->paymentMethod->getCreditCardTypes();
72+
$brands = $this->paymentMethod->getCreditCardCodes();
7373
$CardCode = $this->getOrder()->getPayment()->getCcType();
7474

7575
return isset($brands[$CardCode]) ? $brands[$CardCode] : null;

Block/Product/ProductRecurrence.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ public function __construct(
7272
$this->_localeFormat = $localeFormat;
7373
}
7474

75+
/**
76+
* Get cache key informative items
77+
*
78+
* @return array
79+
*/
80+
public function getCacheKeyInfo()
81+
{
82+
return [
83+
'BLOCK_TPL',
84+
$this->_storeManager->getStore()->getCode(),
85+
$this->getTemplateFile(),
86+
'base_url' => $this->getBaseUrl(),
87+
'template' => $this->getTemplate(),
88+
'current_product' => $this->getCurrentProduct()->getId(),
89+
];
90+
}
91+
7592
/**
7693
* Returns the current product from the registry.
7794
*
@@ -82,6 +99,14 @@ public function getCurrentProduct()
8299
return $this->_registry->registry('current_product');
83100
}
84101

102+
public function getProductId(): int
103+
{
104+
try {
105+
return $this->getCurrentProduct()->getId();
106+
} catch (\Exception $e) {
107+
return 0;
108+
}
109+
}
85110
/**
86111
* Returns the name of a plan by its ID.
87112
*

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## [2.2.0 - 14/01/2025](https://github.com/vindi/vindi-magento2/releases/tag/2.2.0)
44

55
- Novo layout do cartão de crédito na página de checkout
6+
- Nova Configuração de Templates Personalizados para Notificação de Link de Pagamento
7+
- Novo Recurso de cancelamento de Pedidos com Link de Pagamento Expirado Após 30 Dias
68

79
## [2.1.0 - 30/10/2024](https://github.com/vindi/vindi-magento2/releases/tag/2.1.0)
810

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vindi\Payment\Console\Command;
6+
7+
use Vindi\Payment\Cron\CancelOrdersWithExpiredLinks;
8+
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
use Psr\Log\LoggerInterface;
12+
13+
class RunCancelOrdersWithExpiredLinks extends Command
14+
{
15+
/**
16+
* @var CancelOrdersWithExpiredLinks
17+
*/
18+
private CancelOrdersWithExpiredLinks $cancelOrdersWithExpiredLinks;
19+
20+
/**
21+
* @var LoggerInterface
22+
*/
23+
private LoggerInterface $logger;
24+
25+
/**
26+
* @param CancelOrdersWithExpiredLinks $cancelOrdersWithExpiredLinks
27+
* @param LoggerInterface $logger
28+
*/
29+
public function __construct(
30+
CancelOrdersWithExpiredLinks $cancelOrdersWithExpiredLinks,
31+
LoggerInterface $logger
32+
) {
33+
$this->cancelOrdersWithExpiredLinks = $cancelOrdersWithExpiredLinks;
34+
$this->logger = $logger;
35+
parent::__construct();
36+
}
37+
38+
/**
39+
* Configure the command
40+
*/
41+
protected function configure()
42+
{
43+
$this->setName('vindi:payment:cancel-orders-with-expired-links');
44+
$this->setDescription('Manually run the cron to cancel orders with expired payment links');
45+
parent::configure();
46+
}
47+
48+
/**
49+
* Execute the command
50+
*
51+
* @param InputInterface $input
52+
* @param OutputInterface $output
53+
* @return int
54+
*/
55+
protected function execute(InputInterface $input, OutputInterface $output): int
56+
{
57+
try {
58+
$this->cancelOrdersWithExpiredLinks->execute();
59+
$output->writeln('<info>Orders with expired payment links have been canceled successfully.</info>');
60+
return Command::SUCCESS;
61+
} catch (\Exception $e) {
62+
$this->logger->error('Error while canceling orders with expired payment links: ' . $e->getMessage());
63+
$output->writeln('<error>An error occurred while canceling orders with expired payment links.</error>');
64+
return Command::FAILURE;
65+
}
66+
}
67+
}

Controller/Checkout/Success.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* @category Vindi
1313
* @package Vindi_Payment
1414
*
15-
*
1615
*/
1716

1817
namespace Vindi\Payment\Controller\Checkout;
@@ -24,6 +23,7 @@
2423
use Magento\Framework\Message\ManagerInterface;
2524
use Vindi\Payment\Helper\Data;
2625
use Vindi\Payment\Model\PaymentLinkService;
26+
use Magento\Sales\Model\OrderRepository;
2727

2828
class Success implements HttpGetActionInterface
2929
{
@@ -57,21 +57,28 @@ class Success implements HttpGetActionInterface
5757
*/
5858
private ManagerInterface $messageManager;
5959

60+
/**
61+
* @var OrderRepository
62+
*/
63+
private OrderRepository $orderRepository;
64+
6065
/**
6166
* @param PageFactory $resultPageFactory
6267
* @param PaymentLinkService $paymentLinkService
6368
* @param RequestInterface $request
6469
* @param RedirectFactory $redirectFactory
6570
* @param Data $helperData
6671
* @param ManagerInterface $messageManager
72+
* @param OrderRepository $orderRepository
6773
*/
6874
public function __construct(
6975
PageFactory $resultPageFactory,
7076
PaymentLinkService $paymentLinkService,
7177
RequestInterface $request,
7278
RedirectFactory $redirectFactory,
7379
Data $helperData,
74-
ManagerInterface $messageManager
80+
ManagerInterface $messageManager,
81+
OrderRepository $orderRepository
7582
)
7683
{
7784
$this->resultPageFactory = $resultPageFactory;
@@ -80,6 +87,7 @@ public function __construct(
8087
$this->redirectFactory = $redirectFactory;
8188
$this->helperData = $helperData;
8289
$this->messageManager = $messageManager;
90+
$this->orderRepository = $orderRepository;
8391
}
8492

8593
/**
@@ -98,6 +106,20 @@ public function execute()
98106

99107
return $this->redirectFactory->create()->setPath('/');
100108
}
109+
110+
$paymentLink = $this->paymentLinkService->getPaymentLinkByOrderId($orderId);
111+
112+
if ($paymentLink && $paymentLink->getSuccessPageAccessed()) {
113+
$this->messageManager->addWarningMessage(
114+
__('The payment success page has already been accessed.')
115+
);
116+
117+
return $this->redirectFactory->create()->setPath('/');
118+
}
119+
120+
$paymentLink->setSuccessPageAccessed(true);
121+
$this->paymentLinkService->savePaymentLink($paymentLink);
122+
101123
} catch (\Exception $e) {
102124
$this->messageManager->addErrorMessage(
103125
__('An error occurred while processing your request. Please try again later.')

Controller/PaymentProfile/Save.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\ResponseInterface;
1111
use Magento\Framework\Exception\NotFoundException;
1212
use Magento\Framework\View\Result\PageFactory;
13+
use Vindi\Payment\Model\Payment\PaymentMethod;
1314
use Vindi\Payment\Model\Payment\Profile as PaymentProfileManager;
1415
use Vindi\Payment\Model\PaymentProfileFactory;
1516
use Vindi\Payment\Model\PaymentProfileRepository;
@@ -80,6 +81,11 @@ class Save extends Action
8081
*/
8182
protected $api;
8283

84+
/**
85+
* @var PaymentMethod
86+
*/
87+
protected $paymentMethod;
88+
8389
/**
8490
* @param Context $context
8591
* @param PageFactory $resultPageFactory
@@ -93,6 +99,7 @@ class Save extends Action
9399
* @param SubscriptionFactory $subscriptionFactory
94100
* @param SubscriptionResource $subscriptionResource
95101
* @param Api $api
102+
* @param PaymentMethod $paymentMethod
96103
*/
97104
public function __construct(
98105
Context $context,
@@ -106,7 +113,8 @@ public function __construct(
106113
VindiCustomer $vindiCustomer,
107114
SubscriptionFactory $subscriptionFactory,
108115
SubscriptionResource $subscriptionResource,
109-
Api $api
116+
Api $api,
117+
PaymentMethod $paymentMethod
110118
) {
111119
parent::__construct($context);
112120
$this->resultPageFactory = $resultPageFactory;
@@ -120,6 +128,7 @@ public function __construct(
120128
$this->subscriptionFactory = $subscriptionFactory;
121129
$this->subscriptionResource = $subscriptionResource;
122130
$this->api = $api;
131+
$this->paymentMethod = $paymentMethod;
123132
}
124133

125134
/**
@@ -210,7 +219,7 @@ public function execute()
210219
* @param int $customerId
211220
* @return array
212221
*/
213-
private function formatPaymentProfileData($data, $customerId)
222+
private function formatPaymentProfileData(array $data, $customerId): array
214223
{
215224
$cardNumber = preg_replace('/\D/', '', $data['cc_number']);
216225

@@ -219,17 +228,16 @@ private function formatPaymentProfileData($data, $customerId)
219228
$cardExpiration = $expirationParts[0] . '/' . $expirationYear;
220229
$paymentCompanyCode = $data['cc_type'];
221230

222-
$formattedData = [
231+
$ccTypeCode = $this->paymentMethod->getCreditCardApiCode($paymentCompanyCode);
232+
return [
223233
'holder_name' => $data['cc_name'],
224234
'card_expiration' => $cardExpiration,
225235
'card_number' => $cardNumber,
226236
'card_cvv' => $data['cc_cvv'],
227237
'customer_id' => $customerId,
228-
'payment_company_code' => $paymentCompanyCode,
238+
'payment_company_code' => $ccTypeCode,
229239
'payment_method_code' => 'credit_card',
230240
];
231-
232-
return $formattedData;
233241
}
234242

235243
/**

0 commit comments

Comments
 (0)