Permalink
Browse files

Fixed test for preapprovals.

  • Loading branch information...
1 parent fbc4014 commit 5b9cf54cd3e8ce51b9588f012c3e98780e77b3f3 @cakestylestaging cakestylestaging committed Apr 11, 2013
Showing with 9 additions and 2 deletions.
  1. +4 −0 lib/api/preapproval_methods.rb
  2. +5 −2 test/test_wepay_rails_preapproval_methods.rb
@@ -60,7 +60,11 @@ def perform_preapproval(params)
:account_id => @wepay_config[:account_id]
}.merge(params)
+ begin
resp = self.call_api("/preapproval/create", defaults)
+ rescue => e
+ puts e.message
+ end
resp.merge({:security_token => security_token})
end
@@ -9,7 +9,7 @@ def setup
@checkout_params = {
:amount => 300,
:period => "once",
- :short_description => "This is a checkout test!",
+ :short_description => "This is a preapproval test!",
:account_id => "12345"
}
end
@@ -19,8 +19,11 @@ def teardown
end
test "should create a new WePay preapproval object" do
+
+ security_token = Digest::SHA2.hexdigest("1#{Time.now.to_i}")
stub_request(:post, "https://stage.wepayapi.com/v2/preapproval/create").
- with(:headers => wepay_gateway.wepay_auth_header).
+ with(:body => "callback_uri=http%3A%2F%2Fwww.example.com%2Fwepay%2Fipn%3Fsecurity_token%3D#{security_token}&redirect_uri=http%3A%2F%2Fwww.example.com%2Fpreapproval%2Fsuccess%3Fsecurity_token%3D#{security_token}&fee_payer=Payee&charge_tax=0&app_fee=0&require_shipping=0&shipping_fee=0&account_id=12345&amount=300&period=once&short_description=This%20is%20a%20preapproval%20test!",
+ :headers => {'Authorization'=>'Bearer: 1c69cebd40ababb0447700377dd7751bb645e874edac140f1ba0c35ad6e98c97', 'User-Agent'=>'WepayRails'}).
to_return(:status => 200, :body => sample_preapproval_response, :headers => {})
@response = wepay_gateway.perform_preapproval(@checkout_params)

0 comments on commit 5b9cf54

Please sign in to comment.