37 revealed that we were trying to charge an old card if a user added a new card and purchased a membership: it went like this:
User chooses "Change Card," enters new card info, submits
Create method receives both stripe_card_token and card_id (because old card still existed on the form)
Both are passed to save_with_payment!
A new card is created, all other cards are destroyed
card_id is passed along if present (it is, and it represents the now-destroyed original card)
The next issue is that rather than seeing the error, users were being allowed to continue. We were even getting notified of new memberships. This is because validation would be re-applied with save! so the error we added to :base with the StripeError got wiped out and everything went along just fine. I've removed the catch that caught the StripeError and applied a :base error; now the StripeError bubbles up to the save! call, which in turn bubbles up to the Controller, which catches it and redisplays the "new" page. Still need more feature specs there, but just our luck we've had three people today stumble across this bug so let's get this in.
Also added an ErrorNotifier service (with specs!) since we're doing the same few things almost everywhere and this will let us do more with errors in the future if we want. For now it just extracts a few lines of repeated code. Should be applied throughout.
37 revealed that we were trying to charge an old card if a user added a new card and purchased a membership: it went like this:
save_with_payment!
The next issue is that rather than seeing the error, users were being allowed to continue. We were even getting notified of new memberships. This is because validation would be re-applied with
save!
so the error we added to:base
with the StripeError got wiped out and everything went along just fine. I've removed thecatch
that caught the StripeError and applied a:base
error; now the StripeError bubbles up to thesave!
call, which in turn bubbles up to the Controller, which catches it and redisplays the "new" page. Still need more feature specs there, but just our luck we've had three people today stumble across this bug so let's get this in.Also added an
ErrorNotifier
service (with specs!) since we're doing the same few things almost everywhere and this will let us do more with errors in the future if we want. For now it just extracts a few lines of repeated code. Should be applied throughout.