stripe 3.28.0 → 3.29.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4eb060e72f272d124c007002c81daf48dcca52f4
4
- data.tar.gz: e83e5e822df5490f6be60e3f21a5166c10784b97
2
+ SHA256:
3
+ metadata.gz: 6e298206c847cff44415718ea2e06a6893c45a6f14c7ed1e9a57991f219202b4
4
+ data.tar.gz: 4bad1dabea6a309281c68abd4fac7ce2b554d5968021498874d5a1883d6cc0aa
5
5
  SHA512:
6
- metadata.gz: aed1ca1d298ea99d11bbbd90a89524aba0d6c5ffad67b983072ca1de1a31832ef1b397617dbe46aa84c3dec4e1959ddeae942e34a540e4b1ece07fcaaf2ab669
7
- data.tar.gz: 8abe85a2bbca841f42b26dde96e1e27104975d950973c640f45e8908370a07037419c9941c43aad88b8ddd72a300f1d1baaa2695d8fac0c1b1b86a4848fa817f
6
+ metadata.gz: a0d542b06fada309a4e4027f4f56866b5f4ee4352eb204c07579d055cc104f741641ec34186d8363c7091a6b7add22377ce910850f5b1c3138684cf5edca4452
7
+ data.tar.gz: 2656d0642e185fb4648c04b860d834f348bdca474a4298218eb9ad862c5c596126bd6188ba93e47bd64d2c0e39f8b2405759b53ff00d15bfc1062bbfd8abfc0b
@@ -18,7 +18,7 @@ sudo: false
18
18
  env:
19
19
  global:
20
20
  # If changing this number, please also change it in `test/test_helper.rb`.
21
- - STRIPE_MOCK_VERSION=0.33.0
21
+ - STRIPE_MOCK_VERSION=0.35.0
22
22
 
23
23
  cache:
24
24
  directories:
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.29.0 - 2018-10-30
4
+ * [#692](https://github.com/stripe/stripe-ruby/pull/692) Add support for the `Person` resource
5
+ * [#694](https://github.com/stripe/stripe-ruby/pull/694) Add support for the `WebhookEndpoint` resource
6
+
3
7
  ## 3.28.0 - 2018-09-24
4
8
  * [#690](https://github.com/stripe/stripe-ruby/pull/690) Add support for Stripe Terminal
5
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.28.0
1
+ 3.29.0
@@ -72,6 +72,7 @@ require "stripe/order"
72
72
  require "stripe/order_return"
73
73
  require "stripe/payment_intent"
74
74
  require "stripe/payout"
75
+ require "stripe/person"
75
76
  require "stripe/plan"
76
77
  require "stripe/product"
77
78
  require "stripe/recipient"
@@ -95,6 +96,7 @@ require "stripe/topup"
95
96
  require "stripe/transfer"
96
97
  require "stripe/usage_record"
97
98
  require "stripe/usage_record_summary"
99
+ require "stripe/webhook_endpoint"
98
100
 
99
101
  # OAuth
100
102
  require "stripe/oauth"
@@ -15,6 +15,8 @@ module Stripe
15
15
  nested_resource_class_methods :external_account,
16
16
  operations: %i[create retrieve update delete list]
17
17
  nested_resource_class_methods :login_link, operations: %i[create]
18
+ nested_resource_class_methods :person,
19
+ operations: %i[create retrieve update delete list]
18
20
 
19
21
  # This method is deprecated. Please use `#external_account=` instead.
20
22
  save_nested_resource :bank_account
@@ -43,6 +45,11 @@ module Stripe
43
45
  super(id, opts)
44
46
  end
45
47
 
48
+ def persons(params = {}, opts = {})
49
+ resp, opts = request(:get, resource_url + "/persons", params, Util.normalize_opts(opts))
50
+ Util.convert_to_stripe_object(resp.data, opts)
51
+ end
52
+
46
53
  def reject(params = {}, opts = {})
47
54
  opts = Util.normalize_opts(opts)
48
55
  resp, opts = request(:post, resource_url + "/reject", params, opts)
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ class Person < APIResource
5
+ extend Stripe::APIOperations::List
6
+ include Stripe::APIOperations::Save
7
+
8
+ OBJECT_NAME = "person".freeze
9
+
10
+ def resource_url
11
+ if !respond_to?(:account) || account.nil?
12
+ raise NotImplementedError,
13
+ "Persons cannot be accessed without an account ID."
14
+ end
15
+ "#{Account.resource_url}/#{CGI.escape(account)}/persons/#{CGI.escape(id)}"
16
+ end
17
+
18
+ def self.retrieve(_id, _opts = {})
19
+ raise NotImplementedError, "Persons cannot be retrieved without an account ID. Retrieve a person using account.persons.retrieve('person_id')"
20
+ end
21
+
22
+ def self.update(_id, _params = nil, _opts = nil)
23
+ raise NotImplementedError, "Persons cannot be updated without an account ID. Update a person using `p = account.persons.retrieve('person_id'); p.save`"
24
+ end
25
+ end
26
+ end
@@ -82,6 +82,7 @@ module Stripe
82
82
  OrderReturn::OBJECT_NAME => OrderReturn,
83
83
  PaymentIntent::OBJECT_NAME => PaymentIntent,
84
84
  Payout::OBJECT_NAME => Payout,
85
+ Person::OBJECT_NAME => Person,
85
86
  Plan::OBJECT_NAME => Plan,
86
87
  Product::OBJECT_NAME => Product,
87
88
  Recipient::OBJECT_NAME => Recipient,
@@ -105,6 +106,7 @@ module Stripe
105
106
  Transfer::OBJECT_NAME => Transfer,
106
107
  UsageRecord::OBJECT_NAME => UsageRecord,
107
108
  UsageRecordSummary::OBJECT_NAME => UsageRecordSummary,
109
+ WebhookEndpoint::OBJECT_NAME => WebhookEndpoint,
108
110
  }
109
111
  end
110
112
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "3.28.0".freeze
4
+ VERSION = "3.29.0".freeze
5
5
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ class WebhookEndpoint < APIResource
5
+ extend Stripe::APIOperations::Create
6
+ include Stripe::APIOperations::Save
7
+ include Stripe::APIOperations::Delete
8
+ extend Stripe::APIOperations::List
9
+
10
+ OBJECT_NAME = "webhook_endpoint".freeze
11
+ end
12
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __FILE__)
4
+
5
+ module Stripe
6
+ class AccountPersonsOperationsTest < Test::Unit::TestCase
7
+ setup do
8
+ @account_id = "acct_123"
9
+ @person_id = "person_123"
10
+ end
11
+
12
+ context "#create_person" do
13
+ should "create a person" do
14
+ person = Stripe::Account.create_person(
15
+ @account_id,
16
+ first_name: "John",
17
+ last_name: "Doe"
18
+ )
19
+ assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons"
20
+ assert person.is_a?(Stripe::Person)
21
+ end
22
+ end
23
+
24
+ context "#retrieve_person" do
25
+ should "retrieve a person" do
26
+ person = Stripe::Account.retrieve_person(
27
+ @account_id,
28
+ @person_id
29
+ )
30
+ assert_requested :get, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons/#{@person_id}"
31
+ assert person.is_a?(Stripe::Person)
32
+ end
33
+ end
34
+
35
+ context "#update_person" do
36
+ should "update a person" do
37
+ person = Stripe::Account.update_person(
38
+ @account_id,
39
+ @person_id,
40
+ first_name: "John"
41
+ )
42
+ assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons/#{@person_id}"
43
+ assert person.is_a?(Stripe::Person)
44
+ end
45
+ end
46
+
47
+ context "#delete_person" do
48
+ should "delete an person" do
49
+ person = Stripe::Account.delete_person(
50
+ @account_id,
51
+ @person_id
52
+ )
53
+ assert_requested :delete, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons/#{@person_id}"
54
+ assert person.deleted
55
+ assert_equal @person_id, person.id
56
+ end
57
+ end
58
+
59
+ context "#list_persons" do
60
+ should "list the account's external accounts" do
61
+ persons = Stripe::Account.list_persons(
62
+ @account_id
63
+ )
64
+ assert_requested :get, "#{Stripe.api_base}/v1/accounts/#{@account_id}/persons"
65
+ assert persons.is_a?(Stripe::ListObject)
66
+ assert persons.data.is_a?(Array)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -61,6 +61,14 @@ module Stripe
61
61
  assert account.is_a?(Stripe::Account)
62
62
  end
63
63
 
64
+ should "be able to list Persons" do
65
+ account = Stripe::Account.retrieve("acct_123")
66
+ persons = account.persons
67
+ assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/persons"
68
+ assert persons.data.is_a?(Array)
69
+ assert persons.data[0].is_a?(Stripe::Person)
70
+ end
71
+
64
72
  context "#bank_account=" do
65
73
  should "warn that #bank_account= is deprecated" do
66
74
  old_stderr = $stderr
@@ -17,19 +17,17 @@ module Stripe
17
17
  end
18
18
 
19
19
  should "be creatable" do
20
- card = @customer.sources.create(
20
+ @customer.sources.create(
21
21
  source: "tok_123"
22
22
  )
23
23
  assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
24
- assert card.is_a?(Stripe::BankAccount)
25
24
  end
26
25
 
27
26
  should "be deletable" do
28
27
  card = Stripe::Card.construct_from(customer: @customer.id,
29
28
  id: "card_123")
30
- card = card.delete
29
+ card.delete
31
30
  assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
32
- assert card.is_a?(Stripe::Card)
33
31
  end
34
32
 
35
33
  should "be saveable" do
@@ -11,46 +11,42 @@ module Stripe
11
11
 
12
12
  context "#create_source" do
13
13
  should "create a source" do
14
- source = Stripe::Customer.create_source(
14
+ Stripe::Customer.create_source(
15
15
  @customer_id,
16
16
  source: "tok_123"
17
17
  )
18
18
  assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
19
- assert source.is_a?(Stripe::BankAccount)
20
19
  end
21
20
  end
22
21
 
23
22
  context "#retrieve_source" do
24
23
  should "retrieve a source" do
25
- source = Stripe::Customer.retrieve_source(
24
+ Stripe::Customer.retrieve_source(
26
25
  @customer_id,
27
26
  @source_id
28
27
  )
29
28
  assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
30
- assert source.is_a?(Stripe::BankAccount)
31
29
  end
32
30
  end
33
31
 
34
32
  context "#update_source" do
35
33
  should "update a source" do
36
- source = Stripe::Customer.update_source(
34
+ Stripe::Customer.update_source(
37
35
  @customer_id,
38
36
  @source_id,
39
37
  metadata: { foo: "bar" }
40
38
  )
41
39
  assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
42
- assert source.is_a?(Stripe::Card)
43
40
  end
44
41
  end
45
42
 
46
43
  context "#delete_source" do
47
44
  should "delete a source" do
48
- source = Stripe::Customer.delete_source(
45
+ Stripe::Customer.delete_source(
49
46
  @customer_id,
50
47
  @source_id
51
48
  )
52
49
  assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
53
- assert source.is_a?(Stripe::BankAccount)
54
50
  end
55
51
  end
56
52
 
@@ -49,9 +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(items: [
53
- { parent: "sku_123" },
54
- ])
52
+ order = order.return_order({})
55
53
  assert order.is_a?(Stripe::OrderReturn)
56
54
  end
57
55
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __FILE__)
4
+
5
+ module Stripe
6
+ class PersonTest < Test::Unit::TestCase
7
+ context "#resource_url" do
8
+ should "return a resource URL" do
9
+ person = Stripe::Person.construct_from(
10
+ id: "person_123",
11
+ account: "acct_123"
12
+ )
13
+ assert_equal "/v1/accounts/acct_123/persons/person_123",
14
+ person.resource_url
15
+ end
16
+
17
+ should "raise without an account" do
18
+ person = Stripe::Person.construct_from(id: "person_123")
19
+ assert_raises NotImplementedError do
20
+ person.resource_url
21
+ end
22
+ end
23
+ end
24
+
25
+ should "raise on #retrieve" do
26
+ assert_raises NotImplementedError do
27
+ Stripe::Person.retrieve("person_123")
28
+ end
29
+ end
30
+
31
+ should "raise on #update" do
32
+ assert_raises NotImplementedError do
33
+ Stripe::Person.update("person_123", {})
34
+ end
35
+ end
36
+
37
+ should "be saveable" do
38
+ account = Stripe::Account.retrieve("acct_123")
39
+ person = account.persons.retrieve("person_123")
40
+ person.first_name = "John"
41
+ person.save
42
+ assert_requested :post,
43
+ "#{Stripe.api_base}/v1/accounts/#{person.account}/persons/#{person.id}"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("../../test_helper", __FILE__)
4
+
5
+ module Stripe
6
+ class WebhookEndpointTest < Test::Unit::TestCase
7
+ should "be listable" do
8
+ webhook_endpoints = Stripe::WebhookEndpoint.list
9
+ assert_requested :get, "#{Stripe.api_base}/v1/webhook_endpoints"
10
+ assert webhook_endpoints.data.is_a?(Array)
11
+ assert webhook_endpoints.first.is_a?(Stripe::WebhookEndpoint)
12
+ end
13
+
14
+ should "be retrievable" do
15
+ webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123")
16
+ assert_requested :get, "#{Stripe.api_base}/v1/webhook_endpoints/we_123"
17
+ assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
18
+ end
19
+
20
+ should "be creatable" do
21
+ webhook_endpoint = Stripe::WebhookEndpoint.create(
22
+ enabled_events: ["charge.succeeded"],
23
+ url: "https://stripe.com"
24
+ )
25
+ assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints"
26
+ assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
27
+ end
28
+
29
+ should "be saveable" do
30
+ webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123")
31
+ webhook_endpoint.enabled_events = ["charge.succeeded"]
32
+ webhook_endpoint.save
33
+ assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints/#{webhook_endpoint.id}"
34
+ end
35
+
36
+ should "be updateable" do
37
+ webhook_endpoint = Stripe::WebhookEndpoint.update("we_123", enabled_events: ["charge.succeeded"])
38
+ assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints/we_123"
39
+ assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
40
+ end
41
+ end
42
+ end
@@ -16,7 +16,7 @@ PROJECT_ROOT = ::File.expand_path("../../", __FILE__)
16
16
  require ::File.expand_path("../test_data", __FILE__)
17
17
 
18
18
  # If changing this number, please also change it in `.travis.yml`.
19
- MOCK_MINIMUM_VERSION = "0.33.0".freeze
19
+ MOCK_MINIMUM_VERSION = "0.35.0".freeze
20
20
  MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
21
21
 
22
22
  # Disable all real network connections except those that are outgoing to
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.28.0
4
+ version: 3.29.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-09-24 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -95,6 +95,7 @@ files:
95
95
  - lib/stripe/order_return.rb
96
96
  - lib/stripe/payment_intent.rb
97
97
  - lib/stripe/payout.rb
98
+ - lib/stripe/person.rb
98
99
  - lib/stripe/plan.rb
99
100
  - lib/stripe/product.rb
100
101
  - lib/stripe/recipient.rb
@@ -125,10 +126,12 @@ files:
125
126
  - lib/stripe/util.rb
126
127
  - lib/stripe/version.rb
127
128
  - lib/stripe/webhook.rb
129
+ - lib/stripe/webhook_endpoint.rb
128
130
  - stripe.gemspec
129
131
  - test/api_stub_helpers.rb
130
132
  - test/stripe/account_external_accounts_operations_test.rb
131
133
  - test/stripe/account_login_links_operations_test.rb
134
+ - test/stripe/account_persons_operations_test.rb
132
135
  - test/stripe/account_test.rb
133
136
  - test/stripe/alipay_account_test.rb
134
137
  - test/stripe/api_operations_test.rb
@@ -168,6 +171,7 @@ files:
168
171
  - test/stripe/order_test.rb
169
172
  - test/stripe/payment_intent_test.rb
170
173
  - test/stripe/payout_test.rb
174
+ - test/stripe/person_test.rb
171
175
  - test/stripe/plan_test.rb
172
176
  - test/stripe/product_test.rb
173
177
  - test/stripe/recipient_test.rb
@@ -194,6 +198,7 @@ files:
194
198
  - test/stripe/usage_record_summary_test.rb
195
199
  - test/stripe/usage_record_test.rb
196
200
  - test/stripe/util_test.rb
201
+ - test/stripe/webhook_endpoint_test.rb
197
202
  - test/stripe/webhook_test.rb
198
203
  - test/stripe_test.rb
199
204
  - test/test_data.rb
@@ -218,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
223
  version: '0'
219
224
  requirements: []
220
225
  rubyforge_project:
221
- rubygems_version: 2.6.14
226
+ rubygems_version: 2.7.7
222
227
  signing_key:
223
228
  specification_version: 4
224
229
  summary: Ruby bindings for the Stripe API
@@ -226,6 +231,7 @@ test_files:
226
231
  - test/api_stub_helpers.rb
227
232
  - test/stripe/account_external_accounts_operations_test.rb
228
233
  - test/stripe/account_login_links_operations_test.rb
234
+ - test/stripe/account_persons_operations_test.rb
229
235
  - test/stripe/account_test.rb
230
236
  - test/stripe/alipay_account_test.rb
231
237
  - test/stripe/api_operations_test.rb
@@ -265,6 +271,7 @@ test_files:
265
271
  - test/stripe/order_test.rb
266
272
  - test/stripe/payment_intent_test.rb
267
273
  - test/stripe/payout_test.rb
274
+ - test/stripe/person_test.rb
268
275
  - test/stripe/plan_test.rb
269
276
  - test/stripe/product_test.rb
270
277
  - test/stripe/recipient_test.rb
@@ -291,6 +298,7 @@ test_files:
291
298
  - test/stripe/usage_record_summary_test.rb
292
299
  - test/stripe/usage_record_test.rb
293
300
  - test/stripe/util_test.rb
301
+ - test/stripe/webhook_endpoint_test.rb
294
302
  - test/stripe/webhook_test.rb
295
303
  - test/stripe_test.rb
296
304
  - test/test_data.rb