Skip to content

Commit

Permalink
Qvalent: Map CVV Result to responses
Browse files Browse the repository at this point in the history
Closes activemerchant#3135

Remote:
19 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Unit:
18 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
curiousepic authored and whitby3001 committed Sep 3, 2019
1 parent 71c04a2 commit b218153
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* NMI: Add customer id to authorization on store [curiousepic] #3130
* Trans First Express: Don't pass blank name field [curiousepic] #3133
* TrustCommerce: Send full name on ACH transactions [jknipp] #3132
* Qvalent: Map CVV Result to responses [curiousepic] #3135

== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
Expand Down
11 changes: 11 additions & 0 deletions lib/active_merchant/billing/gateways/qvalent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class QvalentGateway < Gateway
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners]

CVV_CODE_MAPPING = {
'S' => 'D'
}

def initialize(options={})
requires!(options, :username, :password, :merchant, :pem, :pem_password)
super
Expand Down Expand Up @@ -168,11 +172,18 @@ def commit(action, post)
message_from(succeeded, raw),
raw,
authorization: raw['response.orderNumber'] || raw['response.customerReferenceNumber'],
cvv_result: cvv_result(succeeded, raw),
error_code: error_code_from(succeeded, raw),
test: test?
)
end

def cvv_result(succeeded, raw)
return unless succeeded
code = CVV_CODE_MAPPING[raw['response.cvnResponse']] || raw['response.cvnResponse']
CVVResult.new(code)
end

def headers
{
'Content-Type' => 'application/x-www-form-urlencoded'
Expand Down
2 changes: 1 addition & 1 deletion test/remote/gateways/remote_qvalent_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_invalid_login
pem_password: 'bad'
)

assert_raise ActiveMerchant::ClientCertificateError do
assert_raise OpenSSL::X509::CertificateError do
gateway.purchase(@amount, @credit_card, @options)
end
end
Expand Down
20 changes: 19 additions & 1 deletion test/unit/gateways/qvalent_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_successful_purchase
assert_success response

assert_equal '5d53a33d960c46d00f5dc061947d998c', response.authorization
assert_equal 'M', response.cvv_result['code']
assert response.test?
end

Expand Down Expand Up @@ -186,6 +187,15 @@ def test_3d_secure_fields
assert_success response
end

def test_cvv_result
response = stub_comms do
@gateway.purchase(@amount, @credit_card)
end.respond_with(mapped_cvv_response)

assert_success response
assert_equal 'D', response.cvv_result['code']
end

def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
Expand All @@ -194,7 +204,8 @@ def test_transcript_scrubbing

def successful_purchase_response
%(
response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907124\r\nresponse.orderNumber=5d53a33d960c46d00f5dc061947d998c\r\nresponse.RRN=723907124 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:34:15\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n
response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907124\r\nresponse.orderNumber=5d53a33d960c46d00f5dc061947d998c\r\nresponse.RRN=723907124 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:34:15\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.cvnResponse=M
\r\nresponse.end\r\n
)
end

Expand Down Expand Up @@ -281,6 +292,13 @@ def empty_purchase_response
)
end

def mapped_cvv_response
%(
response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907124\r\nresponse.orderNumber=5d53a33d960c46d00f5dc061947d998c\r\nresponse.RRN=723907124 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:34:15\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.cvnResponse=S
\r\nresponse.end\r\n
)
end

def transcript
%(
opening connection to ccapi.client.support.qvalent.com:443...
Expand Down

0 comments on commit b218153

Please sign in to comment.