Skip to content

Commit

Permalink
Merge branch 'release' into PFW-223
Browse files Browse the repository at this point in the history
  • Loading branch information
angelleye committed Aug 28, 2018
2 parents 43dc485 + 621438e commit 95ae7fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
7 changes: 7 additions & 0 deletions angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ public function pfw_do_capture($order, $transaction_id = null, $capture_total =
'CURRENCYCODE' => version_compare(WC_VERSION, '3.0', '<') ? $order->get_order_currency() : $order->get_currency(),
'COMPLETETYPE' => 'NotComplete',
);

$payment_gateway = wc_get_payment_gateway_by_order( $order );
if ( $payment_gateway && isset( $payment_gateway->invoice_id_prefix ) ) {
$invnum = $payment_gateway->invoice_id_prefix . preg_replace("/[^a-zA-Z0-9]/", "", str_replace("#", "", $order->get_order_number()));
$DataArray['INVNUM'] = $invnum;
}

$PayPalRequest = array(
'DCFields' => $DataArray
);
Expand Down
4 changes: 2 additions & 2 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ public function init_form_fields() {
'type' => 'multiselect',
'class' => 'wc-enhanced-select in_context_checkout_part',
'description' => __('Funding methods selected here will be hidden from buyers during checkout.', 'paypal-for-woocommerce'),
'default' => 'medium',
'default' => '',
'desc_tip' => true,
'options' => $this->disallowed_funding_methods_array,
),
Expand All @@ -1040,7 +1040,7 @@ public function init_form_fields() {
'type' => 'multiselect',
'class' => 'wc-enhanced-select in_context_checkout_part',
'description' => __('Individual credit card type(s) selected here will be hidden from buyers during checkout.', 'paypal-for-woocommerce'),
'default' => 'medium',
'default' => '',
'desc_tip' => true,
'options' => $this->disallowed_card_types,
),
Expand Down
2 changes: 1 addition & 1 deletion classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public function validate_fields() {

$card_type = AngellEYE_Utility::card_type_from_account_number($card->number);

if ($card_type == 'amex' && (WC()->countries->get_base_country() != 'CA' || get_woocommerce_currency() != 'CAD')) {
if ($card_type == 'amex' && (get_woocommerce_currency() != 'USD' && get_woocommerce_currency() != 'AUD')) {
throw new Exception(__('Your processor is unable to process the Card Type in the currency requested. Please try another card type', 'paypal-for-woocommerce'));
}

Expand Down
49 changes: 19 additions & 30 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,25 +479,9 @@ public function is_available() {
*/
function process_payment($order_id) {
$order = new WC_Order($order_id);
$card_number = isset($_POST['paypal_pro_payflow-card-number']) ? wc_clean($_POST['paypal_pro_payflow-card-number']) : '';
$card_cvc = isset($_POST['paypal_pro_payflow-card-cvc']) ? wc_clean($_POST['paypal_pro_payflow-card-cvc']) : '';
$card_exp_year = isset($_POST['paypal_pro_payflow_card_expiration_year']) ? wc_clean($_POST['paypal_pro_payflow_card_expiration_year']) : '';
$card_exp_month = isset($_POST['paypal_pro_payflow_card_expiration_month']) ? wc_clean($_POST['paypal_pro_payflow_card_expiration_month']) : '';
$card_number = str_replace(array(' ', '-'), '', $card_number);
$card_type = AngellEYE_Utility::card_type_from_account_number($card_number);
if ($card_type == 'amex' && (WC()->countries->get_base_country() != 'CA' || get_woocommerce_currency() != 'CAD')) {
throw new Exception(__('Your processor is unable to process the Card Type in the currency requested. Please try another card type', 'paypal-for-woocommerce'));
}
if (strlen($card_exp_year) == 4) {
$card_exp_year = $card_exp_year - 2000;
}

$card_exp_month = (int) $card_exp_month;
if ($card_exp_month < 10) {
$card_exp_month = '0' . $card_exp_month;
}
$card = $this->get_posted_card();
// Do payment with paypal
return $this->do_payment($order, $card_number, $card_exp_month . $card_exp_year, $card_cvc);
return $this->do_payment($order, $card->number, $card->exp_month . $card->exp_year, $card->cvc);
}

/**
Expand Down Expand Up @@ -670,13 +654,15 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
$PayPalRequestData['expdate'] = '';
$log['origid'] = $token->get_token();
} else {
$log['acct'] = '****';
$log['cvv2'] = '****';
}
if ($this->is_subscription($order_id)) {
$PayPalRequestData['origid'] = get_post_meta($order_id, '_payment_tokens', true);
$log['origid'] = get_post_meta($order_id, '_payment_tokens', true);
if ($this->is_subscription($order_id)) {
$PayPalRequestData['origid'] = get_post_meta($order_id, '_payment_tokens', true);
$log['origid'] = get_post_meta($order_id, '_payment_tokens', true);
} else {
$log['acct'] = '****';
$log['cvv2'] = '****';
}
}

$this->add_log('PayFlow Request: ' . print_r($log, true));
$PayPalResult = $PayPal->ProcessTransaction(apply_filters('angelleye_woocommerce_paypal_pro_payflow_process_transaction_request_args', $PayPalRequestData));

Expand Down Expand Up @@ -1171,16 +1157,21 @@ public function angelleye_woocommerce_credit_card_form_start($current_id) {
}

public function get_posted_card() {
try {
$card_number = isset($_POST['paypal_pro_payflow-card-number']) ? wc_clean($_POST['paypal_pro_payflow-card-number']) : '';
$card_cvc = isset($_POST['paypal_pro_payflow-card-cvc']) ? wc_clean($_POST['paypal_pro_payflow-card-cvc']) : '';
$card_exp_year = isset($_POST['paypal_pro_payflow_card_expiration_year']) ? wc_clean($_POST['paypal_pro_payflow_card_expiration_year']) : '';
$card_exp_month = isset($_POST['paypal_pro_payflow_card_expiration_month']) ? wc_clean($_POST['paypal_pro_payflow_card_expiration_month']) : '';
$card_number = str_replace(array(' ', '-'), '', $card_number);
$card_type = AngellEYE_Utility::card_type_from_account_number($card_number);
if ($card_type == 'amex' && (WC()->countries->get_base_country() != 'CA' || get_woocommerce_currency() != 'CAD')) {
throw new Exception(__('Your processor is unable to process the Card Type in the currency requested. Please try another card type', 'paypal-for-woocommerce'));
if ($card_type == 'amex') {
if (WC()->countries->get_base_country() == 'CA' && get_woocommerce_currency() == 'USD' && apply_filters('angelleye_paypal_pro_payflow_amex_ca_usd', true, $this)) {
throw new Exception(__('Your processor is unable to process the Card Type in the currency requested. Please try another card type', 'paypal-for-woocommerce'));
}
if (get_woocommerce_currency() != 'USD' && get_woocommerce_currency() != 'AUD' && get_woocommerce_currency() != 'CAD') {
throw new Exception(__('Your processor is unable to process the Card Type in the currency requested. Please try another card type', 'paypal-for-woocommerce'));
}
}

if (strlen($card_exp_year) == 4) {
$card_exp_year = $card_exp_year - 2000;
}
Expand All @@ -1197,9 +1188,7 @@ public function get_posted_card() {
'start_month' => '',
'start_year' => ''
);
} catch (Exception $ex) {

}

}

public function add_payment_method() {
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ Automatic updates should work great for you. As always, though, we recommend ba
* [PFW-191](https://github.com/angelleye/paypal-woocommerce/pull/1187) - Tweak - Adjusts CSS related to admin notice.
* [PFW-197](https://github.com/angelleye/paypal-woocommerce/pull/1178) - Tweak - Adjustment to Braintree token payments experience.
* [PFW-203](https://github.com/angelleye/paypal-woocommerce/pull/1184) - Tweak - Adjustment to refunds so it pulls current open amount instead of original order amount by default.
* [PFW-218](https://github.com/angelleye/paypal-woocommerce/pull/1189) - Tweak - Adjusts Amex logic in PayPal Pro so it will accept CAD currency when used in CA country.
* [PFW-188](https://github.com/angelleye/paypal-woocommerce/pull/1194) - Fix - Resolves a problem with Sale transactions failing when using token payments.
* [PFW-206](https://github.com/angelleye/paypal-woocommerce/pull/1183) - Fix - Resolves a problem with the Proceed to Checkout button localization/translation.
* [PFW-216](https://github.com/angelleye/paypal-woocommerce/pull/1181) - Fix - Adds localization to confirmation message that was missing it.
* [PFW-221](https://github.com/angelleye/paypal-woocommerce/pull/1191) - Fix - Resolves some PHP notices that get displayed when the plugin is activated with debug mode enabled.
* [PFW-222](https://github.com/angelleye/paypal-woocommerce/pull/1185) - Fix - Adds Invoice ID to DoCapture requests per new PayPal requirements.

= 1.4.14 - 07.17.2018 =
* [PFW-167](https://github.com/angelleye/paypal-woocommerce/pull/1171) - Tweak - Adjustments to Braintree data validation.
Expand Down

1 comment on commit 95ae7fb

@kcppdevelopers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelleye

I have review code and now this good to do 223 merge now

Please sign in to comment.