stripe 4.11.0 → 4.12.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 +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +1 -0
- data/lib/stripe/account.rb +2 -0
- data/lib/stripe/api_operations/delete.rb +24 -0
- data/lib/stripe/api_resource.rb +24 -0
- data/lib/stripe/charge.rb +2 -0
- data/lib/stripe/customer.rb +2 -0
- data/lib/stripe/discount.rb +7 -0
- data/lib/stripe/dispute.rb +2 -0
- data/lib/stripe/invoice.rb +6 -0
- data/lib/stripe/issuing/authorization.rb +3 -0
- data/lib/stripe/issuing/card.rb +2 -0
- data/lib/stripe/order.rb +3 -0
- data/lib/stripe/payment_intent.rb +4 -0
- data/lib/stripe/payment_method.rb +3 -0
- data/lib/stripe/payout.rb +2 -0
- data/lib/stripe/review.rb +2 -0
- data/lib/stripe/source.rb +2 -0
- data/lib/stripe/subscription.rb +2 -0
- data/lib/stripe/subscription_schedule.rb +3 -0
- data/lib/stripe/topup.rb +2 -0
- data/lib/stripe/transfer.rb +2 -0
- data/lib/stripe/util.rb +1 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_test.rb +26 -13
- data/test/stripe/apple_pay_domain_test.rb +17 -4
- data/test/stripe/charge_test.rb +21 -0
- data/test/stripe/coupon_test.rb +15 -5
- data/test/stripe/customer_test.rb +27 -9
- data/test/stripe/dispute_test.rb +9 -0
- data/test/stripe/ephemeral_key_test.rb +7 -0
- data/test/stripe/invoice_item_test.rb +17 -6
- data/test/stripe/invoice_test.rb +60 -6
- data/test/stripe/issuing/authorization_test.rb +32 -10
- data/test/stripe/issuing/card_test.rb +14 -5
- data/test/stripe/order_test.rb +20 -2
- data/test/stripe/payment_intent_test.rb +27 -0
- data/test/stripe/payment_method_test.rb +18 -0
- data/test/stripe/payout_test.rb +7 -0
- data/test/stripe/plan_test.rb +21 -15
- data/test/stripe/product_test.rb +15 -5
- data/test/stripe/radar/value_list_item_test.rb +15 -5
- data/test/stripe/radar/value_list_test.rb +15 -5
- data/test/stripe/recipient_test.rb +17 -4
- data/test/stripe/sku_test.rb +15 -5
- data/test/stripe/source_test.rb +13 -0
- data/test/stripe/subscription_item_test.rb +15 -5
- data/test/stripe/subscription_schedule_test.rb +29 -0
- data/test/stripe/subscription_test.rb +26 -6
- data/test/stripe/terminal/location_test.rb +15 -5
- data/test/stripe/terminal/reader_test.rb +15 -5
- data/test/stripe/topup_test.rb +8 -0
- data/test/stripe/webhook_endpoint_test.rb +17 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a30c5b27bb9161913905e0ada304efcef00519446eb64cbf2e7c3d0d625a2810
|
4
|
+
data.tar.gz: d8503b19941c67e68c75b7b4e1c24cae2bd7a4c80a5b91e5c4e81058d23b658d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3a0ecd3172c802dc16bacab0be7f3d34373ed2230d18e5a89b84814d3705568e6f0ca261fb576492c1ec3ef39132b17a9b9126ba69f3941e45a4b3f851a3f07
|
7
|
+
data.tar.gz: 7a6d70ebe915abe5774a4f5e55815e43ea24d6db4f4553ce77f18394b93aca8eeae051f9fd557d74bdda4d3e4d77112b821dca22a62c7284fc942392fc797638
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.12.0 - 2019-04-02
|
4
|
+
* [#752](https://github.com/stripe/stripe-ruby/pull/752) Add `.delete` class method on deletable API resources
|
5
|
+
* [#754](https://github.com/stripe/stripe-ruby/pull/754) Add class methods for all custom API requests (e.g. `Charge.capture`)
|
6
|
+
|
3
7
|
## 4.11.0 - 2019-03-26
|
4
8
|
* [#753](https://github.com/stripe/stripe-ruby/pull/753) Add a global proxy configuration parameter
|
5
9
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.12.0
|
data/lib/stripe.rb
CHANGED
data/lib/stripe/account.rb
CHANGED
@@ -3,11 +3,35 @@
|
|
3
3
|
module Stripe
|
4
4
|
module APIOperations
|
5
5
|
module Delete
|
6
|
+
module ClassMethods
|
7
|
+
# Deletes an API resource
|
8
|
+
#
|
9
|
+
# Deletes the identified resource with the passed in parameters.
|
10
|
+
#
|
11
|
+
# ==== Attributes
|
12
|
+
#
|
13
|
+
# * +id+ - ID of the resource to delete.
|
14
|
+
# * +params+ - A hash of parameters to pass to the API
|
15
|
+
# * +opts+ - A Hash of additional options (separate from the params /
|
16
|
+
# object values) to be added to the request. E.g. to allow for an
|
17
|
+
# idempotency_key to be passed in the request headers, or for the
|
18
|
+
# api_key to be overwritten. See {APIOperations::Request.request}.
|
19
|
+
def delete(id, params = {}, opts = {})
|
20
|
+
opts = Util.normalize_opts(opts)
|
21
|
+
resp, opts = request(:delete, "#{resource_url}/#{id}", params, opts)
|
22
|
+
Util.convert_to_stripe_object(resp.data, opts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
6
26
|
def delete(params = {}, opts = {})
|
7
27
|
opts = Util.normalize_opts(opts)
|
8
28
|
resp, opts = request(:delete, resource_url, params, opts)
|
9
29
|
initialize_from(resp.data, opts)
|
10
30
|
end
|
31
|
+
|
32
|
+
def self.included(base)
|
33
|
+
base.extend(ClassMethods)
|
34
|
+
end
|
11
35
|
end
|
12
36
|
end
|
13
37
|
end
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -48,6 +48,30 @@ module Stripe
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
# Adds a custom method to a resource class. This is used to add support for
|
52
|
+
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
|
53
|
+
# following parameters:
|
54
|
+
# - name: the name of the custom method to create (as a symbol)
|
55
|
+
# - http_verb: the HTTP verb for the API request (:get, :post, or :delete)
|
56
|
+
# - http_path: the path to append to the resource's URL. If not provided,
|
57
|
+
# the name is used as the path
|
58
|
+
#
|
59
|
+
# For example, this call:
|
60
|
+
# custom_method :capture, http_verb: post
|
61
|
+
# adds a `capture` class method to the resource class that, when called,
|
62
|
+
# will send a POST request to `/v1/<object_name>/capture`.
|
63
|
+
def self.custom_method(name, http_verb:, http_path: nil)
|
64
|
+
unless %i[get post delete].include?(http_verb)
|
65
|
+
raise ArgumentError, "Invalid http_verb value: #{http_verb.inspect}. Should be one of :get, :post or :delete."
|
66
|
+
end
|
67
|
+
http_path ||= name.to_s
|
68
|
+
define_singleton_method(name) do |id, params = {}, opts = {}|
|
69
|
+
url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
|
70
|
+
resp, opts = request(http_verb, url, params, opts)
|
71
|
+
Util.convert_to_stripe_object(resp.data, opts)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
51
75
|
def resource_url
|
52
76
|
unless (id = self["id"])
|
53
77
|
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", "id")
|
data/lib/stripe/charge.rb
CHANGED
@@ -8,6 +8,8 @@ module Stripe
|
|
8
8
|
|
9
9
|
OBJECT_NAME = "charge".freeze
|
10
10
|
|
11
|
+
custom_method :capture, http_verb: :post
|
12
|
+
|
11
13
|
def refund(params = {}, opts = {})
|
12
14
|
# Old versions of charge objects included a `refunds` field that was just
|
13
15
|
# a vanilla array instead of a Stripe list object.
|
data/lib/stripe/customer.rb
CHANGED
@@ -10,6 +10,8 @@ module Stripe
|
|
10
10
|
|
11
11
|
OBJECT_NAME = "customer".freeze
|
12
12
|
|
13
|
+
custom_method :delete_discount, http_verb: :delete, http_path: "discount"
|
14
|
+
|
13
15
|
save_nested_resource :source
|
14
16
|
nested_resource_class_methods :source,
|
15
17
|
operations: %i[create retrieve update delete list]
|
data/lib/stripe/dispute.rb
CHANGED
data/lib/stripe/invoice.rb
CHANGED
@@ -9,6 +9,12 @@ module Stripe
|
|
9
9
|
|
10
10
|
OBJECT_NAME = "invoice".freeze
|
11
11
|
|
12
|
+
custom_method :finalize_invoice, http_verb: :post, http_path: "finalize"
|
13
|
+
custom_method :mark_uncollectible, http_verb: :post
|
14
|
+
custom_method :pay, http_verb: :post
|
15
|
+
custom_method :send_invoice, http_verb: :post, http_path: "send"
|
16
|
+
custom_method :void_invoice, http_verb: :post, http_path: "void"
|
17
|
+
|
12
18
|
def finalize_invoice(params = {}, opts = {})
|
13
19
|
url = resource_url + "/finalize"
|
14
20
|
resp, opts = request(:post, url, params, opts)
|
@@ -8,6 +8,9 @@ module Stripe
|
|
8
8
|
|
9
9
|
OBJECT_NAME = "issuing.authorization".freeze
|
10
10
|
|
11
|
+
custom_method :approve, http_verb: :post
|
12
|
+
custom_method :decline, http_verb: :post
|
13
|
+
|
11
14
|
def approve(params = {}, opts = {})
|
12
15
|
resp, opts = request(:post, resource_url + "/approve", params, opts)
|
13
16
|
initialize_from(resp.data, opts)
|
data/lib/stripe/issuing/card.rb
CHANGED
@@ -9,6 +9,8 @@ module Stripe
|
|
9
9
|
|
10
10
|
OBJECT_NAME = "issuing.card".freeze
|
11
11
|
|
12
|
+
custom_method :details, http_verb: :get
|
13
|
+
|
12
14
|
def details(params = {}, opts = {})
|
13
15
|
resp, opts = request(:get, resource_url + "/details", params, opts)
|
14
16
|
Util.convert_to_stripe_object(resp.data, opts)
|
data/lib/stripe/order.rb
CHANGED
@@ -8,6 +8,9 @@ module Stripe
|
|
8
8
|
|
9
9
|
OBJECT_NAME = "order".freeze
|
10
10
|
|
11
|
+
custom_method :pay, http_verb: :post
|
12
|
+
custom_method :return_order, http_verb: :post, http_path: "returns"
|
13
|
+
|
11
14
|
def pay(params, opts = {})
|
12
15
|
resp, opts = request(:post, pay_url, params, opts)
|
13
16
|
initialize_from(resp.data, opts)
|
@@ -8,6 +8,10 @@ module Stripe
|
|
8
8
|
|
9
9
|
OBJECT_NAME = "payment_intent".freeze
|
10
10
|
|
11
|
+
custom_method :cancel, http_verb: :post
|
12
|
+
custom_method :capture, http_verb: :post
|
13
|
+
custom_method :confirm, http_verb: :post
|
14
|
+
|
11
15
|
def cancel(params = {}, opts = {})
|
12
16
|
resp, opts = request(:post, resource_url + "/cancel", params, opts)
|
13
17
|
initialize_from(resp.data, opts)
|
@@ -8,6 +8,9 @@ module Stripe
|
|
8
8
|
|
9
9
|
OBJECT_NAME = "payment_method".freeze
|
10
10
|
|
11
|
+
custom_method :attach, http_verb: :post
|
12
|
+
custom_method :detach, http_verb: :post
|
13
|
+
|
11
14
|
def attach(params = {}, opts = {})
|
12
15
|
url = resource_url + "/attach"
|
13
16
|
resp, opts = request(:post, url, params, opts)
|
data/lib/stripe/payout.rb
CHANGED
data/lib/stripe/review.rb
CHANGED
data/lib/stripe/source.rb
CHANGED
data/lib/stripe/subscription.rb
CHANGED
data/lib/stripe/topup.rb
CHANGED
data/lib/stripe/transfer.rb
CHANGED
data/lib/stripe/util.rb
CHANGED
@@ -62,6 +62,7 @@ module Stripe
|
|
62
62
|
CountrySpec::OBJECT_NAME => CountrySpec,
|
63
63
|
Coupon::OBJECT_NAME => Coupon,
|
64
64
|
Customer::OBJECT_NAME => Customer,
|
65
|
+
Discount::OBJECT_NAME => Discount,
|
65
66
|
Dispute::OBJECT_NAME => Dispute,
|
66
67
|
EphemeralKey::OBJECT_NAME => EphemeralKey,
|
67
68
|
Event::OBJECT_NAME => Event,
|
data/lib/stripe/version.rb
CHANGED
data/test/stripe/account_test.rb
CHANGED
@@ -24,15 +24,18 @@ module Stripe
|
|
24
24
|
end
|
25
25
|
|
26
26
|
should "be rejectable" do
|
27
|
-
account_data = { id: "acct_foo" }
|
28
|
-
stub_request(:get, "#{Stripe.api_base}/v1/accounts/acct_foo")
|
29
|
-
.to_return(body: JSON.generate(account_data))
|
30
|
-
|
31
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/acct_foo/reject")
|
32
|
-
.to_return(body: JSON.generate(account_data))
|
33
|
-
|
34
27
|
account = Stripe::Account.retrieve("acct_foo")
|
35
|
-
account.reject(reason: "fraud")
|
28
|
+
account = account.reject(reason: "fraud")
|
29
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{account.id}/reject"
|
30
|
+
assert account.is_a?(Stripe::Account)
|
31
|
+
end
|
32
|
+
|
33
|
+
context ".reject" do
|
34
|
+
should "reject the account" do
|
35
|
+
account = Stripe::Account.reject("acct_foo", reason: "fraud")
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{account.id}/reject"
|
37
|
+
assert account.is_a?(Stripe::Account)
|
38
|
+
end
|
36
39
|
end
|
37
40
|
|
38
41
|
should "be creatable" do
|
@@ -54,11 +57,21 @@ module Stripe
|
|
54
57
|
assert account.is_a?(Stripe::Account)
|
55
58
|
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
context "#delete" do
|
61
|
+
should "be deletable" do
|
62
|
+
account = Stripe::Account.retrieve("acct_123")
|
63
|
+
account = account.delete
|
64
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/#{account.id}"
|
65
|
+
assert account.is_a?(Stripe::Account)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context ".delete" do
|
70
|
+
should "be deletable" do
|
71
|
+
account = Stripe::Account.delete("acct_123")
|
72
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_123"
|
73
|
+
assert account.is_a?(Stripe::Account)
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
should "be able to list Persons" do
|
@@ -24,10 +24,23 @@ module Stripe
|
|
24
24
|
end
|
25
25
|
|
26
26
|
should "be deletable" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
end
|
28
|
+
|
29
|
+
context "#delete" do
|
30
|
+
should "be deletable" do
|
31
|
+
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
32
|
+
domain = domain.delete
|
33
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{domain.id}"
|
34
|
+
assert domain.is_a?(Stripe::ApplePayDomain)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context ".delete" do
|
39
|
+
should "be deletable" do
|
40
|
+
domain = Stripe::ApplePayDomain.delete("apwc_123")
|
41
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/apwc_123"
|
42
|
+
assert domain.is_a?(Stripe::ApplePayDomain)
|
43
|
+
end
|
31
44
|
end
|
32
45
|
end
|
33
46
|
end
|
data/test/stripe/charge_test.rb
CHANGED
@@ -40,6 +40,27 @@ module Stripe
|
|
40
40
|
assert charge.is_a?(Stripe::Charge)
|
41
41
|
end
|
42
42
|
|
43
|
+
context "#capture" do
|
44
|
+
should "capture the charge" do
|
45
|
+
charge = Stripe::Charge.retrieve("ch_123")
|
46
|
+
charge = charge.capture(amount: 100)
|
47
|
+
assert_requested :post,
|
48
|
+
"#{Stripe.api_base}/v1/charges/ch_123/capture",
|
49
|
+
body: { amount: 100 }
|
50
|
+
assert charge.is_a?(Stripe::Charge)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context ".capture" do
|
55
|
+
should "capture the charge" do
|
56
|
+
charge = Stripe::Charge.capture("ch_123", amount: 100)
|
57
|
+
assert_requested :post,
|
58
|
+
"#{Stripe.api_base}/v1/charges/ch_123/capture",
|
59
|
+
body: { amount: 100 }
|
60
|
+
assert charge.is_a?(Stripe::Charge)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
43
64
|
context "#mark_as_fraudulent" do
|
44
65
|
should "charges should be able to be marked as fraudulent" do
|
45
66
|
charge = Stripe::Charge.retrieve("ch_123")
|
data/test/stripe/coupon_test.rb
CHANGED
@@ -41,11 +41,21 @@ module Stripe
|
|
41
41
|
assert coupon.is_a?(Stripe::Coupon)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
context "#delete" do
|
45
|
+
should "be deletable" do
|
46
|
+
coupon = Stripe::Coupon.delete("25OFF")
|
47
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/coupons/#{coupon.id}"
|
48
|
+
assert coupon.is_a?(Stripe::Coupon)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context ".delete" do
|
53
|
+
should "be deletable" do
|
54
|
+
coupon = Stripe::Coupon.retrieve("25OFF")
|
55
|
+
coupon = coupon.delete
|
56
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/coupons/25OFF"
|
57
|
+
assert coupon.is_a?(Stripe::Coupon)
|
58
|
+
end
|
49
59
|
end
|
50
60
|
end
|
51
61
|
end
|