本文整理汇总了Python中recurly.Account.update_billing_info方法的典型用法代码示例。如果您正苦于以下问题:Python Account.update_billing_info方法的具体用法?Python Account.update_billing_info怎么用?Python Account.update_billing_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recurly.Account
的用法示例。
在下文中一共展示了Account.update_billing_info方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_billing_info
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import update_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: BillingInfo
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import update_billing_info [as 别名]
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('subscription/update-billing-info.xml'):
account.update_billing_info(binfo)
with self.mock_request('subscription/subscribed.xml'):
account.subscribe(sub)
self.assertTrue(sub._url)
with self.mock_request('subscription/account-subscriptions.xml'):
subs = account.subscriptions()
self.assertTrue(len(subs) > 0)
self.assertEqual(subs[0].uuid, sub.uuid)
with self.mock_request('subscription/all-subscriptions.xml'):
subs = Subscription.all()
self.assertTrue(len(subs) > 0)
self.assertEqual(subs[0].uuid, sub.uuid)
示例3: test_subscribe
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import update_billing_info [as 别名]
def test_subscribe(self):
logging.basicConfig(level=logging.DEBUG) # make sure it's init'ed
logger = logging.getLogger('recurly.http.request')
logger.setLevel(logging.DEBUG)
plan = Plan(
plan_code='basicplan',
name='Basic Plan',
setup_fee_in_cents=Money(0),
unit_amount_in_cents=Money(1000),
)
with self.mock_request('subscription/plan-created.xml'):
plan.save()
try:
account = Account(account_code='subscribe%s' % self.test_id)
with self.mock_request('subscription/account-created.xml'):
account.save()
try:
sub = Subscription(
plan_code='basicplan',
currency='USD',
unit_amount_in_cents=1000,
bulk=True
)
with self.mock_request('subscription/error-no-billing-info.xml'):
try:
account.subscribe(sub)
except BadRequestError as exc:
error = exc
else:
self.fail("Subscribing with no billing info did not raise a BadRequestError")
self.assertEqual(error.symbol, 'billing_info_required')
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('subscription/update-billing-info.xml'):
account.update_billing_info(binfo)
with self.mock_request('subscription/subscribed.xml'):
account.subscribe(sub)
self.assertTrue(sub._url)
manualsub = Subscription(
plan_code='basicplan',
currency='USD',
net_terms=10,
po_number='1000',
collection_method='manual'
)
with self.mock_request('subscription/subscribed-manual.xml'):
account.subscribe(manualsub)
self.assertTrue(manualsub._url)
self.assertEqual(manualsub.net_terms, 10)
self.assertEqual(manualsub.collection_method, 'manual')
self.assertEqual(manualsub.po_number, '1000')
with self.mock_request('subscription/account-subscriptions.xml'):
subs = account.subscriptions()
self.assertTrue(len(subs) > 0)
self.assertEqual(subs[0].uuid, sub.uuid)
with self.mock_request('subscription/all-subscriptions.xml'):
subs = Subscription.all()
self.assertTrue(len(subs) > 0)
self.assertEqual(subs[0].uuid, sub.uuid)
with self.mock_request('subscription/cancelled.xml'):
sub.cancel()
with self.mock_request('subscription/reactivated.xml'):
sub.reactivate()
# Try modifying the subscription.
sub.timeframe = 'renewal'
sub.unit_amount_in_cents = 800
with self.mock_request('subscription/updated-at-renewal.xml'):
sub.save()
pending_sub = sub.pending_subscription
self.assertTrue(isinstance(pending_sub, Subscription))
self.assertEqual(pending_sub.unit_amount_in_cents, 800)
self.assertEqual(sub.unit_amount_in_cents, 1000)
with self.mock_request('subscription/terminated.xml'):
sub.terminate(refund='none')
#.........这里部分代码省略.........
示例4: test_transaction_with_balance
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import update_billing_info [as 别名]
def test_transaction_with_balance(self):
transaction = Transaction(
amount_in_cents=1000,
currency='USD',
account=Account(),
)
error = None
with self.mock_request('transaction-balance/transaction-no-account.xml'):
try:
transaction.save()
except ValidationError as _error:
error = _error
else:
self.fail("Posting a transaction without an account code did not raise a ValidationError")
# Make sure there really were errors.
self.assertTrue(len(error.errors) > 0)
account_code = 'transbalance%s' % self.test_id
account = Account(account_code=account_code)
with self.mock_request('transaction-balance/account-created.xml'):
account.save()
try:
# Try to charge without billing info, should break.
transaction = Transaction(
amount_in_cents=1000,
currency='USD',
account=account,
)
error = None
with self.mock_request('transaction-balance/transaction-no-billing-fails.xml'):
try:
transaction.save()
except ValidationError as _error:
error = _error
else:
self.fail("Posting a transaction without billing info did not raise a ValidationError")
# Make sure there really were errors.
self.assertTrue(len(error.errors) > 0)
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('transaction-balance/set-billing-info.xml'):
account.update_billing_info(binfo)
# Try to charge now, should be okay.
transaction = Transaction(
amount_in_cents=1000,
currency='USD',
account=account,
)
with self.mock_request('transaction-balance/transacted.xml'):
transaction.save()
# Give the account a credit.
credit = Adjustment(unit_amount_in_cents=-2000, currency='USD', description='transaction test credit')
with self.mock_request('transaction-balance/credited.xml'):
# TODO: maybe this should be adjust()?
account.charge(credit)
# Try to charge less than the account balance, which should fail (not a CC transaction).
transaction = Transaction(
amount_in_cents=500,
currency='USD',
account=account,
)
with self.mock_request('transaction-balance/transacted-2.xml'):
transaction.save()
# The transaction doesn't actually save.
self.assertTrue(transaction._url is None)
# Try to charge more than the account balance, which should work.
transaction = Transaction(
amount_in_cents=3000,
currency='USD',
account=account,
)
with self.mock_request('transaction-balance/transacted-3.xml'):
transaction.save()
# This transaction should be recorded.
self.assertTrue(transaction._url is not None)
finally:
with self.mock_request('transaction-balance/account-deleted.xml'):
account.delete()
示例5: test_subscribe
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import update_billing_info [as 别名]
def test_subscribe(self):
logging.basicConfig(level=logging.DEBUG) # make sure it's init'ed
logger = logging.getLogger("recurly.http.request")
logger.setLevel(logging.DEBUG)
plan = Plan(
plan_code="basicplan", name="Basic Plan", setup_fee_in_cents=Money(0), unit_amount_in_cents=Money(1000)
)
with self.mock_request("subscription/plan-created.xml"):
plan.save()
try:
account = Account(account_code="subscribe%s" % self.test_id)
with self.mock_request("subscription/account-created.xml"):
account.save()
try:
sub = Subscription(
plan_code="basicplan",
currency="USD",
unit_amount_in_cents=1000,
bulk=True,
terms_and_conditions="Some Terms and Conditions",
customer_notes="Some Customer Notes",
)
with self.mock_request("subscription/error-no-billing-info.xml"):
try:
account.subscribe(sub)
except BadRequestError as exc:
error = exc
else:
self.fail("Subscribing with no billing info did not raise a BadRequestError")
self.assertEqual(error.symbol, "billing_info_required")
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("subscription/update-billing-info.xml"):
account.update_billing_info(binfo)
with self.mock_request("subscription/subscribed.xml"):
account.subscribe(sub)
self.assertTrue(sub._url)
manualsub = Subscription(
plan_code="basicplan", currency="USD", net_terms=10, po_number="1000", collection_method="manual"
)
with self.mock_request("subscription/subscribed-manual.xml"):
account.subscribe(manualsub)
self.assertTrue(manualsub._url)
self.assertEqual(manualsub.net_terms, 10)
self.assertEqual(manualsub.collection_method, "manual")
self.assertEqual(manualsub.po_number, "1000")
with self.mock_request("subscription/account-subscriptions.xml"):
subs = account.subscriptions()
self.assertTrue(len(subs) > 0)
self.assertEqual(subs[0].uuid, sub.uuid)
with self.mock_request("subscription/all-subscriptions.xml"):
subs = Subscription.all()
self.assertTrue(len(subs) > 0)
self.assertEqual(subs[0].uuid, sub.uuid)
with self.mock_request("subscription/cancelled.xml"):
sub.cancel()
with self.mock_request("subscription/reactivated.xml"):
sub.reactivate()
# Try modifying the subscription.
sub.timeframe = "renewal"
sub.unit_amount_in_cents = 800
with self.mock_request("subscription/updated-at-renewal.xml"):
sub.save()
pending_sub = sub.pending_subscription
self.assertTrue(isinstance(pending_sub, Subscription))
self.assertEqual(pending_sub.unit_amount_in_cents, 800)
self.assertEqual(sub.unit_amount_in_cents, 1000)
with self.mock_request("subscription/terminated.xml"):
sub.terminate(refund="none")
log_content = StringIO()
log_handler = logging.StreamHandler(log_content)
logger.addHandler(log_handler)
sub = Subscription(
#.........这里部分代码省略.........
示例6: test_billing_info
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import update_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"):
#.........这里部分代码省略.........