stripe 4.11.0 → 4.12.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -36,17 +36,28 @@ module Stripe
|
|
36
36
|
assert customer.is_a?(Stripe::Customer)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
context "#delete" do
|
40
|
+
should "be deletable" do
|
41
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
42
|
+
customer = customer.delete
|
43
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}"
|
44
|
+
assert customer.is_a?(Stripe::Customer)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context ".delete" do
|
49
|
+
should "be deletable" do
|
50
|
+
customer = Stripe::Customer.delete("cus_123")
|
51
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123"
|
52
|
+
assert customer.is_a?(Stripe::Customer)
|
53
|
+
end
|
44
54
|
end
|
45
55
|
|
46
56
|
context "#create_subscription" do
|
47
57
|
should "create a new subscription" do
|
48
58
|
customer = Stripe::Customer.retrieve("cus_123")
|
49
59
|
subscription = customer.create_subscription(items: [{ plan: "silver" }])
|
60
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscriptions"
|
50
61
|
assert subscription.is_a?(Stripe::Subscription)
|
51
62
|
end
|
52
63
|
end
|
@@ -55,6 +66,7 @@ module Stripe
|
|
55
66
|
should "create a new invoice" do
|
56
67
|
customer = Stripe::Customer.retrieve("cus_123")
|
57
68
|
invoice = customer.create_upcoming_invoice
|
69
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices"
|
58
70
|
assert invoice.is_a?(Stripe::Invoice)
|
59
71
|
end
|
60
72
|
end
|
@@ -88,11 +100,17 @@ module Stripe
|
|
88
100
|
context "#delete_discount" do
|
89
101
|
should "delete a discount" do
|
90
102
|
customer = Stripe::Customer.retrieve("cus_123")
|
103
|
+
customer = customer.delete_discount
|
104
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount"
|
105
|
+
assert customer.is_a?(Stripe::Customer)
|
106
|
+
end
|
107
|
+
end
|
91
108
|
|
92
|
-
|
93
|
-
|
94
|
-
discount =
|
95
|
-
|
109
|
+
context ".delete_discount" do
|
110
|
+
should "delete a discount" do
|
111
|
+
discount = Stripe::Customer.delete_discount("cus_123")
|
112
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_123/discount"
|
113
|
+
assert discount.is_a?(Stripe::Discount)
|
96
114
|
end
|
97
115
|
end
|
98
116
|
|
data/test/stripe/dispute_test.rb
CHANGED
@@ -36,6 +36,15 @@ module Stripe
|
|
36
36
|
dispute.close
|
37
37
|
assert_requested :post,
|
38
38
|
"#{Stripe.api_base}/v1/disputes/#{dispute.id}/close"
|
39
|
+
assert dispute.is_a?(Stripe::Dispute)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context ".close" do
|
44
|
+
should "close a dispute" do
|
45
|
+
dispute = Stripe::Dispute.close("dp_123")
|
46
|
+
assert_requested :post, "#{Stripe.api_base}/v1/disputes/dp_123/close"
|
47
|
+
assert dispute.is_a?(Stripe::Dispute)
|
39
48
|
end
|
40
49
|
end
|
41
50
|
end
|
@@ -82,5 +82,12 @@ module Stripe
|
|
82
82
|
assert_requested :delete, "#{Stripe.api_base}/v1/ephemeral_keys/#{key.id}"
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
context ".delete" do
|
87
|
+
should "succeed" do
|
88
|
+
Stripe::EphemeralKey.delete("ephkey_123")
|
89
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/ephemeral_keys/ephkey_123"
|
90
|
+
end
|
91
|
+
end
|
85
92
|
end
|
86
93
|
end
|
@@ -44,12 +44,23 @@ module Stripe
|
|
44
44
|
assert item.is_a?(Stripe::InvoiceItem)
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
context "#delete" do
|
48
|
+
should "be deletable" do
|
49
|
+
item = Stripe::InvoiceItem.retrieve("ii_123")
|
50
|
+
item = item.delete
|
51
|
+
assert_requested :delete,
|
52
|
+
"#{Stripe.api_base}/v1/invoiceitems/#{item.id}"
|
53
|
+
assert item.is_a?(Stripe::InvoiceItem)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context ".delete" do
|
58
|
+
should "be deletable" do
|
59
|
+
item = Stripe::InvoiceItem.delete("ii_123")
|
60
|
+
assert_requested :delete,
|
61
|
+
"#{Stripe.api_base}/v1/invoiceitems/ii_123"
|
62
|
+
assert item.is_a?(Stripe::InvoiceItem)
|
63
|
+
end
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
data/test/stripe/invoice_test.rb
CHANGED
@@ -39,10 +39,22 @@ module Stripe
|
|
39
39
|
end
|
40
40
|
|
41
41
|
should "be deletable" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
end
|
43
|
+
context "#delete" do
|
44
|
+
should "be deletable" do
|
45
|
+
invoice = Stripe::Invoice.retrieve("in_123")
|
46
|
+
invoice = invoice.delete
|
47
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/invoices/#{invoice.id}"
|
48
|
+
assert invoice.is_a?(Stripe::Invoice)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context ".delete" do
|
53
|
+
should "be deletable" do
|
54
|
+
invoice = Stripe::Invoice.delete("in_123")
|
55
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/invoices/in_123"
|
56
|
+
assert invoice.is_a?(Stripe::Invoice)
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
48
60
|
context "#finalize" do
|
@@ -55,6 +67,14 @@ module Stripe
|
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
70
|
+
context ".finalize" do
|
71
|
+
should "finalize invoice" do
|
72
|
+
invoice = Stripe::Invoice.finalize_invoice("in_123")
|
73
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices/in_123/finalize"
|
74
|
+
assert invoice.is_a?(Stripe::Invoice)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
58
78
|
context "#mark_uncollectible" do
|
59
79
|
should "mark invoice as uncollectible" do
|
60
80
|
invoice = Stripe::Invoice.retrieve("in_123")
|
@@ -65,6 +85,14 @@ module Stripe
|
|
65
85
|
end
|
66
86
|
end
|
67
87
|
|
88
|
+
context ".mark_uncollectible" do
|
89
|
+
should "mark invoice as uncollectible" do
|
90
|
+
invoice = Stripe::Invoice.mark_uncollectible("in_123")
|
91
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices/in_123/mark_uncollectible"
|
92
|
+
assert invoice.is_a?(Stripe::Invoice)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
68
96
|
context "#pay" do
|
69
97
|
should "pay invoice" do
|
70
98
|
invoice = Stripe::Invoice.retrieve("in_123")
|
@@ -88,7 +116,17 @@ module Stripe
|
|
88
116
|
end
|
89
117
|
end
|
90
118
|
|
91
|
-
context "
|
119
|
+
context ".pay" do
|
120
|
+
should "pay invoice" do
|
121
|
+
invoice = Stripe::Invoice.pay("in_123", source: "src_123")
|
122
|
+
assert_requested :post,
|
123
|
+
"#{Stripe.api_base}/v1/invoices/in_123/pay",
|
124
|
+
body: { source: "src_123" }
|
125
|
+
assert invoice.is_a?(Stripe::Invoice)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "#send_invoice" do
|
92
130
|
should "send invoice" do
|
93
131
|
invoice = Stripe::Invoice.retrieve("in_123")
|
94
132
|
invoice = invoice.send_invoice
|
@@ -98,6 +136,14 @@ module Stripe
|
|
98
136
|
end
|
99
137
|
end
|
100
138
|
|
139
|
+
context ".send_invoice" do
|
140
|
+
should "send invoice" do
|
141
|
+
invoice = Stripe::Invoice.send_invoice("in_123")
|
142
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices/in_123/send"
|
143
|
+
assert invoice.is_a?(Stripe::Invoice)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
101
147
|
context "#upcoming" do
|
102
148
|
should "retrieve upcoming invoices" do
|
103
149
|
invoice = Stripe::Invoice.upcoming(
|
@@ -148,7 +194,7 @@ module Stripe
|
|
148
194
|
end
|
149
195
|
end
|
150
196
|
|
151
|
-
context "#
|
197
|
+
context "#void_invoice" do
|
152
198
|
should "void invoice" do
|
153
199
|
invoice = Stripe::Invoice.retrieve("in_123")
|
154
200
|
invoice = invoice.void_invoice
|
@@ -157,5 +203,13 @@ module Stripe
|
|
157
203
|
assert invoice.is_a?(Stripe::Invoice)
|
158
204
|
end
|
159
205
|
end
|
206
|
+
|
207
|
+
context ".void_invoice" do
|
208
|
+
should "void invoice" do
|
209
|
+
invoice = Stripe::Invoice.void_invoice("in_123")
|
210
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices/in_123/void"
|
211
|
+
assert invoice.is_a?(Stripe::Invoice)
|
212
|
+
end
|
213
|
+
end
|
160
214
|
end
|
161
215
|
end
|
@@ -32,18 +32,40 @@ module Stripe
|
|
32
32
|
assert authorization.is_a?(Stripe::Issuing::Authorization)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
context ".approve" do
|
36
|
+
should "approve an authorization" do
|
37
|
+
payment_intent = Stripe::Issuing::Authorization.approve("iauth_123")
|
38
|
+
|
39
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/authorizations/iauth_123/approve"
|
40
|
+
assert payment_intent.is_a?(Stripe::Issuing::Authorization)
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
context "#approve" do
|
45
|
+
should "approve an authorization" do
|
46
|
+
authorization = Stripe::Issuing::Authorization.retrieve("iauth_123")
|
47
|
+
authorization.approve
|
48
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/authorizations/iauth_123/approve"
|
49
|
+
assert authorization.is_a?(Stripe::Issuing::Authorization)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context ".decline" do
|
54
|
+
should "decline an authorization" do
|
55
|
+
payment_intent = Stripe::Issuing::Authorization.decline("iauth_123")
|
56
|
+
|
57
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/authorizations/iauth_123/decline"
|
58
|
+
assert payment_intent.is_a?(Stripe::Issuing::Authorization)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "#decline" do
|
63
|
+
should "decline an authorization" do
|
64
|
+
authorization = Stripe::Issuing::Authorization.retrieve("iauth_123")
|
65
|
+
authorization.decline
|
66
|
+
assert_requested :post, "#{Stripe.api_base}/v1/issuing/authorizations/iauth_123/decline"
|
67
|
+
assert authorization.is_a?(Stripe::Issuing::Authorization)
|
68
|
+
end
|
47
69
|
end
|
48
70
|
end
|
49
71
|
end
|
@@ -41,12 +41,21 @@ module Stripe
|
|
41
41
|
assert card.is_a?(Stripe::Issuing::Card)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
card
|
44
|
+
context "#details" do
|
45
|
+
should "retrieve a card's details" do
|
46
|
+
card_details = Stripe::Issuing::Card.details("ic_123")
|
47
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cards/ic_123/details"
|
48
|
+
assert card_details.is_a?(Stripe::Issuing::CardDetails)
|
49
|
+
end
|
50
|
+
end
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
context ".details" do
|
53
|
+
should "retrieve a card's details" do
|
54
|
+
card = Stripe::Issuing::Card.retrieve("ic_123")
|
55
|
+
card_details = card.details
|
56
|
+
assert_requested :get, "#{Stripe.api_base}/v1/issuing/cards/ic_123/details"
|
57
|
+
assert card_details.is_a?(Stripe::Issuing::CardDetails)
|
58
|
+
end
|
50
59
|
end
|
51
60
|
end
|
52
61
|
end
|
data/test/stripe/order_test.rb
CHANGED
@@ -42,6 +42,15 @@ module Stripe
|
|
42
42
|
should "pay an order" do
|
43
43
|
order = Stripe::Order.retrieve("or_123")
|
44
44
|
order = order.pay(source: "tok_123")
|
45
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{order.id}/pay"
|
46
|
+
assert order.is_a?(Stripe::Order)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context ".pay" do
|
51
|
+
should "pay an order" do
|
52
|
+
order = Stripe::Order.pay("or_123", source: "tok_123")
|
53
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/or_123/pay"
|
45
54
|
assert order.is_a?(Stripe::Order)
|
46
55
|
end
|
47
56
|
end
|
@@ -49,8 +58,17 @@ module Stripe
|
|
49
58
|
context "#return_order" do
|
50
59
|
should "return an order" do
|
51
60
|
order = Stripe::Order.retrieve("or_123")
|
52
|
-
|
53
|
-
|
61
|
+
order_return = order.return_order({})
|
62
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{order.id}/returns"
|
63
|
+
assert order_return.is_a?(Stripe::OrderReturn)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context ".return_order" do
|
68
|
+
should "return an order" do
|
69
|
+
order_return = Stripe::Order.return_order("or_123")
|
70
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/or_123/returns"
|
71
|
+
assert order_return.is_a?(Stripe::OrderReturn)
|
54
72
|
end
|
55
73
|
end
|
56
74
|
end
|
@@ -53,6 +53,15 @@ module Stripe
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
context ".cancel" do
|
57
|
+
should "cancel a payment_intent" do
|
58
|
+
payment_intent = Stripe::PaymentIntent.cancel("pi_123")
|
59
|
+
|
60
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/cancel"
|
61
|
+
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
context "#capture" do
|
57
66
|
should "capture a payment_intent" do
|
58
67
|
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
@@ -65,6 +74,15 @@ module Stripe
|
|
65
74
|
end
|
66
75
|
end
|
67
76
|
|
77
|
+
context ".capture" do
|
78
|
+
should "capture a payment_intent" do
|
79
|
+
payment_intent = Stripe::PaymentIntent.capture("pi_123", amount_to_capture: 1234)
|
80
|
+
|
81
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/capture"
|
82
|
+
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
68
86
|
context "#confirm" do
|
69
87
|
should "confirm a payment_intent" do
|
70
88
|
payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
|
@@ -76,5 +94,14 @@ module Stripe
|
|
76
94
|
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
77
95
|
end
|
78
96
|
end
|
97
|
+
|
98
|
+
context ".confirm" do
|
99
|
+
should "confirm a payment_intent" do
|
100
|
+
payment_intent = Stripe::PaymentIntent.confirm("pi_123", source: "src_123")
|
101
|
+
|
102
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/confirm"
|
103
|
+
assert payment_intent.is_a?(Stripe::PaymentIntent)
|
104
|
+
end
|
105
|
+
end
|
79
106
|
end
|
80
107
|
end
|
@@ -53,6 +53,15 @@ module Stripe
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
context ".attach" do
|
57
|
+
should "attach payment_method" do
|
58
|
+
payment_method = Stripe::PaymentMethod.attach("pm_123", customer: "cus_123")
|
59
|
+
|
60
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/pm_123/attach"
|
61
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
context "#detach" do
|
57
66
|
should "detach payment_method" do
|
58
67
|
payment_method = Stripe::PaymentMethod.construct_from(id: "pm_123", object: "payment_method")
|
@@ -62,5 +71,14 @@ module Stripe
|
|
62
71
|
assert payment_method.is_a?(Stripe::PaymentMethod)
|
63
72
|
end
|
64
73
|
end
|
74
|
+
|
75
|
+
context ".detach" do
|
76
|
+
should "detach payment_method" do
|
77
|
+
payment_method = Stripe::PaymentMethod.detach("pm_123")
|
78
|
+
|
79
|
+
assert_requested :post, "#{Stripe.api_base}/v1/payment_methods/pm_123/detach"
|
80
|
+
assert payment_method.is_a?(Stripe::PaymentMethod)
|
81
|
+
end
|
82
|
+
end
|
65
83
|
end
|
66
84
|
end
|
data/test/stripe/payout_test.rb
CHANGED
data/test/stripe/plan_test.rb
CHANGED
@@ -12,8 +12,8 @@ module Stripe
|
|
12
12
|
end
|
13
13
|
|
14
14
|
should "be retrievable" do
|
15
|
-
plan = Stripe::Plan.retrieve("
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/plans/
|
15
|
+
plan = Stripe::Plan.retrieve("pl_123")
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/plans/pl_123"
|
17
17
|
assert plan.is_a?(Stripe::Plan)
|
18
18
|
end
|
19
19
|
|
@@ -22,8 +22,7 @@ module Stripe
|
|
22
22
|
amount: 5000,
|
23
23
|
interval: "month",
|
24
24
|
name: "Sapphire elite",
|
25
|
-
currency: "usd"
|
26
|
-
id: "sapphire-elite"
|
25
|
+
currency: "usd"
|
27
26
|
)
|
28
27
|
assert_requested :post, "#{Stripe.api_base}/v1/plans"
|
29
28
|
assert plan.is_a?(Stripe::Plan)
|
@@ -35,7 +34,6 @@ module Stripe
|
|
35
34
|
interval: "month",
|
36
35
|
name: "Sapphire elite",
|
37
36
|
currency: "usd",
|
38
|
-
id: "sapphire-elite",
|
39
37
|
usage_type: "metered"
|
40
38
|
)
|
41
39
|
assert_requested :post, "#{Stripe.api_base}/v1/plans"
|
@@ -47,7 +45,6 @@ module Stripe
|
|
47
45
|
interval: "month",
|
48
46
|
name: "Sapphire elite",
|
49
47
|
currency: "usd",
|
50
|
-
id: "sapphire-elite",
|
51
48
|
billing_scheme: "tiered",
|
52
49
|
tiers_mode: "volume",
|
53
50
|
tiers: [{ up_to: 100, amount: 1000 }, { up_to: "inf", amount: 2000 }]
|
@@ -61,7 +58,6 @@ module Stripe
|
|
61
58
|
interval: "month",
|
62
59
|
name: "Sapphire elite",
|
63
60
|
currency: "usd",
|
64
|
-
id: "sapphire-elite",
|
65
61
|
amount: 5000,
|
66
62
|
transform_usage: { round: "up", divide_by: 50 }
|
67
63
|
)
|
@@ -70,23 +66,33 @@ module Stripe
|
|
70
66
|
end
|
71
67
|
|
72
68
|
should "be saveable" do
|
73
|
-
plan = Stripe::Plan.retrieve("
|
69
|
+
plan = Stripe::Plan.retrieve("pl_123")
|
74
70
|
plan.metadata["key"] = "value"
|
75
71
|
plan.save
|
76
72
|
assert_requested :post, "#{Stripe.api_base}/v1/plans/#{plan.id}"
|
77
73
|
end
|
78
74
|
|
79
75
|
should "be updateable" do
|
80
|
-
plan = Stripe::Plan.update("
|
81
|
-
assert_requested :post, "#{Stripe.api_base}/v1/plans/
|
76
|
+
plan = Stripe::Plan.update("pl_123", metadata: { foo: "bar" })
|
77
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans/pl_123"
|
82
78
|
assert plan.is_a?(Stripe::Plan)
|
83
79
|
end
|
84
80
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
81
|
+
context "#delete" do
|
82
|
+
should "be deletable" do
|
83
|
+
plan = Stripe::Plan.retrieve("pl_123")
|
84
|
+
plan = plan.delete
|
85
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/plans/#{plan.id}"
|
86
|
+
assert plan.is_a?(Stripe::Plan)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context ".delete" do
|
91
|
+
should "be deletable" do
|
92
|
+
plan = Stripe::Plan.delete("pl_123")
|
93
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/plans/pl_123"
|
94
|
+
assert plan.is_a?(Stripe::Plan)
|
95
|
+
end
|
90
96
|
end
|
91
97
|
end
|
92
98
|
end
|