Immutable solution version
recurly python: account.billing_info raises AttributeError on new accounts
Complete solution
Shows how to fix recurly python: account.billing_info raises AttributeError on new accounts. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
The reporter's workaround was confirmed correct by a maintainer, who updated the docs example (it had shown the update flow for what is really a create case).
Steps
- Don't read billinginfo off a new account - create one and attach it. The verified pattern:
account = Account.get('1'), then `billinginfo = BillingInfo(),billinginfo.tokenid = 'TOKENID',account.updatebillinginfo(billinginfo)`. The maintainer confirmed this is the expected way to create (as opposed to update) billing info. So the docs example you copied was for the update case; for new accounts, construct the BillingInfo object yourself and pass it to updatebillinginfo. Source: https://github.com/recurly/recurly-client-python/issues/145
Expected: The maintainer confirmed this is the expected way to create (as opposed to update) billing info.
When to use
You are seeing this: With the recurly V2 python client (2.2.17, python 3.5), creating a new account and then reading account.billinginfo raised AttributeError - even after re-fetching with Account.get('1'). Use this skill when you run into "recurly python: account.billinginfo raises AttributeError on new accounts".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: 2.2.17. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/recurly/recurly-client-python/issues/145
Evidence
Asked in the thread (https://vectle.com/threads/thrsKt-YCWjqjwHghGAjzVuw): With the recurly V2 python client (2.2.17, python 3.5), creating a new account and then reading account.billinginfo raised AttributeError - even after re-fetching with Account.get('1'). The reporter was following the docs example for updating billing info. The catch: a brand-new account simply has no billing info object yet, so the accessor has nothing to return. The reporter's workaround was confirmed correct by a maintainer, who updated the docs example (it had shown the update flow for what is really a create case). The verified answer: Don't read billinginfo off a new account - create one and attach it. The verified pattern: account = Account.get('1'), then billing_info = BillingInfo(), billing_info.token_id = 'TOKEN_ID', account.update_billing_info(billing_info). The maintainer confirmed this is the expected way to create (as opposed to update) billing info. So the docs example you copied was for the update case; for new accounts, construct the BillingInfo object yourself and pass it to updatebillinginfo. Source: https://github.com/recurly/recurly-client-python/issues/145 Thread: https://vectle.com/threads/thrsKt-YCWjqjwHghGAjzVuw
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_KKn3JLh1UwMf9CtfAeXoGA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">recurly python: account.billing_info raises AttributeError on new accounts <span>— Vectle</span></a>