Skip to content

Commit 0d85b36

Browse files
Update to Mollie v2 API: Part 2 electric boogaloo (#1147)
* feat: update to mollie v3 api * chore: run linter * fix: add ideal as method so we return to Koala on failure * chore: linter ✨ * chore: satisfy linter 🤡 * chore: satisfy linter 🤡 * feat: remove issuer * fix: resolved brakeman warning * fix: resolved linter warning * fix: second attempt at securing mollie redirect * fix: pass stirng to `redirect_to` funciton * fix: update mollie host * chore: add comment about whitelisted mollie uri --------- Co-authored-by: Silas <[email protected]>
1 parent f372405 commit 0d85b36

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/controllers/members/payments_controller.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def pay_activities
4545
transaction_type: :activity,
4646
redirect_uri: member_payments_path
4747
)
48+
4849
if payment.save
4950
# Check URI for safety (supresses brakeman warning)
5051
url = begin
@@ -54,8 +55,8 @@ def pay_activities
5455
end
5556

5657
# Check if it's a valid URI and matches your whitelist of acceptable domains (e.g., only http(s)://example.com)
57-
if url.is_a?(URI::HTTP) && ['mollie.com'].include?(url.host)
58-
redirect_to(url)
58+
if url.is_a?(URI::HTTP) && ['www.mollie.com'].include?(url.host)
59+
redirect_to(url.to_s)
5960
else
6061
# Fallback to a safe default redirect if the URI is invalid or not in the whitelist
6162
redirect_to(root_path)

app/models/payment.rb

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def request_payment
6565
)
6666

6767
self.trxid = payment.id
68+
69+
# The host of this url is `www.mollie.com` so it will redirect to the mollie payment page
70+
# if this ever chanes, the redirect_uri whitelist in the controller should be updated
6871
self.payment_uri = payment._links['checkout']['href']
6972
self.status = :in_progress
7073

0 commit comments

Comments
 (0)