1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
<?php
defined( 'ABSPATH' ) || exit();
class WC_Braintree_3ds_Validation {
private $nonce = null;
private $threeds_info = '';
public $_3ds_card_ineligible;
public $_3ds_liability_not_shifted;
private $gateway;
public function __construct( $payment_method_nonce, $gateway ) {
$this->set_nonce( $payment_method_nonce );
$this->threeds_info = $payment_method_nonce->threeDSecureInfo;
$this->gateway = $gateway;
$this->_3ds_card_ineligible = $gateway->get_option( '3ds_card_ineligible' );
$this->_3ds_liability_not_shifted = $gateway->get_option( '3ds_liability_not_shifted' );
$this->init();
}
public function init() {
$action = '';
if ( $this->is_card_ineligible() ) {
$action = $this->_3ds_card_ineligible;
} elseif ( ! $this->is_liability_shifted() ) {
$action = $this->_3ds_liability_not_shifted;
}
if ( $action ) {
switch ( $action ) {
case 'authorize_only':
add_action( 'wc_braintree_order_transaction_args', array( $this->gateway, '_3ds_authorize_order' ), 10, 2 );
break;
case 'reject':
add_action( 'wc_braintree_before_process_order_braintree_cc', array( $this->gateway, '_3ds_reject_order' ) );
break;
case 'accept':
}
}
}
public function get_nonce() {
return $this->nonce;
}
public function set_nonce( $nonce ) {
$this->nonce = $nonce;
}
public function is_liability_shifted() {
return $this->threeds_info->liabilityShifted;
}
public function is_liability_shift_possible() {
return $this->threeds_info->liabilityShiftPossible;
}
public function is_card_ineligible() {
return ! $this->is_liability_shifted() && ! $this->is_liability_shift_possible();
}
}