Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for Card Verification Instead of Full Authorization, PFW-272 #1222

Merged
merged 2 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -1769,12 +1769,13 @@ public function call_paypal_pro_payflow_docapture($order, $transaction_id, $capt
} else {
$AMT = $capture_total;
}

$AMT = self::round($AMT - $order->get_total_refunded());
$payment_action_authorization = get_post_meta($order_id, 'payment_action_authorization', true);

if (isset($transaction_id) && !empty($transaction_id)) {
$PayPalRequestData = array(
'TENDER' => 'C', // C = credit card, P = PayPal
'TRXTYPE' => 'D', // S=Sale, A= Auth, C=Credit, D=Delayed Capture, V=Void
'TRXTYPE' => (isset($payment_action_authorization) && $payment_action_authorization == 'Card Verification') ? 'S' : 'D', // S=Sale, A= Auth, C=Credit, D=Delayed Capture, V=Void
'ORIGID' => $transaction_id,
'AMT' => $AMT,
'CAPTURECOMPLETE' => 'N'
Expand Down
26 changes: 24 additions & 2 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function __construct() {
$this->error_display_type = $this->get_option('error_display_type', 'no');
$this->send_items = 'yes' === $this->get_option('send_items', 'yes');
$this->payment_action = $this->get_option('payment_action', 'Sale');
$this->payment_action_authorization = $this->get_option('payment_action_authorization', 'Full Authorization');

//fix ssl for image icon
$this->icon = $this->get_option('card_icon', plugins_url('/assets/images/payflow-cards.png', plugin_basename(dirname(__FILE__))));
Expand Down Expand Up @@ -285,6 +286,17 @@ function init_form_fields() {
),
'default' => 'Sale'
),
'payment_action_authorization' => array(
'title' => __('Authorization Type', 'paypal-for-woocommerce'),
'description' => __(''),
'type' => 'select',
'class' => 'wc-enhanced-select',
'options' => array(
'Full Authorization' => __('Full Authorization', 'paypal-for-woocommerce'),
'Card Verification' => __('Card Verification', 'paypal-for-woocommerce'),
),
'default' => 'Full Authorization'
),
'pending_authorization_order_status' => array(
'title' => __('Pending Authorization Order Status', 'paypal-for-woocommerce'),
'label' => __('Pending Authorization Order Status.', 'paypal-for-woocommerce'),
Expand Down Expand Up @@ -429,9 +441,11 @@ public function admin_options() {
<script type="text/javascript">
jQuery('#woocommerce_paypal_pro_payflow_payment_action').change(function () {
if ( this.value === 'Authorization' ) {
jQuery('#woocommerce_paypal_pro_payflow_payment_action_authorization').closest('tr').show();
jQuery('#woocommerce_paypal_pro_payflow_pending_authorization_order_status').closest('tr').show();
jQuery('#woocommerce_paypal_pro_payflow_default_order_status').closest('tr').hide();
} else {
jQuery('#woocommerce_paypal_pro_payflow_payment_action_authorization').closest('tr').hide();
jQuery('#woocommerce_paypal_pro_payflow_pending_authorization_order_status').closest('tr').hide();
jQuery('#woocommerce_paypal_pro_payflow_default_order_status').closest('tr').show();
}
Expand Down Expand Up @@ -534,12 +548,17 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
$lastname = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_last_name : $order->get_billing_last_name();
}

$order_amt = AngellEYE_Gateway_Paypal::number_format($order->get_total());
if( $this->payment_action == 'Authorization' && $this->payment_action_authorization == 'Card Verification' ) {
$order_amt = '0.00';
}

$PayPalRequestData = array(
'tender' => 'C', // Required. The method of payment. Values are: A = ACH, C = Credit Card, D = Pinless Debit, K = Telecheck, P = PayPal
'trxtype' => ($this->payment_action == 'Authorization' || $order->get_total() == 0 ) ? 'A' : 'S', // Required. Indicates the type of transaction to perform. Values are: A = Authorization, B = Balance Inquiry, C = Credit, D = Delayed Capture, F = Voice Authorization, I = Inquiry, L = Data Upload, N = Duplicate Transaction, S = Sale, V = Void
'acct' => $card_number, // Required for credit card transaction. Credit card or purchase card number.
'expdate' => $card_exp, // Required for credit card transaction. Expiration date of the credit card. Format: MMYY
'amt' => AngellEYE_Gateway_Paypal::number_format($order->get_total()), // Required. Amount of the transaction. Must have 2 decimal places.
'amt' => $order_amt, // Required. Amount of the transaction. Must have 2 decimal places.
'currency' => version_compare(WC_VERSION, '3.0', '<') ? $order->get_order_currency() : $order->get_currency(), //
'dutyamt' => '', //
'freightamt' => '', //
Expand Down Expand Up @@ -675,7 +694,10 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
* Check for errors or fraud filter warnings and proceed accordingly.
*/
if (isset($PayPalResult['RESULT']) && ($PayPalResult['RESULT'] == 0 || in_array($PayPalResult['RESULT'], $this->fraud_error_codes))) {
// Add order note
if( $this->payment_action == 'Authorization' && $this->payment_action_authorization == 'Card Verification' ) {
$order->add_order_note('Card : ' . $PayPalResult['RESPMSG']);
add_post_meta($order_id, 'payment_action_authorization', $this->payment_action_authorization);
}
if (in_array($PayPalResult['RESULT'], $this->fraud_error_codes)) {
$order->add_order_note($PayPalResult['RESPMSG']);
$order->add_order_note($PayPalResult['PREFPSMSG']);
Expand Down