stripe 5.0.1 → 5.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe/connection_manager.rb +11 -8
- data/lib/stripe/stripe_client.rb +10 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/stripe_client_test.rb +12 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 52049216e773c7f0f33c6c1b99ab895927df85cc1a818086af835e6f4ae7e3b7
         | 
| 4 | 
            +
              data.tar.gz: a44404e74a7fa7834672a71aeb2ff6b56f49f1def42f9cca984fe7cc2edc486e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1f68b7b4fecb087800254fdcb9346be6c0d56fbe1494e4882f273802ab571d27f2b01d87b2466a9899ba0cb2566f209d93142883c073dda2aaecccb3e6372632
         | 
| 7 | 
            +
              data.tar.gz: 97e07a834fbc3d2ecdb04f88aaa6198221aa030db6637f5404545e33d007fcb80bb23a426dbbca96eef2ed64e61167a86db671062adf58a0189ab2cccfbba410
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,8 @@ | |
| 1 1 | 
             
            # Changelog
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 5.1.0 - 2019-08-27
         | 
| 4 | 
            +
            * [#841](https://github.com/stripe/stripe-ruby/pull/841) Retry requests on a 429 that's a lock timeout
         | 
| 5 | 
            +
             | 
| 3 6 | 
             
            ## 5.0.1 - 2019-08-20
         | 
| 4 7 | 
             
            * [#836](https://github.com/stripe/stripe-ruby/pull/836) Increase connection keep alive timeout to 30 seconds
         | 
| 5 8 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            5.0 | 
| 1 | 
            +
            5.1.0
         | 
| @@ -109,14 +109,7 @@ module Stripe | |
| 109 109 | 
             
                    connection.cert_store = Stripe.ca_store
         | 
| 110 110 | 
             
                  else
         | 
| 111 111 | 
             
                    connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
         | 
| 112 | 
            -
             | 
| 113 | 
            -
                    unless @verify_ssl_warned
         | 
| 114 | 
            -
                      @verify_ssl_warned = true
         | 
| 115 | 
            -
                      warn("WARNING: Running without SSL cert verification. " \
         | 
| 116 | 
            -
                        "You should never do this in production. " \
         | 
| 117 | 
            -
                        "Execute `Stripe.verify_ssl_certs = true` to enable " \
         | 
| 118 | 
            -
                        "verification.")
         | 
| 119 | 
            -
                    end
         | 
| 112 | 
            +
                    warn_ssl_verify_none
         | 
| 120 113 | 
             
                  end
         | 
| 121 114 |  | 
| 122 115 | 
             
                  connection
         | 
| @@ -134,5 +127,15 @@ module Stripe | |
| 134 127 | 
             
                    [u.host, u.port, u.user, u.password]
         | 
| 135 128 | 
             
                  end
         | 
| 136 129 | 
             
                end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                private def warn_ssl_verify_none
         | 
| 132 | 
            +
                  return if @verify_ssl_warned
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                  @verify_ssl_warned = true
         | 
| 135 | 
            +
                  warn("WARNING: Running without SSL cert verification. " \
         | 
| 136 | 
            +
                    "You should never do this in production. " \
         | 
| 137 | 
            +
                    "Execute `Stripe.verify_ssl_certs = true` to enable " \
         | 
| 138 | 
            +
                    "verification.")
         | 
| 139 | 
            +
                end
         | 
| 137 140 | 
             
              end
         | 
| 138 141 | 
             
            end
         | 
    
        data/lib/stripe/stripe_client.rb
    CHANGED
    
    | @@ -88,6 +88,16 @@ module Stripe | |
| 88 88 | 
             
                    # 409 Conflict
         | 
| 89 89 | 
             
                    return true if error.http_status == 409
         | 
| 90 90 |  | 
| 91 | 
            +
                    # 429 Too Many Requests
         | 
| 92 | 
            +
                    #
         | 
| 93 | 
            +
                    # There are a few different problems that can lead to a 429. The most
         | 
| 94 | 
            +
                    # common is rate limiting, on which we *don't* want to retry because
         | 
| 95 | 
            +
                    # that'd likely contribute to more contention problems. However, some
         | 
| 96 | 
            +
                    # 429s are lock timeouts, which is when a request conflicted with
         | 
| 97 | 
            +
                    # another request or an internal process on some particular object.
         | 
| 98 | 
            +
                    # These 429s are safe to retry.
         | 
| 99 | 
            +
                    return true if error.http_status == 429 && error.code == "lock_timeout"
         | 
| 100 | 
            +
             | 
| 91 101 | 
             
                    # 500 Internal Server Error
         | 
| 92 102 | 
             
                    #
         | 
| 93 103 | 
             
                    # We only bother retrying these for non-POST requests. POSTs end up
         | 
    
        data/lib/stripe/version.rb
    CHANGED
    
    
| @@ -122,6 +122,12 @@ module Stripe | |
| 122 122 | 
             
                                                      method: :post, num_retries: 0)
         | 
| 123 123 | 
             
                  end
         | 
| 124 124 |  | 
| 125 | 
            +
                  should "retry on a 429 Too Many Requests when lock timeout" do
         | 
| 126 | 
            +
                    assert StripeClient.should_retry?(Stripe::StripeError.new(http_status: 429,
         | 
| 127 | 
            +
                                                                              code: "lock_timeout"),
         | 
| 128 | 
            +
                                                      method: :post, num_retries: 0)
         | 
| 129 | 
            +
                  end
         | 
| 130 | 
            +
             | 
| 125 131 | 
             
                  should "retry on a 500 Internal Server Error when non-POST" do
         | 
| 126 132 | 
             
                    assert StripeClient.should_retry?(Stripe::StripeError.new(http_status: 500),
         | 
| 127 133 | 
             
                                                      method: :get, num_retries: 0)
         | 
| @@ -142,6 +148,12 @@ module Stripe | |
| 142 148 | 
             
                                                      method: :post, num_retries: 0)
         | 
| 143 149 | 
             
                  end
         | 
| 144 150 |  | 
| 151 | 
            +
                  should "not retry on a 429 Too Many Requests when not lock timeout" do
         | 
| 152 | 
            +
                    refute StripeClient.should_retry?(Stripe::StripeError.new(http_status: 429,
         | 
| 153 | 
            +
                                                                              code: "rate_limited"),
         | 
| 154 | 
            +
                                                      method: :post, num_retries: 0)
         | 
| 155 | 
            +
                  end
         | 
| 156 | 
            +
             | 
| 145 157 | 
             
                  should "not retry on a 500 Internal Server Error when POST" do
         | 
| 146 158 | 
             
                    refute StripeClient.should_retry?(Stripe::StripeError.new(http_status: 500),
         | 
| 147 159 | 
             
                                                      method: :post, num_retries: 0)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: stripe
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 5.0 | 
| 4 | 
            +
              version: 5.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Stripe
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-08- | 
| 11 | 
            +
            date: 2019-08-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Stripe is the easiest way to accept payments online.  See https://stripe.com
         | 
| 14 14 | 
             
              for details.
         |