stripe 1.31.0 → 1.58.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +5 -0
  3. data/.travis.yml +2 -12
  4. data/Gemfile +29 -4
  5. data/History.txt +168 -0
  6. data/README.md +134 -0
  7. data/Rakefile +10 -0
  8. data/VERSION +1 -1
  9. data/bin/stripe-console +12 -5
  10. data/lib/data/ca-certificates.crt +3868 -5114
  11. data/lib/stripe/account.rb +41 -21
  12. data/lib/stripe/alipay_account.rb +20 -0
  13. data/lib/stripe/api_operations/create.rb +1 -1
  14. data/lib/stripe/api_operations/delete.rb +1 -1
  15. data/lib/stripe/api_operations/list.rb +1 -2
  16. data/lib/stripe/api_operations/save.rb +87 -0
  17. data/lib/stripe/api_resource.rb +37 -4
  18. data/lib/stripe/apple_pay_domain.rb +12 -0
  19. data/lib/stripe/application_fee.rb +8 -8
  20. data/lib/stripe/application_fee_refund.rb +7 -3
  21. data/lib/stripe/balance_transaction.rb +1 -1
  22. data/lib/stripe/bank_account.rb +9 -5
  23. data/lib/stripe/bitcoin_receiver.rb +6 -6
  24. data/lib/stripe/bitcoin_transaction.rb +1 -1
  25. data/lib/stripe/card.rb +9 -5
  26. data/lib/stripe/charge.rb +30 -12
  27. data/lib/stripe/country_spec.rb +9 -0
  28. data/lib/stripe/coupon.rb +1 -1
  29. data/lib/stripe/customer.rb +6 -4
  30. data/lib/stripe/dispute.rb +2 -2
  31. data/lib/stripe/errors.rb +82 -0
  32. data/lib/stripe/file_upload.rb +1 -1
  33. data/lib/stripe/invoice.rb +3 -3
  34. data/lib/stripe/invoice_item.rb +1 -1
  35. data/lib/stripe/list_object.rb +7 -6
  36. data/lib/stripe/order.rb +10 -2
  37. data/lib/stripe/order_return.rb +9 -0
  38. data/lib/stripe/plan.rb +1 -1
  39. data/lib/stripe/product.rb +2 -10
  40. data/lib/stripe/recipient.rb +1 -1
  41. data/lib/stripe/refund.rb +1 -1
  42. data/lib/stripe/reversal.rb +7 -3
  43. data/lib/stripe/singleton_api_resource.rb +3 -3
  44. data/lib/stripe/sku.rb +2 -2
  45. data/lib/stripe/source.rb +11 -0
  46. data/lib/stripe/stripe_object.rb +167 -91
  47. data/lib/stripe/subscription.rb +15 -9
  48. data/lib/stripe/subscription_item.rb +12 -0
  49. data/lib/stripe/three_d_secure.rb +9 -0
  50. data/lib/stripe/transfer.rb +3 -4
  51. data/lib/stripe/util.rb +100 -28
  52. data/lib/stripe/version.rb +1 -1
  53. data/lib/stripe.rb +283 -140
  54. data/stripe.gemspec +5 -18
  55. data/test/stripe/account_test.rb +55 -9
  56. data/test/stripe/alipay_account_test.rb +11 -0
  57. data/test/stripe/api_operations_test.rb +31 -0
  58. data/test/stripe/api_resource_test.rb +204 -10
  59. data/test/stripe/apple_pay_domain_test.rb +34 -0
  60. data/test/stripe/application_fee_test.rb +8 -5
  61. data/test/stripe/bitcoin_receiver_test.rb +2 -2
  62. data/test/stripe/charge_refund_test.rb +12 -0
  63. data/test/stripe/charge_test.rb +32 -4
  64. data/test/stripe/country_spec_test.rb +43 -0
  65. data/test/stripe/coupon_test.rb +9 -1
  66. data/test/stripe/customer_card_test.rb +2 -2
  67. data/test/stripe/customer_test.rb +24 -1
  68. data/test/stripe/dispute_test.rb +8 -0
  69. data/test/stripe/errors_test.rb +18 -0
  70. data/test/stripe/invoice_item_test.rb +19 -0
  71. data/test/stripe/invoice_test.rb +27 -1
  72. data/test/stripe/list_object_test.rb +36 -15
  73. data/test/stripe/order_return_test.rb +25 -0
  74. data/test/stripe/order_test.rb +21 -1
  75. data/test/stripe/plan_test.rb +31 -0
  76. data/test/stripe/product_test.rb +17 -7
  77. data/test/stripe/recipient_card_test.rb +2 -2
  78. data/test/stripe/recipient_test.rb +21 -0
  79. data/test/stripe/refund_test.rb +10 -1
  80. data/test/stripe/sku_test.rb +15 -6
  81. data/test/stripe/source_test.rb +83 -0
  82. data/test/stripe/stripe_object_test.rb +180 -11
  83. data/test/stripe/subscription_item_test.rb +76 -0
  84. data/test/stripe/subscription_test.rb +161 -37
  85. data/test/stripe/three_d_secure_test.rb +22 -0
  86. data/test/stripe/transfer_test.rb +8 -0
  87. data/test/stripe/util_test.rb +48 -16
  88. data/test/stripe_test.rb +58 -0
  89. data/test/test_data.rb +337 -27
  90. data/test/test_helper.rb +7 -3
  91. metadata +47 -133
  92. data/README.rdoc +0 -68
  93. data/gemfiles/default-with-activesupport.gemfile +0 -10
  94. data/gemfiles/json.gemfile +0 -12
  95. data/gemfiles/yajl.gemfile +0 -12
  96. data/lib/stripe/api_operations/update.rb +0 -58
  97. data/lib/stripe/errors/api_connection_error.rb +0 -4
  98. data/lib/stripe/errors/api_error.rb +0 -4
  99. data/lib/stripe/errors/authentication_error.rb +0 -4
  100. data/lib/stripe/errors/card_error.rb +0 -12
  101. data/lib/stripe/errors/invalid_request_error.rb +0 -11
  102. data/lib/stripe/errors/rate_limit_error.rb +0 -4
  103. data/lib/stripe/errors/stripe_error.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa445bd78b07bd208f1b693f173ac8f554e3f9a0
4
- data.tar.gz: c4f1334cf81a71e6ffbf8c2b87b1f6bb53e3c953
3
+ metadata.gz: 62e0a925e86bf0a18b48c88a9a359241075cd94a
4
+ data.tar.gz: 8de490482c9fd1a2e7e8d5bd28ac8eb34a0276c6
5
5
  SHA512:
6
- metadata.gz: 95423d6dd94213f236d462fa0764bfa88cadc1a490ad89749fb0bdf78622e6c78a9523e35ca74a8c27e3be9e980a67d39c90e473219176e21a4f0970008edcce
7
- data.tar.gz: 9fae58a91cad0929d902ba5c34e782260cfc998a708c20299d69f864fb09941b063ede335cbe455b03fd1c43bb45ca5d12dbcbd0b13f44887c16b3c63bb4a575
6
+ metadata.gz: bf4525ce47f09b015d0a450667df948a15794538b13c076aefa0ba147d7d6829e344abd7c61285f38c2fcbad7a859f708942a661fe6521b4f76357383627ca6d
7
+ data.tar.gz: b86195048056fb06aade87235e6bf46c7d642101bf55b7bfd1f3375bf9f741ff522c22f1b74cee3fa4c7d8228a47f1fd53bf548e89b243e8af5826f5ebef3393
@@ -0,0 +1,5 @@
1
+ Please only file issues here that you believe represent actual bugs or feature requests for the Stripe Ruby library.
2
+
3
+ If you're having general trouble with your Stripe integration, please reach out to support using the form at https://support.stripe.com/ (preferred) or via email to support@stripe.com.
4
+
5
+ If you are reporting a bug, please include your Ruby version and the version of the Stripe Ruby library you're using, as well as any other details that may be helpful in reproducing the problem.
data/.travis.yml CHANGED
@@ -1,23 +1,13 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.8.7
5
- - 1.9.2
6
4
  - 1.9.3
7
5
  - 2.0.0
8
6
  - 2.1
9
7
  - 2.2
8
+ - 2.3.0
10
9
  - jruby-19mode
11
-
12
- gemfile:
13
- - gemfiles/default-with-activesupport.gemfile
14
- - gemfiles/json.gemfile
15
- - gemfiles/yajl.gemfile
16
-
17
- matrix:
18
- exclude:
19
- - rvm: jruby-19mode
20
- gemfile: gemfiles/yajl.gemfile
10
+ - jruby-9.0.5.0
21
11
 
22
12
  notifications:
23
13
  email:
data/Gemfile CHANGED
@@ -1,8 +1,33 @@
1
1
  source "https://rubygems.org"
2
+
2
3
  gemspec
3
4
 
4
- if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.3')
5
- gem 'i18n', '< 0.7'
6
- gem 'rest-client', '~> 1.6.8'
7
- gem 'activesupport', '~> 3.2'
5
+ group :development do
6
+ gem 'mocha', '~> 0.13.2'
7
+ gem 'pry'
8
+ gem 'rake'
9
+ gem 'shoulda-context'
10
+ gem 'test-unit'
11
+
12
+ # mime-types has become only compatible with Ruby versions > 2 and we're
13
+ # still supporting 1.9 for the time being. Lock to old versions of
14
+ # mime-types and rest-client which are known to work in our Gemfile (it's
15
+ # fine to use newer versions in live environments so we don't have these in
16
+ # the gemspec).
17
+ #
18
+ # https://github.com/travis-ci/travis-ci/issues/5145
19
+ #
20
+ if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
21
+ gem 'mime-types', '2.6.2'
22
+ gem 'rest-client', '1.8.0'
23
+ end
24
+
25
+ platforms :mri do
26
+ # to avoid problems, bring Byebug in on just versions of Ruby under which
27
+ # it's known to work well
28
+ if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0.0')
29
+ gem 'byebug'
30
+ gem 'pry-byebug'
31
+ end
32
+ end
8
33
  end
data/History.txt CHANGED
@@ -1,3 +1,171 @@
1
+ === 1.58.0 2017-01-19
2
+
3
+ * Remove erroneously added list methods for `Source` model
4
+
5
+ === 1.57.1 2016-11-28
6
+
7
+ * Disallow sending protected fields along with API resource `.update`
8
+
9
+ === 1.57.0 2016-11-21
10
+
11
+ * Add retrieve method for 3-D Secure resources
12
+
13
+ === 1.56.2 2016-11-17
14
+
15
+ * Improve `StripeObject`'s `#to_s` to better handle how embedded objects are displayed
16
+
17
+ === 1.56.1 2016-11-09
18
+
19
+ * Fix (fairly serious) memory like in `StripeObject`
20
+
21
+ === 1.56.0 2016-10-24
22
+
23
+ * Add accessors for new fields added in `#update_attributes`
24
+ * Handle multi-plan subscriptions through new subscription items
25
+ * Handle 403 status codes from the API
26
+
27
+ === 1.55.1 2016-10-24
28
+
29
+ Identical to 1.56.0 above. I incorrectly cut a patch-level release.
30
+
31
+ === 1.55.0 2016-09-15
32
+
33
+ * Add support for Apple Pay domains
34
+
35
+ === 1.54.0 2016-09-01
36
+
37
+ * Whitelist errors that should be retried; scope to known socket and HTTP errors
38
+
39
+ === 1.53.0 2016-08-31
40
+
41
+ * Relax version constraint on rest-client (and by extension mime-types) for users on Ruby 2+
42
+
43
+ === 1.52.0 2016-08-30
44
+
45
+ * Make sure `Subscription`'s `source` is saved with its parent
46
+
47
+ === 1.51.1 2016-08-30
48
+
49
+ * Make sure `Account`'s `external_account` is saved with its parent
50
+
51
+ === 1.51.0 2016-08-26
52
+
53
+ * Error when an array of maps is detected that cannot be accurately encoded
54
+ * Start using strings for header names instead of symbols for better clarity
55
+
56
+ === 1.50.1 2016-08-25
57
+
58
+ * Fix encoding of arrays of maps where maps unequal sets of keys
59
+
60
+ === 1.50.0 2016-08-15
61
+
62
+ * Allow sources to be created
63
+
64
+ === 1.49.0 2016-07-28
65
+
66
+ * Add top-level `Source` model
67
+
68
+ === 1.48.0 2016-07-12
69
+
70
+ * Add `ThreeDSecure` model for 3-D secure payments
71
+
72
+ === 1.47.0 2016-07-11
73
+
74
+ * Allow rest-client version 2.0+ to be used with the gem
75
+
76
+ === 1.46.0 2016-07-07
77
+
78
+ * Allow retry when a 409 conflict is encountered
79
+
80
+ === 1.45.0 2016-07-07
81
+
82
+ * Do not send subresources when updating except when explicitly told to do so (see #433)
83
+
84
+ === 1.44.0 2016-06-29
85
+
86
+ * Add `update` class method to all resources that can be updated
87
+
88
+ === 1.43.1 2016-06-17
89
+
90
+ * Fix type of resource returned from `Order#return_order`
91
+
92
+ === 1.43.0 2016-05-20
93
+
94
+ * Allow Relay orders to be returned and add associated types
95
+ * Support Alipay account retrieval and deletion
96
+
97
+ === 1.42.0 2016-05-04
98
+
99
+ * Add support for the new /v1/subscriptions endpoint
100
+ * Stripe::Subscription.retrieve
101
+ * Stripe::Subscription.list
102
+ * Stripe::Subscription.create
103
+ * Stripe::Subscription.update
104
+ * Stripe::Subscription.delete
105
+
106
+ === 1.41.0 2016-04-13
107
+
108
+ * Add global `stripe_account` option that adds a `Stripe-Account` header to all requests
109
+
110
+ === 1.40.0 2016-04-06
111
+
112
+ * Fix bug that omitted subresources from serialization
113
+
114
+ === 1.39.0 2016-03-31
115
+
116
+ * Update CA cert bundle for compatibility with OpenSSL versions below 1.0.1
117
+
118
+ === 1.38.0 2016-03-18
119
+
120
+ * Allow `opts` to be passed to an API resource's `#save` method
121
+
122
+ === 1.37.0 2016-03-14
123
+
124
+ * Add `Account#reject` to support the new API feature
125
+
126
+ === 1.36.2 2016-03-14
127
+
128
+ * Fix reference to non-existent `#url` in `ListObject`
129
+
130
+ === 1.36.1 2016-03-04
131
+
132
+ * Fix serialization when subhash given to `#save` or `#update_attributes`
133
+
134
+ === 1.36.0 2016-02-08
135
+
136
+ * Add `CountrySpec` model for looking up country payment information
137
+
138
+ === 1.35.1 2016-02-03
139
+
140
+ * Add compatibility layer for old API versions on `Charge#refund`
141
+
142
+ === 1.35.0 2016-02-01
143
+
144
+ * Allow CA cert bundle location to be configured
145
+ * Updated bundled CA certs
146
+
147
+ === 1.34.0 2016-01-25
148
+
149
+ * Add support for deleting products and SKUs
150
+
151
+ === 1.33.1 2016-01-21
152
+
153
+ * Pass through arguments of `Charge#refund`
154
+
155
+ === 1.33.0 2016-01-19
156
+
157
+ * Re-implement `Charge#refund` helper to use the modern endpoint suggested by docs
158
+
159
+ === 1.32.1 2016-01-07
160
+
161
+ * Fix bug where ivar left uninitialized in StripeObject could error on serialization
162
+ * Fix bug where a nil customer from API could error Bitcoin model on refresh
163
+
164
+ === 1.32.0 2016-01-05
165
+
166
+ * Add configuration to optionally retry network failures
167
+ * Use modern API endpoint for producing application fee refunds
168
+
1
169
  === 1.31.0 2015-10-29
2
170
 
3
171
  * Add BankAccount#verify convenience method
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # Stripe Ruby Bindings [![Build Status](https://travis-ci.org/stripe/stripe-ruby.svg?branch=master)](https://travis-ci.org/stripe/stripe-ruby)
2
+
3
+ The Stripe Ruby bindings provide a small SDK for convenient access to the
4
+ Stripe API from applications written in the Ruby language. It provides a
5
+ pre-defined set of classes for API resources that initialize themselves
6
+ dynamically from API responses which allows the bindings to tolerate a number
7
+ of different versions of the API.
8
+
9
+ The bindings also provide other features. For example:
10
+
11
+ * Easy configuration path for fast setup and use.
12
+ * Helpers for pagination.
13
+ * Tracking of "fresh" values in API resources so that partial updates can be
14
+ executed.
15
+ * Built-in mechanisms for the serialization of parameters according to the
16
+ expectations of Stripe's API.
17
+
18
+ ## Documentation
19
+
20
+ See the [Ruby API docs](https://stripe.com/docs/api/ruby#intro).
21
+
22
+ ## Installation
23
+
24
+ You don't need this source code unless you want to modify the gem. If you just
25
+ want to use the Stripe Ruby bindings, you should run:
26
+
27
+ gem install stripe
28
+
29
+ If you want to build the gem from source:
30
+
31
+ gem build stripe.gemspec
32
+
33
+ ### Requirements
34
+
35
+ * Ruby 1.9.3 or above.
36
+ * rest-client
37
+
38
+ ### Bundler
39
+
40
+ If you are installing via bundler, you should be sure to use the https rubygems
41
+ source in your Gemfile, as any gems fetched over http could potentially be
42
+ compromised in transit and alter the code of gems fetched securely over https:
43
+
44
+ ``` ruby
45
+ source 'https://rubygems.org'
46
+
47
+ gem 'rails'
48
+ gem 'stripe'
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ The library needs to be configured with your account's secret key which is
54
+ available in the [Dashboard][dashboard]. Assign its value to `Stripe.api_key`
55
+ and the library will send it along automatically with every request:
56
+
57
+ ``` ruby
58
+ require "stripe"
59
+ Stripe.api_key = "sk_test_..."
60
+
61
+ # list charges
62
+ Stripe::Charge.list()
63
+
64
+ # retrieve single charge
65
+ Stripe::Charge.retrieve(
66
+ "ch_18atAXCdGbJFKhCuBAa4532Z",
67
+ )
68
+ ```
69
+
70
+ You can also set a per-request key and/or account like in the examples below.
71
+ This is often useful for Connect applications that use multiple API keys during
72
+ the lifetime of a process.
73
+
74
+ Authentication is transparently handled for you in subsequent method calls on
75
+ the returned object.
76
+
77
+ For example:
78
+
79
+ ``` ruby
80
+ require "stripe"
81
+
82
+ Stripe::Charge.list(
83
+ {},
84
+ :api_key => "sk_test_...",
85
+ :stripe_account => "acct_..."
86
+ )
87
+
88
+ Stripe::Charge.retrieve(
89
+ "ch_18atAXCdGbJFKhCuBAa4532Z",
90
+ :api_key => "sk_test_...",
91
+ :stripe_account => "acct_..."
92
+ )
93
+ ```
94
+
95
+ ## Development
96
+
97
+ Run all tests:
98
+
99
+ bundle exec rake
100
+
101
+ Run a single test suite:
102
+
103
+ bundle exec ruby -Ilib/ test/stripe/util_test.rb
104
+
105
+ Run a single test:
106
+
107
+ bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.symbols/
108
+
109
+ Update bundled CA certificates from the [Mozilla cURL release][curl]:
110
+
111
+ bundle exec rake update_certs
112
+
113
+ ## Configuration
114
+
115
+ ### ca_bundle_path
116
+
117
+ The location of a file containing a bundle of CA certificates. By default the
118
+ library will use an included bundle that can successfully validate Stripe
119
+ certificates.
120
+
121
+ ### max_network_retries
122
+
123
+ When `max_network_retries` is set to a positive integer, stripe will retry
124
+ requests that fail on a network error. Idempotency keys will be added to `POST`
125
+ and `DELETE` requests to ensure the safety of retrying. There will be a short delay
126
+ between each retry, with an exponential backoff algorithm used to determine the
127
+ length of the delay. Default value is 0.
128
+
129
+ Example:
130
+
131
+ Stripe.max_network_retries = 2
132
+
133
+ [curl]: http://curl.haxx.se/docs/caextract.html
134
+ [dashboard]: https://dashboard.stripe.com/account
data/Rakefile CHANGED
@@ -5,3 +5,13 @@ task :default => [:test]
5
5
  Rake::TestTask.new do |t|
6
6
  t.pattern = './test/**/*_test.rb'
7
7
  end
8
+
9
+ desc "update bundled certs"
10
+ task :update_certs do
11
+ require "restclient"
12
+ File.open(File.join(File.dirname(__FILE__), 'lib', 'data', 'ca-certificates.crt'), 'w') do |file|
13
+ resp = RestClient.get "https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt"
14
+ abort("bad response when fetching bundle") unless resp.code == 200
15
+ file.write(resp.to_str)
16
+ end
17
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.31.0
1
+ 1.58.0
data/bin/stripe-console CHANGED
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
3
2
 
4
- libs = " -r irb/completion"
5
- libs << " -r #{File.dirname(__FILE__) + '/../lib/stripe'}"
6
- puts "Loading stripe gem"
7
- exec "#{irb} #{libs} --simple-prompt"
3
+ require 'irb'
4
+ require 'irb/completion'
5
+
6
+ require "#{File.dirname(__FILE__)}/../lib/stripe"
7
+
8
+ # Config IRB to enable --simple-prompt and auto indent
9
+ IRB.conf[:PROMPT_MODE] = :SIMPLE
10
+ IRB.conf[:AUTO_INDENT] = true
11
+
12
+ puts "Loaded gem 'stripe'"
13
+
14
+ IRB.start