本文整理汇总了Python中recurly.Account.billing_info方法的典型用法代码示例。如果您正苦于以下问题:Python Account.billing_info方法的具体用法?Python Account.billing_info怎么用?Python Account.billing_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recurly.Account
的用法示例。
在下文中一共展示了Account.billing_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_billing_info
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import billing_info [as 别名]
def test_billing_info(self):
logging.basicConfig(level=logging.DEBUG) # make sure it's init'ed
logger = logging.getLogger('recurly.http.request')
logger.setLevel(logging.DEBUG)
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
account = Account(account_code='binfo%s' % self.test_id)
with self.mock_request('billing-info/account-created.xml'):
account.save()
logger.removeHandler(log_handler)
self.assertTrue('<account' in log_content.getvalue())
try:
# Billing info link won't be present at all yet.
self.assertRaises(AttributeError, getattr, account, 'billing_info')
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
binfo = BillingInfo(
first_name='Verena',
last_name='Example',
address1='123 Main St',
city=u'San Jos\xe9',
state='CA',
zip='94105',
country='US',
type='credit_card',
number='4111 1111 1111 1111',
verification_value='7777',
year='2015',
month='12',
)
with self.mock_request('billing-info/created.xml'):
account.update_billing_info(binfo)
logger.removeHandler(log_handler)
log_content = log_content.getvalue()
self.assertTrue('<billing_info' in log_content)
# See if we redacted our sensitive fields properly.
self.assertTrue('4111' not in log_content)
self.assertTrue('7777' not in log_content)
with self.mock_request('billing-info/account-exists.xml'):
same_account = Account.get('binfo%s' % self.test_id)
with self.mock_request('billing-info/exists.xml'):
same_binfo = same_account.billing_info
self.assertEqual(same_binfo.first_name, 'Verena')
self.assertEqual(same_binfo.city, u'San Jos\xe9')
with self.mock_request('billing-info/deleted.xml'):
binfo.delete()
finally:
with self.mock_request('billing-info/account-deleted.xml'):
account.delete()
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
account = Account(account_code='binfo-%s-2' % self.test_id)
account.billing_info = BillingInfo(
first_name='Verena',
last_name='Example',
address1='123 Main St',
city=u'San Jos\xe9',
state='CA',
zip='94105',
country='US',
type='credit_card',
number='4111 1111 1111 1111',
verification_value='7777',
year='2015',
month='12',
)
with self.mock_request('billing-info/account-embed-created.xml'):
account.save()
try:
logger.removeHandler(log_handler)
log_content = log_content.getvalue()
self.assertTrue('<account' in log_content)
self.assertTrue('<billing_info' in log_content)
self.assertTrue('4111' not in log_content)
self.assertTrue('7777' not in log_content)
with self.mock_request('billing-info/account-embed-exists.xml'):
same_account = Account.get('binfo-%s-2' % self.test_id)
with self.mock_request('billing-info/embedded-exists.xml'):
binfo = same_account.billing_info
self.assertEqual(binfo.first_name, 'Verena')
finally:
with self.mock_request('billing-info/account-embed-deleted.xml'):
account.delete()
示例2: test_billing_info
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import billing_info [as 别名]
def test_billing_info(self):
logging.basicConfig(level=logging.DEBUG) # make sure it's init'ed
logger = logging.getLogger("recurly.http.request")
logger.setLevel(logging.DEBUG)
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
account = Account(account_code="binfo%s" % self.test_id)
with self.mock_request("billing-info/account-created.xml"):
account.save()
logger.removeHandler(log_handler)
self.assertTrue("<account" in log_content.getvalue())
try:
# Billing info link won't be present at all yet.
self.assertRaises(AttributeError, getattr, account, "billing_info")
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
binfo = BillingInfo(
first_name="Verena",
last_name="Example",
address1="123 Main St",
city=six.u("San Jos\xe9"),
state="CA",
zip="94105",
country="US",
type="credit_card",
number="4111 1111 1111 1111",
verification_value="7777",
year="2015",
month="12",
)
with self.mock_request("billing-info/created.xml"):
account.update_billing_info(binfo)
logger.removeHandler(log_handler)
log_content = log_content.getvalue()
self.assertTrue("<billing_info" in log_content)
# See if we redacted our sensitive fields properly.
self.assertTrue("4111" not in log_content)
self.assertTrue("7777" not in log_content)
with self.mock_request("billing-info/account-exists.xml"):
same_account = Account.get("binfo%s" % self.test_id)
with self.mock_request("billing-info/exists.xml"):
same_binfo = same_account.billing_info
self.assertEqual(same_binfo.first_name, "Verena")
self.assertEqual(same_binfo.city, six.u("San Jos\xe9"))
with self.mock_request("billing-info/deleted.xml"):
binfo.delete()
finally:
with self.mock_request("billing-info/account-deleted.xml"):
account.delete()
# Credit Card
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
account = Account(account_code="binfo-%s-2" % self.test_id)
account.billing_info = BillingInfo(
first_name="Verena",
last_name="Example",
address1="123 Main St",
city=six.u("San Jos\xe9"),
state="CA",
zip="94105",
country="US",
type="credit_card",
number="4111 1111 1111 1111",
verification_value="7777",
year="2015",
month="12",
)
with self.mock_request("billing-info/account-embed-created.xml"):
account.save()
try:
logger.removeHandler(log_handler)
log_content = log_content.getvalue()
self.assertTrue("<account" in log_content)
self.assertTrue("<billing_info" in log_content)
self.assertTrue("4111" not in log_content)
self.assertTrue("7777" not in log_content)
with self.mock_request("billing-info/account-embed-exists.xml"):
same_account = Account.get("binfo-%s-2" % self.test_id)
with self.mock_request("billing-info/embedded-exists.xml"):
binfo = same_account.billing_info
self.assertEqual(binfo.first_name, "Verena")
finally:
with self.mock_request("billing-info/account-embed-deleted.xml"):
#.........这里部分代码省略.........