stripe 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +2 -2
- data/lib/stripe/version.rb +1 -1
- data/test/test_helper.rb +52 -0
- data/test/test_stripe.rb +19 -1
- metadata +4 -4
    
        data/.travis.yml
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/History.txt
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.7. | 
| 1 | 
            +
            1.7.4
         | 
    
        data/lib/stripe.rb
    CHANGED
    
    | @@ -77,7 +77,7 @@ module Stripe | |
| 77 77 | 
             
                @@verify_ssl_certs
         | 
| 78 78 | 
             
              end
         | 
| 79 79 |  | 
| 80 | 
            -
              def self.request(method, url, api_key, params= | 
| 80 | 
            +
              def self.request(method, url, api_key, params={}, headers={})
         | 
| 81 81 | 
             
                api_key ||= @@api_key
         | 
| 82 82 | 
             
                raise AuthenticationError.new('No API key provided.  (HINT: set your API key using "Stripe.api_key = <API-KEY>".  You can generate API keys from the Stripe web interface.  See https://stripe.com/api for details, or email support@stripe.com if you have any questions.)') unless api_key
         | 
| 83 83 |  | 
| @@ -115,7 +115,7 @@ module Stripe | |
| 115 115 | 
             
                case method.to_s.downcase.to_sym
         | 
| 116 116 | 
             
                when :get, :head, :delete
         | 
| 117 117 | 
             
                  # Make params into GET parameters
         | 
| 118 | 
            -
                  if params && params.count
         | 
| 118 | 
            +
                  if params && params.count > 0
         | 
| 119 119 | 
             
                    query_string = Util.flatten_params(params).collect{|key, value| "#{key}=#{Util.url_encode(value)}"}.join('&')
         | 
| 120 120 | 
             
                    url += "?#{query_string}"
         | 
| 121 121 | 
             
                  end
         | 
    
        data/lib/stripe/version.rb
    CHANGED
    
    
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -129,6 +129,58 @@ def test_subscription(plan_id="gold") | |
| 129 129 | 
             
              }
         | 
| 130 130 | 
             
            end
         | 
| 131 131 |  | 
| 132 | 
            +
            def test_invoice
         | 
| 133 | 
            +
              {
         | 
| 134 | 
            +
                :id => 'in_test_invoice',
         | 
| 135 | 
            +
                :object => 'invoice',
         | 
| 136 | 
            +
                :livemode => false,
         | 
| 137 | 
            +
                :amount_due => 1000,
         | 
| 138 | 
            +
                :attempt_count => 0,
         | 
| 139 | 
            +
                :attempted => false,
         | 
| 140 | 
            +
                :closed => false,
         | 
| 141 | 
            +
                :currency => 'usd',
         | 
| 142 | 
            +
                :customer => 'c_test_customer',
         | 
| 143 | 
            +
                :date => 1349738950,
         | 
| 144 | 
            +
                :lines => {
         | 
| 145 | 
            +
                  "invoiceitems" => [
         | 
| 146 | 
            +
                    {
         | 
| 147 | 
            +
                      :id => 'ii_test_invoice_item',
         | 
| 148 | 
            +
                      :object => '',
         | 
| 149 | 
            +
                      :livemode => false,
         | 
| 150 | 
            +
                      :amount => 1000,
         | 
| 151 | 
            +
                      :currency => 'usd',
         | 
| 152 | 
            +
                      :customer => 'c_test_customer',
         | 
| 153 | 
            +
                      :date => 1349738950,
         | 
| 154 | 
            +
                      :description => "A Test Invoice Item",
         | 
| 155 | 
            +
                      :invoice => 'in_test_invoice'
         | 
| 156 | 
            +
                    },
         | 
| 157 | 
            +
                  ],
         | 
| 158 | 
            +
                },
         | 
| 159 | 
            +
                :paid => false,
         | 
| 160 | 
            +
                :period_end => 1349738950,
         | 
| 161 | 
            +
                :period_start => 1349738950,
         | 
| 162 | 
            +
                :starting_balance => 0,
         | 
| 163 | 
            +
                :subtotal => 1000,
         | 
| 164 | 
            +
                :total => 1000,
         | 
| 165 | 
            +
                :charge => nil,
         | 
| 166 | 
            +
                :discount => nil,
         | 
| 167 | 
            +
                :ending_balance => nil,
         | 
| 168 | 
            +
                :next_payemnt_attempt => 1349825350,
         | 
| 169 | 
            +
              }
         | 
| 170 | 
            +
            end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            def test_paid_invoice
         | 
| 173 | 
            +
              test_invoice.merge({
         | 
| 174 | 
            +
                  :attempt_count => 1,
         | 
| 175 | 
            +
                  :attempted => true,
         | 
| 176 | 
            +
                  :closed => true,
         | 
| 177 | 
            +
                  :paid => true,
         | 
| 178 | 
            +
                  :charge => 'ch_test_charge',
         | 
| 179 | 
            +
                  :ending_balance => 0,
         | 
| 180 | 
            +
                  :next_payment_attempt => nil,
         | 
| 181 | 
            +
                })
         | 
| 182 | 
            +
            end
         | 
| 183 | 
            +
             | 
| 132 184 | 
             
            def test_invalid_api_key_error
         | 
| 133 185 | 
             
              {
         | 
| 134 186 | 
             
                "error" => {
         | 
    
        data/test/test_stripe.rb
    CHANGED
    
    | @@ -410,7 +410,7 @@ class TestStripeRuby < Test::Unit::TestCase | |
| 410 410 | 
             
                      @mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription?at_period_end=true", nil, nil).returns(test_response(test_subscription('silver')))
         | 
| 411 411 | 
             
                      s = c.cancel_subscription({:at_period_end => 'true'})
         | 
| 412 412 |  | 
| 413 | 
            -
                      @mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription | 
| 413 | 
            +
                      @mock.expects(:delete).once.with("https://api.stripe.com/v1/customers/c_test_customer/subscription", nil, nil).returns(test_response(test_subscription('silver')))
         | 
| 414 414 | 
             
                      s = c.cancel_subscription
         | 
| 415 415 | 
             
                    end
         | 
| 416 416 |  | 
| @@ -434,6 +434,24 @@ class TestStripeRuby < Test::Unit::TestCase | |
| 434 434 | 
             
                      assert_equal "co_test_coupon", c.id
         | 
| 435 435 | 
             
                    end
         | 
| 436 436 | 
             
                  end
         | 
| 437 | 
            +
             | 
| 438 | 
            +
                  context "invoice tests" do
         | 
| 439 | 
            +
                    should "retrieve should retrieve invoices" do
         | 
| 440 | 
            +
                      @mock.expects(:get).once.returns(test_response(test_invoice))
         | 
| 441 | 
            +
                      i = Stripe::Invoice.retrieve('in_test_invoice')
         | 
| 442 | 
            +
                      assert_equal 'in_test_invoice', i.id
         | 
| 443 | 
            +
                    end
         | 
| 444 | 
            +
             | 
| 445 | 
            +
                    should "pay should pay an invoice" do
         | 
| 446 | 
            +
                      @mock.expects(:get).once.returns(test_response(test_invoice))
         | 
| 447 | 
            +
                      i = Stripe::Invoice.retrieve('in_test_invoice')
         | 
| 448 | 
            +
             | 
| 449 | 
            +
                      @mock.expects(:post).once.with('https://api.stripe.com/v1/invoices/in_test_invoice/pay', nil, '').returns(test_response(test_paid_invoice))
         | 
| 450 | 
            +
                      i.pay
         | 
| 451 | 
            +
                      assert_equal i.next_payment_attempt, nil
         | 
| 452 | 
            +
                    end
         | 
| 453 | 
            +
                  end
         | 
| 454 | 
            +
             | 
| 437 455 | 
             
                  context "error checking" do
         | 
| 438 456 |  | 
| 439 457 | 
             
                    should "404s should raise an InvalidRequestError" do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: stripe
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 3
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 1
         | 
| 8 8 | 
             
              - 7
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 1.7. | 
| 9 | 
            +
              - 4
         | 
| 10 | 
            +
              version: 1.7.4
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Ross Boucher
         | 
| @@ -16,7 +16,7 @@ autorequire: | |
| 16 16 | 
             
            bindir: bin
         | 
| 17 17 | 
             
            cert_chain: []
         | 
| 18 18 |  | 
| 19 | 
            -
            date: 2012-09 | 
| 19 | 
            +
            date: 2012-10-09 00:00:00 Z
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 22 22 | 
             
              prerelease: false
         |