Skip to content

Commit

Permalink
VisaNetPeru: Fix error when billing address empty
Browse files Browse the repository at this point in the history
  • Loading branch information
shasum authored and rwdaigle committed Apr 5, 2016
1 parent 18ee020 commit 2650454
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Barclaycard Smartpay: Proper AVS return codes [curiousepic]
* VisaNetPeru: Pass through CVV [duff]
* Barclaycard Smartpay: Use strict_encode64 [duff]
* VisaNetPeru: Fix error when billing address empty [shasum]


== Version 1.58.0 (March 1, 2016)
Expand Down
15 changes: 8 additions & 7 deletions lib/active_merchant/billing/gateways/visanet_peru.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(%r((\"cardNumber\\\":\\\")\d+), '\1[FILTERED]').
gsub(%r((\"cvv2Code\\\":)\d+), '\1[FILTERED]')
gsub(%r((\"cvv2Code\\\":\\\")\d+), '\1[FILTERED]')
end

private
Expand Down Expand Up @@ -108,12 +108,13 @@ def add_payment_method(params, payment_method)
def add_antifraud_data(params, options)
antifraud = {}

billing_address = options[:billing_address] || options[:address]
antifraud[:billTo_street1] = billing_address[:address1]
antifraud[:billTo_city] = billing_address[:city]
antifraud[:billTo_state] = billing_address[:state]
antifraud[:billTo_country] = billing_address[:country]
antifraud[:billTo_postalCode] = billing_address[:zip]
if billing_address = options[:billing_address] || options[:address]
antifraud[:billTo_street1] = billing_address[:address1]
antifraud[:billTo_city] = billing_address[:city]
antifraud[:billTo_state] = billing_address[:state]
antifraud[:billTo_country] = billing_address[:country]
antifraud[:billTo_postalCode] = billing_address[:zip]
end

antifraud[:deviceFingerprintId] = options[:device_fingerprint_id]
antifraud[:merchantDefineData] = options[:merchant_define_data]
Expand Down
4 changes: 2 additions & 2 deletions test/unit/gateways/visanet_peru_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def pre_scrubbed
starting SSL for devapi.vnforapps.com:443...
SSL established
<- "POST /api.tokenization/api/v2/merchant/101266802 HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic QUtJQUpQT1FaN0JBWEpaNUszNUE6VXIrVTBwbjFia2pSaFBHeitHK09MTmpxSWk3T0Jsd2taMmVUSHlTRw==\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: devapi.vnforapps.com\r\nContent-Length: 551\r\n\r\n"
<- "{\"amount\":100.0,\"purchaseNumber\":\"858169315\",\"externalTransactionId\":\"858169315\",\"currencyId\":604,\"firstName\":\"Longbob\",\"lastName\":\"Longsen\",\"cardNumber\":\"4500340090000016\",\"cvv2Code\":377,\"expirationYear\":\"2017\",\"expirationMonth\":\"09\",\"email\":\"[email protected]\",\"antifraud\":{\"billTo_street1\":\"456 My Street\",\"billTo_city\":\"Ottawa\",\"billTo_state\":\"ON\",\"billTo_country\":\"CA\",\"billTo_postalCode\":\"K1C2N6\",\"deviceFingerprintId\":\"deadbeef\",\"merchantDefineData\":{\"field3\":\"movil\",\"field91\":\"101266802\",\"field92\":\"Cabify\"}},\"createAlias\":false}"
<- "{\"amount\":100.0,\"purchaseNumber\":\"858169315\",\"externalTransactionId\":\"858169315\",\"currencyId\":604,\"firstName\":\"Longbob\",\"lastName\":\"Longsen\",\"cardNumber\":\"4500340090000016\",\"cvv2Code\":\"377\",\"expirationYear\":\"2017\",\"expirationMonth\":\"09\",\"email\":\"[email protected]\",\"antifraud\":{\"billTo_street1\":\"456 My Street\",\"billTo_city\":\"Ottawa\",\"billTo_state\":\"ON\",\"billTo_country\":\"CA\",\"billTo_postalCode\":\"K1C2N6\",\"deviceFingerprintId\":\"deadbeef\",\"merchantDefineData\":{\"field3\":\"movil\",\"field91\":\"101266802\",\"field92\":\"Cabify\"}},\"createAlias\":false}"
-> "HTTP/1.1 200 OK\r\n"
-> "Content-Type: application/json\r\n"
-> "Date: Mon, 21 Mar 2016 07:21:09 GMT\r\n"
Expand Down Expand Up @@ -195,7 +195,7 @@ def post_scrubbed
starting SSL for devapi.vnforapps.com:443...
SSL established
<- "POST /api.tokenization/api/v2/merchant/101266802 HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic [FILTERED]==\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: devapi.vnforapps.com\r\nContent-Length: 551\r\n\r\n"
<- "{\"amount\":100.0,\"purchaseNumber\":\"858169315\",\"externalTransactionId\":\"858169315\",\"currencyId\":604,\"firstName\":\"Longbob\",\"lastName\":\"Longsen\",\"cardNumber\":\"[FILTERED]\",\"cvv2Code\":[FILTERED],\"expirationYear\":\"2017\",\"expirationMonth\":\"09\",\"email\":\"[email protected]\",\"antifraud\":{\"billTo_street1\":\"456 My Street\",\"billTo_city\":\"Ottawa\",\"billTo_state\":\"ON\",\"billTo_country\":\"CA\",\"billTo_postalCode\":\"K1C2N6\",\"deviceFingerprintId\":\"deadbeef\",\"merchantDefineData\":{\"field3\":\"movil\",\"field91\":\"101266802\",\"field92\":\"Cabify\"}},\"createAlias\":false}"
<- "{\"amount\":100.0,\"purchaseNumber\":\"858169315\",\"externalTransactionId\":\"858169315\",\"currencyId\":604,\"firstName\":\"Longbob\",\"lastName\":\"Longsen\",\"cardNumber\":\"[FILTERED]\",\"cvv2Code\":\"[FILTERED]\",\"expirationYear\":\"2017\",\"expirationMonth\":\"09\",\"email\":\"[email protected]\",\"antifraud\":{\"billTo_street1\":\"456 My Street\",\"billTo_city\":\"Ottawa\",\"billTo_state\":\"ON\",\"billTo_country\":\"CA\",\"billTo_postalCode\":\"K1C2N6\",\"deviceFingerprintId\":\"deadbeef\",\"merchantDefineData\":{\"field3\":\"movil\",\"field91\":\"101266802\",\"field92\":\"Cabify\"}},\"createAlias\":false}"
-> "HTTP/1.1 200 OK\r\n"
-> "Content-Type: application/json\r\n"
-> "Date: Mon, 21 Mar 2016 07:21:09 GMT\r\n"
Expand Down

0 comments on commit 2650454

Please sign in to comment.