Skip to content

Commit

Permalink
CC Processing - Fraud Filters - Place Order On Hold, ref #618
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Mar 14, 2017
1 parent b0c2ddc commit e755424
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct($gateway) {
$this->save_abandoned_checkout = 'yes' === $this->gateway->get_option('save_abandoned_checkout', 'no');
$this->softdescriptor = $this->gateway->get_option('softdescriptor', '');
$this->testmode = 'yes' === $this->gateway->get_option('testmode', 'yes');
$this->fraud_management_filters = $this->gateway->get_option('fraud_management_filters', 'place_order_on_hold_for_further_review');
if( $this->testmode == false ) {
$this->testmode = AngellEYE_Utility::angelleye_paypal_for_woocommerce_is_set_sandbox_product();
}
Expand Down Expand Up @@ -167,7 +168,7 @@ public function angelleye_do_express_checkout_payment() {
$this->angelleye_do_express_checkout_payment_request();
$this->angelleye_add_order_note($order);
$this->angelleye_add_extra_order_meta($order);
if ($this->response_helper->ec_is_response_success_or_successwithwarning($this->paypal_response)) {
if($this->response_helper->ec_is_response_success($this->paypal_response)) {
$this->angelleye_ec_get_customer_email_address($this->confirm_order_id);
$this->angelleye_ec_sellerprotection_handler($this->confirm_order_id);
update_post_meta($order->id, 'is_sandbox', $this->testmode);
Expand All @@ -186,6 +187,30 @@ public function angelleye_do_express_checkout_payment() {
wc_clear_notices();
wp_redirect($this->gateway->get_return_url($order));
exit();
} elseif ($this->response_helper->ec_is_response_successwithwarning($this->paypal_response)) {
$this->angelleye_ec_get_customer_email_address($this->confirm_order_id);
$this->angelleye_ec_sellerprotection_handler($this->confirm_order_id);
update_post_meta($order->id, 'is_sandbox', $this->testmode);
if ($this->paypal_response['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Completed') {
$order->payment_complete($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']);
} else {
if($this->fraud_management_filters == 'place_order_on_hold_for_further_review' && (!empty($this->paypal_response['L_ERRORCODE0']) && $this->paypal_response['L_ERRORCODE0'] == '11610')) {
$error = !empty($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['L_SHORTMESSAGE0'];
$order->update_status('on-hold', $error);
} else {
$this->update_payment_status_by_paypal_responce($this->confirm_order_id, $this->paypal_response);
}
update_post_meta($order->id, '_transaction_id', $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']);
$order->reduce_order_stock();
WC()->cart->empty_cart();
}
update_post_meta($order->id, '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '');
$order->add_order_note(sprintf(__('%s payment approved! Trnsaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']));
$this->angelleye_ec_save_billing_agreement($order->id);
WC()->cart->empty_cart();
wc_clear_notices();
wp_redirect($this->gateway->get_return_url($order));
exit();
} else {
$this->angelleye_add_order_note_with_error($order, $paypal_action_name = 'DoExpressCheckoutPayment');
$this->angelleye_write_error_log_and_send_email_notification($paypal_action_name = 'DoExpressCheckoutPayment');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ public function ec_is_response_success_or_successwithwarning($paypal_response) {
}
}

public function ec_is_response_successwithwarning($paypal_response) {
if (strtoupper($paypal_response['ACK']) == 'SUCCESSWITHWARNING') {
return true;
}
}
}
14 changes: 14 additions & 0 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function __construct() {
$this->notifyurl = '';
$this->is_encrypt = $this->get_option('is_encrypt', 'no');
$this->cancel_page_id = $this->get_option('cancel_page', '');
$this->fraud_management_filters = $this->get_option('fraud_management_filters', 'place_order_on_hold_for_further_review');
if ($this->enable_notifyurl == 'yes') {
$this->notifyurl = $this->get_option('notifyurl');
if (isset($this->notifyurl) && !empty($this->notifyurl)) {
Expand Down Expand Up @@ -538,6 +539,19 @@ public function init_form_fields() {
'default' => 'disabled',
'desc_tip' => true,
),
'fraud_management_filters' => array(
'title' => __('Fraud Management Filters ', 'paypal-for-woocommerce'),
'label' => '',
'description' => __('Allows you to Place order On Hold for further review or Ignore warnings and proceed as usual.', 'paypal-for-woocommerce'),
'type' => 'select',
'class' => '',
'options' => array(
'ignore_warnings_and_proceed_as_usual' => __('Ignore warnings and proceed as usual', 'paypal-for-woocommerce'),
'place_order_on_hold_for_further_review' => __('Place order On Hold for further review', 'paypal-for-woocommerce'),
),
'default' => 'place_order_on_hold_for_further_review',
'desc_tip' => true,
),
'email_notify_order_cancellations' => array(
'title' => __('Order canceled/refunded Email Notifications', 'paypal-for-woocommerce'),
'label' => __('Enable buyer email notifications for Order canceled/refunded', 'paypal-for-woocommerce'),
Expand Down
33 changes: 29 additions & 4 deletions classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function __construct()
$this->is_encrypt = $this->get_option('is_encrypt', 'no');
$this->softdescriptor = $this->get_option('softdescriptor', '');
$this->avs_cvv2_result_admin_email = 'yes' === $this->get_option('avs_cvv2_result_admin_email', 'no');
$this->fraud_management_filters = $this->get_option('fraud_management_filters', 'place_order_on_hold_for_further_review');
$this->notifyurl = '';
if($this->enable_notifyurl == 'yes') {
$this->notifyurl = $this->get_option('notifyurl');
Expand Down Expand Up @@ -331,6 +332,19 @@ function init_form_fields()
'description' => __('Your URL for receiving Instant Payment Notification (IPN) about transactions.', 'paypal-for-woocommerce'),
'class' => 'angelleye_notifyurl'
),
'fraud_management_filters' => array(
'title' => __('Fraud Management Filters ', 'paypal-for-woocommerce'),
'label' => '',
'description' => __('Allows you to Place order On Hold for further review or Ignore warnings and proceed as usual.', 'paypal-for-woocommerce'),
'type' => 'select',
'class' => '',
'options' => array(
'ignore_warnings_and_proceed_as_usual' => __('Ignore warnings and proceed as usual', 'paypal-for-woocommerce'),
'place_order_on_hold_for_further_review' => __('Place order On Hold for further review', 'paypal-for-woocommerce'),
),
'default' => 'place_order_on_hold_for_further_review',
'desc_tip' => true,
),
'enable_cardholder_first_last_name' => array(
'title' => __('Enable Cardholder Name', 'paypal-for-woocommerce'),
'label' => __('Adds fields for "card holder name" to checkout in addition to the "billing name" fields.', 'paypal-for-woocommerce'),
Expand Down Expand Up @@ -1126,18 +1140,29 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp
}

// Payment complete
if ($this->payment_action == "Sale") {
$order->payment_complete($PayPalResult['TRANSACTIONID']);
if($PayPalResult['ACK'] == 'SuccessWithWarning' && !empty($PayPalResult['L_ERRORCODE0']) ) {
if($this->fraud_management_filters == 'place_order_on_hold_for_further_review' && $PayPalResult['L_ERRORCODE0'] == '11610') {
$error = !empty($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['L_SHORTMESSAGE0'];
$order->update_status('on-hold', $error);
} elseif (!empty($PayPalResult['L_ERRORCODE0'])) {
$error = !empty($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['L_SHORTMESSAGE0'];
$order->add_order_note('ERROR MESSAGE: ' . $error);
} else {
$order->payment_complete($PayPalResult['TRANSACTIONID']);
}
} else {
$order->payment_complete($PayPalResult['TRANSACTIONID']);
}

if ($this->payment_action == "Authorization") {
update_post_meta( $order->id, '_first_transaction_id', $PayPalResult['TRANSACTIONID'] );
$payment_order_meta = array('_transaction_id' => $PayPalResult['TRANSACTIONID'], '_payment_action' => $this->payment_action);
AngellEYE_Utility::angelleye_add_order_meta($order->id, $payment_order_meta);
AngellEYE_Utility::angelleye_paypal_for_woocommerce_add_paypal_transaction($PayPalResult, $order, $this->payment_action);
$angelleye_utility = new AngellEYE_Utility(null, null);
$angelleye_utility->angelleye_get_transactionDetails($PayPalResult['TRANSACTIONID']);
$order->payment_complete($PayPalResult['TRANSACTIONID']);
$order->add_order_note('Payment Action: ' . $this->payment_action);
}
}

// Remove cart
WC()->cart->empty_cart();
Expand Down
21 changes: 20 additions & 1 deletion classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function __construct() {
$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');
$this->fraud_management_filters = $this->get_option('fraud_management_filters', 'place_order_on_hold_for_further_review');
/* 1.6.6 */
add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );

Expand Down Expand Up @@ -250,6 +251,19 @@ function init_form_fields() {
'default' => '',
'desc_tip' => true,
),
'fraud_management_filters' => array(
'title' => __('Fraud Management Filters ', 'paypal-for-woocommerce'),
'label' => '',
'description' => __('Allows you to Place order On Hold for further review or Ignore warnings and proceed as usual.', 'paypal-for-woocommerce'),
'type' => 'select',
'class' => '',
'options' => array(
'ignore_warnings_and_proceed_as_usual' => __('Ignore warnings and proceed as usual', 'paypal-for-woocommerce'),
'place_order_on_hold_for_further_review' => __('Place order On Hold for further review', 'paypal-for-woocommerce'),
),
'default' => 'place_order_on_hold_for_further_review',
'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'),
Expand Down Expand Up @@ -675,7 +689,12 @@ function do_payment( $order, $card_number, $card_exp, $card_csc, $centinelPAResS
}
}
}
$order->payment_complete($PayPalResult['PNREF']);
if($this->fraud_management_filters == 'place_order_on_hold_for_further_review' && $PayPalResult['RESULT'] == 126) {
$order->update_status('on-hold', $PayPalResult['RESPMSG']);
} else {
$order->payment_complete($PayPalResult['PNREF']);
}


// Remove cart
WC()->cart->empty_cart();
Expand Down

0 comments on commit e755424

Please sign in to comment.