Skip to content

Commit

Permalink
Merge pull request #5 from 202-ecommerce/develop
Browse files Browse the repository at this point in the history
1.1.2
  • Loading branch information
202-ecommerce authored Dec 17, 2019
2 parents 806f12f + 9d5e7a0 commit 3dbba42
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
12 changes: 5 additions & 7 deletions _dev/js/payment_bt.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {selectOption} from './functions.js';
$(document).ready(() => {
if ($('#checkout-payment-step').hasClass('js-current-step')) {
initBraintreeCard();
if (use3dVerification) {
if (use3dVerification == false) {
initBraintreeCvvField();
}
}
Expand Down Expand Up @@ -225,12 +225,6 @@ const BraintreeSubmitPayment = () => {
let use3dVerification = response["use3dVerification"];

if (use3dVerification) {
if (vaultToken && (cvvField.length == 0 || cvvField.val() == '')) {
btnConfirmation.prop('disabled', false);
$('[data-bt-cvv-error-msg]').show().text(bt_translations_cvv);
return false;
}

braintree.threeDSecure.create({
version: 2, //Using 3DS 2
client: bt_client_instance,
Expand Down Expand Up @@ -286,6 +280,10 @@ const BraintreeSubmitPayment = () => {
if (typeof(vaultToken) == 'undefined' || vaultToken == false) {
$('[data-payment-method-nonce="bt"]').val(payload.nonce);
$('[data-bt-card-type]').val(payload.details.cardType);
} else if (vaultToken && (cvvField.length == 0 || cvvField.val() == '')) {
btnConfirmation.prop('disabled', false);
$('[data-bt-cvv-error-msg]').show().text(bt_translations_cvv);
return false;
}

bt_form.submit();
Expand Down
15 changes: 13 additions & 2 deletions classes/MethodBraintreeOfficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public function sale($cart, $token_payment)
if ($vaultExists && $this->payment_method_bt == 'paypal-braintree') {
$data['paymentMethodToken'] = $vault_token;
} elseif ($vaultExists) {
if ($module->use3dVerification()) {
if ($module->use3dVerification() == false) {
if (empty($this->cvv_field)) {
$error_msg = $module->l('Card verification failed.', get_class($this));

Expand Down Expand Up @@ -768,14 +768,25 @@ public function sale($cart, $token_payment)
'options' => array('verifyCard' => true),
));

if (isset($payment_method->verification) && $payment_method->verification->status != 'verified') {
if (isset($payment_method->verification) && $payment_method->verification != null &&
isset($payment_method->verification->status) && $payment_method->verification->status != 'verified') {
$error_msg = $module->l('Card verification respond with status', get_class($this)).' '.$payment_method->verification->status.'. ';
$error_msg .= $module->l('The reason : ', get_class($this)).' '.$payment_method->verification->processorResponseText.'. ';

if ($payment_method->verification->gatewayRejectionReason) {
$error_msg .= $module->l('Rejection reason : ', get_class($this)).' '.$payment_method->verification->gatewayRejectionReason;
}

throw new Exception($error_msg, '00000');
}

if ($payment_method instanceof Braintree\Result\Error) {
$error_msg = $module->l('Card verification is failed. ', get_class($this));
$error_msg .= $module->l('The reason : ', get_class($this)).' '.$payment_method->message.'. ';

throw new Exception($error_msg, '00000');
}

$paymentMethodToken = $payment_method->paymentMethod->token;
}
$options['storeInVaultOnSuccess'] = true;
Expand Down
2 changes: 1 addition & 1 deletion views/templates/front/payment_bt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</div>

<div data-form-cvv-field class="bt__hidden">
<div id="block-cvv-field" class="form-group col-md-6">
<div id="block-cvv-field" class="form-group col-md-6 bt__pl-0">
<label for="btCvvField" class="bt__form-label">{l s='CVV' mod='braintreeofficial'}</label>
<input type="number" name="btCvvField" id="btCvvField" class="form-control bt__form-control bt__number-field" placeholder="123">
</div>
Expand Down

0 comments on commit 3dbba42

Please sign in to comment.