stripe 4.9.1 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +1 -0
- data/lib/stripe/payment_method.rb +23 -0
- data/lib/stripe/terminal/location.rb +1 -0
- data/lib/stripe/terminal/reader.rb +1 -0
- data/lib/stripe/util.rb +1 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/checkout/session_test.rb +6 -0
- data/test/stripe/payment_method_test.rb +66 -0
- data/test/stripe/terminal/location_test.rb +7 -0
- data/test/stripe/terminal/reader_test.rb +7 -0
- data/test/test_helper.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09105a67e4d42983626822bcf90bf3351cc649b675685eaf9cb32c3933906495'
|
4
|
+
data.tar.gz: 210510e3a1ea6c59af40032f686c5e134b782ade08a6105d642f839ee29abe7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3c5cfe19a51851fb7b10db82f628a3584222ad8a7bf3151bc007d867659d0090c4eee8683edc4e2fd45f6ba875c117197522001dca145820e96ead9a627030
|
7
|
+
data.tar.gz: 74e73fb61e12848686c1b842c149a3709576cbe82debf77f9aa1b213bf4a4c5e938c018d347c0edd7315a75f388b78140e1f546c9d80a45a13c343885056f4ec
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.10.0 - 2019-03-18
|
4
|
+
* [#745](https://github.com/stripe/stripe-ruby/pull/745) Add support for the `PaymentMethod` resource and APIs
|
5
|
+
* [#747](https://github.com/stripe/stripe-ruby/pull/747) Add support for retrieving a Checkout `Session`
|
6
|
+
* [#748](https://github.com/stripe/stripe-ruby/pull/748) Add support for deleting a Terminal `Location` and `Reader`
|
7
|
+
|
3
8
|
## 4.9.1 - 2019-03-18
|
4
9
|
* [#750](https://github.com/stripe/stripe-ruby/pull/750) Catch error and warn if unable to remove a method
|
5
10
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.10.0
|
data/lib/stripe.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class PaymentMethod < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
include Stripe::APIOperations::Save
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
|
9
|
+
OBJECT_NAME = "payment_method".freeze
|
10
|
+
|
11
|
+
def attach(params = {}, opts = {})
|
12
|
+
url = resource_url + "/attach"
|
13
|
+
resp, opts = request(:post, url, params, opts)
|
14
|
+
initialize_from(resp.data, opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def detach(params = {}, opts = {})
|
18
|
+
url = resource_url + "/detach"
|
19
|
+
resp, opts = request(:post, url, params, opts)
|
20
|
+
initialize_from(resp.data, opts)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/stripe/util.rb
CHANGED
@@ -83,6 +83,7 @@ module Stripe
|
|
83
83
|
Order::OBJECT_NAME => Order,
|
84
84
|
OrderReturn::OBJECT_NAME => OrderReturn,
|
85
85
|
PaymentIntent::OBJECT_NAME => PaymentIntent,
|
86
|
+
PaymentMethod::OBJECT_NAME => PaymentMethod,
|
86
87
|
Payout::OBJECT_NAME => Payout,
|
87
88
|
Person::OBJECT_NAME => Person,
|
88
89
|
Plan::OBJECT_NAME => Plan,
|
data/lib/stripe/version.rb
CHANGED
@@ -30,6 +30,12 @@ module Stripe
|
|
30
30
|
assert_requested :post, "#{Stripe.api_base}/v1/checkout/sessions"
|
31
31
|
assert session.is_a?(Stripe::Checkout::Session)
|
32
32
|
end
|
33
|
+
|
34
|
+
should "be retrievable" do
|
35
|
+
charge = Stripe::Checkout::Session.retrieve("cs_123")
|
36
|
+
assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123"
|
37
|
+
assert charge.is_a?(Stripe::Checkout::Session)
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../test_helper", __FILE__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
class PaymentMethodTest < Test::Unit::TestCase
|
7
|
+
should "be listable" do
|
8
|
+
payment_methods = Stripe::PaymentMethod.list(
|
9
|
+
customer: "cus_123",
|
10
|
+
type: "card"
|
11
|
+
)
|
12
|
+
assert_requested :get, "#{Stripe.api_base}/v1/payment_methods?customer=cus_123&type=card"
|
13
|
+
assert payment_methods.data.is_a?(Array)
|
14
|
+
assert payment_methods.first.is_a?(Stripe::PaymentMethod)
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be retrievable" do
|
18
|
+
payment_method = Stripe::PaymentMethod.retrieve("pm_123")
|
19
|
+
assert_requested :get, "#{Stripe.api_base}/v1/payment_methods/pm_123"
|
20
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
21
|
+
end
|
22
|
+
|
23
|
+
should "be creatable" do
|
24
|
+
payment_method = Stripe::PaymentMethod.create(
|
25
|
+
type: "card"
|
26
|
+
)
|
27
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods"
|
28
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "be saveable" do
|
32
|
+
payment_method = Stripe::PaymentMethod.retrieve("pm_123")
|
33
|
+
payment_method.metadata["key"] = "value"
|
34
|
+
payment_method.save
|
35
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/#{payment_method.id}"
|
36
|
+
end
|
37
|
+
|
38
|
+
should "be updateable" do
|
39
|
+
payment_method = Stripe::PaymentMethod.update("pm_123", metadata: { key: "value" })
|
40
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/pm_123"
|
41
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#attach" do
|
45
|
+
should "attach payment_method" do
|
46
|
+
payment_method = Stripe::PaymentMethod.construct_from(id: "pm_123", object: "payment_method")
|
47
|
+
payment_method = payment_method.attach(
|
48
|
+
customer: "cus_123"
|
49
|
+
)
|
50
|
+
|
51
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/pm_123/attach"
|
52
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "#detach" do
|
57
|
+
should "detach payment_method" do
|
58
|
+
payment_method = Stripe::PaymentMethod.construct_from(id: "pm_123", object: "payment_method")
|
59
|
+
payment_method = payment_method.detach
|
60
|
+
|
61
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/pm_123/detach"
|
62
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -46,6 +46,13 @@ module Stripe
|
|
46
46
|
assert_requested :post, "#{Stripe.api_base}/v1/terminal/locations/loc_123"
|
47
47
|
assert location.is_a?(Stripe::Terminal::Location)
|
48
48
|
end
|
49
|
+
|
50
|
+
should "be deletable" do
|
51
|
+
location = Stripe::Terminal::Location.retrieve("loc_123")
|
52
|
+
location = location.delete
|
53
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/terminal/locations/#{location.id}"
|
54
|
+
assert location.is_a?(Stripe::Terminal::Location)
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
@@ -40,6 +40,13 @@ module Stripe
|
|
40
40
|
assert_requested :post, "#{Stripe.api_base}/v1/terminal/readers/rdr_123"
|
41
41
|
assert reader.is_a?(Stripe::Terminal::Reader)
|
42
42
|
end
|
43
|
+
|
44
|
+
should "be deletable" do
|
45
|
+
reader = Stripe::Terminal::Reader.retrieve("rdr_123")
|
46
|
+
reader = reader.delete
|
47
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/terminal/readers/#{reader.id}"
|
48
|
+
assert reader.is_a?(Stripe::Terminal::Reader)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
data/test/test_helper.rb
CHANGED
@@ -17,7 +17,7 @@ require ::File.expand_path("../test_data", __FILE__)
|
|
17
17
|
require ::File.expand_path("../stripe_mock", __FILE__)
|
18
18
|
|
19
19
|
# If changing this number, please also change it in `.travis.yml`.
|
20
|
-
MOCK_MINIMUM_VERSION = "0.
|
20
|
+
MOCK_MINIMUM_VERSION = "0.49.0".freeze
|
21
21
|
MOCK_PORT = Stripe::StripeMock.start
|
22
22
|
|
23
23
|
# Disable all real network connections except those that are outgoing to
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/stripe/order.rb
|
111
111
|
- lib/stripe/order_return.rb
|
112
112
|
- lib/stripe/payment_intent.rb
|
113
|
+
- lib/stripe/payment_method.rb
|
113
114
|
- lib/stripe/payout.rb
|
114
115
|
- lib/stripe/person.rb
|
115
116
|
- lib/stripe/plan.rb
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- test/stripe/order_return_test.rb
|
195
196
|
- test/stripe/order_test.rb
|
196
197
|
- test/stripe/payment_intent_test.rb
|
198
|
+
- test/stripe/payment_method_test.rb
|
197
199
|
- test/stripe/payout_test.rb
|
198
200
|
- test/stripe/person_test.rb
|
199
201
|
- test/stripe/plan_test.rb
|
@@ -303,6 +305,7 @@ test_files:
|
|
303
305
|
- test/stripe/order_return_test.rb
|
304
306
|
- test/stripe/order_test.rb
|
305
307
|
- test/stripe/payment_intent_test.rb
|
308
|
+
- test/stripe/payment_method_test.rb
|
306
309
|
- test/stripe/payout_test.rb
|
307
310
|
- test/stripe/person_test.rb
|
308
311
|
- test/stripe/plan_test.rb
|