Skip to content

Commit c525ef7

Browse files
cedrancontardiThiago ContardiGabrielAntalcarolineesteves
authored
Pagamento com um clique (One-click Buy) (#22)
* 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 * Feature para compra com um clique na página do produto * Update composer.json * fix: floating point error * Ajuste para não cachear o bloco phtml do oneclickbuy * Ajuste na sessão do pedido no one click buy * Ajuste para simplificar o código --------- 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> Co-authored-by: Guilherme Venerato <guilhermevenerato@hotmail.com>
1 parent 62de9df commit c525ef7

File tree

8 files changed

+594
-1
lines changed

8 files changed

+594
-1
lines changed

Block/Product/OneClickBuy.php

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vindi\VP\Block\Product;
6+
7+
use Magento\Customer\Model\Session as CustomerSession;
8+
use Magento\Framework\Registry;
9+
use Magento\Framework\View\Element\Template;
10+
use Magento\Framework\View\Element\Template\Context;
11+
use Vindi\VP\Model\ResourceModel\CreditCard\Collection as PaymentProfileCollection;
12+
13+
class OneClickBuy extends Template
14+
{
15+
16+
/**
17+
* @var PaymentProfileCollection
18+
*/
19+
protected $paymentProfileCollection;
20+
21+
/**
22+
* @var CustomerSession
23+
*/
24+
protected $customerSession;
25+
26+
/**
27+
* @var Registry
28+
*/
29+
protected $registry;
30+
31+
/**
32+
* @var Product
33+
*/
34+
protected $product;
35+
36+
/**
37+
* @param Context $context
38+
* @param Registry $registry
39+
* @param PaymentProfileCollection $paymentProfileCollection
40+
* @param CustomerSession $customerSession
41+
* @param array $data
42+
*/
43+
public function __construct(
44+
Context $context,
45+
Registry $registry,
46+
PaymentProfileCollection $paymentProfileCollection,
47+
CustomerSession $customerSession,
48+
array $data = []
49+
) {
50+
$this->paymentProfileCollection = $paymentProfileCollection;
51+
$this->customerSession = $customerSession;
52+
$this->registry = $registry;
53+
parent::__construct($context, $data);
54+
}
55+
56+
public function getButtonText()
57+
{
58+
return __('One click buy');
59+
}
60+
61+
/**
62+
* @return Product
63+
*/
64+
private function getProduct()
65+
{
66+
if (is_null($this->product)) {
67+
$this->product = $this->registry->registry('product');
68+
69+
if (!$this->product->getId()) {
70+
throw new LocalizedException(__('Failed to initialize product'));
71+
}
72+
}
73+
74+
return $this->product;
75+
}
76+
77+
/**
78+
* @return bool
79+
*/
80+
public function showOneclickBuy()
81+
{
82+
return $this->getProduct()->getTypeId() === 'virtual' && $this->customerSession->isLoggedIn();
83+
}
84+
85+
public function getProductId() {
86+
return $this->getProduct()->getId();
87+
}
88+
89+
public function getCards()
90+
{
91+
$cards = [];
92+
$paymentProfiles = $this->getPaymentProfiles();
93+
if($paymentProfiles != null){
94+
foreach ($paymentProfiles->getItems() as $item){
95+
$card['value'] = $item->getEntityId();
96+
$card['label'] = $item->getCcType() . '****' . $item->getCcLast4();
97+
$cards[] = $card;
98+
}
99+
}
100+
return $cards;
101+
}
102+
103+
public function getPaymentProfiles()
104+
{
105+
if ($this->customerSession->isLoggedIn()) {
106+
$customerId = $this->customerSession->getCustomerId();
107+
if ($customerId) {
108+
$paymentProfileCollection = $this->paymentProfileCollection->addFieldToFilter('customer_id', $customerId)
109+
->setOrder('created_at', 'DESC');
110+
111+
return $paymentProfileCollection;
112+
}
113+
}
114+
return null;
115+
}
116+
}

0 commit comments

Comments
 (0)