Beispiel #1
0
    def obj_get(self, request, **kw):
        # Work around tastypie by not getting a list, but just
        # an object. With some data in the body.
        if kw['pk'] != 'status':
            raise ImmediateHttpResponse(response=HttpNotFound())

        data = self.deserialize(request, request.body,
                                format='application/json')
        form = RefundStatusForm(data)
        if not form.is_valid():
            raise self.form_errors(form)

        obj = form.cleaned_data['uuid']
        is_manual = obj.type == TYPE_REFUND_MANUAL

        try:
            res = self.client(
                'GetRefundStatus',
                {'refundTransactionId': obj.uid_pay},
                raise_on=(PENDING, CANT_REFUND, NOT_SUPPORTED),
                client=self.get_client(data, fake=is_manual)
            )
            code = res.responseCode
        except BangoFormError, exc:
            res = BangoResponse(exc.id, exc.message, '')
Beispiel #2
0
    def list(self, request, *args, **kwargs):
        form = RefundStatusForm(request.DATA)
        if not form.is_valid():
            return self.form_errors(form)

        transaction = form.cleaned_data['uuid']
        is_manual = transaction.type == TYPE_REFUND_MANUAL

        try:
            res = self.client(
                'GetRefundStatus',
                {'refundTransactionId': transaction.uid_pay},
                raise_on=(PENDING, CANT_REFUND, NOT_SUPPORTED),
                client=self.get_client(request.DATA, fake=is_manual)
            )
        except BangoAnticipatedError, exc:
            res = EasyObject(
                responseCode=exc.id,
                responseMessage=exc.message,
                refundTransactionId='')