Skip to content

Commit

Permalink
Credorax: Update OpCode for Credit transactions
Browse files Browse the repository at this point in the history
Credit should now be using `O=35` instead of `O=6`

CE-2235

Unit:
80 tests, 381 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
46 tests, 157 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
86.9565% passed
*6 test failures have been failing since April

Local:
5273 tests, 76175 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
rachelkirk committed Aug 8, 2022
1 parent f222c6d commit 11f016c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
10 changes: 4 additions & 6 deletions lib/active_merchant/billing/gateways/credorax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def add_authorization_details(post, options)
capture: '3',
authorize_void: '4',
refund: '5',
credit: '6',
credit: '35',
purchase_void: '7',
refund_void: '8',
capture_void: '9',
Expand Down Expand Up @@ -482,11 +482,9 @@ def post_data(action, params, reference_action)
end

def request_action(action, reference_action)
if reference_action
ACTIONS["#{reference_action}_#{action}".to_sym]
else
ACTIONS[action]
end
return ACTIONS["#{reference_action}_#{action}".to_sym] if reference_action

ACTIONS[action]
end

def url
Expand Down
4 changes: 2 additions & 2 deletions test/remote/gateways/remote_credorax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,12 @@ def test_failed_referral_cft
end

def test_successful_credit
response = @gateway.credit(@amount, @credit_card, @options)
response = @gateway.credit(@amount, @credit_card, @options.merge(first_name: 'Test', last_name: 'McTest'))
assert_success response
assert_equal 'Succeeded', response.message
end

def test_failed_credit
def test_failed_credit_with_zero_amount
response = @gateway.credit(0, @declined_card, @options)
assert_failure response
assert_equal 'Invalid amount', response.message
Expand Down
21 changes: 19 additions & 2 deletions test/unit/gateways/credorax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,23 @@ def test_successful_credit
assert response.test?
end

def test_credit_sends_correct_action_code
stub_comms do
@gateway.credit(@amount, @credit_card)
end.check_request do |_endpoint, data, _headers|
assert_match(/O=35/, data)
end.respond_with(successful_credit_response)
end

def test_credit_sends_customer_name
stub_comms do
@gateway.credit(@amount, @credit_card, { first_name: 'Test', last_name: 'McTest' })
end.check_request do |_endpoint, data, _headers|
assert_match(/j5=Test/, data)
assert_match(/j13=McTest/, data)
end.respond_with(successful_credit_response)
end

def test_failed_credit
response = stub_comms do
@gateway.credit(@amount, @credit_card)
Expand Down Expand Up @@ -1092,11 +1109,11 @@ def failed_referral_cft_response
end

def successful_credit_response
'M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A35&V=413&a1=868f8b942fae639d28e27e8933d575d4&a2=2&a4=100&z1=8a82944a53515706015359604c135301&z13=606944188289&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z5=0&z6=00&K=51ba24f6ef3aa161f86e53c34c9616ac'
'M=SPREE978&O=35&T=03%2F09%2F2016+03%3A16%3A35&V=413&a1=868f8b942fae639d28e27e8933d575d4&a2=2&a4=100&z1=8a82944a53515706015359604c135301&z13=606944188289&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z5=0&z6=00&K=51ba24f6ef3aa161f86e53c34c9616ac'
end

def failed_credit_response
'M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A59&V=413&a1=ff28246cfc811b1c686a52d08d075d9c&a2=2&a4=100&z1=8a829449535154bc01535960a962524f&z13=606944188290&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=cf34816d5c25dc007ef3525505c4c610'
'M=SPREE978&O=35&T=03%2F09%2F2016+03%3A16%3A59&V=413&a1=ff28246cfc811b1c686a52d08d075d9c&a2=2&a4=100&z1=8a829449535154bc01535960a962524f&z13=606944188290&z15=100&z2=05&z3=Transaction+has+been+declined.&z5=0&z6=57&K=cf34816d5c25dc007ef3525505c4c610'
end

def empty_purchase_response
Expand Down

0 comments on commit 11f016c

Please sign in to comment.