-
Notifications
You must be signed in to change notification settings - Fork 2
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
Avs validation #1
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,13 +162,25 @@ private function _authorize(Varien_Object $payment, $amount, $capture) | |
} | ||
|
||
$response = $builder->execute(); | ||
|
||
if ($response->responseCode !== '00' || $response->responseMessage === 'Partially Approved') { | ||
if ($response->responseCode !== '00') { | ||
// TODO: move this | ||
// $this->updateVelocity($e); | ||
|
||
if ($response->responseCode === '10' || $response->responseMessage === 'Partially Approved') { | ||
$status = self::STATUS_APPROVED; | ||
if($response->responseCode === '10' || $response->responseMessage === 'Partially Approved'){ | ||
try { $response->void()->withDescription('POST_AUTH_USER_DECLINE')->execute(); } catch (\Exception $e) {} | ||
} else { | ||
$avsCvvValidation = Mage::getStoreConfig('payment/hps_transit/avs_cvv_validation'); | ||
if($avsCvvValidation === true && | ||
(!empty($response->avsResponseCode) || !empty($response->cvnResponseCode))){ | ||
$declinedAvsCodes = Mage::getStoreConfig('payment/hps_transit/avs_decline_codes'); | ||
$declinedCvnCodes = Mage::getStoreConfig('payment/hps_transit/cvv_decline_codes'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks.. I updated the code with explode function |
||
if(in_array($response->avsResponseCode, $declinedAvsCodes) || | ||
in_array($response->cvnResponseCode, $declinedCvnCodes)){ | ||
try { $cardOrToken->reverse($amount)->execute(); } catch (\Exception $e) {} | ||
$status = self::STATUS_DECLINED; | ||
} | ||
} | ||
} | ||
|
||
if (!$this->_allow_fraud || $response->responseCode !== 'FR') { | ||
|
@@ -186,14 +198,14 @@ private function _authorize(Varien_Object $payment, $amount, $capture) | |
); | ||
} | ||
|
||
$this->closeTransaction($payment,$amount,$e); | ||
$this->closeTransaction($payment,$amount,$response, $status); | ||
|
||
return; | ||
} | ||
|
||
$this->_debugChargeService(); | ||
// \Hps_Transit_Model_Payment::closeTransaction | ||
$this->closeTransaction($payment, $amount, $response); | ||
$this->closeTransaction($payment, $amount, $response, $status); | ||
|
||
if ($multiToken) { | ||
$this->saveMultiUseToken($response, $cardData, $customerId, $cardType); | ||
|
@@ -319,12 +331,12 @@ protected function closeTransaction($payment, $amount, $response, $status = self | |
|
||
if (property_exists($response, 'avsResultCode')) { | ||
$payment->setCcAvsStatus($response->avsResultCode); | ||
$details['avs_response_code'] = $response->avsResultCode; | ||
$details['avs_response_text'] = $response->avsResultText; | ||
$details['avs_response_code'] = $response->avsResponseCode; | ||
$details['avs_response_text'] = $response->avsResponseMessage; | ||
} | ||
|
||
if (property_exists($response, 'cvvResultCode')) { | ||
$details['cvv_response_code'] = $response->cvvResultCode; | ||
if (property_exists($response, 'cavvResponseCode')) { | ||
$details['cvv_response_code'] = $response->cavvResponseCode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the response code and message |
||
$details['cvv_response_text'] = $response->cvvResultText; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* @category Hps | ||
* @package Hps_Transit | ||
* @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com) | ||
* @license https://github.com/hps/transit-magento-extension/blob/master/LICENSE Custom License | ||
*/ | ||
|
||
class Hps_Transit_Model_Source_AvsResultCodes | ||
{ | ||
public function toOptionArray() | ||
{ | ||
return array( | ||
array( | ||
'value' => 'D2018', | ||
'label' => 'AVS FAILED' | ||
), | ||
array( | ||
'value' => 'D2027', | ||
'label' => 'AVS and CVV2 failed' | ||
), | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be using the individual AVS result codes instead of the gateway's general response code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slogsdon from the available transit documents which you already shared, I found only these 2 result codes related to AVS/CVV, is there any other document available for the result codes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're performing the comparison against the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok.. updated the result codes |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* @category Hps | ||
* @package Hps_Transit | ||
* @copyright Copyright (c) 2015 Heartland Payment Systems (https://www.magento.com) | ||
* @license https://github.com/hps/transit-magento-extension/blob/master/LICENSE Custom License | ||
*/ | ||
|
||
class Hps_Transit_Model_Source_CvvResultCodes | ||
{ | ||
public function toOptionArray() | ||
{ | ||
return array( | ||
array( | ||
'value' => 'D2020', | ||
'label' => 'CVV2 verification failed' | ||
), | ||
array( | ||
'value' => 'D2027', | ||
'label' => 'AVS and CVV2 failed' | ||
) | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be using the individual CVV result codes instead of the gateway's general response code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok.. updated the result codes |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,44 @@ | |
<comment><![CDATA[The amount of time (in minutes) before recent failures are ignored.]]></comment> | ||
<depends><enable_anti_fraud>1</enable_anti_fraud></depends> | ||
</fraud_velocity_timeout> | ||
<avs_cvv_validation translate="label"> | ||
<label>AVS/CVV Validation</label> | ||
<frontend_type>select</frontend_type> | ||
<source_model>adminhtml/system_config_source_yesno</source_model> | ||
<sort_order>67</sort_order> | ||
<show_in_default>1</show_in_default> | ||
<show_in_website>1</show_in_website> | ||
<show_in_store>1</show_in_store> | ||
<depends><enable_anti_fraud>1</enable_anti_fraud></depends> | ||
<comment><![CDATA[Address Verification Service (AVS) and Cardholder Verification Value (CVV) are | ||
simple service offered by the cardholders’ issuing banks. With Heartland’s payment gateway, | ||
you can elect to send automatic reversals for undersired AVS / CVV result codes, freeing you | ||
to focus on your core business logic. As an added bonus, the inclusion of AVS and CVV | ||
information during the request helps your transactions qualify for lower Interchange rates, | ||
further helping to reduce your overall cost of payment acceptance..]]></comment> | ||
</avs_cvv_validation> | ||
<avs_decline_codes translate="label"> | ||
<label>AVS Decline Condition</label> | ||
<frontend_type>multiselect</frontend_type> | ||
<source_model>hps_transit/source_avsresultcodes</source_model> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the model name |
||
<sort_order>68</sort_order> | ||
<show_in_default>1</show_in_default> | ||
<show_in_website>1</show_in_website> | ||
<show_in_store>1</show_in_store> | ||
<depends><avs_cvv_validation>1</avs_cvv_validation></depends> | ||
<comment><![CDATA[Select in what scenarios transaction needs to be reversed.]]></comment> | ||
</avs_decline_codes> | ||
<cvv_decline_codes translate="label"> | ||
<label>CVV Decline Condition</label> | ||
<frontend_type>multiselect</frontend_type> | ||
<source_model>hps_transit/source_cvvresultcodes</source_model> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the model name |
||
<sort_order>69</sort_order> | ||
<show_in_default>1</show_in_default> | ||
<show_in_website>1</show_in_website> | ||
<show_in_store>1</show_in_store> | ||
<depends><avs_cvv_validation>1</avs_cvv_validation></depends> | ||
<comment><![CDATA[Select in what scenarios transaction needs to be reversed.]]></comment> | ||
</cvv_decline_codes> | ||
<!-- Misc. --> | ||
<custom_message translate="label"> | ||
<label>Custom Error Message</label> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the code inside the if statement will never be run because response code different than '00' throw an exception. An exception is thrown in checkResponse function (https://github.com/hps/php-sdk/blob/962f6826c5938ec9b7c13dbad911970c019057da/src/Gateways/TransITConnector.php#L573).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slogsdon shall we update the PHP SDK to allow the AVS failure code and handle this in plugin side