stripe 4.9.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +10 -0
  3. data/.rubocop.yml +28 -4
  4. data/.rubocop_todo.yml +11 -22
  5. data/.travis.yml +3 -6
  6. data/.vscode/extensions.json +7 -0
  7. data/.vscode/settings.json +8 -0
  8. data/CHANGELOG.md +102 -2
  9. data/Gemfile +2 -10
  10. data/README.md +96 -40
  11. data/Rakefile +8 -7
  12. data/VERSION +1 -1
  13. data/lib/stripe.rb +64 -85
  14. data/lib/stripe/api_operations/delete.rb +23 -1
  15. data/lib/stripe/api_operations/list.rb +0 -6
  16. data/lib/stripe/api_operations/nested_resource.rb +14 -7
  17. data/lib/stripe/api_operations/request.rb +3 -7
  18. data/lib/stripe/api_operations/save.rb +1 -3
  19. data/lib/stripe/api_resource.rb +50 -2
  20. data/lib/stripe/connection_manager.rb +141 -0
  21. data/lib/stripe/error_object.rb +94 -0
  22. data/lib/stripe/errors.rb +22 -9
  23. data/lib/stripe/list_object.rb +11 -5
  24. data/lib/stripe/multipart_encoder.rb +131 -0
  25. data/lib/stripe/object_types.rb +94 -0
  26. data/lib/stripe/resources.rb +77 -0
  27. data/lib/stripe/{account.rb → resources/account.rb} +49 -27
  28. data/lib/stripe/{account_link.rb → resources/account_link.rb} +1 -1
  29. data/lib/stripe/resources/alipay_account.rb +34 -0
  30. data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +1 -1
  31. data/lib/stripe/resources/application_fee.rb +13 -0
  32. data/lib/stripe/resources/application_fee_refund.rb +30 -0
  33. data/lib/stripe/{balance.rb → resources/balance.rb} +1 -1
  34. data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +1 -5
  35. data/lib/stripe/{bank_account.rb → resources/bank_account.rb} +14 -4
  36. data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +3 -3
  37. data/lib/stripe/{bitcoin_transaction.rb → resources/bitcoin_transaction.rb} +1 -1
  38. data/lib/stripe/resources/capability.rb +33 -0
  39. data/lib/stripe/{card.rb → resources/card.rb} +12 -4
  40. data/lib/stripe/resources/charge.rb +22 -0
  41. data/lib/stripe/{checkout → resources/checkout}/session.rb +2 -2
  42. data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +1 -1
  43. data/lib/stripe/{coupon.rb → resources/coupon.rb} +2 -2
  44. data/lib/stripe/resources/credit_note.rb +22 -0
  45. data/lib/stripe/resources/customer.rb +35 -0
  46. data/lib/stripe/resources/customer_balance_transaction.rb +30 -0
  47. data/lib/stripe/resources/discount.rb +7 -0
  48. data/lib/stripe/{dispute.rb → resources/dispute.rb} +9 -7
  49. data/lib/stripe/{ephemeral_key.rb → resources/ephemeral_key.rb} +5 -2
  50. data/lib/stripe/{event.rb → resources/event.rb} +1 -1
  51. data/lib/stripe/{exchange_rate.rb → resources/exchange_rate.rb} +1 -1
  52. data/lib/stripe/{file.rb → resources/file.rb} +8 -11
  53. data/lib/stripe/{file_link.rb → resources/file_link.rb} +2 -2
  54. data/lib/stripe/resources/invoice.rb +73 -0
  55. data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +2 -2
  56. data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +1 -1
  57. data/lib/stripe/resources/issuing/authorization.rb +33 -0
  58. data/lib/stripe/resources/issuing/card.rb +24 -0
  59. data/lib/stripe/{issuing → resources/issuing}/card_details.rb +1 -1
  60. data/lib/stripe/{issuing → resources/issuing}/cardholder.rb +2 -2
  61. data/lib/stripe/{issuing → resources/issuing}/dispute.rb +2 -2
  62. data/lib/stripe/{issuing → resources/issuing}/transaction.rb +2 -2
  63. data/lib/stripe/resources/login_link.rb +14 -0
  64. data/lib/stripe/resources/order.rb +32 -0
  65. data/lib/stripe/{order_return.rb → resources/order_return.rb} +1 -1
  66. data/lib/stripe/resources/payment_intent.rb +42 -0
  67. data/lib/stripe/resources/payment_method.rb +32 -0
  68. data/lib/stripe/resources/payout.rb +22 -0
  69. data/lib/stripe/{person.rb → resources/person.rb} +8 -3
  70. data/lib/stripe/{plan.rb → resources/plan.rb} +1 -1
  71. data/lib/stripe/{product.rb → resources/product.rb} +3 -3
  72. data/lib/stripe/resources/radar/early_fraud_warning.rb +11 -0
  73. data/lib/stripe/{radar → resources/radar}/value_list.rb +2 -2
  74. data/lib/stripe/{radar → resources/radar}/value_list_item.rb +2 -2
  75. data/lib/stripe/{recipient.rb → resources/recipient.rb} +2 -6
  76. data/lib/stripe/{recipient_transfer.rb → resources/recipient_transfer.rb} +1 -1
  77. data/lib/stripe/{refund.rb → resources/refund.rb} +1 -1
  78. data/lib/stripe/{reporting → resources/reporting}/report_run.rb +2 -2
  79. data/lib/stripe/{reporting → resources/reporting}/report_type.rb +2 -2
  80. data/lib/stripe/resources/reversal.rb +29 -0
  81. data/lib/stripe/resources/review.rb +20 -0
  82. data/lib/stripe/resources/setup_intent.rb +32 -0
  83. data/lib/stripe/{sigma → resources/sigma}/scheduled_query_run.rb +2 -2
  84. data/lib/stripe/{sku.rb → resources/sku.rb} +3 -3
  85. data/lib/stripe/{source.rb → resources/source.rb} +17 -15
  86. data/lib/stripe/{source_transaction.rb → resources/source_transaction.rb} +1 -1
  87. data/lib/stripe/resources/subscription.rb +25 -0
  88. data/lib/stripe/{subscription_item.rb → resources/subscription_item.rb} +5 -2
  89. data/lib/stripe/resources/subscription_schedule.rb +32 -0
  90. data/lib/stripe/resources/tax_id.rb +26 -0
  91. data/lib/stripe/resources/tax_rate.rb +11 -0
  92. data/lib/stripe/{terminal → resources/terminal}/connection_token.rb +2 -2
  93. data/lib/stripe/{terminal → resources/terminal}/location.rb +3 -2
  94. data/lib/stripe/{terminal → resources/terminal}/reader.rb +3 -2
  95. data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +1 -1
  96. data/lib/stripe/{token.rb → resources/token.rb} +1 -1
  97. data/lib/stripe/resources/topup.rb +22 -0
  98. data/lib/stripe/resources/transfer.rb +26 -0
  99. data/lib/stripe/resources/usage_record.rb +7 -0
  100. data/lib/stripe/{usage_record_summary.rb → resources/usage_record_summary.rb} +1 -1
  101. data/lib/stripe/{webhook_endpoint.rb → resources/webhook_endpoint.rb} +2 -2
  102. data/lib/stripe/singleton_api_resource.rb +3 -1
  103. data/lib/stripe/stripe_client.rb +347 -218
  104. data/lib/stripe/stripe_object.rb +72 -59
  105. data/lib/stripe/stripe_response.rb +53 -21
  106. data/lib/stripe/util.rb +54 -109
  107. data/lib/stripe/version.rb +1 -1
  108. data/lib/stripe/webhook.rb +5 -3
  109. data/stripe.gemspec +14 -5
  110. data/test/stripe/account_link_test.rb +1 -1
  111. data/test/stripe/account_test.rb +193 -32
  112. data/test/stripe/alipay_account_test.rb +1 -1
  113. data/test/stripe/api_operations_test.rb +3 -4
  114. data/test/stripe/api_resource_test.rb +119 -30
  115. data/test/stripe/apple_pay_domain_test.rb +18 -5
  116. data/test/stripe/application_fee_refund_test.rb +1 -1
  117. data/test/stripe/application_fee_test.rb +45 -1
  118. data/test/stripe/balance_test.rb +1 -1
  119. data/test/stripe/balance_transaction_test.rb +20 -0
  120. data/test/stripe/bank_account_test.rb +1 -1
  121. data/test/stripe/capability_test.rb +45 -0
  122. data/test/stripe/charge_test.rb +13 -8
  123. data/test/stripe/checkout/session_test.rb +7 -1
  124. data/test/stripe/connection_manager_test.rb +138 -0
  125. data/test/stripe/country_spec_test.rb +1 -1
  126. data/test/stripe/coupon_test.rb +16 -6
  127. data/test/stripe/credit_note_test.rb +61 -0
  128. data/test/stripe/customer_balance_transaction_test.rb +37 -0
  129. data/test/stripe/customer_card_test.rb +1 -1
  130. data/test/stripe/customer_test.rb +151 -40
  131. data/test/stripe/dispute_test.rb +10 -1
  132. data/test/stripe/ephemeral_key_test.rb +8 -1
  133. data/test/stripe/errors_test.rb +30 -9
  134. data/test/stripe/exchange_rate_test.rb +1 -1
  135. data/test/stripe/file_link_test.rb +1 -1
  136. data/test/stripe/file_test.rb +19 -5
  137. data/test/stripe/invoice_item_test.rb +18 -7
  138. data/test/stripe/invoice_line_item_test.rb +1 -1
  139. data/test/stripe/invoice_test.rb +77 -9
  140. data/test/stripe/issuing/authorization_test.rb +33 -11
  141. data/test/stripe/issuing/card_test.rb +15 -6
  142. data/test/stripe/issuing/cardholder_test.rb +1 -1
  143. data/test/stripe/issuing/dispute_test.rb +1 -1
  144. data/test/stripe/issuing/transaction_test.rb +1 -1
  145. data/test/stripe/list_object_test.rb +1 -17
  146. data/test/stripe/login_link_test.rb +2 -2
  147. data/test/stripe/multipart_encoder_test.rb +130 -0
  148. data/test/stripe/oauth_test.rb +1 -1
  149. data/test/stripe/order_return_test.rb +1 -1
  150. data/test/stripe/order_test.rb +28 -3
  151. data/test/stripe/payment_intent_test.rb +31 -4
  152. data/test/stripe/payment_method_test.rb +84 -0
  153. data/test/stripe/payout_test.rb +8 -1
  154. data/test/stripe/person_test.rb +1 -1
  155. data/test/stripe/plan_test.rb +26 -20
  156. data/test/stripe/product_test.rb +16 -6
  157. data/test/stripe/radar/early_fraud_warning_test.rb +22 -0
  158. data/test/stripe/radar/value_list_item_test.rb +16 -6
  159. data/test/stripe/radar/value_list_test.rb +16 -6
  160. data/test/stripe/recipient_test.rb +18 -5
  161. data/test/stripe/refund_test.rb +1 -1
  162. data/test/stripe/reporting/report_run_test.rb +1 -1
  163. data/test/stripe/reporting/report_type_test.rb +1 -1
  164. data/test/stripe/reversal_test.rb +1 -1
  165. data/test/stripe/review_test.rb +1 -1
  166. data/test/stripe/setup_intent_test.rb +84 -0
  167. data/test/stripe/sigma/scheduled_query_run_test.rb +1 -1
  168. data/test/stripe/sku_test.rb +16 -6
  169. data/test/stripe/source_test.rb +14 -19
  170. data/test/stripe/source_transaction_test.rb +1 -1
  171. data/test/stripe/stripe_client_test.rb +242 -26
  172. data/test/stripe/stripe_object_test.rb +8 -36
  173. data/test/stripe/stripe_response_test.rb +71 -25
  174. data/test/stripe/subscription_item_test.rb +28 -6
  175. data/test/stripe/subscription_schedule_test.rb +19 -1
  176. data/test/stripe/subscription_test.rb +29 -9
  177. data/test/stripe/tax_id_test.rb +31 -0
  178. data/test/stripe/tax_rate_test.rb +43 -0
  179. data/test/stripe/terminal/connection_token_test.rb +1 -1
  180. data/test/stripe/terminal/location_test.rb +18 -1
  181. data/test/stripe/terminal/reader_test.rb +18 -1
  182. data/test/stripe/three_d_secure_test.rb +1 -1
  183. data/test/stripe/topup_test.rb +9 -1
  184. data/test/stripe/transfer_test.rb +46 -1
  185. data/test/stripe/usage_record_summary_test.rb +1 -1
  186. data/test/stripe/util_test.rb +1 -1
  187. data/test/stripe/webhook_endpoint_test.rb +18 -1
  188. data/test/stripe/webhook_test.rb +4 -4
  189. data/test/stripe_mock.rb +4 -3
  190. data/test/stripe_test.rb +1 -14
  191. data/test/test_helper.rb +14 -11
  192. metadata +117 -125
  193. data/lib/stripe/alipay_account.rb +0 -27
  194. data/lib/stripe/application_fee.rb +0 -23
  195. data/lib/stripe/application_fee_refund.rb +0 -22
  196. data/lib/stripe/charge.rb +0 -84
  197. data/lib/stripe/customer.rb +0 -90
  198. data/lib/stripe/invoice.rb +0 -48
  199. data/lib/stripe/issuer_fraud_record.rb +0 -9
  200. data/lib/stripe/issuing/authorization.rb +0 -22
  201. data/lib/stripe/issuing/card.rb +0 -18
  202. data/lib/stripe/login_link.rb +0 -11
  203. data/lib/stripe/order.rb +0 -31
  204. data/lib/stripe/payment_intent.rb +0 -26
  205. data/lib/stripe/payout.rb +0 -20
  206. data/lib/stripe/reversal.rb +0 -22
  207. data/lib/stripe/review.rb +0 -14
  208. data/lib/stripe/subscription.rb +0 -25
  209. data/lib/stripe/subscription_schedule.rb +0 -32
  210. data/lib/stripe/subscription_schedule_revision.rb +0 -25
  211. data/lib/stripe/topup.rb +0 -16
  212. data/lib/stripe/transfer.rb +0 -23
  213. data/lib/stripe/usage_record.rb +0 -14
  214. data/test/stripe/account_external_accounts_operations_test.rb +0 -69
  215. data/test/stripe/account_login_links_operations_test.rb +0 -21
  216. data/test/stripe/account_persons_operations_test.rb +0 -70
  217. data/test/stripe/application_fee_refunds_operations_test.rb +0 -56
  218. data/test/stripe/customer_sources_operations_test.rb +0 -64
  219. data/test/stripe/file_upload_test.rb +0 -76
  220. data/test/stripe/issuer_fraud_record_test.rb +0 -20
  221. data/test/stripe/subscription_schedule_revision_test.rb +0 -37
  222. data/test/stripe/subscription_schedule_revisions_operations_test.rb +0 -35
  223. data/test/stripe/transfer_reversals_operations_test.rb +0 -57
  224. data/test/stripe/usage_record_test.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26baa8832b98118a80e495a63c9ac784ebaaf6c05a6f45470e4d2bddfd81679f
4
- data.tar.gz: 06ca6de0b1b8363ebf49df745722f095bb943105dbc22d51c688c39e9e06e4b9
3
+ metadata.gz: 52049216e773c7f0f33c6c1b99ab895927df85cc1a818086af835e6f4ae7e3b7
4
+ data.tar.gz: a44404e74a7fa7834672a71aeb2ff6b56f49f1def42f9cca984fe7cc2edc486e
5
5
  SHA512:
6
- metadata.gz: 9c19e6198d482addce7c6a9fd6e469a6c362139ada4926901c3e0d1704283de1b746c94c13ecee944741b8a7ad60f9acd0830bda020a3516b2a485f8e260c2ee
7
- data.tar.gz: 545bd13709cb412e3c6505756eb566566d1658667c19572339811c6fd70d3425ecd0999a4d07fb1dd24bdebd5f4f4739bdf15e5a3286e058fbca1f06da884f7e
6
+ metadata.gz: 1f68b7b4fecb087800254fdcb9346be6c0d56fbe1494e4882f273802ab571d27f2b01d87b2466a9899ba0cb2566f209d93142883c073dda2aaecccb3e6372632
7
+ data.tar.gz: 97e07a834fbc3d2ecdb04f88aaa6198221aa030db6637f5404545e33d007fcb80bb23a426dbbca96eef2ed64e61167a86db671062adf58a0189ab2cccfbba410
@@ -0,0 +1,10 @@
1
+ # see http://editorconfig.org/
2
+
3
+ root = true
4
+
5
+ [*]
6
+ indent_style = space
7
+ indent_size = 2
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ insert_final_newline = true
@@ -2,17 +2,32 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
4
  DisplayCopNames: true
5
- TargetRubyVersion: 2.0
5
+ TargetRubyVersion: 2.3
6
6
 
7
7
  Layout/CaseIndentation:
8
8
  EnforcedStyle: end
9
9
 
10
- Layout/IndentArray:
10
+ Layout/IndentFirstArrayElement:
11
11
  EnforcedStyle: consistent
12
12
 
13
- Layout/IndentHash:
13
+ Layout/IndentFirstHashElement:
14
14
  EnforcedStyle: consistent
15
15
 
16
+ # This can be re-enabled once we're 2.3+ only and can use the squiggly heredoc
17
+ # operator. Prior to that, Rubocop recommended bringing in a library like
18
+ # ActiveSupport to get heredoc indentation, which is just terrible.
19
+ Layout/IndentHeredoc:
20
+ Enabled: false
21
+
22
+ Metrics/ClassLength:
23
+ Exclude:
24
+ - "test/**/*.rb"
25
+
26
+ Metrics/LineLength:
27
+ Exclude:
28
+ - "lib/stripe/resources/**/*.rb"
29
+ - "test/**/*.rb"
30
+
16
31
  Metrics/MethodLength:
17
32
  # There's ~2 long methods in `StripeClient`. If we want to truncate those a
18
33
  # little, we could move this to be closer to ~30 (but the default of 10 is
@@ -22,11 +37,20 @@ Metrics/MethodLength:
22
37
  Metrics/ModuleLength:
23
38
  Enabled: false
24
39
 
40
+ Style/AccessModifierDeclarations:
41
+ EnforcedStyle: inline
42
+
25
43
  Style/FrozenStringLiteralComment:
26
44
  EnforcedStyle: always
27
45
 
46
+ Style/NumericPredicate:
47
+ Enabled: false
48
+
28
49
  Style/StringLiterals:
29
50
  EnforcedStyle: double_quotes
30
51
 
31
- Style/TrailingCommaInLiteral:
52
+ Style/TrailingCommaInArrayLiteral:
53
+ EnforcedStyleForMultiline: consistent_comma
54
+
55
+ Style/TrailingCommaInHashLiteral:
32
56
  EnforcedStyleForMultiline: consistent_comma
@@ -1,50 +1,39 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-07-19 14:22:24 +0200 using RuboCop version 0.50.0.
3
+ # on 2019-07-30 09:56:31 +0800 using RuboCop version 0.73.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 19
9
+ # Offense count: 23
10
10
  Metrics/AbcSize:
11
- Max: 54
11
+ Max: 51
12
12
 
13
- # Offense count: 27
13
+ # Offense count: 33
14
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
15
16
  Metrics/BlockLength:
16
- Max: 498
17
+ Max: 509
17
18
 
18
- # Offense count: 8
19
+ # Offense count: 12
19
20
  # Configuration parameters: CountComments.
20
21
  Metrics/ClassLength:
21
- Max: 670
22
+ Max: 694
22
23
 
23
- # Offense count: 11
24
+ # Offense count: 12
24
25
  Metrics/CyclomaticComplexity:
25
26
  Max: 15
26
27
 
27
- # Offense count: 278
28
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
29
- # URISchemes: http, https
30
- Metrics/LineLength:
31
- Max: 310
32
-
33
28
  # Offense count: 6
34
29
  # Configuration parameters: CountKeywordArgs.
35
30
  Metrics/ParameterLists:
36
31
  Max: 7
37
32
 
38
- # Offense count: 5
33
+ # Offense count: 8
39
34
  Metrics/PerceivedComplexity:
40
35
  Max: 17
41
36
 
42
- # Offense count: 2
43
- Style/ClassVars:
44
- Exclude:
45
- - 'lib/stripe/stripe_object.rb'
46
- - 'test/stripe/api_resource_test.rb'
47
-
48
- # Offense count: 56
37
+ # Offense count: 86
49
38
  Style/Documentation:
50
39
  Enabled: false
@@ -1,12 +1,11 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.1
5
- - 2.2
6
4
  - 2.3
7
5
  - 2.4
8
6
  - 2.5
9
- - jruby-9.0.5.0
7
+ - 2.6
8
+ - jruby-9.2.7.0
10
9
 
11
10
  notifications:
12
11
  email:
@@ -17,15 +16,13 @@ sudo: false
17
16
  env:
18
17
  global:
19
18
  # If changing this number, please also change it in `test/test_helper.rb`.
20
- - STRIPE_MOCK_VERSION=0.44.0
19
+ - STRIPE_MOCK_VERSION=0.63.0
21
20
 
22
21
  cache:
23
22
  directories:
24
23
  - stripe-mock
25
24
 
26
25
  before_install:
27
- # Install bundler 1.x, because we need to support Ruby 2.1 for now
28
- - gem install bundler -v "~> 1.0"
29
26
  # Unpack and start stripe-mock so that the test suite can talk to it
30
27
  - |
31
28
  if [ ! -d "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" ]; then
@@ -0,0 +1,7 @@
1
+ {
2
+ "recommendations": [
3
+ "rebornix.ruby",
4
+ "misogi.ruby-rubocop",
5
+ "EditorConfig.editorconfig"
6
+ ]
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "files.trimTrailingWhitespace": true,
4
+
5
+ // Rubocop settings
6
+ "ruby.rubocop.configFilePath": ".rubocop.yml",
7
+ "ruby.rubocop.onSave": true
8
+ }
@@ -1,5 +1,104 @@
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
+
6
+ ## 5.0.1 - 2019-08-20
7
+ * [#836](https://github.com/stripe/stripe-ruby/pull/836) Increase connection keep alive timeout to 30 seconds
8
+
9
+ ## 5.0.0 - 2019-08-20
10
+ Major version release. The [migration guide](https://github.com/stripe/stripe-ruby/wiki/Migration-guide-for-v5) contains a detailed list of backwards-incompatible changes with upgrade instructions.
11
+
12
+ Pull requests included in this release (cf. [#815](https://github.com/stripe/stripe-ruby/pull/815)) (⚠️ = breaking changes):
13
+ * [x] ⚠️ #813: Convert library to use built-in `Net::HTTP`
14
+ * [x] ⚠️ #816: Make `code` argument in `CardError` named instead of positional.
15
+ * [x] ⚠️ #817: Drop support for very old Ruby versions.
16
+ * [x] #818: Bump Rubocop to latest version
17
+ * [x] #819: Ruby minimum version increase followup
18
+ * [x] ⚠️ #820: Remove old deprecated methods
19
+ * [x] ⚠️ #823: Remove all alias for list methods
20
+ * [x] ⚠️ #826: Remove `UsageRecord.create` method
21
+ * [x] ⚠️ #827: Remove `IssuerFraudRecord`
22
+ * [x] #811: Add `ErrorObject` to `StripeError` exceptions
23
+ * [x] #828: Tweak retry logic to be a little more like stripe-node
24
+ * [x] #829: Reset connections when connection-changing configuration changes (optional)
25
+ * [x] #830: Fix inverted sign for 500 retries
26
+ * [x] ⚠️#831: Remove a few more very old deprecated methods
27
+ * [x] #832: Minor cleanup in `StripeClient`
28
+ * [x] #833: Do better bookkeeping when tracking state in `Thread.current`
29
+ * [x] #834: Add `Invoice.list_upcoming_line_items` method
30
+
31
+ ## 4.24.0 - 2019-08-12
32
+ * [#825](https://github.com/stripe/stripe-ruby/pull/825) Add `SubscriptionItem.create_usage_record` method
33
+ - This release also removed the `SubscriptionSchedule.revisions` method. This should have been included in the previous release (4.23.0)
34
+
35
+ ## 4.23.0 - 2019-08-09
36
+ * [#824](https://github.com/stripe/stripe-ruby/pull/824) Remove SubscriptionScheduleRevision
37
+ - This is technically a breaking change. We've chosen to release it as a minor vesion bump because the associated API is unused.
38
+
39
+ ## 4.22.1 - 2019-08-09
40
+ * [#808](https://github.com/stripe/stripe-ruby/pull/808) Unify request/response handling
41
+
42
+ ## 4.22.0 - 2019-07-30
43
+ * [#821](https://github.com/stripe/stripe-ruby/pull/821) Listing `BalanceTransaction` objects now uses `/v1/balance_transactions` instead of `/v1/balance/history`
44
+
45
+ ## 4.21.3 - 2019-07-15
46
+ * [#810](https://github.com/stripe/stripe-ruby/pull/810) Better error message when passing non-string to custom method
47
+
48
+ ## 4.21.2 - 2019-07-05
49
+ * [#806](https://github.com/stripe/stripe-ruby/pull/806) Revert back to `initialize_from` from `Util.convert_to_stripe_object`
50
+
51
+ ## 4.21.1 - 2019-07-04
52
+ * [#807](https://github.com/stripe/stripe-ruby/pull/807) Add gem metadata
53
+
54
+ ## 4.21.0 - 2019-06-28
55
+ * [#803](https://github.com/stripe/stripe-ruby/pull/803) Add support for the `SetupIntent` resource and APIs
56
+
57
+ ## 4.20.1 - 2019-06-28
58
+ * [#805](https://github.com/stripe/stripe-ruby/pull/805) Fix formatting in `ConnectionFailed` error message
59
+
60
+ ## 4.20.0 - 2019-06-24
61
+ * [#800](https://github.com/stripe/stripe-ruby/pull/800) Enable request latency telemetry by default
62
+
63
+ ## 4.19.0 - 2019-06-17
64
+ * [#770](https://github.com/stripe/stripe-ruby/pull/770) Add support for `CustomerBalanceTransaction` resource and APIs
65
+
66
+ ## 4.18.1 - 2019-05-27
67
+ * [#789](https://github.com/stripe/stripe-ruby/pull/789) Allow `Order#pay` to be called without arguments
68
+
69
+ ## 4.18.0 - 2019-05-23
70
+ * [#783](https://github.com/stripe/stripe-ruby/pull/783) Add support for `radar.early_fraud_warning` resource
71
+
72
+ ## 4.17.0 - 2019-05-14
73
+ * [#779](https://github.com/stripe/stripe-ruby/pull/779) Add support for the Capability resource and APIs
74
+
75
+ ## 4.16.0 - 2019-04-24
76
+ * [#760](https://github.com/stripe/stripe-ruby/pull/760) Add support for the `TaxRate` resource and APIs
77
+
78
+ ## 4.15.0 - 2019-04-22
79
+ * [#762](https://github.com/stripe/stripe-ruby/pull/762) Add support for the `TaxId` resource and APIs
80
+
81
+ ## 4.14.0 - 2019-04-18
82
+ * [#758](https://github.com/stripe/stripe-ruby/pull/758) Add support for the `CreditNote` resource and APIs
83
+
84
+ ## 4.13.0 - 2019-04-16
85
+ * [#766](https://github.com/stripe/stripe-ruby/pull/766) Relax constraints on objects that we'll accept as a file (now they just need to respond to `#read`)
86
+
87
+ ## 4.12.0 - 2019-04-02
88
+ * [#752](https://github.com/stripe/stripe-ruby/pull/752) Add `.delete` class method on deletable API resources
89
+ * [#754](https://github.com/stripe/stripe-ruby/pull/754) Add class methods for all custom API requests (e.g. `Charge.capture`)
90
+
91
+ ## 4.11.0 - 2019-03-26
92
+ * [#753](https://github.com/stripe/stripe-ruby/pull/753) Add a global proxy configuration parameter
93
+
94
+ ## 4.10.0 - 2019-03-18
95
+ * [#745](https://github.com/stripe/stripe-ruby/pull/745) Add support for the `PaymentMethod` resource and APIs
96
+ * [#747](https://github.com/stripe/stripe-ruby/pull/747) Add support for retrieving a Checkout `Session`
97
+ * [#748](https://github.com/stripe/stripe-ruby/pull/748) Add support for deleting a Terminal `Location` and `Reader`
98
+
99
+ ## 4.9.1 - 2019-03-18
100
+ * [#750](https://github.com/stripe/stripe-ruby/pull/750) Catch error and warn if unable to remove a method
101
+
3
102
  ## 4.9.0 - 2019-02-12
4
103
  * [#739](https://github.com/stripe/stripe-ruby/pull/739) Add support for `SubscriptionSchedule` and `SubscriptionScheduleRevision`
5
104
 
@@ -25,7 +124,7 @@
25
124
  * [#718](https://github.com/stripe/stripe-ruby/pull/718) Fix an error message typo
26
125
 
27
126
  ## 4.4.0 - 2018-12-21
28
- * [#716](https://github.com/stripe/stripe-ruby/pull/716) Add support for the `CheckoutSession` resource
127
+ * [#716](https://github.com/stripe/stripe-ruby/pull/716) Add support for the `CheckoutSession` resource
29
128
 
30
129
  ## 4.3.0 - 2018-12-10
31
130
  * [#711](https://github.com/stripe/stripe-ruby/pull/711) Add support for account links
@@ -208,7 +307,8 @@
208
307
  * Handle `invalid_client` OAuth error code
209
308
  * Improve safety of error handling logic safer for unrecognized OAuth error codes
210
309
 
211
- ## 3.0.2 - 2017-07-12 (yanked)
310
+ ## 3.0.2 - 2017-07-12
311
+ **Important:** This version is non-functional and has been yanked in favor of 3.0.3.
212
312
  * Convert `nil` to empty string when serializing parameters (instead of opaquely dropping it) -- NOTE: this change has since been reverted
213
313
 
214
314
  ## 3.0.1 - 2017-07-11
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gemspec
7
7
  group :development do
8
8
  gem "coveralls", require: false
9
9
  gem "mocha", "~> 0.13.2"
10
+ gem "rack", ">= 2.0.6"
10
11
  gem "rake"
11
12
  gem "shoulda-context"
12
13
  gem "test-unit"
@@ -18,16 +19,7 @@ group :development do
18
19
  # `Gemfile.lock` checked in, so to prevent good builds from suddenly going
19
20
  # bad, pin to a specific version number here. Try to keep this relatively
20
21
  # up-to-date, but it's not the end of the world if it's not.
21
- gem "rubocop", "0.50.0"
22
-
23
- # Rack 2.0+ requires Ruby >= 2.2.2 which is problematic for the test suite on
24
- # older Ruby versions. Check Ruby the version here and put a maximum
25
- # constraint on Rack if necessary.
26
- if RUBY_VERSION >= "2.2.2"
27
- gem "rack", ">= 2.0.6"
28
- else
29
- gem "rack", ">= 1.6.11", "< 2.0" # rubocop:disable Bundler/DuplicatedGem
30
- end
22
+ gem "rubocop", "0.73"
31
23
 
32
24
  platforms :mri do
33
25
  gem "byebug"
data/README.md CHANGED
@@ -11,11 +11,11 @@ API.
11
11
 
12
12
  The library also provides other features. For example:
13
13
 
14
- * Easy configuration path for fast setup and use.
15
- * Helpers for pagination.
16
- * Tracking of "fresh" values in API resources so that partial updates can be
14
+ - Easy configuration path for fast setup and use.
15
+ - Helpers for pagination.
16
+ - Tracking of "fresh" values in API resources so that partial updates can be
17
17
  executed.
18
- * Built-in mechanisms for the serialization of parameters according to the
18
+ - Built-in mechanisms for the serialization of parameters according to the
19
19
  expectations of Stripe's API.
20
20
 
21
21
  ## Documentation
@@ -27,15 +27,19 @@ See the [Ruby API docs](https://stripe.com/docs/api/ruby#intro).
27
27
  You don't need this source code unless you want to modify the gem. If you just
28
28
  want to use the package, just run:
29
29
 
30
- gem install stripe
30
+ ```sh
31
+ gem install stripe
32
+ ```
31
33
 
32
34
  If you want to build the gem from source:
33
35
 
34
- gem build stripe.gemspec
36
+ ```sh
37
+ gem build stripe.gemspec
38
+ ```
35
39
 
36
40
  ### Requirements
37
41
 
38
- * Ruby 2.0+.
42
+ - Ruby 2.3+.
39
43
 
40
44
  ### Bundler
41
45
 
@@ -43,7 +47,7 @@ If you are installing via bundler, you should be sure to use the https rubygems
43
47
  source in your Gemfile, as any gems fetched over http could potentially be
44
48
  compromised in transit and alter the code of gems fetched securely over https:
45
49
 
46
- ``` ruby
50
+ ```ruby
47
51
  source 'https://rubygems.org'
48
52
 
49
53
  gem 'rails'
@@ -56,7 +60,7 @@ The library needs to be configured with your account's secret key which is
56
60
  available in your [Stripe Dashboard][api-keys]. Set `Stripe.api_key` to its
57
61
  value:
58
62
 
59
- ``` ruby
63
+ ```ruby
60
64
  require "stripe"
61
65
  Stripe.api_key = "sk_test_..."
62
66
 
@@ -75,37 +79,46 @@ For apps that need to use multiple keys during the lifetime of a process, like
75
79
  one that uses [Stripe Connect][connect], it's also possible to set a
76
80
  per-request key and/or account:
77
81
 
78
- ``` ruby
82
+ ```ruby
79
83
  require "stripe"
80
84
 
81
85
  Stripe::Charge.list(
82
86
  {},
83
87
  {
84
- :api_key => "sk_test_...",
85
- :stripe_account => "acct_...",
86
- :stripe_version => "2018-02-28"
88
+ api_key: "sk_test_...",
89
+ stripe_account: "acct_...",
90
+ stripe_version: "2018-02-28",
87
91
  }
88
92
  )
89
93
 
90
94
  Stripe::Charge.retrieve(
91
95
  "ch_18atAXCdGbJFKhCuBAa4532Z",
92
96
  {
93
- :api_key => "sk_test_...",
94
- :stripe_account => "acct_...",
95
- :stripe_version => "2018-02-28"
97
+ api_key: "sk_test_...",
98
+ stripe_account: "acct_...",
99
+ stripe_version: "2018-02-28",
100
+ }
101
+ )
102
+
103
+ Stripe::Charge.retrieve(
104
+ {
105
+ id: "ch_18atAXCdGbJFKhCuBAa4532Z",
106
+ expand: %w(balance_transaction)
107
+ },
108
+ {
109
+ stripe_version: "2018-02-28",
110
+ api_key: "sk_test_...",
96
111
  }
97
112
  )
98
113
  ```
99
114
 
100
- ### Configuring a Client
115
+ ### Accessing a response object
101
116
 
102
- While a default HTTP client is used by default, it's also possible to have the
103
- library use any client supported by [Faraday][faraday] by initializing a
104
- `Stripe::StripeClient` object and giving it a connection:
117
+ Get access to response objects by initializing a client and using its `request`
118
+ method:
105
119
 
106
- ``` ruby
107
- conn = Faraday.new
108
- client = Stripe::StripeClient.new(conn)
120
+ ```ruby
121
+ client = Stripe::StripeClient.new
109
122
  charge, resp = client.request do
110
123
  Stripe::Charge.retrieve(
111
124
  "ch_18atAXCdGbJFKhCuBAa4532Z",
@@ -114,12 +127,22 @@ end
114
127
  puts resp.request_id
115
128
  ```
116
129
 
130
+ ### Configuring a proxy
131
+
132
+ A proxy can be configured with `Stripe.proxy`:
133
+
134
+ ```ruby
135
+ Stripe.proxy = "https://user:pass@example.com:1234"
136
+ ```
137
+
117
138
  ### Configuring an API Version
118
139
 
119
140
  By default, the library will use the API version pinned to the account making
120
141
  a request. This can be overridden with this global option:
121
142
 
122
- Stripe.api_version = "2018-02-28"
143
+ ```ruby
144
+ Stripe.api_version = "2018-02-28"
145
+ ```
123
146
 
124
147
  See [versioning in the API reference][versioning] for more information.
125
148
 
@@ -128,14 +151,21 @@ See [versioning in the API reference][versioning] for more information.
128
151
  By default, the library will use its own internal bundle of known CA
129
152
  certificates, but it's possible to configure your own:
130
153
 
131
- Stripe.ca_bundle_path = "path/to/ca/bundle"
154
+ ```ruby
155
+ Stripe.ca_bundle_path = "path/to/ca/bundle"
156
+ ```
132
157
 
133
158
  ### Configuring Automatic Retries
134
159
 
135
- The library can be configured to automatically retry requests that fail due to
136
- an intermittent network problem:
160
+ You can enable automatic retries on requests that fail due to a transient
161
+ problem by configuring the maximum number of retries:
162
+
163
+ ```ruby
164
+ Stripe.max_network_retries = 2
165
+ ```
137
166
 
138
- Stripe.max_network_retries = 2
167
+ Various errors can trigger a retry, like a connection error or a timeout, and
168
+ also certain API responses like HTTP status `409 Conflict`.
139
169
 
140
170
  [Idempotency keys][idempotency-keys] are added to requests to guarantee that
141
171
  retries are safe.
@@ -144,7 +174,7 @@ retries are safe.
144
174
 
145
175
  Open and read timeouts are configurable:
146
176
 
147
- ```java
177
+ ```ruby
148
178
  Stripe.open_timeout = 30 // in seconds
149
179
  Stripe.read_timeout = 80
150
180
  ```
@@ -162,12 +192,14 @@ production use, but `debug` is also available for more verbosity.
162
192
  There are a few options for enabling it:
163
193
 
164
194
  1. Set the environment variable `STRIPE_LOG` to the value `debug` or `info`:
165
- ```
195
+
196
+ ```sh
166
197
  $ export STRIPE_LOG=info
167
198
  ```
168
199
 
169
200
  2. Set `Stripe.log_level`:
170
- ``` ruby
201
+
202
+ ```ruby
171
203
  Stripe.log_level = Stripe::LEVEL_INFO
172
204
  ```
173
205
 
@@ -176,39 +208,64 @@ There are a few options for enabling it:
176
208
  If you're writing a plugin that uses the library, we'd appreciate it if you
177
209
  identified using `#set_app_info`:
178
210
 
179
- Stripe.set_app_info("MyAwesomePlugin", version: "1.2.34", url: "https://myawesomeplugin.info");
211
+ ```ruby
212
+ Stripe.set_app_info("MyAwesomePlugin", version: "1.2.34", url: "https://myawesomeplugin.info");
213
+ ```
180
214
 
181
215
  This information is passed along when the library makes calls to the Stripe
182
216
  API.
183
217
 
218
+ ### Request latency telemetry
219
+
220
+ By default, the library sends request latency telemetry to Stripe. These
221
+ numbers help Stripe improve the overall latency of its API for all users.
222
+
223
+ You can disable this behavior if you prefer:
224
+
225
+ ```ruby
226
+ Stripe.enable_telemetry = false
227
+ ```
228
+
184
229
  ## Development
185
230
 
186
231
  The test suite depends on [stripe-mock], so make sure to fetch and run it from a
187
232
  background terminal ([stripe-mock's README][stripe-mock] also contains
188
233
  instructions for installing via Homebrew and other methods):
189
234
 
190
- go get -u github.com/stripe/stripe-mock
191
- stripe-mock
235
+ ```sh
236
+ go get -u github.com/stripe/stripe-mock
237
+ stripe-mock
238
+ ```
192
239
 
193
240
  Run all tests:
194
241
 
195
- bundle exec rake test
242
+ ```sh
243
+ bundle exec rake test
244
+ ```
196
245
 
197
246
  Run a single test suite:
198
247
 
199
- bundle exec ruby -Ilib/ test/stripe/util_test.rb
248
+ ```sh
249
+ bundle exec ruby -Ilib/ test/stripe/util_test.rb
250
+ ```
200
251
 
201
252
  Run a single test:
202
253
 
203
- bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.symbols/
254
+ ```sh
255
+ bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.symbols/
256
+ ```
204
257
 
205
258
  Run the linter:
206
259
 
207
- bundle exec rake rubocop
260
+ ```sh
261
+ bundle exec rake rubocop
262
+ ```
208
263
 
209
264
  Update bundled CA certificates from the [Mozilla cURL release][curl]:
210
265
 
211
- bundle exec rake update_certs
266
+ ```sh
267
+ bundle exec rake update_certs
268
+ ```
212
269
 
213
270
  Update the bundled [stripe-mock] by editing the version number found in
214
271
  `.travis.yml`.
@@ -216,7 +273,6 @@ Update the bundled [stripe-mock] by editing the version number found in
216
273
  [api-keys]: https://dashboard.stripe.com/account/apikeys
217
274
  [connect]: https://stripe.com/connect
218
275
  [curl]: http://curl.haxx.se/docs/caextract.html
219
- [faraday]: https://github.com/lostisland/faraday
220
276
  [idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
221
277
  [stripe-mock]: https://github.com/stripe/stripe-mock
222
278
  [versioning]: https://stripe.com/docs/api/ruby#versioning