Exemplo n.º 1
0
    def test_transactions_order(self):
        process = Processor(notification(
            subject=subscription(transactions=[
                # Repeated transactions only most recent (first)
                # should be used.
                transaction(id='first:id'),
                transaction(id='another:id')
            ]),
            kind=self.kind))
        process.process()

        eq_(process.transactions[0].uid_support, 'first:id')
Exemplo n.º 2
0
    def test_transactions_order(self):
        process = Processor(
            notification(
                subject=subscription(transactions=[
                    # Repeated transactions only most recent (first)
                    # should be used.
                    transaction(id='first:id'),
                    transaction(id='another:id')
                ]),
                kind=self.kind))
        process.process()

        eq_(process.transactions[0].uid_support, 'first:id')
Exemplo n.º 3
0
def parse(request):
    form = WebhookParseForm(request.DATA)
    if not form.is_valid():
        raise FormError(form.errors)

    # Parse the gateway without doing a validation on this server.
    # The validation has happened on the solitude-auth server.
    gateway = get_client().Configuration.instantiate().gateway()
    payload = base64.decodestring(form.cleaned_data['bt_payload'])
    attributes = XmlUtil.dict_from_xml(payload)
    parsed = WebhookNotification(gateway, attributes['notification'])

    log.info('Received webhook: {p.kind}.'.format(p=parsed))
    debug_log.debug(parsed)

    processor = Processor(parsed)
    processor.process()
    data = processor.data
    return Response(data, status=200 if data else 204)
Exemplo n.º 4
0
 def test_none(self):
     self.braintree_sub.delete()
     obj = Processor(notification(kind=self.kind, subject=self.sub))
     with self.assertRaises(BraintreeSubscription.DoesNotExist):
         obj.process()
Exemplo n.º 5
0
 def test_no_transactions_data(self):
     process = Processor(
         notification(subject=subscription(transactions=[]),
                      kind=self.kind))
     process.process()
     eq_(process.transaction, None)
Exemplo n.º 6
0
 def process(self, subscription):
     hook = Processor(notification(subject=subscription, kind=self.kind))
     hook.process()
     hook.get_subscription()
     hook.update_transactions()
     return hook
Exemplo n.º 7
0
 def test_none(self):
     self.braintree_sub.delete()
     obj = Processor(notification(kind=self.kind, subject=self.sub))
     with self.assertRaises(BraintreeSubscription.DoesNotExist):
         obj.process()
Exemplo n.º 8
0
 def test_no_transactions_data(self):
     process = Processor(notification(
         subject=subscription(transactions=[]), kind=self.kind))
     process.process()
     eq_(process.transaction, None)
Exemplo n.º 9
0
 def process(self, subscription):
     hook = Processor(notification(subject=subscription, kind=self.kind))
     hook.process()
     hook.get_subscription()
     hook.update_transactions()
     return hook