Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #20 from changs/master

Add cancel! method to GoCardless::PreAuthorization
  • Loading branch information...
commit 983cfe709f4ff8984f329976f7a8a4f0c95fa418 2 parents 6c16cd9 + ba54c08
@hmarr hmarr authored
View
6 lib/gocardless/pre_authorization.rb
@@ -25,6 +25,12 @@ class PreAuthorization < Resource
def create_bill(attrs)
Bill.new_with_client(client, attrs.merge(:source => self)).save
end
+
+ def cancel!
+ path = self.class.endpoint.gsub(':id', id.to_s) + '/cancel'
+ client.api_put(path)
+ end
+
end
end
View
18 spec/pre_authorization_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe GoCardless::PreAuthorization do
+ before :each do
+ @app_id = 'abc'
+ @app_secret = 'xyz'
+ GoCardless.account_details = {:app_id => @app_id, :app_secret => @app_secret,
+ :token => 'xxx manage_merchant:1'}
+ @client = GoCardless.client
+ end
+
+ it "should be cancellable" do
+ s = GoCardless::PreAuthorization.new_with_client(@client, :id => '009988')
+ @client.expects(:api_put).with('/pre_authorizations/009988/cancel')
+ s.cancel!
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.