Skip to content

Commit

Permalink
USA Epay Transaction: Scrub sensitive data
Browse files Browse the repository at this point in the history
Closes activemerchant#2745

Remote:
20 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Unit:
41 tests, 241 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
curiousepic authored and molejnik-mergebit committed Feb 22, 2018
1 parent e606488 commit 58d0ee6
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Worldpay US: Scrub sensitive data [curiousepic] #2742
* WorldPay: Remove Israel from supported country list [dtykocki] #2746
* Optimal Payments: Scrub sensitive data [curiousepic] #2743
* USA Epay Transaction: Scrub sensitive data [curiousepic] #2745

== Version 1.77.0 (January 31, 2018)
* Authorize.net: Allow Transaction Id to be passed for refuds [nfarve] #2698
Expand Down
12 changes: 12 additions & 0 deletions lib/active_merchant/billing/gateways/usa_epay_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ def void(authorization, options = {})
commit(command, post)
end

def supports_scrubbing?
true
end

def scrub(transcript)
transcript.
gsub(%r((&?UMcard=)\d*(&?))i, '\1[FILTERED]\2').
gsub(%r((&?UMcvv2=)\d*(&?))i, '\1[FILTERED]\2').
gsub(%r((&?UMmagstripe=)[^&]*)i, '\1[FILTERED]\2').
gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]')
end

private

def add_amount(post, money)
Expand Down
18 changes: 18 additions & 0 deletions test/remote/gateways/remote_usa_epay_transaction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,22 @@ def test_failed_verify
assert_match "Card Declined (00)", response.message
end

def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
end
transcript = @gateway.scrub(transcript)

assert_scrubbed(@credit_card.number, transcript)
assert_scrubbed(@credit_card.verification_value, transcript)
assert_scrubbed(@gateway.options[:login], transcript)

transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card_with_track_data, @options)
end
transcript = @gateway.scrub(transcript)

assert_scrubbed(@credit_card_with_track_data.track_data, transcript)
assert_scrubbed(@gateway.options[:login], transcript)
end
end
102 changes: 102 additions & 0 deletions test/unit/gateways/usa_epay_transaction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ def test_does_not_raise_error_on_missing_values
end
end

def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
assert_equal @gateway.scrub(pre_scrubbed_track_data), post_scrubbed_track_data
end

private

def assert_address(type, post, expected_first_name = nil, expected_last_name = nil)
Expand Down Expand Up @@ -436,4 +442,100 @@ def successful_refund_response
def successful_void_response
"UMversion=2.9&UMstatus=Approved&UMauthCode=&UMrefNum=63812270&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=Transaction%20Voided%20Successfully&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled"
end

def pre_scrubbed
<<-EOS
opening connection to sandbox.usaepay.com:443...
opened
starting SSL for sandbox.usaepay.com:443...
SSL established
<- "POST /gate HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\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: sandbox.usaepay.com\r\nContent-Length: 774\r\n\r\n"
<- "UMamount=1.00&UMinvoice=&UMdescription=&UMcard=4000100011112224&UMcvv2=123&UMexpir=0919&UMname=Longbob+Longsen&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=NC&UMbillzip=27614&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=27614&UMcommand=cc%3Asale&UMkey=4EoZ5U2Q55j976W7eplC71i6b7kn4pcV&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2F5268F91058BC9F9FA944693D799F324B2497B7247850A51E53226309FB2540F0%2F7b4c4f6a4e775141cc0e4e10c0388d9adeb47fd1%2Fn"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: http\r\n"
-> "Date: Tue, 13 Feb 2018 18:17:20 GMT\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 485\r\n"
-> "Connection: close\r\n"
-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n"
-> "Strict-Transport-Security: max-age=15768000\r\n"
-> "\r\n"
reading 485 bytes...
-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042366&UMrefNum=132020588&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled"
read 485 bytes
Conn close
EOS
end

def post_scrubbed
<<-EOS
opening connection to sandbox.usaepay.com:443...
opened
starting SSL for sandbox.usaepay.com:443...
SSL established
<- "POST /gate HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\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: sandbox.usaepay.com\r\nContent-Length: 774\r\n\r\n"
<- "UMamount=1.00&UMinvoice=&UMdescription=&UMcard=[FILTERED]&UMcvv2=[FILTERED]&UMexpir=0919&UMname=Longbob+Longsen&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=NC&UMbillzip=27614&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=27614&UMcommand=cc%3Asale&UMkey=[FILTERED]&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2F5268F91058BC9F9FA944693D799F324B2497B7247850A51E53226309FB2540F0%2F7b4c4f6a4e775141cc0e4e10c0388d9adeb47fd1%2Fn"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: http\r\n"
-> "Date: Tue, 13 Feb 2018 18:17:20 GMT\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 485\r\n"
-> "Connection: close\r\n"
-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n"
-> "Strict-Transport-Security: max-age=15768000\r\n"
-> "\r\n"
reading 485 bytes...
-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042366&UMrefNum=132020588&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled"
read 485 bytes
Conn close
EOS
end

def pre_scrubbed_track_data
<<-EOS
opening connection to sandbox.usaepay.com:443...
opened
starting SSL for sandbox.usaepay.com:443...
SSL established
<- "POST /gate HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\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: sandbox.usaepay.com\r\nContent-Length: 382\r\n\r\n"
<- "UMamount=1.00&UMinvoice=&UMdescription=&UMmagstripe=%25B4000100011112224%5ELONGSEN%2FL.+%5E19091200000000000000%2A%2A123%2A%2A%2A%2A%2A%2A%3F&UMcardpresent=true&UMcommand=cc%3Asale&UMkey=4EoZ5U2Q55j976W7eplC71i6b7kn4pcV&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2FE27734F076643B23131E5432C1E225EFF982A73D350179EFC2F191CA499B59A4%2F13391bd14ab6e61058cc9a1b78f259a4c26aa8e1%2Fn"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: http\r\n"
-> "Date: Tue, 13 Feb 2018 18:13:11 GMT\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 485\r\n"
-> "Connection: close\r\n"
-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n"
-> "Strict-Transport-Security: max-age=15768000\r\n"
-> "\r\n"
reading 485 bytes...
-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042087&UMrefNum=132020522&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled"
read 485 bytes
Conn close
EOS
end

def post_scrubbed_track_data
<<-EOS
opening connection to sandbox.usaepay.com:443...
opened
starting SSL for sandbox.usaepay.com:443...
SSL established
<- "POST /gate HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\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: sandbox.usaepay.com\r\nContent-Length: 382\r\n\r\n"
<- "UMamount=1.00&UMinvoice=&UMdescription=&UMmagstripe=[FILTERED]&UMcardpresent=true&UMcommand=cc%3Asale&UMkey=[FILTERED]&UMsoftware=Active+Merchant&UMtestmode=0&UMhash=s%2FE27734F076643B23131E5432C1E225EFF982A73D350179EFC2F191CA499B59A4%2F13391bd14ab6e61058cc9a1b78f259a4c26aa8e1%2Fn"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: http\r\n"
-> "Date: Tue, 13 Feb 2018 18:13:11 GMT\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 485\r\n"
-> "Connection: close\r\n"
-> "P3P: policyref=\"http://www.usaepay.com/w3c/p3p.xml\", CP=\"NON TAIa IVAa IVDa OUR NOR PHY ONL UNI FIN INT DEM\"\r\n"
-> "Strict-Transport-Security: max-age=15768000\r\n"
-> "\r\n"
reading 485 bytes...
-> "UMversion=2.9&UMstatus=Approved&UMauthCode=042087&UMrefNum=132020522&UMavsResult=Address%3A%20Match%20%26%205%20Digit%20Zip%3A%20Match&UMavsResultCode=YYY&UMcvv2Result=Match&UMcvv2ResultCode=M&UMresult=A&UMvpasResultCode=&UMerror=Approved&UMerrorcode=00000&UMcustnum=&UMbatch=120&UMbatchRefNum=848&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=A&UMauthAmount=1&UMfiller=filled"
read 485 bytes
Conn close
EOS
end
end

0 comments on commit 58d0ee6

Please sign in to comment.