}
/*
- * Run PreAuth to check address and CSV if set
+ * Run requested transaction
*
*
- * @var string $tans_type 'PreAuth', 'Settle', 'Sale', or 'Refund'
+ * @var string $tans_type 'AVS', 'Settle', 'Sale', or 'Refund'
* @var float $amount Override order amount, used for refunds
*
* @access public
// Select transaction object by type requested
switch ($trans_type) {
- case 'PreAuth':
+ // Address Verification Service
+ case 'AVS':
if (GLM_MES_DEBUG_VERBOSE) {
- wc_add_notice('GLM MeS Gateway: Running Pre-Authorization', 'success');
+ wc_add_notice('GLM MeS Gateway: Running Address Verification', 'success');
}
- // Only run pre-auth if address verification or CVV test is selected
- if ($this->settings['address_verification'] == 'yes' ||
- $this->settings['cvv_required'] == 'yes' ) {
+ // Only run address verification test if selected
+ if ($this->settings['address_verification'] == 'yes') {
+
+ $trans = new TpgSale($this->profile_id, $this->profile_key);
- $trans = new TpgPreAuth($this->profile_id, $this->profile_key);
+ // Set transaction type to Address Verification Only
+ $trans->TranType = "A";
$sendRequestData = true;
break;
- // otherwise, no pre-auth needs to be run, so say we're OK to go
+ // otherwise, no AVS, so say we're OK to go
} else {
if (GLM_MES_DEBUG_VERBOSE) {
- wc_add_notice('GLM MeS Gateway: No Pre-Authorization requested', 'success');
+ wc_add_notice('GLM MeS Gateway: Address Verification Not Required', 'success');
}
}
// break; - If no pre-auth was required, we're just falling through to Sale
+ //
case 'Sale':
if (GLM_MES_DEBUG_VERBOSE) {
break;
+/*
case 'Settle': // Requires a prior pre-auth
if (GLM_MES_DEBUG_VERBOSE) {
$sendRequestData = false;
break;
+*/
case 'Refund':
if ($sendRequestData) {
- // Send transaction amount
- if ($this->amount_driven_test) {
+ // Set transaction amount
+ if ($trans->TranType == "A") {
+
+ // AVS Only
+ $amount = 0;
+
+ } elseif ($this->amount_driven_test) {
+
+ // An amount driven test has been selected in admin
$amount = $this->amount_driven_test;
+
} else {
+
+ // A normal transaction
$amount = $this->cust_order->order_total;
+
}
// Send billing information
// Check for success based on transaction type
switch ($trans_type) {
- case 'PreAuth':
+ case 'AVS':
$auth = true;
$response['auth_response_descr'] = "The address you entered does not seem to match the address for this credit card.
Please check your address and try again.<br>";
}
+ } else {
+
+ if (GLM_MES_DEBUG_VERBOSE) {
+ wc_add_notice('GLM MeS Gateway: Address Verification OK', 'success');
+ }
+
}
// If CVV required
if ($this->settings['cvv_required'] == 'yes') {
if (!in_array($response['cvv2_result'], array('M'))) {
$auth = false;
- $response['auth_response_descr'] = 'You may not have entered the correct "Card Code" below.
+ $response['auth_response_descr'] .= 'You may not have entered the correct "Card Code" below.
Please check the code on the back of your card and try again.<br>';
}
}
break;
- case 'Settle':
case 'Sale':
// Ask MES gateway code if the transaction was approved
print_r($this->cust_order, 1) . '</pre></p>', 'success');
}
- // Check if pre-authorization is required
- if ($this->settings['address_verification'] == 'yes' ||
- $this->settings['cvv_required'] == 'yes' ) {
+ // Check if Address Verification is required
+ if ($this->settings['address_verification'] == 'yes') {
- // Try pre-authorization first
- $response = $this->run_transaction('PreAuth');
+ // Try Address Verification
+ $response = $this->run_transaction('AVS');
- // If pre-auth was not requested or was successful - run sale
+ // If AVS was successful - run sale
if ($response['success']) {
- $response = $this->run_transaction('Settle', false, $response['transaction_id']);
+ $response = $this->run_transaction('Sale', false);
}
// Ohterwise we're just going to run it as a final sale
} else {
- $response = $this->run_transaction('Sale', false, $response['transaction_id']);
+ $response = $this->run_transaction('Sale', false);
}