I'm trying to create a Recurly account using their python API, and keep hitting the same error:
def upsert_recurly_account(office):
try:
account = recurly.Account.get(office.pk)
except recurly.errors.NotFoundError:
logger.warning("Creating new recurly account for pk %s" % office.pk)
account = recurly.Account(account_code=office.pk)
else:
logger.info("Recurly account %s already exists, we will update it")
account.email = office.manager.email
account.first_name = office.manager.first_name
account.last_name = office.manager.last_name
account.company_name = '%s - %s' % (office.legal_name, office.name)
account.vat_number = office.tax_id
account.tax_exempt = office.tax_exempt
billing_info = recurly.BillingInfo()
billing_info.first_name = office.manager.first_name
billing_info.last_name = office.manager.last_name
billing_info.address1 = office.address1
billing_info.address2 = office.address2
billing_info.city = office.city
billing_info.country = office.country
billing_info.zip = office.postal_code
billing_info.phone = office.phone
billing_info.vat_number = office.tax_id
account.billing_info = billing_info
account.save()
The error I'm getting is:
ValidationError:required: account.number is required
Manually adding
account.number = 1234
Doesn't solve the problem.
Any ideas?
Since you're creating a new Account with nested billing info you need to provide a valid credit card number in the billing_info
hash like so:
billing_info.number = 123
There are other mandatory fields (like month
and year
) when creating a new account with nested billing info. Please read the docs