Shopify.RecurringApplicationCharge.cancel() AttributeError: 'function' Object Has No Attribute 'body'

- 1 answer

I see this issue about cancelling orders, I am getting the same behavior when trying to cancel RecurringApplicationCharges.

I get the error:

AttributeError: 'function' object has no attribute 'body'

I get the shops current charge:

user_current_charge = shopify.RecurringApplicationCharge.current()

then I try and cancel it:


Is this not how it is supposed to work?



To cancel recurring charge, delete it using the resource's destroy method (which is available on most resources):

user_current_charge = shopify.RecurringApplicationCharge.current()

For future reference, if you're unsure on how to use the API library, you can always look at the tests, since test coverage is required for accepting pull requests on this library. This isn't the best replacement for real documentation, but it's way better than nothing.

(In this particular case, there is no test for the RecurringApplicationCharge's destroy method. While I don't necessarily agree that this should not have an explicit test, the reason it's not there is because, as mentioned before, that method is not special to this resource, and indeed is available on all resource classes that inherit from ShopifyResource. You still can't see the destroy method on that class however, because it inherits that from the ActiveResource class. Oh the joys and horrors of metaprogramming.)