Skip to content

Commit

Permalink
Nuvie/SafeCharge: Add unreferenced refund field
Browse files Browse the repository at this point in the history
  • Loading branch information
yunnydang committed Jul 17, 2023
1 parent c8b989e commit c91b917
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/safe_charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def refund(money, authorization, options = {})
add_transaction_data('Credit', post, money, options.merge!({ currency: original_currency }))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
post[:sg_ExpYear] = exp_year
post[:sg_TransactionID] = transaction_id if !options[:unreferenced_refund] || options[:unreferenced_refund] != true

commit(post)
end
Expand Down
12 changes: 12 additions & 0 deletions test/remote/gateways/remote_safe_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ def test_failed_refund
assert_equal 'Transaction must contain a Card/Token/Account', response.message
end

def test_successful_unreferenced_refund
option = {
unreferenced_refund: true
}
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase

assert refund = @gateway.refund(@amount, purchase.authorization, option)
assert_success refund
assert_equal 'Success', refund.message
end

def test_successful_credit
response = @gateway.credit(@amount, credit_card('4444436501403986'), @options)
assert_success response
Expand Down

0 comments on commit c91b917

Please sign in to comment.