Immutable solution version
recurly python: account.billing_info raises AttributeError on new accounts
Complete solution
Don't read billing_info 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 update_billing_info.
recurly python: account.billing_info raises AttributeError on new accounts
The problem
With the recurly V2 python client (2.2.17, python 3.5), creating a new account and then reading account.billing_info 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 fix
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
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 1 · 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>