diff --git a/_dev/js/payment_bt.js b/_dev/js/payment_bt.js index 457733b..a87c6f8 100755 --- a/_dev/js/payment_bt.js +++ b/_dev/js/payment_bt.js @@ -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(); } } @@ -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, @@ -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(); diff --git a/classes/MethodBraintreeOfficial.php b/classes/MethodBraintreeOfficial.php index 225396e..ee11d2b 100644 --- a/classes/MethodBraintreeOfficial.php +++ b/classes/MethodBraintreeOfficial.php @@ -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)); @@ -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; diff --git a/views/templates/front/payment_bt.tpl b/views/templates/front/payment_bt.tpl index 74dc944..cd01dbe 100755 --- a/views/templates/front/payment_bt.tpl +++ b/views/templates/front/payment_bt.tpl @@ -92,7 +92,7 @@