Skip to content

Commit

Permalink
feat: remove issuer
Browse files Browse the repository at this point in the history
  • Loading branch information
leuke-naam committed Dec 16, 2024
1 parent 5bec79c commit 560297f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
7 changes: 3 additions & 4 deletions app/controllers/members/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def pay_activities
redirect_to(member_payments_path)
return
end

payment = Payment.new(
description: description,
amount: amount,
issuer: transaction_params[:bank],
member: member,
payment_type: :ideal,
transaction_id: unpaid.pluck(:activity_id),
Expand Down Expand Up @@ -97,13 +97,12 @@ def add_funds
description: description,
amount: amount,
member: member,
issuer: transaction_params[:bank],
payment_type: :ideal,

transaction_id: nil,
transaction_type: :checkout,
redirect_uri: member_payments_path
)

if payment.save
redirect_to(payment.payment_uri)
else
Expand All @@ -115,6 +114,6 @@ def add_funds
private

def transaction_params
params.permit(:amount, :bank, :activity_ids, :payment_type)
params.permit(:amount, :activity_ids, :payment_type)
end
end
12 changes: 0 additions & 12 deletions app/models/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def request_payment
payment = Mollie::Payment.create(
amount: { value: format('%.2f', amount), currency: 'EUR' },
method: 'ideal', # only ideal for now
issuer: issuer,
description: description,
webhook_url: webhook_url,
redirect_url: redirect_url
Expand Down Expand Up @@ -143,17 +142,6 @@ def transaction_fee
end
end

def self.ideal_issuers
# cache the payment issuers for 12 hours, don't request it to often. Stored in tmp/cache
return [] if ENV['MOLLIE_TOKEN'].blank?

Rails.cache.fetch('mollie_issuers', expires_in: 12.hours) do
method = Mollie::Method.get('ideal', include: 'issuers')

method.issuers.map { |issuer| [issuer["name"], issuer["id"]] }
end
end

def activities
Activity.find(transaction_id) if activity?
end
Expand Down
5 changes: 1 addition & 4 deletions app/views/members/payments/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@
%tr
%td
%td
.ideal-activities
= I18n.t("members.payments.unpaid_activity.footer.bank")
.float-xl-right= f.select :bank, options_for_select(Payment::ideal_issuers), {}, {style: '', class:'ideal-activities'}
%td
%div
= I18n.t("members.payments.unpaid_activity.footer.transactioncosts")
%span.transaction_cost_activities.ideal-activities{:price =>@transaction_costs}= number_to_currency(@transaction_costs, :unit => '€')
%span.transaction_cost_activities.ideal-activities{:price => @transaction_costs}= number_to_currency(@transaction_costs, :unit => '€')
%tr
%td
%td
Expand Down

0 comments on commit 560297f

Please sign in to comment.