Skip to content

Commit

Permalink
Merge pull request gocardless#20 from gocardless/refund-and-cancel
Browse files Browse the repository at this point in the history
Added a refund and cancel endpoint
  • Loading branch information
kitgocardless committed May 14, 2014
2 parents b8fe9ae + 3a314ef commit f80318b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gocardless/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ def retry(self):
path = "{0}/retry".format(self.endpoint.replace(":id", self.id))
self.client.api_post(path)

def cancel(self):
path = "{0}/cancel".format(self.endpoint.replace(":id", self.id))
self.client.api_put(path)

"""Please note the refund endpoint is disabled by default
If you have over 50 successful payments on your account and you
require access to the refund endpoint, please email help@gocardless.com
"""
def refund(self):
path = "{0}/refund".format(self.endpoint.replace(":id", self.id))
self.client.api_post(path)

class Payout(Resource):
endpoint = "/payouts/:id"
date_fields = ["paid_at"]
Expand Down
12 changes: 12 additions & 0 deletions test/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,16 @@ def test_retry_post(self):
retry_url = "/bills/{0}/retry".format(fixtures.bill_json["id"])
client.api_post.assert_called_with(retry_url)

def test_cancel_put(self):
client = mock.Mock()
bill = Bill(fixtures.bill_json, client)
bill.cancel()
cancel_url = "/bills/{0}/cancel".format(fixtures.bill_json["id"])
client.api_put.assert_called_with(cancel_url)

def test_refund_post(self):
client = mock.Mock()
bill = Bill(fixtures.bill_json, client)
bill.refund()
refund_url = "/bills/{0}/refund".format(fixtures.bill_json["id"])
client.api_post.assert_called_with(refund_url)

0 comments on commit f80318b

Please sign in to comment.