def capture(self, source, options = {}): """Capture the invoice using the given source (customer or token) Keyword argument: source -- Source used to authorization the payment. Can be a card, a token or a gateway request options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(self.id) + "/capture" data = { 'authorize_only': options.get("authorize_only"), 'synchronous': options.get("synchronous"), 'retry_drop_liability_shift': options.get("retry_drop_liability_shift"), 'capture_amount': options.get("capture_amount"), 'source': source } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["transaction"] transaction = processout.Transaction(self._client) return_values.append(transaction.fill_with_data(body)) return return_values[0]
def transaction(self, val): """Set transaction Keyword argument: val -- New transaction value""" if val is None: self._transaction = val return self if isinstance(val, dict): obj = processout.Transaction(self._client) obj.fill_with_data(val) self._transaction = obj else: self._transaction = val return self
def transactions(self, val): """Set transactions Keyword argument: val -- New transactions value""" if val is None: self._transactions = [] return self if len(val) > 0 and isinstance(val[0], processout.Transaction): self._transactions = val else: l = [] for v in val: obj = processout.Transaction(self._client) obj.fill_with_data(v) l.append(obj) self._transactions = l return self
def find(self, transaction_id, options={}): """Find a transaction by its ID. 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) + "" data = {} response = Response(request.get(path, data, options)) return_values = [] body = response.body body = body["transaction"] obj = processout.Transaction(self._client) return_values.append(obj.fill_with_data(body)) return return_values[0]
def void(self, options = {}): """Void the invoice Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/invoices/" + quote_plus(self.id) + "/void" data = { } response = Response(request.post(path, data, options)) return_values = [] body = response.body body = body["transaction"] transaction = processout.Transaction(self._client) return_values.append(transaction.fill_with_data(body)) return return_values[0]
def all(self, options={}): """Get all the transactions. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/transactions" data = {} response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['transactions']: tmp = processout.Transaction(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def fetch_transactions(self, options={}): """Get the transactions belonging to the customer. Keyword argument: options -- Options for the request""" self.fill_with_data(options) request = Request(self._client) path = "/customers/" + quote_plus(self.id) + "/transactions" data = {} response = Response(request.get(path, data, options)) return_values = [] a = [] body = response.body for v in body['transactions']: tmp = processout.Transaction(self._client) tmp.fill_with_data(v) a.append(tmp) return_values.append(a) return return_values[0]
def new_transaction(self, prefill=None): """Create a new Transaction instance Keyword argument: prefill -- Data used to prefill the object (optional)""" return processout.Transaction(self, prefill)