chargify/chargify_api_ares

@subscription.reactivate returning object instead of True/False

Closed this issue · 5 comments

Problem: A call to @susbcription.reactivate has stopped returning true/false but instead is returning the subscription itself.

Steps to reproduce: Try reactivating a cancelled subscription with the bogus card 2.

Expected response: False

Actual Response: The subscription object containing errors.

Misc thoughts

I'm seeing that the re-activate function here is wrapped in process_capturing_errors which I'm unsure of what this does. Maybe there was a change in how errors are handled in the gem I missed?

My expectation is that a @subscription.save or @subscription.reactivate call would return true/false like any standard ActiveRecord resource allow us to then inspect the errors on the object afterwards.

(cc: @YesThatAllen)

Further review of process_capturing_errors it appears the resource_invalid errors are being intentionally rescued. Our only having recent updated to the latest chargify_api_ares version would mean we are just now being subjected to this change.

It still seems odd to me to just return the object rather than a true / false here. While it's not hard to simple look for @subscription.errors after the reactivate call it seems inconsistent with rails standards.

Closing this as It's obviously by design on Chargify's behalf. We've adjusted our billing actions as needed. @jeremywrowe I'd still love to hear about the reasons behind decision to return the object rather than true/false.

@jonathansimmons When designing the endpoint we designed it to match API standards not Rails standards. The gem simply wraps the API, there are other consumers of the API outside of just Ruby/Rails. Java, PHP, etc. We also wanted to provide reasons of why the reactivation failed so that issues can be resolved either internally by a merchant or externally by a customer. Also since reactivate doesn't fit into the normal REST standard we are doing something a bit abnormal yet trying to maintain usefulness.

Where's this all documented? (these details in particular)