Skip to content

Commit eb54d8d

Browse files
authored
Merge pull request #186 from mollie/GH-185
Payment: add release payment authorization API
2 parents f880c8e + bc414d0 commit eb54d8d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lib/mollie/client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def perform_http_call(http_method, api_method, id = nil, http_body = {}, query =
126126
case http_code
127127
when 200, 201
128128
Util.nested_underscore_keys(JSON.parse(response.body))
129+
when 202
130+
JSON.parse(response.body)
129131
when 204
130132
{} # No Content
131133
when 404

lib/mollie/payment.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ def refund!(options = {})
196196
Payment::Refund.create(options)
197197
end
198198

199+
def release_authorization(options = {})
200+
Client.instance.perform_http_call("POST", "payments/#{id}", "release-authorization", {}, options) == {}
201+
end
202+
199203
def refunds(options = {})
200204
resources = (attributes['_embedded']['refunds'] if attributes['_embedded'])
201205

test/mollie/payment_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,22 @@ def test_create_payment_for_customer
151151
assert_equal 'cst_8wmqcHMN4U', payment.customer_id
152152
end
153153

154+
def test_release_authorization
155+
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
156+
.to_return(status: 200, body: %(
157+
{
158+
"resource": "payment",
159+
"id": "tr_WDqYK6vllg"
160+
}
161+
), headers: {})
162+
163+
stub_request(:post, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/release-authorization')
164+
.to_return(status: 202, body: %({}), headers: {})
165+
166+
payment = Payment.get('tr_WDqYK6vllg')
167+
assert payment.release_authorization
168+
end
169+
154170
def test_refund!
155171
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
156172
.to_return(status: 200, body: %(

0 commit comments

Comments
 (0)