Skip to content

Commit

Permalink
Braintree Issues..?? #625
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Jan 19, 2017
1 parent 6753eae commit 0350c81
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions classes/wc-gateway-braintree-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,22 @@ public function validate_fields() {
}else {
return true;
}
} else {
$card = $this->get_posted_card();
if (empty($card->exp_month) || empty($card->exp_year)) {
throw new Exception(__('Card expiration date is invalid', 'paypal-for-woocommerce'));
}
if (!ctype_digit($card->cvc)) {
throw new Exception(__('Card security code is invalid (only digits are allowed)', 'paypal-for-woocommerce'));
}
if (!ctype_digit($card->exp_month) || !ctype_digit($card->exp_year) || $card->exp_month > 12 || $card->exp_month < 1 || $card->exp_year < date('y')) {
throw new Exception(__('Card expiration date is invalid', 'paypal-for-woocommerce'));
}
if (empty($card->number) || !ctype_digit($card->number)) {
throw new Exception(__('Card number is invalid', 'paypal-for-woocommerce'));
}
return true;
}
$card = $this->get_posted_card();
if (empty($card->exp_month) || empty($card->exp_year)) {
throw new Exception(__('Card expiration date is invalid', 'paypal-for-woocommerce'));
}
if (!ctype_digit($card->cvc)) {
throw new Exception(__('Card security code is invalid (only digits are allowed)', 'paypal-for-woocommerce'));
}
if (!ctype_digit($card->exp_month) || !ctype_digit($card->exp_year) || $card->exp_month > 12 || $card->exp_month < 1 || $card->exp_year < date('y')) {
throw new Exception(__('Card expiration date is invalid', 'paypal-for-woocommerce'));
}
if (empty($card->number) || !ctype_digit($card->number)) {
throw new Exception(__('Card number is invalid', 'paypal-for-woocommerce'));
}
return true;
} catch (Exception $e) {
wc_add_notice($e->getMessage(), 'error');
return false;
Expand Down Expand Up @@ -482,14 +483,12 @@ public function angelleye_do_payment($order) {
);
if ($this->enable_braintree_drop_in == false) {
if(!empty($_POST['wc-braintree-payment-token']) && $_POST['wc-braintree-payment-token'] == 'new') {
if(!empty($_POST['wc-braintree-new-payment-method']) && $_POST['wc-braintree-new-payment-method'] == true) {
$request_data['creditCard'] = array(
'number' => $card->number,
'expirationDate' => $card->exp_month . '/' . $card->exp_year,
'cvv' => $card->cvc,
'cardholderName' => $order->billing_first_name . ' ' . $order->billing_last_name
);
}
} else {
if(is_user_logged_in()) {
$customer_id = get_current_user_id();
Expand Down

0 comments on commit 0350c81

Please sign in to comment.