Reputation: 5803
This error: cancel_agreement() missing 1 required positional argument: 'agreement_id'
appeared while executing this method:
def force_cancel(self):
api = model_from_ref(self.processor.api)
api.cancel_agreement(self.subscription_reference)
# transaction.cancel_subscription() # runs in the callback
Here is cancel_agreement()
method:
def cancel_agreement(self, agreement_id, is_upgrade=False):
note = _("Upgrading billing plan") if is_upgrade else _("Canceling a service")
r = self.session.post(self.server + '/v1/payments/billing-agreements/%s/cancel' % agreement_id,
data='{"note": "%s"}' % note,
headers={'content-type': 'application/json'})
if r.status_code != requests.codes.ok:
raise RuntimeError(_("Cannot cancel a billing agreement at PayPal. Please contact support."))
I don't understand why the error happens: It is calling a two-argument function (api
and self.subscription_reference
) and its definition is also two required arguments (self
and agreement_id
).
Sadly I can't show the entire code, because my business partner is against releasing it open source.
Upvotes: 0
Views: 54
Reputation: 5803
It should be:
def force_cancel(self):
klass = model_from_ref(self.processor.api)
api = klass()
api.cancel_agreement(self.subscription_reference)
Upvotes: 1