Skip to content

Commit

Permalink
CC Processing - Options for Adjusting Display of CC Fields, ref #617
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Mar 7, 2017
1 parent b1f1da3 commit 571cab1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
16 changes: 13 additions & 3 deletions classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ function __construct()
array_push($this->supports, "tokenization");
}
$this->Force_tls_one_point_two = get_option('Force_tls_one_point_two', 'no');

$this->credit_card_month_field = $this->get_option('credit_card_month_field', 'names');
$this->credit_card_year_field = $this->get_option('credit_card_year_field', 'four_digit');
if ($this->testmode == 'yes') {
$this->api_username = $this->get_option('sandbox_api_username');
$this->api_password = $this->get_option('sandbox_api_password');
Expand Down Expand Up @@ -455,13 +456,22 @@ public function paypal_for_woocommerce_paypal_pro_credit_card_form_expiration_da
$months[date('n', $timestamp)] = date_i18n(_x('F', 'Month Names', 'paypal-for-woocommerce'), $timestamp);
endfor;
foreach ($months as $num => $name) {
$form_html .= '<option value=' . $num . '>' . $name . '</option>';
if($this->credit_card_month_field == 'names') {
$form_html .= '<option value=' . $num . '>' . $name . '</option>';
} else {
$month_value = ($num < 10) ? '0'.$num : $num;
$form_html .= '<option value=' . $num . '>' . $month_value . '</option>';
}
}
$form_html .= '</select>';
$form_html .= '<select name="paypal_pro_card_expiration_year" id="cc-expire-year" class="woocommerce-select woocommerce-cc-year ml5">';
$form_html .= '<option value="">' . __('Year', 'paypal-for-woocommerce') . '</option>';
for ($i = date('y'); $i <= date('y') + 15; $i++) {
$form_html .= '<option value=' . $i . '>20' . $i . '</option>';
if($this->credit_card_year_field == 'four_digit') {
$form_html .= '<option value=' . $i . '>20' . $i . '</option>';
} else {
$form_html .= '<option value=' . $i . '>' . $i . '</option>';
}
}
$form_html .= '</select>';
$form_html .= '</p>';
Expand Down
41 changes: 39 additions & 2 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function __construct() {
$this->Force_tls_one_point_two = get_option('Force_tls_one_point_two', 'no');
$this->enable_cardholder_first_last_name = 'yes' === $this->get_option('enable_cardholder_first_last_name', 'no');
$this->is_encrypt = $this->get_option('is_encrypt', 'no');
$this->credit_card_month_field = $this->get_option('credit_card_month_field', 'names');
$this->credit_card_year_field = $this->get_option('credit_card_year_field', 'four_digit');
/* 1.6.6 */
add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );

Expand Down Expand Up @@ -278,6 +280,32 @@ function init_form_fields() {
'default' => 'no',
'desc_tip' => true,
),
'credit_card_month_field' => array(
'title' => __('Choose Credit Card Month Field', 'paypal-for-woocommerce'),
'label' => __('Choose Credit Card Month Field Format.', 'paypal-for-woocommerce'),
'description' => __('Choose whether you wish to display Name format or Number format of Month field in the credit card form.'),
'type' => 'select',
'css' => 'max-width:200px;',
'class' => 'wc-enhanced-select',
'options' => array(
'numbers' => 'Numbers',
'names' => 'Names',
),
'default' => 'names'
),
'credit_card_year_field' => array(
'title' => __('Choose Credit Card Year Field', 'paypal-for-woocommerce'),
'label' => __('Choose Credit Card Year Field Format.', 'paypal-for-woocommerce'),
'description' => __('Choose whether you wish to display Show Two digit format or Four digit of Year field in the credit card form.'),
'type' => 'select',
'css' => 'max-width:200px;',
'class' => 'wc-enhanced-select',
'options' => array(
'two_digit' => 'Show Two Digit Years',
'four_digit' => 'Show Four Digit Years',
),
'default' => 'four_digit'
),
'enable_tokenized_payments' => array(
'title' => __('Enable Tokenized Payments', 'paypal-for-woocommerce'),
'label' => __('Enable Tokenized Payments', 'paypal-for-woocommerce'),
Expand Down Expand Up @@ -729,13 +757,22 @@ public function paypal_for_woocommerce_paypal_pro_payflow_credit_card_form_expir
$months[date('n', $timestamp)] = date_i18n(_x('F', 'Month Names', 'paypal-for-woocommerce'), $timestamp);
endfor;
foreach ($months as $num => $name) {
$form_html .= '<option value=' . $num . '>' . $name . '</option>';
if($this->credit_card_month_field == 'names') {
$form_html .= '<option value=' . $num . '>' . $name . '</option>';
} else {
$month_value = ($num < 10) ? '0'.$num : $num;
$form_html .= '<option value=' . $num . '>' . $month_value . '</option>';
}
}
$form_html .= '</select>';
$form_html .= '<select name="paypal_pro_payflow_card_expiration_year" id="cc-expire-year" class="woocommerce-select woocommerce-cc-year ml5">';
$form_html .= '<option value="">' . __('Year', 'paypal-for-woocommerce') . '</option>';
for ($i = date('y'); $i <= date('y') + 15; $i++) {
$form_html .= '<option value=' . $i . '>20' . $i . '</option>';
if($this->credit_card_year_field == 'four_digit') {
$form_html .= '<option value=' . $i . '>20' . $i . '</option>';
} else {
$form_html .= '<option value=' . $i . '>' . $i . '</option>';
}
}
$form_html .= '</select>';
$form_html .= '</p>';
Expand Down

0 comments on commit 571cab1

Please sign in to comment.