Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
return AUD when mandate scheme is becs
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Sep 25, 2018
1 parent 0081355 commit c3056f7
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions app/lib/payment_processor/go_cardless/populator.rb
Expand Up @@ -58,18 +58,26 @@ def amount_in_whole_currency
end

def currency
scheme = mandate.scheme.downcase
return 'GBP' if scheme == 'bacs'
return 'SEK' if scheme == 'autogiro'
'EUR'
case mandate.scheme.downcase
when 'becs'
'AUD'
when 'bacs'
'GBP'
when 'autogiro'
'SEK'
else
'EUR'
end
end

def bacs?
mandate.scheme.downcase.inquiry.bacs?
end

def complete_redirect_flow
@complete_redirect_flow ||= client.redirect_flows.complete(@redirect_flow_id, params: { session_token: @session_token })
@complete_redirect_flow ||= client
.redirect_flows
.complete(@redirect_flow_id, params: { session_token: @session_token })
rescue GoCardlessPro::InvalidStateError => e
raise e unless e.message.match?(/already completed/)
@complete_redirect_flow = client.redirect_flows.get(@redirect_flow_id)
Expand Down Expand Up @@ -102,10 +110,16 @@ def settings_charge_day

def create_gbp_date(mandate_date)
# GBP needs to be charged on the specified date. Use the next possible time that date is possible.
Date.new(mandate_date.year, mandate_date.month, Settings.gocardless.gbp_charge_day.to_i)
Date.new(
mandate_date.year,
mandate_date.month,
Settings.gocardless.gbp_charge_day.to_i
)
rescue ArgumentError
Rails.logger.error("With #{mandate_date.year}-#{mandate_date.month}-#{Settings.gocardless.gbp_charge_day.to_i}, \
your GBP charge date is invalid! Resorting to the mandate's next possible charge date.")
Rails.logger.error(
"With #{mandate_date.year}-#{mandate_date.month}-#{Settings.gocardless.gbp_charge_day.to_i}, \
your GBP charge date is invalid! Resorting to the mandate's next possible charge date."
)
mandate_date
end

Expand Down

0 comments on commit c3056f7

Please sign in to comment.