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

feat: added min value to 3ds #303

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion Gateway/Transaction/CreditCard/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ public function getOrderWithTdsRefused()
{
return (bool) $this->getConfig(static::PATH_ORDER_WITH_TDS_REFUSED);
}


/**
* @return string
*/
public function getTdsMinAmount()
{
return $this->getConfig(static::PATH_TDS_MIN_AMOUNT);
}

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions Gateway/Transaction/CreditCard/Config/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ConfigInterface
const PATH_ENABLED_SAVED_CARDS = 'payment/pagarme_creditcard/enabled_saved_cards';
const PATH_TDS_ACTIVE = 'payment/pagarme_creditcard/tds_active';
const PATH_ORDER_WITH_TDS_REFUSED = 'payment/pagarme_creditcard/order_with_tds_refused';
const PATH_TDS_MIN_AMOUNT = 'payment/pagarme_creditcard/tds_min_amount';
const PATH_PAYMENT_ACTION = 'payment/pagarme_creditcard/payment_action';
const PATH_ANTIFRAUD_ACTIVE = 'payment/pagarme_creditcard/antifraud_active';
const PATH_ANTIFRAUD_MIN_AMOUNT = 'payment/pagarme_creditcard/antifraud_min_amount';
Expand Down
5 changes: 2 additions & 3 deletions Model/Ui/CreditCard/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ public function getConfig()
'active' => $this->getCreditCardConfig()->getActive(),
'title' => $this->getCreditCardConfig()->getTitle(),
'is_saved_card' => $is_saved_card,
'enabled_saved_cards' => $this->getCreditCardConfig()
->getEnabledSavedCards(),
'enabled_saved_cards' => $this->getCreditCardConfig()->getEnabledSavedCards(),
'tds_active' => $this->getCreditCardConfig()->getTdsActive(),

'order_with_tds_refused' => $this->getCreditCardConfig()->getOrderWithTdsRefused(),
'tds_min_amount' => $this->getCreditCardConfig()->getTdsMinAmount(),
'cards' => $cards,
'selected_card' => $selectedCard,
'size_credit_card' => '18',
Expand Down
12 changes: 11 additions & 1 deletion etc/adminhtml/system/transaction/creditcard/tds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<group id="pagarme_pagarme_transaction_creditcard_3ds" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="90">
<label>3DS</label>
<frontend_model>Pagarme\Pagarme\Block\Adminhtml\Form\Fieldset\CreditCardGatewayFieldset</frontend_model>
<field id="tds_active" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="select">
<field id="tds_active" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="select">
<label>Active</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/pagarme_creditcard/tds_active</config_path>
Expand All @@ -24,6 +24,16 @@
<field id="tds_active">1</field>
</depends>
</field>
<field id="tds_min_amount" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label" type="text">
<backend_model>Pagarme\Pagarme\Model\Validation\GenericValidation</backend_model>
<label>Minimum value for 3DS authentication</label>
<comment />
<config_path>payment/pagarme_creditcard/tds_min_amount</config_path>
<validate>validate-currency-dollar</validate>
<depends>
<field id="tds_active">1</field>
</depends>
</field>
<depends>
<field id="active">1</field>
</depends>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<can_initialize>1</can_initialize>
<allow_multiple_address>0</allow_multiple_address>
<order_with_tds_refused>1</order_with_tds_refused>
<tds_min_amount>0.00</tds_min_amount>
</pagarme_creditcard>

<pagarme_billet_creditcard>
Expand Down
1 change: 1 addition & 0 deletions i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@
"Proceed with payment without confirmed 3DS authentication","Prosseguir com pagamento sem autenticação 3DS confirmada"
"If the issuing bank/brand does not approve 3DS authentication, we will continue with the transaction in the common flow (without 3DS)","Caso o banco emissor/bandeira não aprove a autenticação 3DS, seguiremos com a transação no fluxo comum (sem 3DS)"
"If the Issuing Bank rejects 3DS authentication, you may receive a fraud chargeback","Caso o Banco Emissor rejeite a autenticação 3DS, você poderá receber chargerback por fraude"
"Minimum value for 3DS authentication","Valor mínimo para autenticação 3DS"
"Order declined, do not try again.","Pedido recusado, não tente novamente."
"Can't create payment. Please review the information and try again.","Não foi possível realizar o pagamento. Por favor revise os dados e tente novamente."
"Order # %1 : %2","Pedido # %1 : %2"
Expand Down
20 changes: 13 additions & 7 deletions view/frontend/web/js/core/models/CreditCardModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ define([
'Pagarme_Pagarme/js/core/validators/MultibuyerValidator',
'Pagarme_Pagarme/js/core/checkout/CreditCardToken',
'Pagarme_Pagarme/js/core/checkout/Tds',
], (CreditCardValidator, MultibuyerValidator, CreditCardToken, Tds) => {
'Magento_Checkout/js/model/quote',
], (CreditCardValidator, MultibuyerValidator, CreditCardToken, Tds, quote) => {
return class CreditCardModel {
constructor(formObject, publicKey) {
this.formObject = formObject;
Expand All @@ -24,9 +25,7 @@ define([
return;
}

const configCard = window.checkoutConfig.payment.pagarme_creditcard;

if(configCard['tds_active'] === true && this.brandIsVisaOrMaster()) {
if(this.canTdsRun()) {
const tds = new Tds(this.formObject)
tds.addTdsAttributeData();
jQuery('body').trigger('processStart');
Expand Down Expand Up @@ -83,9 +82,16 @@ define([
.done(success)
.fail(error);
}
canTdsRun() {
const configCard = window.checkoutConfig.payment.pagarme_creditcard;

return configCard['tds_active'] === true
&& quote.totals().grand_total * 100 >= configCard['tds_min_amount'] * 100
&& this.brandIsVisaOrMaster()
}
brandIsVisaOrMaster() {
return this.formObject.creditCardBrand.val() === "visa" ||
this.formObject.creditCardBrand.val() === "mastercard"
return this.formObject.creditCardBrand.val() === "visa"
|| this.formObject.creditCardBrand.val() === "mastercard"
}
initTds(tdsToken) {
const modelTds = new Tds(this.formObject)
Expand All @@ -107,7 +113,7 @@ define([
if(data?.trans_status === '' || data?.trans_status === undefined){
return;
}

this.formObject.authentication = JSON.stringify(data);
this.getCreditCardToken(
function (data) {
Expand Down
Loading