Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions lib/mollie/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def perform_http_call(http_method, api_method, id = nil, http_body = {}, query =
case http_code
when 200, 201
Util.nested_underscore_keys(JSON.parse(response.body))
when 202
JSON.parse(response.body)
when 204
{} # No Content
when 404
Expand Down
4 changes: 4 additions & 0 deletions lib/mollie/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def refund!(options = {})
Payment::Refund.create(options)
end

def release_authorization(options = {})
Client.instance.perform_http_call("POST", "payments/#{id}", "release-authorization", {}, options) == {}
end

def refunds(options = {})
resources = (attributes['_embedded']['refunds'] if attributes['_embedded'])

Expand Down
16 changes: 16 additions & 0 deletions test/mollie/payment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ def test_create_payment_for_customer
assert_equal 'cst_8wmqcHMN4U', payment.customer_id
end

def test_release_authorization
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
.to_return(status: 200, body: %(
{
"resource": "payment",
"id": "tr_WDqYK6vllg"
}
), headers: {})

stub_request(:post, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/release-authorization')
.to_return(status: 202, body: %({}), headers: {})

payment = Payment.get('tr_WDqYK6vllg')
assert payment.release_authorization
end

def test_refund!
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
.to_return(status: 200, body: %(
Expand Down