Exemplo n.º 1
0
def check(model, data):
    """
    Checks the validity of the receipt against the verification service.

    `model`: the mode, of the receipt object to update with the results
    `data`: the actual receipt string sent from the client
    """
    model.checked = datetime.now()
    receipt = Receipt(data)
    log.info('Checking receipt: %s' % model.pk)
    try:
        result = receipt.verify_server()['status']
    except:
        log.error('There was an error with the verification.', exc_info=True)
        result = 'error'

    status = constants.VALID_LOOKUP[result]
    model.valid = status
    model.save()
    return constants.VALID_INVERTED[status]
Exemplo n.º 2
0
 def test_verify(self, post):
     post.return_value = FakeResponse(json.dumps({'status': 'ok'}))
     r = Receipt(self.receipt)
     eq_(r.verify_server()['status'], 'ok')
Exemplo n.º 3
0
 def test_verify(self, post):
     post.return_value = FakeResponse(json.dumps({"status": "ok"}))
     r = Receipt(self.receipt)
     eq_(r.verify_server()["status"], "ok")