Skip to content

Commit

Permalink
Merge pull request #68 from mstruve/void-authorized-payments
Browse files Browse the repository at this point in the history
Add #void! Method
  • Loading branch information
nov committed Nov 13, 2014
2 parents 945043a + c07b968 commit f06bebc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/paypal/express/request.rb
Expand Up @@ -69,6 +69,16 @@ def capture!(authorization_id, amount, currency_code)
Response.new response
end

def void!(authorization_id, params={})
params = {
:AUTHORIZATIONID => authorization_id,
:NOTE => params[:note]
}

response = self.request :DoVoid, params
Response.new response
end

# Recurring Payment Specific

def subscribe!(token, recurring_profile)
Expand Down
1 change: 1 addition & 0 deletions spec/fake_response/DoVoid/success.txt
@@ -0,0 +1 @@
ACK=Success&AUTHORIZATIONID=1a2b3c4d5e6f&BUILD=13055236&TIMESTAMP=2014-10-03T17%3A34%3A56Z
20 changes: 20 additions & 0 deletions spec/paypal/express/request_spec.rb
Expand Up @@ -287,6 +287,26 @@ def post_with_logging(method, params)
end
end

describe "#void!" do
it 'should return Paypal::Express::Response' do
fake_response 'DoVoid/success'
response = instance.void! 'authorization_id', note: "note"
response.should be_instance_of Paypal::Express::Response
end

it 'should call DoVoid' do
expect do
instance.void! 'authorization_id', note: "note"
end.to request_to nvp_endpoint, :post

instance._method_.should == :DoVoid
instance._sent_params_.should == {
:AUTHORIZATIONID => 'authorization_id',
:NOTE => "note"
}
end
end

describe '#checkout!' do
it 'should return Paypal::Express::Response' do
fake_response 'DoExpressCheckoutPayment/success'
Expand Down

0 comments on commit f06bebc

Please sign in to comment.