Пример #1
0
def verify(transaction, amount, currency):
    """
    Verify a transaction against Boku.
    """
    def error(msg):
        msg = 'transaction {0}: {1}'.format(transaction.pk, msg)
        log.error(msg)
        raise VerificationError(msg)

    try:
        seller_boku = transaction.seller_product.seller.boku
    except ObjectDoesNotExist:
        error('did not have a seller_boku row')

    if not seller_boku.merchant_id:
        error('did not have a merchant id')

    client = get_client(seller_boku.merchant_id, settings.BOKU_SECRET_KEY)
    res = client.check_transaction(transaction.uid_support)

    try:
        real = fix_price(res['amount'], currency)
    except (KeyError, AssertionError):
        error('not a valid price {0} or currency {1}'
              .format(res['amount'], currency))

    if real != amount:
        error('did not verify: {0} != {1}'.format(real, amount))

    log.info('transaction: {0} verified successfully'.format(transaction.pk))
Пример #2
0
def verify(transaction, amount, currency):
    """
    Verify a transaction against Boku.
    """
    def error(msg):
        msg = 'transaction {0}: {1}'.format(transaction, msg)
        log.error(msg)
        raise VerificationError(msg)

    client = get_client(settings.BOKU_MERCHANT_ID, settings.BOKU_SECRET_KEY)
    res = client.check_transaction(transaction)

    try:
        real = fix_price(res['amount'], currency)
    except (KeyError, AssertionError):
        error('not a valid price {0} or currency {1}'
              .format(res['amount'], currency))

    if real != amount:
        error('did not verify: {0} != {1}'.format(real, amount))

    log.info('transaction: {0} verified successfully'.format(transaction))
Пример #3
0
def verify(transaction, amount, currency):
    """
    Verify a transaction against Boku.
    """
    def error(msg):
        msg = 'transaction {0}: {1}'.format(transaction, msg)
        log.error(msg)
        raise VerificationError(msg)

    client = get_client(settings.BOKU_MERCHANT_ID, settings.BOKU_SECRET_KEY)
    res = client.check_transaction(transaction)

    try:
        real = fix_price(res['amount'], currency)
    except (KeyError, AssertionError):
        error('not a valid price {0} or currency {1}'.format(
            res['amount'], currency))

    if real != amount:
        error('did not verify: {0} != {1}'.format(real, amount))

    log.info('transaction: {0} verified successfully'.format(transaction))
Пример #4
0
 def boku_client(self):
     return get_client(
         self.cleaned_data['seller_uuid'].boku.merchant_id,
         settings.BOKU_SECRET_KEY
     )
Пример #5
0
 def test_real(self):
     with self.settings(BOKU_PROXY='', BOKU_MOCK=False):
         assert isinstance(get_client('', ''), BokuClient)
Пример #6
0
 def test_proxy(self):
     with self.settings(BOKU_PROXY='blah', BOKU_MOCK=False):
         assert isinstance(get_client('', ''), ProxyClient)
Пример #7
0
 def test_mock(self):
     assert isinstance(get_client('', ''), MockClient)
Пример #8
0
 def test_nope(self):
     with self.settings(BOKU_MOCK=False, BOKU_PROXY='',
                        BOKU_SECRET_KEY=''):
         get_client('', '')
Пример #9
0
 def test_real(self):
     with self.settings(BOKU_MOCK=False, BOKU_PROXY='',
                        BOKU_SECRET_KEY='f'):
         assert isinstance(get_client('', ''), BokuClient)
Пример #10
0
 def test_proxy(self):
     with self.settings(BOKU_MOCK=False, BOKU_PROXY='blah'):
         assert isinstance(get_client('', ''), ProxyClient)
Пример #11
0
 def test_mock(self):
     assert isinstance(get_client('', ''), MockClient)