本文整理汇总了Python中gratipay.models.exchange_route.ExchangeRoute.from_address方法的典型用法代码示例。如果您正苦于以下问题:Python ExchangeRoute.from_address方法的具体用法?Python ExchangeRoute.from_address怎么用?Python ExchangeRoute.from_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gratipay.models.exchange_route.ExchangeRoute
的用法示例。
在下文中一共展示了ExchangeRoute.from_address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_associate_and_delete_bank_account_valid
# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_address [as 别名]
def test_associate_and_delete_bank_account_valid(self):
bank_account = balanced.BankAccount( name='Alice G. Krebs'
, routing_number='321174851'
, account_number='9900000001'
, account_type='checking'
).save()
customer = self.david.get_balanced_account()
customer.merchant_status = 'underwritten'
with mock.patch.object(Participant, 'get_balanced_account') as gba:
gba.return_value = customer
self.hit('david', 'associate', 'balanced-ba', bank_account.href)
bank_accounts = customer.bank_accounts.all()
assert len(bank_accounts) == 1
assert bank_accounts[0].href == bank_account.href
assert self.david.get_bank_account_error() == ''
assert self.david.has_payout_route
self.hit('david', 'delete', 'balanced-ba', bank_account.href)
david = Participant.from_username('david')
route = ExchangeRoute.from_address(david, 'balanced-ba', bank_account.href)
assert route.error == david.get_bank_account_error() == 'invalidated'
assert david.balanced_customer_href
# Check that update_error doesn't update an invalidated route
route.update_error('some error')
assert route.error == david.get_bank_account_error() == 'invalidated'
assert not self.david.has_payout_route
示例2: capture_card_hold
# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_address [as 别名]
def capture_card_hold(db, participant, amount, hold):
"""Capture the previously created hold on the participant's credit card.
"""
typecheck( hold, braintree.Transaction
, amount, Decimal
)
username = participant.username
assert participant.id == int(hold.custom_fields['participant_id'])
route = ExchangeRoute.from_address(participant, 'braintree-cc', hold.credit_card['token'])
assert isinstance(route, ExchangeRoute)
cents, amount_str, charge_amount, fee = _prep_hit(amount)
amount = charge_amount - fee # account for possible rounding
e_id = record_exchange(db, route, amount, fee, participant, 'pre')
# TODO: Find a way to link transactions and corresponding exchanges
# meta = dict(participant_id=participant.id, exchange_id=e_id)
error = ''
try:
result = braintree.Transaction.submit_for_settlement(hold.id, str(cents/100.00))
assert result.is_success
if result.transaction.status != 'submitted_for_settlement':
error = result.transaction.status
except Exception as e:
error = repr_exception(e)
if error == '':
record_exchange_result(db, e_id, 'succeeded', None, participant)
log("Captured " + amount_str + " on Braintree for " + username)
else:
record_exchange_result(db, e_id, 'failed', error, participant)
raise Exception(error)
示例3: capture_card_hold
# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_address [as 别名]
def capture_card_hold(db, participant, amount, hold):
"""Capture the previously created hold on the participant's credit card.
"""
typecheck( hold, balanced.CardHold
, amount, Decimal
)
username = participant.username
assert participant.id == int(hold.meta['participant_id'])
route = ExchangeRoute.from_address(participant, 'balanced-cc', hold.card_href)
assert isinstance(route, ExchangeRoute)
cents, amount_str, charge_amount, fee = _prep_hit(amount)
amount = charge_amount - fee # account for possible rounding
e_id = record_exchange(db, route, amount, fee, participant, 'pre')
meta = dict(participant_id=participant.id, exchange_id=e_id)
try:
hold.capture(amount=cents, description=username, meta=meta)
record_exchange_result(db, e_id, 'succeeded', None, participant)
except Exception as e:
error = repr_exception(e)
record_exchange_result(db, e_id, 'failed', error, participant)
raise
hold.meta['state'] = 'captured'
hold.save()
log("Captured " + amount_str + " on Balanced for " + username)