Skip to content

Commit

Permalink
Nuvei (formerly SafeCharge): Add customer details to credit action
Browse files Browse the repository at this point in the history
  • Loading branch information
yunnydang committed Jun 28, 2023
1 parent 34c2caa commit 3aef055
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/safe_charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def credit(money, payment, options = {})

add_payment(post, payment, options)
add_transaction_data('Credit', post, money, options)
add_customer_details(post, payment, options)

post[:sg_CreditType] = 1

Expand Down
6 changes: 6 additions & 0 deletions test/remote/gateways/remote_safe_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ def test_successful_credit_with_extra_options
assert_equal 'Success', response.message
end

def test_successful_credit_with_customer_details
response = @gateway.credit(@amount, credit_card('4444436501403986'), @options.merge(email: 'test@example.com'))
assert_success response
assert_equal 'Success', response.message
end

def test_failed_credit
response = @gateway.credit(@amount, @declined_card, @options)
assert_failure response
Expand Down
10 changes: 10 additions & 0 deletions test/unit/gateways/safe_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ def test_successful_credit
assert_equal 'Success', response.message
end

def test_credit_sends_addtional_info
stub_comms do
@gateway.credit(@amount, @credit_card, @options.merge(email: 'test@example.com'))
end.check_request do |_endpoint, data, _headers|
assert_match(/sg_FirstName=Longbob/, data)
assert_match(/sg_LastName=Longsen/, data)
assert_match(/sg_Email/, data)
end.respond_with(successful_credit_response)
end

def test_failed_credit
@gateway.expects(:ssl_post).returns(failed_credit_response)

Expand Down

0 comments on commit 3aef055

Please sign in to comment.