diff --git a/app/models/payment.rb b/app/models/payment.rb index e4b817793..502ce9891 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -10,7 +10,7 @@ class Payment < ApplicationRecord validates :payment_type, presence: true enum status: { failed: 0, in_progress: 1, successful: 2 } - + # Keep payconiq_online because it is still present in the database enum payment_type: { ideal: 0, payconiq_online: 1, pin: 3 } enum transaction_type: { checkout: 0, activity: 1 } @@ -50,22 +50,22 @@ def request_payment self.token = Digest::SHA256.hexdigest("#{ member.id }#{ Time.now.to_f }#{ redirect_uri }") webhook_url = if Rails.env.development? - "#{ ENV['NGROK_HOST'] }/api/hook/mollie" - else - Rails.application.routes.url_helpers.mollie_hook_url - end + "#{ ENV['NGROK_HOST'] }/api/hook/mollie" + else + Rails.application.routes.url_helpers.mollie_hook_url + end payment = Mollie::Payment.create( amount: { value: amount.to_s, currency: 'EUR' }, description: description, webhookUrl: webhook_url, - redirectUrl: Rails.application.routes.url_helpers.payment_redirect_url(token: token), + redirectUrl: Rails.application.routes.url_helpers.payment_redirect_url(token: token) ) self.trxid = payment.id self.payment_uri = payment._links['checkout']['href'] self.status = :in_progress - + # pin payment shouldn't have any extra work when :pin end @@ -159,12 +159,12 @@ def activities def status_update(new_status) self.status = case new_status.downcase - when "succeeded", "paid" - :successful - when "expired", "canceled", "failed", "cancelled", "authorization_failed" - :failed - else - :in_progress - end + when "succeeded", "paid" + :successful + when "expired", "canceled", "failed", "cancelled", "authorization_failed" + :failed + else + :in_progress + end end end