stripe-rails 2.3.5 → 2.5.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/.github/issue_template.md +2 -3
- data/.github/pull_request_template.md +2 -4
- data/.github/workflows/ruby.yml +2 -2
- data/Changelog.md +7 -1
- data/README.md +17 -2
- data/app/helpers/stripe/javascript_helper.rb +4 -2
- data/app/views/stripe/_elements.html.erb +5 -0
- data/gemfiles/rails51.gemfile +1 -1
- data/gemfiles/rails52.gemfile +1 -1
- data/gemfiles/rails60.gemfile +1 -1
- data/lib/stripe/prices.rb +3 -0
- data/lib/stripe/rails/version.rb +1 -1
- data/test/dummy/config/stripe/prices.rb +6 -0
- data/test/javascript_helper_spec.rb +10 -0
- data/test/price_builder_spec.rb +56 -0
- data/test/spec_helper.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 385a8a9f7a66c294e97df0fc63d6d83eb225abd27a222099404909b6c02a758a
|
4
|
+
data.tar.gz: dcddbee8d217324e186e32eb59b7b4d5037683df57c1a7171aaa63e0ef1bd3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e534281c5ee575ed6e76596d2d78a2073f6be23956f1bd3d0abd2ee0137ca7576e9c6b3066ad7932ec42bdb4252c23316a882b988f88aa7c69a9a07b706d8de
|
7
|
+
data.tar.gz: b8e0a2094c7bf99e009696b414d71f64333b3bd09630e3cb731a471a528d7a6f16a52f00438a2f18d485c78d40b67ec9b282732de28b42ba5f36c4ceb837187b
|
data/.github/issue_template.md
CHANGED
data/.github/workflows/ruby.yml
CHANGED
@@ -14,12 +14,12 @@ jobs:
|
|
14
14
|
|
15
15
|
strategy:
|
16
16
|
matrix:
|
17
|
-
ruby: [2.
|
17
|
+
ruby: [2.7.7]
|
18
18
|
gemfile: [Gemfile, gemfiles/rails60.gemfile, gemfiles/rails52.gemfile, gemfiles/rails51.gemfile]
|
19
19
|
steps:
|
20
20
|
- uses: actions/checkout@v1
|
21
21
|
- name: Set up Ruby
|
22
|
-
uses:
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
23
|
with:
|
24
24
|
ruby-version: ${{ matrix.ruby }}
|
25
25
|
- name: Set up Code Climate
|
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -12,8 +12,6 @@ This gem can help your rails application integrate with Stripe in the following
|
|
12
12
|
* manage product, prices, plans and coupons from within your app.
|
13
13
|
* painlessly receive and validate webhooks from stripe.
|
14
14
|
|
15
|
-
[📫 Sign up for the Newsletter](http://tinyletter.com/stripe-rails) to receive occasional updates.
|
16
|
-
|
17
15
|
[Professionally supported stripe-rails is coming soon](https://tidelift.com/subscription/pkg/rubygems-stripe-rails?utm_source=rubygems-stripe-rails&utm_medium=referral&utm_campaign=readme)
|
18
16
|
|
19
17
|
---
|
@@ -26,6 +24,7 @@ This gem can help your rails application integrate with Stripe in the following
|
|
26
24
|
- [Configuring your plans and coupons](#configuring-your-plans-and-coupons)
|
27
25
|
|
28
26
|
[Stripe Elements](#stripe-elements)
|
27
|
+
- [Custom Elements](#custom-elements)
|
29
28
|
|
30
29
|
[Webhooks](#webhooks)
|
31
30
|
|
@@ -322,6 +321,22 @@ Simply include the `stripe_elements_tag` anywhere below the `stripe_javascript_t
|
|
322
321
|
<%= stripe_elements_tag submit_path: billing_path %>
|
323
322
|
```
|
324
323
|
|
324
|
+
Additionally, you can pass a block containing custom form elements to stripe_elements_tag:
|
325
|
+
|
326
|
+
## Custom Elements
|
327
|
+
|
328
|
+
> Stripe::Rails allows you to easily include your own custom form elements
|
329
|
+
> within the Stripe form by including those form elements in a block passed to
|
330
|
+
> `stripe_elements_tag`:
|
331
|
+
|
332
|
+
```erb
|
333
|
+
<%= stripe_javascript_tag %>
|
334
|
+
<%= stripe_elements_tag(submit_path: billing_path) do %>
|
335
|
+
<%= label_tag 'email', 'Email' %>
|
336
|
+
<%= text_field :user, :email %>
|
337
|
+
<% end %>
|
338
|
+
```
|
339
|
+
|
325
340
|
### Configuration options
|
326
341
|
|
327
342
|
Stripe::Rails comes bundled with default CSS and Javascript for Stripe elements, making it easy to drop in to your app. You can also specify your own assets paths:
|
@@ -10,14 +10,16 @@ module Stripe
|
|
10
10
|
|
11
11
|
def stripe_elements_tag(submit_path:,
|
12
12
|
css_path: asset_path("stripe_elements.css"),
|
13
|
-
js_path: asset_path("stripe_elements.js")
|
13
|
+
js_path: asset_path("stripe_elements.js"),
|
14
|
+
&block)
|
14
15
|
|
15
16
|
render partial: 'stripe/elements', locals: {
|
16
17
|
submit_path: submit_path,
|
17
18
|
label_text: t('stripe_rails.elements.label_text'),
|
18
19
|
submit_button_text: t('stripe_rails.elements.submit_button_text'),
|
19
20
|
css_path: css_path,
|
20
|
-
js_path: js_path
|
21
|
+
js_path: js_path,
|
22
|
+
block: block
|
21
23
|
}
|
22
24
|
end
|
23
25
|
end
|
@@ -5,6 +5,11 @@
|
|
5
5
|
</div>
|
6
6
|
|
7
7
|
<%= form_tag submit_path, id: "stripe-form" do %>
|
8
|
+
<% if local_assigns[:block] %>
|
9
|
+
<div id="stripe-rails-form-fields">
|
10
|
+
<%= capture(&local_assigns[:block]) %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
8
13
|
<%= label_tag :card_element, label_text %>
|
9
14
|
<div id="card-element"><!-- A Stripe Element will be inserted here. --></div>
|
10
15
|
<%= submit_tag submit_button_text %>
|
data/gemfiles/rails51.gemfile
CHANGED
data/gemfiles/rails52.gemfile
CHANGED
data/gemfiles/rails60.gemfile
CHANGED
data/lib/stripe/prices.rb
CHANGED
@@ -16,6 +16,7 @@ module Stripe
|
|
16
16
|
:product_id,
|
17
17
|
:recurring,
|
18
18
|
:statement_descriptor,
|
19
|
+
:tax_behavior,
|
19
20
|
:tiers,
|
20
21
|
:tiers_mode,
|
21
22
|
:transform_quantity,
|
@@ -40,6 +41,7 @@ module Stripe
|
|
40
41
|
validates :billing_scheme, inclusion: { in: %w{ per_unit tiered } }, allow_nil: true
|
41
42
|
validates :recurring_aggregate_usage, inclusion: { in: %w{ sum last_during_period last_ever max } }, allow_nil: true
|
42
43
|
validates :recurring_usage_type, inclusion: { in: %w{ metered licensed } }, allow_nil: true
|
44
|
+
validates :tax_behavior, inclusion: { in: %w{ inclusive exclusive unspecified } }, allow_nil: true
|
43
45
|
validates :tiers_mode, inclusion: { in: %w{ graduated volume } }, allow_nil: true
|
44
46
|
|
45
47
|
validate :name_or_product_id
|
@@ -171,6 +173,7 @@ module Stripe
|
|
171
173
|
tiers_mode: tiers_mode,
|
172
174
|
billing_scheme: billing_scheme,
|
173
175
|
lookup_key: @lookup_key,
|
176
|
+
tax_behavior: tax_behavior,
|
174
177
|
transform_quantity: transform_quantity,
|
175
178
|
}.merge(product_options).compact
|
176
179
|
end
|
data/lib/stripe/rails/version.rb
CHANGED
@@ -6,6 +6,12 @@ Stripe.price :gold do |price|
|
|
6
6
|
}
|
7
7
|
end
|
8
8
|
|
9
|
+
Stripe.price :taxable_gold do |price|
|
10
|
+
price.name = 'Taxable Gold'
|
11
|
+
price.unit_amount = 699
|
12
|
+
price.tax_behavior = 'exclusive'
|
13
|
+
end
|
14
|
+
|
9
15
|
Stripe.price "Solid Gold".to_sym do |price|
|
10
16
|
price.constant_name = 'SOLID_GOLD'
|
11
17
|
price.name = 'Solid Gold'
|
@@ -77,5 +77,15 @@ describe Stripe::JavascriptHelper do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
describe 'with block' do
|
82
|
+
let(:markup) { '<input type="text" />'.html_safe }
|
83
|
+
|
84
|
+
it 'should display block contents' do
|
85
|
+
block = lambda { markup }
|
86
|
+
result = view.stripe_elements_tag(submit_path: '/charge', &block)
|
87
|
+
assert_match %r%<input type="text" />%, result
|
88
|
+
end
|
89
|
+
end
|
80
90
|
end
|
81
91
|
end
|
data/test/price_builder_spec.rb
CHANGED
@@ -267,6 +267,46 @@ describe 'building prices' do
|
|
267
267
|
}).must_raise Stripe::InvalidConfigurationError
|
268
268
|
end
|
269
269
|
|
270
|
+
it 'denies invalid tax_behavior' do
|
271
|
+
_(lambda {
|
272
|
+
Stripe.price :broken do |price|
|
273
|
+
price.name = 'Invalid tax'
|
274
|
+
price.unit_amount = 999
|
275
|
+
price.tax_behavior = 'whatever'
|
276
|
+
end
|
277
|
+
}).must_raise Stripe::InvalidConfigurationError
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'accepts a tax_behavior of exclusive' do
|
281
|
+
Stripe.price :exclusive do |price|
|
282
|
+
price.name = 'Exclusive tax'
|
283
|
+
price.unit_amount = 4800
|
284
|
+
price.tax_behavior = 'exclusive'
|
285
|
+
end
|
286
|
+
|
287
|
+
_(Stripe::Prices::EXCLUSIVE).wont_be_nil
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'accepts a tax_behavior of inclusive' do
|
291
|
+
Stripe.price :inclusive do |price|
|
292
|
+
price.name = 'Inclusive tax'
|
293
|
+
price.unit_amount = 4800
|
294
|
+
price.tax_behavior = 'inclusive'
|
295
|
+
end
|
296
|
+
|
297
|
+
_(Stripe::Prices::INCLUSIVE).wont_be_nil
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'accepts a tax_behavior of unspecified' do
|
301
|
+
Stripe.price :unspecified do |price|
|
302
|
+
price.name = 'Unspecified tax'
|
303
|
+
price.unit_amount = 4800
|
304
|
+
price.tax_behavior = 'unspecified'
|
305
|
+
end
|
306
|
+
|
307
|
+
_(Stripe::Prices::UNSPECIFIED).wont_be_nil
|
308
|
+
end
|
309
|
+
|
270
310
|
describe 'name and product id validation' do
|
271
311
|
it 'should be valid when using just the product id' do
|
272
312
|
Stripe.price :prodded do |price|
|
@@ -322,6 +362,22 @@ describe 'building prices' do
|
|
322
362
|
Stripe::Prices::GOLD.put!
|
323
363
|
end
|
324
364
|
|
365
|
+
it 'creates a price with tax_behavior' do
|
366
|
+
Stripe::Price.expects(:create).with(
|
367
|
+
:lookup_key => 'taxable_gold',
|
368
|
+
:nickname => 'taxable_gold',
|
369
|
+
:currency => 'usd',
|
370
|
+
:product_data => {
|
371
|
+
:name => 'Taxable Gold',
|
372
|
+
:statement_descriptor => nil
|
373
|
+
},
|
374
|
+
:unit_amount => 699,
|
375
|
+
:recurring => {},
|
376
|
+
:tax_behavior => 'exclusive'
|
377
|
+
)
|
378
|
+
Stripe::Prices::TAXABLE_GOLD.put!
|
379
|
+
end
|
380
|
+
|
325
381
|
it 'creates a price with an alternative currency' do
|
326
382
|
Stripe::Price.expects(:create).with(
|
327
383
|
:lookup_key => 'alternative_currency',
|
data/test/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ end
|
|
6
6
|
require 'minitest/autorun'
|
7
7
|
|
8
8
|
require 'webmock/minitest'
|
9
|
-
WebMock.disable_net_connect! allow_localhost: true, allow: ['codeclimate.com', 'chromedriver.storage.googleapis.com']
|
9
|
+
WebMock.disable_net_connect! allow_localhost: true, allow: ['codeclimate.com', 'chromedriver.storage.googleapis.com', 'googlechromelabs.github.io', 'storage.googleapis.com']
|
10
10
|
|
11
11
|
# Chrome Setup
|
12
12
|
require 'selenium-webdriver'
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
8
8
|
- Nola Stowe
|
9
9
|
- SengMing Tan
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-03-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -173,7 +173,7 @@ homepage: https://github.com/tansengming/stripe-rails
|
|
173
173
|
licenses:
|
174
174
|
- MIT
|
175
175
|
metadata: {}
|
176
|
-
post_install_message:
|
176
|
+
post_install_message:
|
177
177
|
rdoc_options: []
|
178
178
|
require_paths:
|
179
179
|
- lib
|
@@ -188,8 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
191
|
+
rubygems_version: 3.5.5
|
192
|
+
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: A gem to integrate stripe into your rails app
|
195
195
|
test_files:
|