-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuk_and_eu_account.rb
More file actions
38 lines (32 loc) · 1.28 KB
/
uk_and_eu_account.rb
File metadata and controls
38 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require_relative "base/base.rb"
require 'json'
class UkPayment < Base
def initiate_charge(data)
base_url = flutterwave_object.base_url
# only update the payload with the transaction reference if it isn't already added to the payload
if !data.key?("tx_ref")
data.merge!({"tx_ref" => Util.transaction_reference_generator})
end
# check the currency to determine the type and the required parameters
currency = data["currency"]
if currency == "GBP"
required_parameters = [ "amount", "email", "tx_ref", "currency", "is_token_io"]
type = "account-ach-uk"
elsif currency == "EUR"
required_parameters = [ "amount", "email", "tx_ref", "currency", "is_token_io"]
type = "account-ach-uk"
else
return "pass a valid currency"
end
check_passed_parameters(required_parameters, data)
type = type
payload = data.to_json
response = post_request("#{base_url}#{BASE_ENDPOINTS::CHARGE_ENDPOINT}?type=#{type}", payload)
return response
end
def verify_charge(id)
base_url = flutterwave_object.base_url
response = get_request("#{base_url}/transactions/#{id}/verify")
return response
end
end