本文整理汇总了Python中recurly.Account.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Python Account.subscribe方法的具体用法?Python Account.subscribe怎么用?Python Account.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recurly.Account
的用法示例。
在下文中一共展示了Account.subscribe方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subscribe
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import subscribe [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,
)
with self.mock_request('subscription/error-no-billing-info.xml'):
try:
account.subscribe(sub)
except BadRequestError, exc:
error = exc
else:
self.fail("Subscribing with no billing info did not raise a BadRequestError")
示例2:
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import subscribe [as 别名]
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)
with self.mock_request('subscription/cancelled.xml'):
sub.cancel()
with self.mock_request('subscription/reactivated.xml'):
示例3: Subscription
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import subscribe [as 别名]
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)
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')
示例4: test_subscribe
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import subscribe [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')
#.........这里部分代码省略.........
示例5: test_subscribe
# 需要导入模块: from recurly import Account [as 别名]
# 或者: from recurly.Account import subscribe [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(
#.........这里部分代码省略.........