@@ -10,7 +10,7 @@ class Payment < ApplicationRecord
10
10
validates :payment_type , presence : true
11
11
12
12
enum status : { failed : 0 , in_progress : 1 , successful : 2 }
13
-
13
+
14
14
# Keep payconiq_online because it is still present in the database
15
15
enum payment_type : { ideal : 0 , payconiq_online : 1 , pin : 3 }
16
16
enum transaction_type : { checkout : 0 , activity : 1 }
@@ -50,22 +50,22 @@ def request_payment
50
50
self . token = Digest ::SHA256 . hexdigest ( "#{ member . id } #{ Time . now . to_f } #{ redirect_uri } " )
51
51
52
52
webhook_url = if Rails . env . development?
53
- "#{ ENV [ 'NGROK_HOST' ] } /api/hook/mollie"
54
- else
55
- Rails . application . routes . url_helpers . mollie_hook_url
56
- end
53
+ "#{ ENV [ 'NGROK_HOST' ] } /api/hook/mollie"
54
+ else
55
+ Rails . application . routes . url_helpers . mollie_hook_url
56
+ end
57
57
58
58
payment = Mollie ::Payment . create (
59
59
amount : { value : amount . to_s , currency : 'EUR' } ,
60
60
description : description ,
61
61
webhookUrl : webhook_url ,
62
- redirectUrl : Rails . application . routes . url_helpers . payment_redirect_url ( token : token ) ,
62
+ redirectUrl : Rails . application . routes . url_helpers . payment_redirect_url ( token : token )
63
63
)
64
64
65
65
self . trxid = payment . id
66
66
self . payment_uri = payment . _links [ 'checkout' ] [ 'href' ]
67
67
self . status = :in_progress
68
-
68
+
69
69
# pin payment shouldn't have any extra work
70
70
when :pin
71
71
end
@@ -159,12 +159,12 @@ def activities
159
159
160
160
def status_update ( new_status )
161
161
self . status = case new_status . downcase
162
- when "succeeded" , "paid"
163
- :successful
164
- when "expired" , "canceled" , "failed" , "cancelled" , "authorization_failed"
165
- :failed
166
- else
167
- :in_progress
168
- end
162
+ when "succeeded" , "paid"
163
+ :successful
164
+ when "expired" , "canceled" , "failed" , "cancelled" , "authorization_failed"
165
+ :failed
166
+ else
167
+ :in_progress
168
+ end
169
169
end
170
170
end
0 commit comments