Skip to content

Commit f949ba2

Browse files
cedrancontardiThiago ContardiGabrielAntalcarolineesteves
authored
Salvar informações de cartão de crédito na VP (#16)
* feat: added new credit card form * feat: added setup for old settings and minor bugfixes * fix: error with 1i18n on setting's page * fix: allow all countris by default * i18n: add new terms for language file * feat: added max installments and minum installment value * feat: added reseller token to transactions * feat: added reseller token to transactions * feat: send tracking code to Vindi * fix: mask also reseller token and token account * fix: when the card number comes with 4 digits, don't add 20 before it * fix: when the card number comes with 4 digits, don't add 20 before it * doc: added pull request template * fix: observer to bankslippix * fix: cancel unapproved orders without config * feat: adjust with phpstan * fix: error monitoring transactions * fix: worng price additional * fix: update terms to ask for a CPF on checkout * feat: don't auto select TaxVat when is not a CPF number * feat: don't auto select TaxVat when is not a CPF number * Payment link functionality created * Vindi payment method verification to send the payment link has been added * The payment link email template changed and made an email configuration to set the template * Template Id changed * Email path and list fixed * feat/VINDI-143: estilo da pagina de link de pagamento com boleto, pix, bolepix e cartao * feat/VINDI-143: estilizacao pagina link de pagamento * Use strict added to js file * ko library added * float cast removed * Applying the requested changes on payment link files * adding the vindi_customer_taxvat to additionalInformation * Fixing the bugs about payment link * VP module version has been updated * payment link email template has been changed * Deleting the payment link when it is expired * Fixing the payment link summary details * Adding a discount verification * Making the discount value positive * fix: change fingerprint loader * VINDI-143: pagina de sucesso * VINDI-143: mensagem de desconto no link de pagamento * Remove linha comentada * The payment link delete has been removed from the payment link page * fix: add fingerprint method in define * fix: customer without taxvat * fix: preventing conflict with the vindi recurrence module * feat: adding security validations and better payment link management * fix: phpstan fix * feat: creating mass sending of payment link * fix: remove await vindi fingerprint * feat: add translate * feat: automatically cancels orders whose payment link has expired more than 30 days ago * feat: custom email template * fix: remove await vindi fingerprint * fix: remove await vindi fingerprint * refactor: adding validation on payment methods and payment link success page * fix: change form with get status * feat: implementing single view system on success page * feat: translate * fix: remove await vindi fingerprint * fix: remove await vindi fingerprint * feat: expire_at field * update * update * update * update * fix: processing payment link when canceling * fix: Adjust payment data displays if the order has already been invoiced * feat: added refund functionality * fix: allow to refund * fix: remove default consumer-key, consumer secret * fix: remove default consumer-key, consumer secret * fix: remove default consumer-key, consumer secret * feat: create authentication button * refactor: add logging in refund flow * fix: address saving repeated * fix: address saving repeated * fix: logger in helper * fix: logger in helper * fix: logger in helper * refactor: add log in RefundRequest * refactor: add log in RefundRequest * refactor: add log in RefundRequest * fix: correcting the way the access_token is taken * fix: generate new access_token * refactor: refactoring duplicate code and creating tests * refactor: refactoring duplicate code and creating tests * refactor: refactoring duplicate code and creating tests * fix: call fingerprint script in all pages * fix: regenerate acces_token * v1.4.1 * fix: refresh token error * fix: it should not be possible to generate payment link via the frontend * feat: added text to return URL * fix: round the discount tag * feat: creation of the 'vindi_vp_credit_cards' table and its respective models * feat: save cart_token * feat: save cart on checkout * feat: creating card management in the customer account * feat: add new adding new payment brands * refactor: implementing installment consultation also for saved cards * feat: creating option to save card with checkbox at checkout * refactor: removing the add card button from the customer center * feat: adding cvv as mandatory when using saved card * fix: fixing card deletion * fix: correcting the saving of card data when purchasing with an already saved card * refactor: added PHPDoc on methods that were missing * feat: changing portuguese function names from 'view/frontend/web/js/customer/account/payment_profile/edit.js' to english * refactor: refactor credit card handling: unify input listeners, extract detectCardType, consolidate BIN patterns, and simplify masking and validations * refactor: refactor PaymentProfile controllers: enforce strict_types, add method type hints and English docblocks, streamline save/delete flows and improve exception handling --------- Co-authored-by: Thiago Contardi <thiagocontardi@hotmail.com> Co-authored-by: Thiago Contardi <thiago@bizcommerce.com.br> Co-authored-by: Contardi <contardi@users.noreply.github.com> Co-authored-by: Gabriel Antal <gabrielantalsilva@gmail.com> Co-authored-by: Caroline Esteves <carol@bizcommerce.com.br> Co-authored-by: Antal <gabriel.antal@bizcommerce.com.br> Co-authored-by: Antal <44688111+GabrielAntal@users.noreply.github.com> Co-authored-by: carolineesteves <131886821+carolineesteves@users.noreply.github.com> Co-authored-by: Iago Cedran <iago@bizcommerce.com.br>
1 parent ccfc138 commit f949ba2

File tree

42 files changed

+2598
-265
lines changed

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

+2598
-265
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Vindi\VP\Api;
4+
5+
use Magento\Framework\Api\SearchCriteriaInterface;
6+
use Vindi\VP\Api\Data\CreditCardInterface;
7+
8+
/**
9+
* Interface CreditCardRepositoryInterface
10+
* @package Vindi\VP\Api
11+
*/
12+
interface CreditCardRepositoryInterface
13+
{
14+
/**
15+
* Save a credit card.
16+
*
17+
* @param CreditCardInterface $creditCard
18+
* @return CreditCardInterface
19+
*/
20+
public function save(CreditCardInterface $creditCard);
21+
22+
/**
23+
* Get credit card by ID.
24+
*
25+
* @param int $id
26+
* @return CreditCardInterface
27+
*/
28+
public function getById($id);
29+
30+
/**
31+
* Delete credit card.
32+
*
33+
* @param CreditCardInterface $creditCard
34+
* @return bool
35+
*/
36+
public function delete(CreditCardInterface $creditCard);
37+
38+
/**
39+
* Delete credit card by ID.
40+
*
41+
* @param int $id
42+
* @return bool
43+
*/
44+
public function deleteById($id);
45+
46+
/**
47+
* Get list of credit cards.
48+
*
49+
* @param SearchCriteriaInterface $searchCriteria
50+
* @return \Magento\Framework\Api\SearchResultsInterface
51+
*/
52+
public function getList(SearchCriteriaInterface $searchCriteria);
53+
}

Api/Data/CreditCardInterface.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Vindi\VP\Api\Data;
4+
5+
/**
6+
* Interface CreditCardInterface
7+
* @package Vindi\VP\Api\Data
8+
*/
9+
interface CreditCardInterface
10+
{
11+
const ENTITY_ID = 'entity_id';
12+
const CUSTOMER_ID = 'customer_id';
13+
const CARD_TOKEN = 'card_token';
14+
const CUSTOMER_EMAIL = 'customer_email';
15+
const STATUS = 'status';
16+
const TYPE = 'type';
17+
const CC_TYPE = 'cc_type';
18+
const CC_LAST_4 = 'cc_last_4';
19+
const CC_NAME = 'cc_name';
20+
const CC_EXP_DATE = 'cc_exp_date';
21+
const CREATED_AT = 'created_at';
22+
const UPDATED_AT = 'updated_at';
23+
24+
public function getEntityId();
25+
public function setEntityId($entityId);
26+
27+
public function getCustomerId();
28+
public function setCustomerId($customerId);
29+
30+
public function getCardToken();
31+
public function setCardToken($cardToken);
32+
33+
public function getCustomerEmail();
34+
public function setCustomerEmail($customerEmail);
35+
36+
public function getStatus();
37+
public function setStatus($status);
38+
39+
public function getType();
40+
public function setType($type);
41+
42+
public function getCcType();
43+
public function setCcType($ccType);
44+
45+
public function getCcLast4();
46+
public function setCcLast4($ccLast4);
47+
48+
public function getCcName();
49+
public function setCcName($ccName);
50+
51+
public function getCcExpDate();
52+
public function setCcExpDate($ccExpDate);
53+
54+
public function getCreatedAt();
55+
public function setCreatedAt($createdAt);
56+
57+
public function getUpdatedAt();
58+
public function setUpdatedAt($updatedAt);
59+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Vindi\VP\Api\Data;
4+
5+
use Magento\Framework\Api\SearchResultsInterface;
6+
7+
/**
8+
* Interface CreditCardSearchResultInterface
9+
* @package Vindi\VP\Api\Data
10+
* Search result interface for credit cards.
11+
*/
12+
interface CreditCardSearchResultInterface extends SearchResultsInterface
13+
{
14+
/**
15+
* Get list of credit cards.
16+
*
17+
* @return \Vindi\VP\Api\Data\CreditCardInterface[]
18+
*/
19+
public function getItems();
20+
21+
/**
22+
* Set list of credit cards.
23+
*
24+
* @param \Vindi\VP\Api\Data\CreditCardInterface[] $items
25+
* @return $this
26+
*/
27+
public function setItems(array $items);
28+
}

Block/PaymentProfile/Edit.php

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
namespace Vindi\VP\Block\PaymentProfile;
3+
4+
use Magento\Customer\Model\Session as CustomerSession;
5+
use Magento\Framework\View\Element\Template;
6+
use Magento\Framework\View\Element\Template\Context;
7+
use Vindi\VP\Model\Config\Source\CardImages as CardImagesSource;
8+
use Vindi\VP\Model\ResourceModel\CreditCard\Collection as CreditCardCollection;
9+
10+
/**
11+
* Class Edit
12+
* @package Vindi\VP\Block
13+
14+
*/
15+
class Edit extends Template
16+
{
17+
/**
18+
* @var CreditCardCollection
19+
*/
20+
protected $_paymentProfileCollection;
21+
22+
/**
23+
* @var CustomerSession
24+
*/
25+
protected $customerSession;
26+
27+
/**
28+
* @var CardImagesSource
29+
*/
30+
protected $creditCardTypeSource;
31+
32+
/**
33+
* @param Context $context
34+
* @param CreditCardCollection $paymentProfileCollection
35+
* @param CustomerSession $customerSession
36+
* @param CardImagesSource $creditCardTypeSource
37+
* @param array $data
38+
*/
39+
public function __construct(
40+
Context $context,
41+
CreditCardCollection $paymentProfileCollection,
42+
CustomerSession $customerSession,
43+
CardImagesSource $creditCardTypeSource,
44+
array $data = []
45+
) {
46+
$this->_paymentProfileCollection = $paymentProfileCollection;
47+
$this->customerSession = $customerSession;
48+
$this->creditCardTypeSource = $creditCardTypeSource;
49+
parent::__construct($context, $data);
50+
}
51+
52+
53+
/**
54+
* @return $this
55+
*/
56+
protected function _prepareLayout()
57+
{
58+
parent::_prepareLayout();
59+
if ($this->getPaymentProfiles()) {
60+
$pager = $this->getLayout()->createBlock(
61+
'Magento\Theme\Block\Html\Pager',
62+
'custom.paymentProfile.list.pager'
63+
)->setAvailableLimit([10=>10, 20=>20, 50=>50])->setShowPerPage(true)->setCollection(
64+
$this->getPaymentProfiles()
65+
);
66+
$this->setChild('pager', $pager);
67+
$this->getPaymentProfiles()->load();
68+
}
69+
return $this;
70+
}
71+
72+
/**
73+
* @return string
74+
*/
75+
public function getPagerHtml()
76+
{
77+
return $this->getChildHtml('pager');
78+
}
79+
80+
/**
81+
* @return CreditCardCollection
82+
*/
83+
public function getPaymentProfiles()
84+
{
85+
if ($this->customerSession->isLoggedIn()) {
86+
$customerId = $this->customerSession->getCustomerId();
87+
$this->_paymentProfileCollection->addFieldToFilter('customer_id', $customerId);
88+
}
89+
90+
return $this->_paymentProfileCollection;
91+
}
92+
93+
/**
94+
* @param $ccType
95+
* @return mixed|void
96+
*/
97+
public function getCreditCardImage($ccType)
98+
{
99+
$creditCardOptionArray = $this->creditCardTypeSource->toOptionArray();
100+
101+
foreach ($creditCardOptionArray as $creditCardOption) {
102+
if ($creditCardOption['label']->getText() == $ccType) {
103+
return $creditCardOption['value'];
104+
}
105+
}
106+
}
107+
108+
/**
109+
* Retrieve current payment profile based on ID in URL.
110+
*
111+
* @return \Vindi\VP\Model\PaymentProfile|null
112+
*/
113+
public function getCurrentPaymentProfile()
114+
{
115+
$profileId = $this->getRequest()->getParam('id');
116+
if ($profileId) {
117+
$profile = $this->_paymentProfileCollection->getItemById($profileId);
118+
return $profile;
119+
}
120+
return null;
121+
}
122+
123+
}

0 commit comments

Comments
 (0)