shopify.RecurringApplicationCharge.cancel() AttributeError: 'function' object has no attribute 'body'

shopify.RecurringApplicationCharge.cancel() AttributeError: 'function' object has no attribute 'body'

see this issue 关于取消订单,我在尝试取消 RecurringApplicationCharges 时遇到了相同的行为。

我收到错误:

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

我得到商店当前费用:

user_current_charge = shopify.RecurringApplicationCharge.current()

然后我尝试取消它:

shopify.RecurringApplicationCharge.cancel(user_current_charge)

这不是应该的工作方式吗?

要取消经常性费用,请使用资源的 destroy 方法(大多数资源都可用)将其删除:

user_current_charge = shopify.RecurringApplicationCharge.current()
user_current_charge.destroy()

为了将来参考,如果您不确定如何使用 API 库,您可以随时 look at the tests,因为接受此库的拉取请求需要测试覆盖率。这不是真实文档的最佳替代品,但总比没有好。

(在 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 中。哦,元编程的乐趣和恐惧。)