3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/services/dscf/payment/banking_integration_service.rb', line 3
def transfer(from_account, to_account, amount, description, transaction_type_code: "TRANSFER")
validate_transfer_params(from_account, to_account, amount)
transfer_service = Dscf::Banking::TransferService.new(
debit_account: from_account,
credit_account: to_account,
amount: amount,
description: description,
transaction_type_code: transaction_type_code
)
result = transfer_service.execute
unless result.success?
raise BankingTransactionError.new("Banking transfer failed: #{result.errors.join(", ")}")
end
result.transaction
rescue AccountNotActiveError, InvalidAmountError, InsufficientFundsError, BankingTransactionError
raise
rescue => e
raise BankingTransactionError.new("Banking transfer error: #{e.message}")
end
|