stripe 3.15.0 → 3.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b9415299005f81ae9a9e04797795f89aef90e76
4
- data.tar.gz: d6108d66d67c858c8a97a35ca4a4279a40f7fcc6
3
+ metadata.gz: bac1f6ddcfa0fad7db03e5929bb02fa20a8d55a1
4
+ data.tar.gz: 7623d4070e7d9e4260d9213638fa7750e0fef6b3
5
5
  SHA512:
6
- metadata.gz: 922b12ee5520a755d9c108dbdc146436e0faf00fbdb5fee5a80fd62f0cd877527d7b1eecb7768c057ba39f29f3a951cfa9151b09e6f859a541065f4dc2e21cf9
7
- data.tar.gz: a1bdc5024e7bfc4f601df3162c497a468464e80a8501c69500fb527ace1cb48322d83984470e2cbc6fbe7bfb57fd579b17f14593acac2f7bafa6ed197753089d
6
+ metadata.gz: 8d79721ac5dceccd1cd8769b1cdb104142750e0f3ddc9d965584e4731a2bd382a8cb5c17d2b3751da8699a0bc39a3fd00ba7589829d0cc4aec7aa8d481fd653e
7
+ data.tar.gz: 5df86bf3c52ee058ce0e00515264c166f14a935382fafdaab578d9545f9affcd63af20d3fa99f96534d6fc488d52aef76da06628db733b317565cdb00c2fe0bb
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-02-23 14:17:07 +0100 using RuboCop version 0.50.0.
3
+ # on 2018-06-28 10:59:56 -0400 using RuboCop version 0.50.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
@@ -13,18 +13,18 @@ Metrics/AbcSize:
13
13
  # Offense count: 27
14
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
15
  Metrics/BlockLength:
16
- Max: 496
16
+ Max: 498
17
17
 
18
18
  # Offense count: 8
19
19
  # Configuration parameters: CountComments.
20
20
  Metrics/ClassLength:
21
- Max: 624
21
+ Max: 626
22
22
 
23
23
  # Offense count: 11
24
24
  Metrics/CyclomaticComplexity:
25
25
  Max: 15
26
26
 
27
- # Offense count: 259
27
+ # Offense count: 269
28
28
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
29
29
  # URISchemes: http, https
30
30
  Metrics/LineLength:
@@ -38,7 +38,7 @@ Metrics/MethodLength:
38
38
  # Offense count: 1
39
39
  # Configuration parameters: CountComments.
40
40
  Metrics/ModuleLength:
41
- Max: 307
41
+ Max: 350
42
42
 
43
43
  # Offense count: 6
44
44
  # Configuration parameters: CountKeywordArgs.
@@ -55,6 +55,6 @@ Style/ClassVars:
55
55
  - 'lib/stripe/stripe_object.rb'
56
56
  - 'test/stripe/api_resource_test.rb'
57
57
 
58
- # Offense count: 53
58
+ # Offense count: 55
59
59
  Style/Documentation:
60
60
  Enabled: false
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.17.0 - 2018-06-28
4
+ * [#658](https://github.com/stripe/stripe-ruby/pull/658) Add support for `partner_id` from `Stripe.set_app_info`
5
+
6
+ ## 3.16.0 - 2018-06-28
7
+ * [#657](https://github.com/stripe/stripe-ruby/pull/657) Add support for payment intents
8
+
3
9
  ## 3.15.0 - 2018-05-10
4
10
  * [#649](https://github.com/stripe/stripe-ruby/pull/649) Freeze all string literals
5
11
 
data/README.md CHANGED
@@ -114,7 +114,7 @@ end
114
114
  puts resp.request_id
115
115
  ```
116
116
 
117
- ### Configuration an API Version
117
+ ### Configuring an API Version
118
118
 
119
119
  By default, the library will use the API version pinned to the account making
120
120
  a request. This can be overridden with this global option:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.15.0
1
+ 3.17.0
@@ -63,6 +63,7 @@ require "stripe/issuer_fraud_record"
63
63
  require "stripe/login_link"
64
64
  require "stripe/order"
65
65
  require "stripe/order_return"
66
+ require "stripe/payment_intent"
66
67
  require "stripe/payout"
67
68
  require "stripe/plan"
68
69
  require "stripe/product"
@@ -212,10 +213,11 @@ module Stripe
212
213
  # with API requests. Useful for plugin authors to identify their plugin when
213
214
  # communicating with Stripe.
214
215
  #
215
- # Takes a name and optional version and plugin URL.
216
- def self.set_app_info(name, version: nil, url: nil)
216
+ # Takes a name and optional partner program ID, plugin URL, and version.
217
+ def self.set_app_info(name, partner_id: nil, url: nil, version: nil)
217
218
  @app_info = {
218
219
  name: name,
220
+ partner_id: partner_id,
219
221
  url: url,
220
222
  version: version,
221
223
  }
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ class PaymentIntent < APIResource
5
+ extend Stripe::APIOperations::Create
6
+ include Stripe::APIOperations::Delete
7
+ extend Stripe::APIOperations::List
8
+ include Stripe::APIOperations::Save
9
+
10
+ OBJECT_NAME = "payment_intent".freeze
11
+
12
+ def self.resource_url
13
+ "/v1/payment_intents"
14
+ end
15
+
16
+ def cancel
17
+ resp, api_key = request(:post, resource_url + "/cancel")
18
+ initialize_from(resp.data, api_key)
19
+ end
20
+
21
+ def capture
22
+ resp, api_key = request(:post, resource_url + "/capture")
23
+ initialize_from(resp.data, api_key)
24
+ end
25
+
26
+ def confirm
27
+ resp, api_key = request(:post, resource_url + "/confirm")
28
+ initialize_from(resp.data, api_key)
29
+ end
30
+ end
31
+ end
@@ -72,6 +72,7 @@ module Stripe
72
72
  LoginLink::OBJECT_NAME => LoginLink,
73
73
  Order::OBJECT_NAME => Order,
74
74
  OrderReturn::OBJECT_NAME => OrderReturn,
75
+ PaymentIntent::OBJECT_NAME => PaymentIntent,
75
76
  Payout::OBJECT_NAME => Payout,
76
77
  Plan::OBJECT_NAME => Plan,
77
78
  Product::OBJECT_NAME => Product,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Stripe
2
- VERSION = "3.15.0".freeze
4
+ VERSION = "3.17.0".freeze
3
5
  end
@@ -46,7 +46,7 @@ module Stripe
46
46
  context "#create_subscription" do
47
47
  should "create a new subscription" do
48
48
  customer = Stripe::Customer.retrieve("cus_123")
49
- subscription = customer.create_subscription(plan: "silver")
49
+ subscription = customer.create_subscription(items: [{ plan: "silver" }])
50
50
  assert subscription.is_a?(Stripe::Subscription)
51
51
  end
52
52
  end
@@ -41,7 +41,7 @@ module Stripe
41
41
  context "#pay" do
42
42
  should "pay an order" do
43
43
  order = Stripe::Order.retrieve("or_123")
44
- order = order.pay(token: "tok_123")
44
+ order = order.pay(source: "tok_123")
45
45
  assert order.is_a?(Stripe::Order)
46
46
  end
47
47
  end
@@ -49,7 +49,7 @@ module Stripe
49
49
  context "#return_order" do
50
50
  should "return an order" do
51
51
  order = Stripe::Order.retrieve("or_123")
52
- order = order.return_order(orders: [
52
+ order = order.return_order(items: [
53
53
  { parent: "sku_123" },
54
54
  ])
55
55
  assert order.is_a?(Stripe::OrderReturn)
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("../../test_helper", __FILE__)
4
+
5
+ module Stripe
6
+ TEST_RESOURCE_ID = "pi_123".freeze
7
+
8
+ class PaymentIntentTest < Test::Unit::TestCase
9
+ should "be listable" do
10
+ stub_request(:get, "#{Stripe.api_base}/v1/payment_intents")
11
+ .to_return(body: JSON.generate(object: "list", data: [{ id: "pi_123", object: "payment_intent" }]))
12
+
13
+ payment_intents = Stripe::PaymentIntent.list
14
+ assert_requested :get, "#{Stripe.api_base}/v1/payment_intents"
15
+ assert payment_intents.data.is_a?(Array)
16
+ assert payment_intents.data[0].is_a?(Stripe::PaymentIntent)
17
+ end
18
+
19
+ should "be retrievable" do
20
+ stub_request(:get, "#{Stripe.api_base}/v1/payment_intents/pi_123")
21
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
22
+
23
+ payment_intent = Stripe::PaymentIntent.retrieve("pi_123")
24
+ assert_requested :get, "#{Stripe.api_base}/v1/payment_intents/pi_123"
25
+ assert payment_intent.is_a?(Stripe::PaymentIntent)
26
+ end
27
+
28
+ should "be creatable" do
29
+ stub_request(:post, "#{Stripe.api_base}/v1/payment_intents")
30
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
31
+
32
+ payment_intent = Stripe::PaymentIntent.create
33
+ assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
34
+ assert payment_intent.is_a?(Stripe::PaymentIntent)
35
+ end
36
+
37
+ should "be saveable" do
38
+ stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123")
39
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
40
+
41
+ payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent", metadata: {})
42
+ payment_intent.metadata["key"] = "value"
43
+ payment_intent.save
44
+ assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/#{payment_intent.id}"
45
+ end
46
+
47
+ should "be updateable" do
48
+ stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123")
49
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
50
+
51
+ payment_intent = Stripe::PaymentIntent.update("pi_123", metadata: { foo: "bar" })
52
+
53
+ assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123"
54
+ assert payment_intent.is_a?(Stripe::PaymentIntent)
55
+ end
56
+
57
+ context "#cancel" do
58
+ should "cancel a payment_intent" do
59
+ stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123/cancel")
60
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
61
+
62
+ payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
63
+ payment_intent = payment_intent.cancel
64
+
65
+ assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/cancel"
66
+ assert payment_intent.is_a?(Stripe::PaymentIntent)
67
+ end
68
+ end
69
+
70
+ context "#capture" do
71
+ should "capture a payment_intent" do
72
+ stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123/capture")
73
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
74
+
75
+ payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
76
+ payment_intent = payment_intent.capture
77
+
78
+ assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/capture"
79
+ assert payment_intent.is_a?(Stripe::PaymentIntent)
80
+ end
81
+ end
82
+
83
+ context "#confirm" do
84
+ should "confirm a payment_intent" do
85
+ stub_request(:post, "#{Stripe.api_base}/v1/payment_intents/pi_123/confirm")
86
+ .to_return(body: JSON.generate(id: "pi_123", object: "payment_intent"))
87
+
88
+ payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
89
+ payment_intent = payment_intent.confirm
90
+
91
+ assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/confirm"
92
+ assert payment_intent.is_a?(Stripe::PaymentIntent)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -345,6 +345,7 @@ module Stripe
345
345
  old = Stripe.app_info
346
346
  Stripe.set_app_info(
347
347
  "MyAwesomePlugin",
348
+ partner_id: "partner_1234",
348
349
  url: "https://myawesomeplugin.info",
349
350
  version: "1.2.34"
350
351
  )
@@ -361,6 +362,7 @@ module Stripe
361
362
 
362
363
  assert_equal({
363
364
  name: "MyAwesomePlugin",
365
+ partner_id: "partner_1234",
364
366
  url: "https://myawesomeplugin.info",
365
367
  version: "1.2.34",
366
368
  }, data[:application])
@@ -22,7 +22,6 @@ module Stripe
22
22
 
23
23
  should "be creatable" do
24
24
  item = Stripe::SubscriptionItem.create(
25
- item: "silver",
26
25
  plan: "sapphire-elite",
27
26
  quantity: 3,
28
27
  subscription: "sub_123"
@@ -21,11 +21,13 @@ class StripeTest < Test::Unit::TestCase
21
21
  old = Stripe.app_info
22
22
  Stripe.set_app_info(
23
23
  "MyAwesomePlugin",
24
+ partner_id: "partner_1234",
24
25
  url: "https://myawesomeplugin.info",
25
26
  version: "1.2.34"
26
27
  )
27
28
  assert_equal({
28
29
  name: "MyAwesomePlugin",
30
+ partner_id: "partner_1234",
29
31
  url: "https://myawesomeplugin.info",
30
32
  version: "1.2.34",
31
33
  }, Stripe.app_info)
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: 3.15.0
4
+ version: 3.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-10 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -86,6 +86,7 @@ files:
86
86
  - lib/stripe/oauth.rb
87
87
  - lib/stripe/order.rb
88
88
  - lib/stripe/order_return.rb
89
+ - lib/stripe/payment_intent.rb
89
90
  - lib/stripe/payout.rb
90
91
  - lib/stripe/plan.rb
91
92
  - lib/stripe/product.rb
@@ -144,6 +145,7 @@ files:
144
145
  - test/stripe/oauth_test.rb
145
146
  - test/stripe/order_return_test.rb
146
147
  - test/stripe/order_test.rb
148
+ - test/stripe/payment_intent_test.rb
147
149
  - test/stripe/payout_test.rb
148
150
  - test/stripe/plan_test.rb
149
151
  - test/stripe/product_test.rb
@@ -226,6 +228,7 @@ test_files:
226
228
  - test/stripe/oauth_test.rb
227
229
  - test/stripe/order_return_test.rb
228
230
  - test/stripe/order_test.rb
231
+ - test/stripe/payment_intent_test.rb
229
232
  - test/stripe/payout_test.rb
230
233
  - test/stripe/plan_test.rb
231
234
  - test/stripe/product_test.rb