当前位置: 首页>>代码示例>>Python>>正文


Python ExchangeRoute.from_network方法代码示例

本文整理汇总了Python中gratipay.models.exchange_route.ExchangeRoute.from_network方法的典型用法代码示例。如果您正苦于以下问题:Python ExchangeRoute.from_network方法的具体用法?Python ExchangeRoute.from_network怎么用?Python ExchangeRoute.from_network使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gratipay.models.exchange_route.ExchangeRoute的用法示例。


在下文中一共展示了ExchangeRoute.from_network方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_giving_is_updated_when_credit_card_fails

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
    def test_giving_is_updated_when_credit_card_fails(self, btd):
        alice = self.make_participant("alice", claimed_time="now", last_bill_result="")
        team = self.make_team(is_approved=True)

        alice.set_payment_instruction(team, "5.00")  # funded

        assert alice.giving == Decimal("5.00")
        assert Team.from_slug(team.slug).receiving == Decimal("5.00")

        ExchangeRoute.from_network(alice, "braintree-cc").update_error("Card expired")

        assert Participant.from_username("alice").giving == Decimal("0.00")
        assert Team.from_slug(team.slug).receiving == Decimal("0.00")
开发者ID:hdushku,项目名称:gratipay.com,代码行数:15,代码来源:test_participant.py

示例2: test_giving_is_updated_when_credit_card_is_updated

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
    def test_giving_is_updated_when_credit_card_is_updated(self, btd):
        alice = self.make_participant('alice', claimed_time='now', last_bill_result='fail')
        team = self.make_team(is_approved=True)

        alice.set_payment_instruction(team, '5.00') # Not funded, failing card

        assert alice.giving == Decimal('0.00')
        assert Team.from_slug(team.slug).receiving == Decimal('0.00')

        # Alice updates her card..
        ExchangeRoute.from_network(alice, 'braintree-cc').invalidate()
        ExchangeRoute.insert(alice, 'braintree-cc', '/cards/bar', '')

        assert alice.giving == Decimal('5.00')
        assert Team.from_slug(team.slug).receiving == Decimal('5.00')
开发者ID:crowdfundingsourcecode,项目名称:gratipay.com,代码行数:17,代码来源:test_participant.py

示例3: test_giving_is_updated_when_credit_card_is_updated

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
    def test_giving_is_updated_when_credit_card_is_updated(self, btd):
        alice = self.make_participant("alice", claimed_time="now", last_bill_result="fail")
        team = self.make_team(is_approved=True)

        alice.set_payment_instruction(team, "5.00")  # Not funded, failing card

        assert alice.giving == Decimal("0.00")
        assert Team.from_slug(team.slug).receiving == Decimal("0.00")

        # Alice updates her card..
        ExchangeRoute.from_network(alice, "braintree-cc").invalidate()
        ExchangeRoute.insert(alice, "braintree-cc", "/cards/bar", "")

        assert alice.giving == Decimal("5.00")
        assert Team.from_slug(team.slug).receiving == Decimal("5.00")
开发者ID:hdushku,项目名称:gratipay.com,代码行数:17,代码来源:test_participant.py

示例4: test_giving_is_updated_when_credit_card_fails

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
    def test_giving_is_updated_when_credit_card_fails(self, btd):
        alice = self.make_participant('alice', claimed_time='now', last_bill_result='')
        team = self.make_team(is_approved=True)

        alice.set_payment_instruction(team, '5.00') # funded

        assert alice.giving == Decimal('5.00')
        assert Team.from_slug(team.slug).receiving == Decimal('5.00')
        assert Participant.from_username(team.owner).taking == Decimal('5.00')

        ExchangeRoute.from_network(alice, 'braintree-cc').update_error("Card expired")

        assert Participant.from_username('alice').giving == Decimal('0.00')
        assert Team.from_slug(team.slug).receiving == Decimal('0.00')
        assert Participant.from_username(team.owner).taking == Decimal('0.00')
开发者ID:crowdfundingsourcecode,项目名称:gratipay.com,代码行数:17,代码来源:test_participant.py

示例5: test_credit_callback

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_credit_callback(self, rer):
     alice = self.make_participant('alice')
     ExchangeRoute.insert(alice, 'balanced-ba', '/bank/foo', '')
     ba = ExchangeRoute.from_network(alice, 'balanced-ba')
     for status in ('succeeded', 'failed'):
         error = 'FOO' if status == 'failed' else None
         e_id = record_exchange(self.db, ba, 10, 0, alice, 'pre')
         body = json.dumps({
             "events": [
                 {
                     "type": "credit."+status,
                     "entity": {
                         "credits": [
                             {
                                 "failure_reason": error,
                                 "meta": {
                                     "participant_id": alice.id,
                                     "exchange_id": e_id,
                                 },
                                 "status": status,
                             }
                         ]
                     }
                 }
             ]
         })
         r = self.callback(body=body, csrf_token=False)
         assert r.code == 200, r.body
         assert rer.call_count == 1
         assert rer.call_args[0][:-1] == (self.db, e_id, status, error)
         assert rer.call_args[0][-1].id == alice.id
         assert rer.call_args[1] == {}
         rer.reset_mock()
开发者ID:neelmanisehgal,项目名称:gratipay.com,代码行数:35,代码来源:test_callbacks.py

示例6: test_re_result_doesnt_restore_balance_on_success

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_re_result_doesnt_restore_balance_on_success(self):
     alice = self.make_participant('alice', balance=50, last_paypal_result='')
     ba = ExchangeRoute.from_network(alice, 'paypal')
     e_id = record_exchange(self.db, ba, D('-43.98'), D('1.60'), alice, 'pre')
     assert alice.balance == D('4.42')
     record_exchange_result(self.db, e_id, 'succeeded', None, alice)
     assert P('alice').balance == D('4.42')
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:9,代码来源:test_billing_exchanges.py

示例7: test_re_result_restores_balance_on_error

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_re_result_restores_balance_on_error(self):
     alice = self.make_participant('alice', balance=30, last_paypal_result='')
     ba = ExchangeRoute.from_network(alice, 'paypal')
     e_id = record_exchange(self.db, ba, D('-27.06'), D('0.81'), alice, 'pre')
     assert alice.balance == D('02.13')
     record_exchange_result(self.db, e_id, 'failed', 'SOME ERROR', alice)
     assert P('alice').balance == D('30.00')
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:9,代码来源:test_billing_exchanges.py

示例8: test_re_result_updates_balance_for_positive_amounts

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_re_result_updates_balance_for_positive_amounts(self):
     alice = self.make_participant('alice', balance=4, last_bill_result='')
     cc = ExchangeRoute.from_network(alice, 'braintree-cc')
     e_id = record_exchange(self.db, cc, D('31.59'), D('0.01'), alice, 'pre')
     assert alice.balance == D('4.00')
     record_exchange_result(self.db, e_id, 'succeeded', None, alice)
     assert P('alice').balance == D('35.59')
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:9,代码来源:test_billing_exchanges.py

示例9: test_associate_paypal

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_associate_paypal(self, mailer):
     mailer.return_value = 1 # Email successfully sent
     self.roman.add_email('[email protected]')
     self.db.run("UPDATE emails SET verified=true WHERE address='[email protected]'")
     self.hit('roman', 'associate', 'paypal', '[email protected]')
     assert ExchangeRoute.from_network(self.roman, 'paypal')
     assert self.roman.has_payout_route
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:9,代码来源:test_routes.py

示例10: create_card_hold

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
def create_card_hold(db, participant, amount):
    """Create a hold on the participant's credit card.

    Amount should be the nominal amount. We'll compute Gratipay's fee below
    this function and add it to amount to end up with charge_amount.

    """
    typecheck(amount, Decimal)

    username = participant.username


    # Perform some last-minute checks.
    # ================================

    if participant.is_suspicious is not False:
        raise NotWhitelisted      # Participant not trusted.

    route = ExchangeRoute.from_network(participant, 'braintree-cc')
    if not route:
        return None, 'No credit card'


    # Go to Braintree.
    # ================

    cents, amount_str, charge_amount, fee = _prep_hit(amount)
    amount = charge_amount - fee
    msg = "Holding " + amount_str + " on Braintree for " + username + " ... "

    hold = None
    error = ""
    try:
        result = braintree.Transaction.sale({
            'amount': str(cents/100.0),
            'customer_id': route.participant.braintree_customer_id,
            'payment_method_token': route.address,
            'options': { 'submit_for_settlement': False },
            'custom_fields': {'participant_id': participant.id}
        })

        if result.is_success and result.transaction.status == 'authorized':
            error = ""
            hold = result.transaction
        elif result.is_success:
            error = "Transaction status was %s" % result.transaction.status
        else:
            error = result.message

    except Exception as e:
        error = repr_exception(e)

    if error == '':
        log(msg + "succeeded.")
    else:
        log(msg + "failed: %s" % error)
        record_exchange(db, route, amount, fee, participant, 'failed', error)

    return hold, error
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:61,代码来源:exchanges.py

示例11: test_associate_and_delete_valid_paypal

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
    def test_associate_and_delete_valid_paypal(self):
        self.add_and_verify_email(self.roman, '[email protected]')

        self.hit('roman', 'associate', 'paypal', '[email protected]')
        assert ExchangeRoute.from_network(self.roman, 'paypal')
        assert self.roman.has_payout_route

        self.hit('roman', 'delete', 'paypal', '[email protected]')
        assert not self.roman.has_payout_route
开发者ID:cyberjacob,项目名称:www.gittip.com,代码行数:11,代码来源:test_www_payment_routes.py

示例12: test_record_exchange_result_restores_balance_on_error_with_invalidated_route

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_record_exchange_result_restores_balance_on_error_with_invalidated_route(self):
     alice = self.make_participant('alice', balance=37, last_ach_result='')
     ba = ExchangeRoute.from_network(alice, 'balanced-ba')
     e_id = record_exchange(self.db, ba, D('-32.45'), D('0.86'), alice, 'pre')
     assert alice.balance == D('3.69')
     ba.update_error('invalidated')
     record_exchange_result(self.db, e_id, 'failed', 'oops', alice)
     alice = Participant.from_username('alice')
     assert alice.balance == D('37.00')
     assert ba.error == alice.get_bank_account_error() == 'invalidated'
开发者ID:j3itchtits,项目名称:gratipay.com,代码行数:12,代码来源:test_billing_exchanges.py

示例13: test_add_new_paypal_address

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
    def test_add_new_paypal_address(self):
        self.add_and_verify_email(self.roman, '[email protected]')
        self.add_and_verify_email(self.roman, '[email protected]')

        self.hit('roman', 'associate', 'paypal', '[email protected]')
        self.hit('roman', 'delete', 'paypal', '[email protected]')
        self.hit('roman', 'associate', 'paypal', '[email protected]')

        assert self.roman.has_payout_route
        assert ExchangeRoute.from_network(self.roman, 'paypal').address == '[email protected]'
开发者ID:cyberjacob,项目名称:www.gittip.com,代码行数:12,代码来源:test_www_payment_routes.py

示例14: make_exchange

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def make_exchange(self, route, amount, fee, participant, status='succeeded', error=''):
     if not isinstance(route, ExchangeRoute):
         network = route
         route = ExchangeRoute.from_network(participant, network)
         if not route:
             route = ExchangeRoute.insert(participant, network, 'dummy-address')
             assert route
     e_id = record_exchange(self.db, route, amount, fee, participant, 'pre')
     record_exchange_result(self.db, e_id, status, error, participant)
     return e_id
开发者ID:HolaChica,项目名称:gratipay.com,代码行数:12,代码来源:__init__.py

示例15: test_re_result_restores_balance_on_error_with_invalidated_route

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import from_network [as 别名]
 def test_re_result_restores_balance_on_error_with_invalidated_route(self):
     alice = self.make_participant('alice', balance=37, last_paypal_result='')
     pp = ExchangeRoute.from_network(alice, 'paypal')
     e_id = record_exchange(self.db, pp, D('-32.45'), D('0.86'), alice, 'pre')
     assert alice.balance == D('3.69')
     pp.update_error('invalidated')
     record_exchange_result(self.db, e_id, 'failed', 'oops', alice)
     alice = P('alice')
     assert alice.balance == D('37.00')
     assert pp.error == alice.get_paypal_error() == 'invalidated'
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:12,代码来源:test_billing_exchanges.py


注:本文中的gratipay.models.exchange_route.ExchangeRoute.from_network方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。