Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atualização de Segurança na Atividade de Links de Pagamento #143

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3d356da
Merge pull request #1 from vindi/master
cedran Oct 1, 2024
c9d712a
feat: removed deprecated magento 2 classes
contardi Oct 9, 2024
3dd0462
feat: removed deprecated magento 2 classes
contardi Oct 9, 2024
096d220
fix: remove unused patch
contardi Oct 9, 2024
079f52c
fix: call non existing class
contardi Oct 10, 2024
f726265
fix: return composer version
Oct 14, 2024
e8f58b3
Merge pull request #2 from vindi/development
cedran Oct 21, 2024
bb738ac
Merge pull request #3 from vindi/development
cedran Oct 25, 2024
e90f745
Versionamento da 2.1.0
thais-kusuki-vindi Oct 30, 2024
32b637a
Merge pull request #135 from vindi/versionamento/2.1.0
thais-kusuki-vindi Oct 30, 2024
da3a058
Merge pull request #4 from vindi/development
cedran Nov 1, 2024
62ff5d9
Merge pull request #5 from vindi/development
cedran Dec 5, 2024
20bf8c0
Merge branch 'master' of github.com:bizcommerce/vindi-magento2
Dec 13, 2024
2d111c3
feat: merge remote
Dec 13, 2024
e874370
Merge branch 'vindi-master'
Dec 13, 2024
bb686e5
Merge remote-tracking branch 'origin/master' into development
Dec 13, 2024
597f80c
feat: new card layout
contardi Dec 14, 2024
f979e70
fix: same input id for different fields
contardi Dec 17, 2024
bcd91fd
fix: cacheable false for product view
contardi Dec 19, 2024
97bf315
fix: add cache key info product block
contardi Dec 19, 2024
a812adf
Merge pull request #7 from bizcommerce/feat/new-card-layout
contardi Dec 29, 2024
7d3c80c
feat: added all available brands
contardi Jan 6, 2025
c44273a
Merge pull request #9 from vindi/development
cedran Jan 15, 2025
e42dff0
feat: removing payment link from email and my orders
devbizcommerce Jan 29, 2025
481cbb6
fix: correcting pix qrcode size
devbizcommerce Feb 2, 2025
551d054
Merge pull request #10 from vindi/development
cedran Feb 3, 2025
591b31e
Merge branch 'development' into fix/payment_link_security_update
cedran Feb 7, 2025
55bea90
merge
devbizcommerce Feb 14, 2025
a241742
Merge branch 'fix/payment_link_security_update' of https://github.com…
devbizcommerce Feb 14, 2025
403564d
fix: error when creating order with new card
devbizcommerce Feb 14, 2025
28e2e9c
fix: save cc_type name
devbizcommerce Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Model/Payment/AbstractMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ protected function isSubscriptionOrder(Order $order)
return false;
}


/**
* @param Order $order
* @throws LocalizedException
Expand Down Expand Up @@ -687,7 +686,7 @@ public function createPaymentProfile(Order $order, InfoInterface $payment, $cust
'customer_id' => $order->getCustomerId(),
'customer_email' => $order->getCustomerEmail(),
'cc_name' => $payment->getCcOwner(),
'cc_type' => $payment->getCcType(),
'cc_type' => $this->paymentMethod->convertCcTypeToFullName($payment->getCcType()),
'cc_last_4' => $payment->getCcLast4(),
'status' => $paymentProfileData["status"],
'token' => $paymentProfileData["token"],
Expand Down
21 changes: 18 additions & 3 deletions Model/Payment/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
class PaymentMethod
{
public const BANK_SLIP = 'bank_slip';

public const BANK_SLIP_PIX = 'pix_bank_slip';

public const PIX = 'pix';
public const CREDIT_CARD = 'credit_card';
public const DEBIT_CARD = 'debit_card';
Expand Down Expand Up @@ -121,7 +119,7 @@ public function get(): array
$method['payment_companies']
);
} elseif ('PaymentMethod::DebitCard' === $method['type']) {
$paymentMethods['debit_card'] = array_merge(
$this->methods['debit_card'] = array_merge(
$this->methods['debit_card'],
$method['payment_companies']
);
Expand All @@ -134,6 +132,23 @@ public function get(): array
return $this->methods;
}

/**
* Convert credit card type abbreviation to full name if necessary.
*
* @param string $ccType
* @return string
*/
public function convertCcTypeToFullName(string $ccType): string
{
$ccTypeTrimmed = strtolower(trim($ccType));
foreach ($this->methodsCodes as $fullName => $abbrev) {
if (strtolower($abbrev) === $ccTypeTrimmed) {
return $fullName;
}
}
return $ccType;
}

/**
* @param $ccType
*
Expand Down
5 changes: 3 additions & 2 deletions Model/PaymentLinkService.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ public function sendPaymentLinkEmail($orderId): bool
}

$templateVars = [
'customer_name' => $order->getCustomerFirstname(),
'payment_link' => $paymentLink->getLink()
'customer_name' => $order->getCustomerFirstname(),
'payment_link' => $paymentLink->getLink(),
'order_increment' => $order->getIncrementId()
];
$from = [
'email' => $this->scopeConfig->getValue(self::SALES_EMAIL, ScopeInterface::SCOPE_STORE),
Expand Down
9 changes: 9 additions & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,15 @@
"This payment link has expired.","Este link de pagamento expirou."
"The payment success page has already been accessed.","A página de sucesso do pagamento já foi acessada."
"Card Information","Dados do Cartão"
"You can access the payment link for your order by logging into your Customer Account. Once logged in, navigate to the Orders section, where you will find the payment link to complete your payment.","Você pode acessar o link de pagamento para o seu pedido fazendo login em sua Conta de Cliente. Depois de logado, acesse a seção de Pedidos, onde você encontrará o link de pagamento para completar seu pagamento."
"A Payment Link Has Been Generated for You","Um link de pagamento foi gerado para você"
"We have generated a payment link for your order. Please log in to your Customer Account to access it.","Geramos um link de pagamento para o seu pedido. Faça login em sua conta de cliente para acessá-lo."
"How to Access the Payment Link?", "Como acessar o link de pagamento?"
"Log in to your account, access the 'Orders' section and click on the payment link access corresponding to the order #", "Faça login em sua conta, acesse a seção 'Pedidos' e clique no link de acesso ao pagamento correspondente ao pedido #"
"Order Details", "Detalhes do Pedido"
"Order Number: ", "Número do Pedido: "
"The payment link was successfully sent.","O link de pagamento foi enviado com sucesso."
"Send Payment Link","Enviar Link de Pagamento"
"A subscription must have at least one non-shipping item with a price greater than zero.","Uma assinatura deve ter pelo menos um item que não seja de frete com preço maior que zero."
"The quantity of the shipping item cannot be changed. Only the price can be updated.","A quantidade do item de frete não pode ser alterada. Somente o preço pode ser atualizado."
"Cannot delete item. Subscription must have at least one non-shipping item with a price greater than zero.","Não é possível excluir o item. A assinatura deve ter pelo menos um item que não seja de frete com preço maior que zero."
17 changes: 17 additions & 0 deletions view/adminhtml/templates/info/bankslippix.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ use Vindi\Payment\Block\Info\BankSlipPix;
<dl class="payment-method">
<dt class="title"><strong><?php echo $block->escapeHtml($block->getMethod()->getTitle()) ?></strong></dt>
<?php if (!$block->hasInvoice() && $block->canShowBankSlipPixInfo()) : ?>
<dd class="content">
<?php if ($block->getQrCodePix()): ?>
<object data="<?= $block->getQrCodePix() ?>" type="image/svg+xml" class="qr-code" id="qrcode" width="200" height="200">
<p>
<?= $block->getQrCodeWarningMessage() ?>
</p>
<button
id="vindi-pix-button-open"
type="button"
class="action primary checkout"
title="Open QR Code Pix"
onclick="window.open('<?= $block->getQrCodePix() ?>', '_blank')">
<?= __('Open QR Code') ?>
</button>
</object>
<?php endif; ?>
</dd>
<dd class="content">
<br/>
<p><?php echo sprintf(__('Print Url: %s'), '<a target="_blank" href="'. $block->getPrintUrl() . '">'. $block->getPrintUrl() . '</a>') ?></p>
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/templates/info/pix.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use Vindi\Payment\Block\Info\Pix;
<?php endif; ?>
<dd class="content">
<?php if ($block->getQrCodePix()): ?>
<object data="<?= $block->getQrCodePix() ?>" type="image/svg+xml" class="qr-code" id="qrcode">
<object data="<?= $block->getQrCodePix() ?>" type="image/svg+xml" class="qr-code" id="qrcode" width="200" height="200">
<p>
<?= $block->getQrCodeWarningMessage() ?>
</p>
Expand Down
14 changes: 1 addition & 13 deletions view/adminhtml/templates/link-field.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,10 @@
echo $param = $request->getParam('order_id'); ?>"/>

<span class="link" style="display: none"><?= $block->getPaymentLink(); ?></span>

<input type="text"
class="admin__control-text"
value="<?php echo $block->getPaymentLink(); ?>"
style="margin-right: 10px"
readonly>
<button class="pix-copy-button"
style="margin-right: 10px"
data-text="<?= $block->escapeHtml(__('Copied!')) ?>"
onclick="vindiVr.copyCode(this, '.link', false)">
<?= $block->escapeHtml(__('Copy link')) ?>
</button>
</fieldset>

<button id="vind_payment_send" class="action-default action-secondary action-send">
<?php /* @escapeNotVerified */ echo __('Create and send new payment link') ?>
<?php /* @escapeNotVerified */ echo __('Send Payment Link') ?>
</button>
<?php endif; ?>
</div>
Expand Down
67 changes: 30 additions & 37 deletions view/frontend/email/payment_link.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
<!--@subject {{trans "Payment Link for Your Order"}} @-->
<!--@subject {{trans "Payment Link"}} @-->
<!--@vars
{"store url=\"\"":"Store Url",
"skin url=\"images/logo_email.gif\" _area='frontend'":"Email Logo Image"}
@-->
<!--@styles
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
a { color: #ffffff; text-decoration: none; }
.pay-now-button {
display: inline-block;
padding: 10px 20px;
background-color: #1a73e8;
color: #ffffff !important;
font-size: 16px;
font-weight: bold;
border-radius: 4px;
text-align: center;
}
.pay-now-button:hover, .pay-now-button:visited {
color: #ffffff !important;
}
body,td { color:#2f2f2f; font:14px/1.5em Arial, Helvetica, sans-serif; }
h1 { font-size:22px; color:#333333; }
p { margin:10px 0; }
a { color:#1a73e8; text-decoration:none; }
@-->
{{template config_path="design/email/header_template"}}
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<table cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color:#f8f8f8; padding:20px 0;">
<tr>
<td align="center" valign="top" style="padding:20px 0 20px 0">
<table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<td align="center">
<table bgcolor="#FFFFFF" cellspacing="0" cellpadding="20" border="0" width="650" style="border:1px solid #e0e0e0; border-radius:8px;">
<tr>
<td valign="top">
<h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">{{trans "Hello"}}, {{var customer_name|raw}}</h1>
<td align="center" style="border-bottom:1px solid #e0e0e0; padding-bottom:20px;">
<h1>{{trans "Hello"}}, {{var customer_name|raw}}</h1>
</td>
</tr>
<tr>
<td>
<p style="font-size:14px;line-height:20px;margin:0 0 20px 0;">{{trans "Thank you for your order!"}}</p>
<p style="font-size:14px;line-height:20px;margin:0 0 20px 0;">{{trans "To complete your purchase, please use the payment link below."}}</p>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tbody>
<tr>
<td align="center" valign="top" style="padding:20px;">
<a href="{{var payment_link}}" class="pay-now-button">{{trans "Pay Now"}}</a>
</td>
</tr>
<tr>
<td valign="top" style="font-size:12px;padding:7px 9px 9px 9px;text-align:center;color:#555;">
{{trans "If you have any questions or need assistance, please contact our support team."}}
</td>
</tr>
</tbody>
</table>
<h2 style="font-size:18px; color:#333;">{{trans "A Payment Link Has Been Generated for You"}}</h2>
<p style="font-size:14px; color:#555;">
{{trans "We have generated a payment link for your order. Please log in to your Customer Account to access it."}}
</p>
</td>
</tr>
<tr>
<td>
<h3 style="font-size:16px; color:#333; margin-bottom:10px;">{{trans "How to Access the Payment Link?"}}</h3>
<p style="font-size:14px; color:#555; margin:0;">
{{trans "Log in to your account, access the 'Orders' section and click on the payment link access corresponding to the order #"}}{{var order_increment}}.
</p>
</td>
</tr>
<tr>
<td style="border-top:1px solid #e0e0e0; padding-top:20px;">
<h4 style="font-size:14px; color:#555; margin-bottom:5px;">{{trans "Order Details"}}</h4>
<p style="font-size:14px; color:#333; margin:0;">
<strong>{{trans "Nº: "}}</strong> #{{var order_increment}}
</p>
</td>
</tr>
</table>
Expand Down
8 changes: 7 additions & 1 deletion view/frontend/templates/custom/payment-link.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,13 @@ $paymentLink = $block->getPaymentLink();
if (icon) {
icon.classList.add('highlighted');
}
document.getElementById('cc_type').value = cardType.toLowerCase().replace(/-/g, '_');
const cardTypeMapping = {
'VISA': 'VI',
'MASTERCARD': 'MC',
'AMERICAN-EXPRESS': 'AE',
'ELO': 'ELO'
};
document.getElementById('cc_type').value = cardTypeMapping[cardType] || cardType;
}

applyCardNumberMask(cardType);
Expand Down