Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions pymill/pymill.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def __init__(self, privatekey):
self.session.auth = (privatekey, "")
self.session.verify = False

def _api_call(self, url, params=None, method="GET", headers=None, parse_json=True, return_type=None):
def _api_call(self, url, params=None, method="GET", headers=None, parse_json=True, return_type=None, force_method=False):
"""Call an API method.

:Parameters:
Expand All @@ -301,7 +301,7 @@ def _api_call(self, url, params=None, method="GET", headers=None, parse_json=Tru
"""
if not params: params = {}
request = {'GET': self.session.get, 'DELETE': self.session.delete, 'PUT': self.session.put, 'POST': self.session.post}[method]
if len(params) > 0 and not method in ('DELETE', 'PUT'):
if len(params) > 0 and not method in ('DELETE', 'PUT') and not force_method:
request = self.session.post
response = request(url, params=params, headers=headers)

Expand Down Expand Up @@ -426,13 +426,30 @@ def get_transaction(self, transaction_id):
"""
return self._api_call("https://api.paymill.com/v2/transactions/" + str(transaction_id), return_type=Transaction)

def get_transactions(self):
"""List all transactions.
def get_transactions(self, client=None, payment=None, amount=None, description=None, created_at=None, updated_at=None, status=None):
"""List transactions.

:param client: the client id
:type client: str
:param payment: payment id
:type payment: str
:param amount: amount=[>|<]<integer> e.g. “300” or with prefix: “>300” or “<300”
:type amount: str
:param description: the description
:type description: str
:param created_at: <unix timestamp > | <unix timestamp (from)>-<unix timestamp (to)>
:type created_at: str
:param updated_at: <unix timestamp > | <unix timestamp (from)>-<unix timestamp (to)>
:type updated_at: str
:param status: the status filter (open, closed, failed, preauth, pending, refunded partially_refunded chargeback)
:type status: str

:Returns:
a dict with a member "data" which is an array of dicts, each representing a transaction
"""
return self._api_call("https://api.paymill.com/v2/transactions/", return_type=Transaction)
params = dict_without_none(client=client, payment=payment, amount=amount, description=description, created_at=created_at, updated_at=updated_at, status=status)

return self._api_call("https://api.paymill.com/v2/transactions/", params=params, return_type=Transaction, force_method=True)

def refund(self, transaction_id, amount, description=None):
"""Refunds an already performed transaction.
Expand Down