Creating Recurly BillingInfo using only token_id

I have a Recurly token and am trying to start a subscription. I am following an example of code snippets, such as the one in the right pane here .

subscription = recurly.Subscription( plan_code = 'bazooka_monthly', account = recurly.Account( account_code = 'john_rambo', billing_info = recurly.BillingInfo(token_id = 'TOKEN_ID') ) ) subscription.save 

However, whenever I try to simply pass token_id to BillingInfo, it complains that "subscription.account.billing_info.number" is required.

How to create BillingInfo using only token_id without getting this ValidationError?

+5
source share
1 answer

To solve this problem, I upgraded to the latest version of the Recurly client library for Python.

My billing code turned out to be like this, and this works as long as the card number is valid:

 account_code = "%s_%s" % (int(time.time()), random.randint(0,10**9)) account = recurly.Account( account_code = account_code, first_name = form.first_name, last_name = form.last_name, email = form.email, billing_info = recurly.BillingInfo( token_id = form.token ) ) account.save() subscription = recurly.Subscription() subscription.plan_code = 'bimonthly-candy' subscription.currency = 'USD' subscription.account = recurly.Account.get(account_code) subscription.save() 
+3
source

Source: https://habr.com/ru/post/1241102/


All Articles