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

Adiciona campo de CPF para transacionar com Pix #90

Closed
wants to merge 81 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
b19af91
#11177 Iniciado criação do meio de pagamento por cartão de crédito
Jul 19, 2018
63e2bae
#11177 adicionado estrutura base
Jul 24, 2018
287ec2a
Merge remote-tracking branch 'origin/11177/estrutura-basica' into 111…
Jul 24, 2018
b157a82
#11177 adicionada estrutura base
Jul 24, 2018
af3269e
resolvido conflitos
Jul 24, 2018
4c6f977
#11177 removido arquivos não necessários para esta release
Jul 24, 2018
2928a73
Merge branch '11177/base' into 11177/estrutura-basica
Jul 24, 2018
4f7f874
#11177 iniciado implementação do checkout
Jul 24, 2018
4df926c
#11177 iniciado criação da opção no carrinho
Jul 24, 2018
b258b11
#11177 criado form para adicionar os dados do cartão de crédito
Jul 25, 2018
cfe3507
#11177 agora é possível salvar os dados do cartão na ordem de compra
Jul 25, 2018
baac7ca
#11177 iniciado implementação do bloco de info da ordem
Jul 25, 2018
da0c116
#11177 agora é mostrado os dados do cartão de crédito na area admin
Jul 26, 2018
f9f5fa1
#11177 removido coisas desnecessárias
Jul 26, 2018
00db28e
#11177 adicionado campo para nome no cartão de crédito
Jul 26, 2018
bb55fa9
#11177 atualizado rota para controller
Jul 26, 2018
07c8f78
Merge branch '11177/base' into save-data
Jul 26, 2018
00b6e73
#11177 corrigido nome dos cartões de crédito, removido códigos não ne…
Jul 26, 2018
f241680
#11177 removido array de status
Jul 26, 2018
0405c94
corrigido conflitos
Jul 26, 2018
8013036
Merge branch 'save-data'
Jul 26, 2018
e185814
Merge remote-tracking branch 'upstream/master'
Aug 1, 2018
6483ec0
Merge remote-tracking branch 'upstream/master'
Aug 6, 2018
00b33a5
Merge branch 'master' of github.com:vindi/vindi-magento2
Aug 8, 2018
7a7abfd
Merge remote-tracking branch 'upstream/master'
Aug 10, 2018
caaa1e6
Merge github.com:vindi/vindi-magento2
Aug 13, 2018
a0633ea
Merge github.com:vindi/vindi-magento2
Aug 13, 2018
87ced05
Merge github.com:vindi/vindi-magento2
Aug 13, 2018
7fa35c9
Merge github.com:vindi/vindi-magento2
Aug 13, 2018
5eaeefd
movido arquivos para base para poder utilizar modman e composer
Aug 13, 2018
a784bac
Merge github.com:vindi/vindi-magento2
Aug 13, 2018
05b9a1d
Merge github.com:vindi/vindi-magento2
Aug 13, 2018
1ed2413
adicionado seletor para status da ordem ao ser confirmada
Aug 13, 2018
51e5851
corrigido chamada da função createCustomer fix #30
Aug 14, 2018
74501bb
Merge branch 'master' of https://github.com/vindi/vindi-magento2
brunoroeder Aug 22, 2018
329d88e
validation for existence of some payment method and validation of fil…
cris-silveira Oct 26, 2018
b49737c
Merge pull request #1 from trezoteam/erros-apontados-pelo-qa-do-magen…
cristhianss Oct 26, 2018
06f3518
Merge remote-tracking branch 'upstream/master'
Mar 26, 2019
fbb20e3
Merge branch 'master' of https://github.com/vindi/vindi-magento2
May 17, 2019
c37b3c5
fix ApiKeyValidator Exception Phrase
May 17, 2019
da95390
Envia valores de desconto e acréscimos para a Vindi
Maikco Jul 26, 2019
795c32a
Update Model/Payment/Product.php
Maikco Jul 29, 2019
021cecc
Update Model/Payment/Product.php
Maikco Jul 29, 2019
3e0f784
Update Model/Payment/Product.php
Maikco Jul 30, 2019
88851a7
Inicio dos testes de cupons, taxas e frete
hawshinka Aug 15, 2019
d753896
Correções nos mocks das respostas esperadas
hawshinka Aug 16, 2019
b8168dc
Merge branch 'master' of github.com:haw-trezo/vindi-magento2
hawshinka Aug 16, 2019
3df9ebd
Merge branch 'master' into feature/ajuste_no_envio_de_informacoes_com…
hawshinka Aug 16, 2019
eeaf859
Trocar o nome da classe
hawshinka Aug 16, 2019
613c1de
Testes nas mudanças de status para pedidos com boletos
hawshinka Aug 16, 2019
36f9a34
Testes nos status dos pedidos de acordo com os meios de pagamento
hawshinka Aug 16, 2019
c85911a
Merge pull request #2 from haw-trezo/feature/trezo_unit_tests
brunoroeder Aug 16, 2019
93cab97
Merge branch 'master' of github.com:vindi/vindi-magento2
hawshinka Aug 22, 2019
b7a8353
Merge branch 'master' into feature/trezo_unit_tests
hawshinka Aug 22, 2019
6da4ea7
Ajustes nos testes para conformidade com PR 55
hawshinka Aug 22, 2019
45181cc
Merge pull request #3 from haw-trezo/feature/trezo_unit_tests
brunoroeder Aug 22, 2019
1352283
Insere informações de Teste
laerte-guimaraes Aug 29, 2019
4b9ef6f
Ajusta link de download
laerte-guimaraes Aug 29, 2019
1bc5b6c
Atualizado com o projeto original
Maikco May 21, 2020
d117f48
Atualizando o status da assinatura no Magento
Maikco May 23, 2020
6993aa3
Merge remote-tracking branch 'upstream/master'
Dec 23, 2021
981ef7b
Vdk9LYXc | 3kcRcQOr - Exibir metodo de pagamento Pix no Magento
dtharssis Jan 4, 2022
e54f438
DgJyEhpZ | Renderizar Qrcode
dtharssis Jan 13, 2022
abaaa14
BU12Gcwm | Criar opção de copiar e colar código Pix
dtharssis Jan 17, 2022
325e680
updated class name configuration
dtharssis Jan 19, 2022
c45361e
PViog04y | Ajustar as mensagens das páginas de Checkout para o PIX
dtharssis Jan 21, 2022
de1ed64
NSNThKFT | Página de Meus Pedidos
dtharssis Jan 25, 2022
8831d3e
Processar mensagens de erros e sucesso API - apresentação para customer
dtharssis Jan 27, 2022
b870271
N2wIEOxd | Cancelar transação Pix
dtharssis Jan 31, 2022
f25efbe
ajustes para mostrar informações do método de pagamento
dtharssis Jan 31, 2022
6d7e431
Merge branch 'feature/pixMyOrders' into feature/pix
dtharssis Feb 1, 2022
ddbe0bd
Merge branch 'feature/pixMyOrders' into feature/signaturePix
dtharssis Feb 2, 2022
edb9c6f
Criar Assinatura Pix
dtharssis Feb 8, 2022
6bbcbf6
resolved conflict
dtharssis Feb 8, 2022
265545c
resolved conflic
dtharssis Feb 8, 2022
dbb1966
Merge branch 'feature/pixMyOrders' into feature/signaturePix
dtharssis Feb 8, 2022
13effea
updated i18n
dtharssis Feb 11, 2022
47f6269
Transacionar Pix: Magento x Vindi
dtharssis Feb 14, 2022
270bd95
Transacionar Pix: Magento x Vindi
dtharssis Feb 14, 2022
9e29541
Merge branch 'master' of github.com:vindi/vindi-magento2 into pr/dtha…
laerte-guimaraes Feb 16, 2022
9168ba9
Merge branch 'master' of github.com:vindi/vindi-magento2 into feature…
laerte-guimaraes Feb 16, 2022
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
9 changes: 9 additions & 0 deletions Api/PixConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
interface PixConfigurationInterface
{

const PATH_ENABLED_DOCUMENT = 'payment/vindi_pix/enabled_document';
const PATH_INFO_MESSAGE = 'checkout/vindi_pix/info_message';
const PATH_INFO_MESSAGE_ONEPAGE_SUCCESS = 'checkout/vindi_pix/info_message_onepage_success';
const PATH_QR_CODE_WARNING_MESSAGE = 'checkout/vindi_pix/qr-code-warning-message';

/**
* @param string $scopeType
* @param string|null $scopeCode
*
* @return bool
*/
public function isEnabledDocument(string $scopeType = ScopeInterface::SCOPE_STORE, string $scopeCode = null);

/**
* @param string $scopeType
* @param string|null $scopeCode
Expand Down
8 changes: 8 additions & 0 deletions Helper/PixConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
class PixConfiguration extends AbstractHelper implements PixConfigurationInterface
{

/**
* @inheritDoc
*/
public function isEnabledDocument(string $scopeType = ScopeInterface::SCOPE_STORE, string $scopeCode = null)
{
return $this->scopeConfig->isSetFlag(static::PATH_ENABLED_DOCUMENT, $scopeType, $scopeCode);
}

/**
* @inheritDoc
*/
Expand Down
48 changes: 43 additions & 5 deletions Model/Payment/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,38 @@

namespace Vindi\Payment\Model\Payment;


use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Message\ManagerInterface;
use Magento\Sales\Model\Order;
use Vindi\Payment\Helper\Api;

class Customer
{

/**
* @param CustomerRepositoryInterface $customerRepository
* @param Api $api
* @param ManagerInterface $messageManager
*/
public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
\Vindi\Payment\Helper\Api $api,
\Magento\Framework\Message\ManagerInterface $messageManager
CustomerRepositoryInterface $customerRepository,
Api $api,
ManagerInterface $messageManager
) {
$this->customerRepository = $customerRepository;
$this->api = $api;
$this->messageManager = $messageManager;
}

public function findOrCreate($order)
/**
* @param Order $order
*
* @return array|bool|mixed
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function findOrCreate(Order $order)
{
$billing = $order->getBillingAddress();
$customer = null;
Expand Down Expand Up @@ -43,7 +62,7 @@ public function findOrCreate($order)
$customerVindi = [
'name' => $billing->getFirstname() . ' ' . $billing->getLastname(),
'email' => $billing->getEmail(),
'registry_code' => $order->getData('customer_taxvat') ?: '',
'registry_code' => $this->getDocumentGuest($order),
'code' => $customer ? $customer->getId() : '',
'phones' => $this->formatPhone($billing->getTelephone()),
'address' => $address
Expand Down Expand Up @@ -95,6 +114,11 @@ public function findVindiCustomer($query)
return false;
}

/**
* @param $phone
*
* @return string|null
*/
public function formatPhone($phone)
{
$digits = strlen('55' . preg_replace('/^0|\D+/', '', $phone));
Expand All @@ -105,4 +129,18 @@ public function formatPhone($phone)

return array_key_exists($digits, $phone_types) ? $phone_types[$digits] : null;
}

/**
* @param \Magento\Sales\Model\Order $order
*
* @return mixed|string
*/
protected function getDocumentGuest(Order $order)
{
if($document = $order->getData('customer_taxvat')) {
return $document;
}

return $order->getPayment()->getAdditionalInformation('document') ?: '';
}
}
1 change: 1 addition & 0 deletions Model/Pix/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getConfig()
return [
'payment' => [
'vindi_pix' => [
'enabledDocument' => $this->pixConfiguration->isEnabledDocument(),
'info_message' => $this->pixConfiguration->getInfoMessage(),
]
]
Expand Down
6 changes: 5 additions & 1 deletion Observer/DataAssignObserver.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?php

namespace Vindi\Payment\Model;
namespace Vindi\Payment\Observer;


use Magento\Framework\Event\Observer;
use Magento\Payment\Observer\AbstractDataAssignObserver;
use Magento\Quote\Api\Data\PaymentInterface;

class DataAssignObserver extends AbstractDataAssignObserver
{

const PAYMENT_METHOD_NONCE = 'payment_method_nonce';
const PIX_DOCUMENT = 'document';

/**
* @var array
*/
protected $additionalInformationList = [
self::PAYMENT_METHOD_NONCE,
self::PIX_DOCUMENT
];

/**
Expand Down
7 changes: 7 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
type="text">
<label>Title</label>
</field>
<field id="enabled_document" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label"
type="select">
<label>Enabled document</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<backend_model>Vindi\Payment\Model\Config\Backend\ApiKeyValidator</backend_model>
<comment>When enabled, it will only be possible to finalize the order with the document informed when selecting the payment method. When disabled, the client will not be asked for the document, but it will still be necessary to send the document when creating the order in VINDI, otherwise it will be rejected by the API.</comment>
</field>
</group>
<group id="vindi_bankslip" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label comment">
<label>Vindi - Boleto Bancário</label>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<active>0</active>
<model>Vindi\Payment\Model\Payment\Pix</model>
<title>Vindi - Pix</title>
<enabled_document>0</enabled_document>
<allowspecific>0</allowspecific>
<payment_action>authorize</payment_action>
<group>offline</group>
Expand Down
8 changes: 5 additions & 3 deletions etc/events.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="payment_method_assign_data_braintree">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

<event name="payment_method_assign_data">
<observer name="braintree_gateway_data_assign" instance="Vindi\Payment\Observer\DataAssignObserver" />
</event>
<event name="catalog_product_save_after">
<observer name="vindi_plan_sync" instance="Vindi\Payment\Observer\ProductSaveObserver" />
</event>
</config>
</config>
2 changes: 2 additions & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@
"Copy QR Code key","Copiar chave QR Code"
"Message if the qr code is not resized.","Mensagem se o QR Code não for redimensionado."
"Pay up: %s","Pague até: %s"
"Enabled document","Ativar documento"
"When enabled, it will only be possible to finalize the order with the document informed when selecting the payment method. When disabled, the client will not be asked for the document, but it will still be necessary to send the document when creating the order in VINDI, otherwise it will be rejected by the API.","Quando habilitado, só será possível finalizar o pedido com o documento informado ao selecionar o método de pagamento. Quando desabilitado, não será solicitado ao cliente o documento, porém ainda será necessário o envio do documento ao criar o pedido na VINDI, caso contrário será rejeitado pela API."
5 changes: 5 additions & 0 deletions view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
paths: {
'jQueryMask': 'Vindi_Payment/js/libs/jquery.mask.min'
},
}
19 changes: 19 additions & 0 deletions view/frontend/web/js/libs/jquery.mask.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions view/frontend/web/js/model/document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define(
[
'jquery',
'ko',
'jQueryMask'
],

function ($, ko) {
'use strict';

$('input[name="payment[_document]"]').mask('999.999.999-99');

const value = ko.observable('');

return {
value: value
};
}
);
43 changes: 43 additions & 0 deletions view/frontend/web/js/model/validate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
define([], function() {
'use strict';

return {
isValidCpf(c){
if((c = c.replace(/[^\d]/g,"")).length != 11)
return false

if (c == "00000000000")
return false;

var r;
var s = 0;

for (var i=1; i<=9; i++)
s = s + parseInt(c[i-1]) * (11 - i);

r = (s * 10) % 11;

if ((r == 10) || (r == 11))
r = 0;

if (r != parseInt(c[9]))
return false;

s = 0;

for (i = 1; i <= 10; i++)
s = s + parseInt(c[i-1]) * (12 - i);

r = (s * 10) % 11;

if ((r == 10) || (r == 11))
r = 0;

if (r != parseInt(c[10]))
return false;

return true;
}
};
}
);
48 changes: 44 additions & 4 deletions view/frontend/web/js/view/payment/method-renderer/vindi-pix.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,59 @@ define(
'Magento_Checkout/js/view/payment/default',
'mage/translate',
'jquery',
'mageUtils'
'mageUtils',
'Vindi_Payment/js/model/document',
'Vindi_Payment/js/model/validate'
],

function (_, Component, $t, $, utils) {
function (_, Component, $t, $, utils, document, documentValidate) {
'use strict';
return Component.extend({
defaults: {
template: 'Vindi_Payment/payment/vindi-pix'
template: 'Vindi_Payment/payment/vindi-pix',
document: document
},

getInfoMessage: function () {
return window?.checkoutConfig?.payment?.vindi_pix?.info_message;
}
},

isActiveDocument: function () {
return window?.checkoutConfig?.payment?.vindi_pix?.enabledDocument;
},

checkCpf: function () {
const message = documentValidate.isValidCpf(this?.document?.value()) ? 'CPF válido' : 'CPF inválido';
$('#cpfResponse').text(message);
},


validate: function () {
const self = this;
const documentValue = this?.document?.value();

if (!documentValue || documentValue === '') {
self.messageContainer.addErrorMessage({'message': ('CPF é obrigatório')});
return false;
}

if (!documentValidate.isValidCpf(documentValue)) {
self.messageContainer.addErrorMessage({'message': ('CPF não é válido')});
return false;
}

return true;
},

getData: function() {
return {
'method': this?.item?.method,
'additional_data': {
'document': this?.document?.value()
}
};
},

});
}
);
Expand Down
Loading