Skip to content

Commit

Permalink
Repair to mercury
Browse files Browse the repository at this point in the history
Remote
20 tests, 66 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95% passed
  • Loading branch information
aenand authored and Alma Malambo committed Aug 8, 2024
1 parent 3e7aa32 commit 72d2a33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/mercury.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def escape_xml(xml)
end

def unescape_xml(escaped_xml)
xml = escaped_xml.gsub(/\>/, '>')
xml = escaped_xml.gsub(/\&gt;/, '>').gsub(/\r/, '').gsub(/\n/, '').gsub(/\t/, '').gsub('&lt;', '<')
xml.slice! "<?xml version=\"1.0\"?>" # rubocop:disable Style/StringLiterals
xml
end
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ merchant_warrior:

# Working credentials, no need to replace
mercury:
login: '089716741701445'
login: '62589006=TEST'
password: 'xyz'

mercury_no_tokenization:
Expand Down
24 changes: 12 additions & 12 deletions test/remote/gateways/remote_mercury_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ def setup
@gateway = MercuryGateway.new(fixtures(:mercury))

@amount = 100
@decline_amount = 257

@credit_card = credit_card('4003000123456781', brand: 'visa', month: '12', year: '18')
@credit_card = credit_card('4895281000000006', brand: 'visa', month: '12', year: Time.now.year)

@track_1_data = '%B4003000123456781^LONGSEN/L. ^18121200000000000000**123******?*'
@track_2_data = ';5413330089010608=2512101097750213?'
@track_1_data = "%B#{@credit_card.number}^LONGSEN/L. ^18121200000000000000**111******?*"
@track_2_data = ";#{@credit_card.number}=18121200000000000000?"

@options = {
order_id: 'c111111111.1',
Expand All @@ -21,8 +22,8 @@ def setup
@options_with_billing = @options.merge(
merchant: '999',
billing_address: {
address1: '4 Corporate SQ',
zip: '30329'
address1: '123 Main Street',
zip: '45209'
}
)
@full_options = @options_with_billing.merge(
Expand All @@ -46,13 +47,13 @@ def test_successful_authorize_and_capture
end

def test_failed_authorize
response = @gateway.authorize(1100, @credit_card, @options)
response = @gateway.authorize(@decline_amount, @credit_card, @options)
assert_failure response
assert_equal 'DECLINE', response.message
end

def test_purchase_and_void
response = @gateway.purchase(102, @credit_card, @options)
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response

void = @gateway.void(response.authorization)
Expand Down Expand Up @@ -82,13 +83,14 @@ def test_credit
end

def test_failed_purchase
response = @gateway.purchase(1100, @credit_card, @options)
response = @gateway.purchase(@decline_amount, @credit_card, @options)
assert_failure response
assert_equal 'DECLINE', response.message
assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
end

def test_avs_and_cvv_results
@credit_card.verification_value = '222'
response = @gateway.authorize(333, @credit_card, @options_with_billing)

assert_success response
Expand Down Expand Up @@ -136,9 +138,7 @@ def test_partial_capture
end

def test_authorize_with_bad_expiration_date
@credit_card.month = 13
@credit_card.year = 2001
response = @gateway.authorize(575, @credit_card, @options_with_billing)
response = @gateway.authorize(267, @credit_card, @options_with_billing)
assert_failure response
assert_equal 'INVLD EXP DATE', response.message
end
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_authorize_and_capture_without_tokenization

def test_successful_authorize_and_capture_with_track_1_data
@credit_card.track_data = @track_1_data
response = @gateway.authorize(100, @credit_card, @options)
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert_equal '1.00', response.params['authorize']

Expand Down
33 changes: 1 addition & 32 deletions test/unit/gateways/mercury_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,38 +126,7 @@ def test_transcript_scrubbing

def successful_purchase_response
<<~RESPONSE
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><CreditTransactionResponse xmlns="http://www.mercurypay.com"><CreditTransactionResult><?xml version="1.0"?>
<RStream>
<CmdResponse>
<ResponseOrigin>Processor</ResponseOrigin>
<DSIXReturnCode>000000</DSIXReturnCode>
<CmdStatus>Approved</CmdStatus>
<TextResponse>AP*</TextResponse>
<UserTraceData></UserTraceData>
</CmdResponse>
<TranResponse>
<MerchantID>595901</MerchantID>
<AcctNo>5499990123456781</AcctNo>
<ExpDate>0813</ExpDate>
<CardType>M/C</CardType>
<TranCode>Sale</TranCode>
<AuthCode>000011</AuthCode>
<CaptureStatus>Captured</CaptureStatus>
<RefNo>0194</RefNo>
<InvoiceNo>1</InvoiceNo>
<AVSResult>Y</AVSResult>
<CVVResult>M</CVVResult>
<OperatorID>999</OperatorID>
<Memo>LM Integration (Ruby)</Memo>
<Amount>
<Purchase>1.00</Purchase>
<Authorize>1.00</Authorize>
</Amount>
<AcqRefData>KbMCC0742510421 </AcqRefData>
<ProcessData>|17|410100700000</ProcessData>
</TranResponse>
</RStream>
</CreditTransactionResult></CreditTransactionResponse></soap:Body></soap:Envelope>
<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><CreditTransactionResponse xmlns=\"http://www.mercurypay.com\"><CreditTransactionResult><?xml version=\"1.0\"?>\r\n<RStream>\r\n\t<CmdResponse>\r\n\t\t<ResponseOrigin>Processor</ResponseOrigin>\r\n\t\t<DSIXReturnCode>000000</DSIXReturnCode>\r\n\t\t<CmdStatus>Approved</CmdStatus>\r\n\t\t<TextResponse>AP</TextResponse>\r\n\t\t<UserTraceData></UserTraceData>\r\n\t</CmdResponse>\r\n\t<TranResponse>\r\n\t\t<MerchantID>595901</MerchantID>\r\n\t\t<AcctNo>5499990123456781</AcctNo>\r\n\t\t<ExpDate>0813</ExpDate>\r\n\t\t<CardType>M/C</CardType>\r\n\t\t<TranCode>Sale</TranCode>\r\n\t\t<AuthCode>000011</AuthCode>\r\n\t\t<CaptureStatus>Captured</CaptureStatus>\r\n\t\t<RefNo>0194</RefNo>\r\n\t\t<InvoiceNo>1</InvoiceNo>\r\n\t\t<AVSResult>Y</AVSResult>\r\n\t\t<CVVResult>M</CVVResult>\r\n\t\t<OperatorID>999</OperatorID>\r\n\t\t<Memo>LM Integration (Ruby)</Memo>\r\n\t\t<Amount>\r\n\t\t\t<Purchase>1.00</Purchase>\r\n\t\t\t<Authorize>1.00</Authorize>\r\n\t\t</Amount>\r\n\t\t<AcqRefData>KbMCC0742510421 </AcqRefData>\r\n\t\t<ProcessData>|17|410100700000</ProcessData>\r\n\t</TranResponse>\r\n</RStream>\r\n</CreditTransactionResult></CreditTransactionResponse></soap:Body></soap:Envelope>
RESPONSE
end

Expand Down

0 comments on commit 72d2a33

Please sign in to comment.