mollie-api-ruby
mollie-api-ruby copied to clipboard
Ensure base get always receives an ID
Yesterday, there was a major disruption in mollie. I found out that some payments were created, but we didn't get a response back. Later on, we did get a webhook calllback though.
The issue we encountered is that when you do a get
without an ID, you get a collection of payments as a response. This cannot be mapped to the object (Payment), but yields an 'empty' Payment object anyway. However, this also means that if you call chargebacks
on that object, that you receive a collection of all available chargebacks for the account. This had some unfortunate consequences for us :)
Thanks @moiristo,
That's certainly unexpected. I think we can safely raise an error when id
is nil. There are no use-cases for a get
without an id
as far as I know.
Hi @justincase, thanks for the feedback. I changed it to raise an ArgumentError instead and also check for blank values.
Thanks again @moiristo,
I've changed the PR slightly. I'll revisit this at some point for further improvements:
-
Mollie::Payment.new(id: nil).chargebacks
also returns all chargebacks - Improve path construction. The current implementation is a bit naive and doesn't work for some endpoints (
/v2/payment-links
(hypen),/v2/wallets/applepay/sessions
and/v2/methods/voucher/issuers
(> 2 path segments). - (maybe) validate resource prefixes,
tr_
,re_
,chb_
,mdt_
, etc though not all resources have a prefix (methods, permissions)