Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuvei (formerly SafeCharge): Add customer details to credit action #4820

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '[email protected]'))
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: '[email protected]'))
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