예제 #1
0
    def refunds(self, val):
        """Set refunds
        Keyword argument:
        val -- New refunds value"""
        if val is None:
            self._refunds = []
            return self

        if len(val) > 0 and isinstance(val[0], processout.Refund):
            self._refunds = val
        else:
            l = []
            for v in val:
                obj = processout.Refund(self._client)
                obj.fill_with_data(v)
                l.append(obj)
            self._refunds = l
        return self
예제 #2
0
    def find_refund(self, refund_id, options={}):
        """Find a transaction's refund by its ID.
        Keyword argument:
        refund_id -- ID of the refund
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/transactions/" + quote_plus(
            self.id) + "/refunds/" + quote_plus(refund_id) + ""
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        body = response.body
        body = body["refund"]
        refund = processout.Refund(self._client)
        return_values.append(refund.fill_with_data(body))

        return return_values[0]
예제 #3
0
    def fetch_transaction_refunds(self, transaction_id, options={}):
        """Get the transaction's refunds.
        Keyword argument:
        transaction_id -- ID of the transaction
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/transactions/" + quote_plus(transaction_id) + "/refunds"
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        a = []
        body = response.body
        for v in body['refunds']:
            tmp = processout.Refund(self._client)
            tmp.fill_with_data(v)
            a.append(tmp)

        return_values.append(a)

        return return_values[0]
예제 #4
0
 def new_refund(self, prefill=None):
     """Create a new Refund instance
     Keyword argument:
     prefill -- Data used to prefill the object (optional)"""
     return processout.Refund(self, prefill)