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


Python ExchangeRoute.insert方法代码示例

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


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

示例1: test_credit_callback

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [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

示例2: setUp

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
    def setUp(self):
        # Balanced Customer without funding instruments
        self.david = self.make_participant('david', is_suspicious=False,
                                           claimed_time='now',
                                           balanced_customer_href=self.david_href)

        # Balanced Customer with CC attached
        self.janet = self.make_participant('janet', is_suspicious=False,
                                           claimed_time='now',
                                           balanced_customer_href=self.janet_href)
        self.janet_route = ExchangeRoute.insert(self.janet, 'balanced-cc', self.card_href)

        # Balanced Customer with BA attached
        self.homer = self.make_participant('homer', is_suspicious=False,
                                           claimed_time='now',
                                           balanced_customer_href=self.homer_href)
        self.homer_route = ExchangeRoute.insert(self.homer, 'balanced-ba', self.bank_account_href)

        # Braintree Customer without funding instruments
        self.roman = self.make_participant('roman', is_suspicious=False,
                                         claimed_time='now',
                                         braintree_customer_id=self.roman_bt_id)
        # Braintree Customer with CC attached
        self.obama = self.make_participant('obama', is_suspicious=False,
                                          claimed_time='now',
                                          braintree_customer_id=self.obama_bt_id)
        self.obama_route = ExchangeRoute.insert(self.obama, 'braintree-cc', self.obama_cc_token)
开发者ID:kzisme,项目名称:gratipay.com,代码行数:29,代码来源:billing.py

示例3: test_grprbn_includes_1_0_payouts

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
 def test_grprbn_includes_1_0_payouts(self):
     alice = self.make_participant( 'alice'
                                  , balance=24
                                  , status_of_1_0_payout='pending-payout'
                                  , claimed_time='now'
                                   )
     ExchangeRoute.insert(alice, 'paypal', '[email protected]')
     routes = get_ready_payout_routes_by_network(self.db, 'paypal')
     assert [r.participant.username for r in routes] == ['alice']
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:11,代码来源:test_billing_exchanges.py

示例4: setUp

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
 def setUp(self):
     self.david = self.make_participant('david', is_suspicious=False,
                                        claimed_time='now',
                                        balanced_customer_href=self.david_href)
     self.janet = self.make_participant('janet', is_suspicious=False,
                                        claimed_time='now',
                                        balanced_customer_href=self.janet_href)
     self.janet_route = ExchangeRoute.insert(self.janet, 'balanced-cc', self.card_href)
     self.homer = self.make_participant('homer', is_suspicious=False,
                                        claimed_time='now',
                                        balanced_customer_href=self.homer_href)
     self.homer_route = ExchangeRoute.insert(self.homer, 'balanced-ba', self.bank_account_href)
开发者ID:SirCmpwn,项目名称:gratipay.com,代码行数:14,代码来源:balanced.py

示例5: test_create_card_hold_bad_card

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
    def test_create_card_hold_bad_card(self):
        bob = self.make_participant('bob', balanced_customer_href='new',
                                    is_suspicious=False)
        card = balanced.Card(
            number='4444444444444448',
            expiration_year=2020,
            expiration_month=12
        ).save()
        card.associate_to_customer(bob.balanced_customer_href)
        ExchangeRoute.insert(bob, 'balanced-cc', card.href)

        hold, error = create_card_hold(self.db, bob, D('10.00'))
        assert error.startswith('402 Payment Required, ')
开发者ID:j3itchtits,项目名称:gratipay.com,代码行数:15,代码来源:test_billing_exchanges.py

示例6: setUp

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
 def setUp(self):
     # Braintree Customer without funding instruments
     self.roman = self.make_participant('roman', is_suspicious=False,
                                      claimed_time='now',
                                      braintree_customer_id=self.roman_bt_id)
     # Braintree Customer with CC attached
     self.obama = self.make_participant('obama', is_suspicious=False,
                                       claimed_time='now',
                                       braintree_customer_id=self.obama_bt_id)
     self.obama_route = ExchangeRoute.insert(self.obama, 'braintree-cc', self.obama_cc_token)
     # A customer with Paypal attached.
     self.homer = self.make_participant('homer', is_suspicious=False,
                                        claimed_time='now')
     self.homer_route = ExchangeRoute.insert(self.homer, 'paypal', '[email protected]')
开发者ID:HolaChica,项目名称:gratipay.com,代码行数:16,代码来源:billing.py

示例7: test_cch_multiple_cards

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
    def test_cch_multiple_cards(self):
        bob = self.make_participant('bob', is_suspicious=False)
        customer_id = bob.get_braintree_account().id

        for i in range(2):
            result = braintree.PaymentMethod.create({
                "customer_id": customer_id,
                "payment_method_nonce": Nonces.Transactable
            })
            assert result.is_success
            ExchangeRoute.insert(bob, 'braintree-cc', result.payment_method.token)

        self.hold, error = create_card_hold(self.db, bob, D('100.00'))
        assert error == ''
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:16,代码来源:test_billing_exchanges.py

示例8: test_giving_is_updated_when_credit_card_is_updated

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [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

示例9: test_cch_bad_card

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
    def test_cch_bad_card(self):
        bob = self.make_participant('bob', is_suspicious=False)
        customer_id = bob.get_braintree_account().id
        result = braintree.PaymentMethod.create({
            "customer_id": customer_id,
            "payment_method_nonce": Nonces.Transactable
        })
        assert result.is_success
        ExchangeRoute.insert(bob, 'braintree-cc', result.payment_method.token)

        # https://developers.braintreepayments.com/ios+python/reference/general/testing#test-amounts
        # $2002 is upcharged to $2062, which corresponds to 'Invalid Tax Amount'
        self.hold, error = create_card_hold(self.db, bob, D('2002.00'))
        assert self.hold is None
        assert error.startswith('Invalid Tax Amount')
开发者ID:PeterDaveHello,项目名称:gratipay.com,代码行数:17,代码来源:test_billing_exchanges.py

示例10: test_giving_is_updated_when_credit_card_is_updated

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [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

示例11: make_participant

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
    def make_participant(self, username, **kw):
        participant = self.db.one(
            """
            INSERT INTO participants
                        (username, username_lower)
                 VALUES (%s, %s)
              RETURNING participants.*::participants
        """,
            (username, username.lower()),
        )

        if "elsewhere" in kw or "claimed_time" in kw:
            platform = kw.pop("elsewhere", "github")
            self.db.run(
                """
                INSERT INTO elsewhere
                            (platform, user_id, user_name, participant)
                     VALUES (%s,%s,%s,%s)
            """,
                (platform, participant.id, username, username),
            )

        # Insert exchange routes
        if "last_bill_result" in kw:
            ExchangeRoute.insert(participant, "braintree-cc", "/cards/foo", kw.pop("last_bill_result"))
        if "last_paypal_result" in kw:
            ExchangeRoute.insert(participant, "paypal", "[email protected]", kw.pop("last_paypal_result"))

        # Update participant
        if kw:
            if kw.get("claimed_time") == "now":
                kw["claimed_time"] = utcnow()
            cols, vals = zip(*kw.items())
            cols = ", ".join(cols)
            placeholders = ", ".join(["%s"] * len(vals))
            participant = self.db.one(
                """
                UPDATE participants
                   SET ({0}) = ({1})
                 WHERE username=%s
             RETURNING participants.*::participants
            """.format(
                    cols, placeholders
                ),
                vals + (username,),
            )

        return participant
开发者ID:RMUCapstone-MIS590,项目名称:gratipay.com,代码行数:50,代码来源:__init__.py

示例12: set_paypal_email

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
def set_paypal_email(username='', email='', api_key_fragment='', overwrite=False):
    """
    Usage:

    [gratipay] $ env/bin/invoke set_paypal_email --username=username [email protected] [--api-key-fragment=12e4s678] [--overwrite]
    """

    if not username or not email:
        print_help(set_paypal_email)
        sys.exit(1)

    if not os.environ.get('DATABASE_URL'):
        load_prod_envvars()

    if not api_key_fragment:
        first_eight = "unknown!"
    else:
        first_eight = api_key_fragment

    wireup.db(wireup.env())

    participant = Participant.from_username(username)
    if not participant:
        print("No Gratipay participant found with username '" + username + "'")
        sys.exit(2)

    route = ExchangeRoute.from_network(participant, 'paypal')

    # PayPal caps the MassPay fee at $20 for users outside the U.S., and $1 for
    # users inside the U.S. Most Gratipay users using PayPal are outside the U.S.
    # so we set to $20 and I'll manually adjust to $1 when running MassPay and
    # noticing that something is off.
    FEE_CAP = 20

    if route:
        print("PayPal email is already set to: " + route.address)
        if not overwrite:
            print("Not overwriting existing PayPal email.")
            sys.exit(3)

    if participant.api_key == None:
        assert first_eight == "None"
    else:
        assert participant.api_key[0:8] == first_eight

    print("Setting PayPal email for " + username + " to " + email)
    ExchangeRoute.insert(participant, 'paypal', email, fee_cap=FEE_CAP)
    print("All done.")
开发者ID:SirCmpwn,项目名称:gratipay.com,代码行数:50,代码来源:__init__.py

示例13: test_scopes_to_cursor

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
 def test_scopes_to_cursor(self):
     alice = self.make_participant('alice', claimed_time='now')
     with self.db.get_cursor() as cursor:
         route = ExchangeRoute.insert(alice, 'paypal', '[email protected]', cursor=cursor)
         assert alice.get_payout_routes() == []
         assert alice.get_payout_routes(cursor=cursor) == [route]
     assert alice.get_payout_routes() == [route]
开发者ID:cyberjacob,项目名称:www.gittip.com,代码行数:9,代码来源:test_participant_routes.py

示例14: test_cch_deleted_card

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
    def test_cch_deleted_card(self):
        bob = self.make_participant('bob', is_suspicious=False)
        route = ExchangeRoute.insert(bob, 'braintree-cc', 'foo')
        self.db.run("UPDATE exchange_routes SET is_deleted=true WHERE id=%s", (route.id,))

        self.hold, error = create_card_hold(self.db, bob, D('10.00'))
        assert error == 'No credit card'
开发者ID:cyberjacob,项目名称:www.gittip.com,代码行数:9,代码来源:test_billing_exchanges.py

示例15: test_bitcoin_payout

# 需要导入模块: from gratipay.models.exchange_route import ExchangeRoute [as 别名]
# 或者: from gratipay.models.exchange_route.ExchangeRoute import insert [as 别名]
 def test_bitcoin_payout(self, cb):
     # https://developers.coinbase.com/api#send-money
     cb.return_value.status_code = 200
     cb.return_value.json = lambda: {
         'success': True,
         'transfer': {
             'fees': {
                 'coinbase': {'currency_iso': 'USD', 'cents': 10},
                 'bank': {'currency_iso': 'USD', 'cents': 15}
             },
             'subtotal': {'currency': 'USD', 'amount': 20},
             'btc': {'currency': 'BTC', 'amount': 1}
         }
     }
     alice = self.make_participant('alice', api_key='abcdefgh', balance=100)
     route = ExchangeRoute.insert(alice, 'bitcoin', '17NdbrSGoUotzeGCcMMCqnFkEvLymoou9j')
     bitcoin_payout(username='alice', amount=20, api_key_fragment=alice.api_key[0:8])
     alice = Participant.from_username('alice')
     assert alice.balance == 79.75
     exchange = self.db.one("""
         SELECT *
           FROM exchanges
          WHERE participant='alice'
     """)
     assert exchange.amount == -20
     assert exchange.fee == 0.25
     assert exchange.route == route.id
开发者ID:SirCmpwn,项目名称:gratipay.com,代码行数:29,代码来源:test_scripts.py


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