stripe-rails 0.4.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +30 -2
- data/Changelog.md +9 -0
- data/Gemfile +4 -0
- data/README.md +5 -4
- data/app/helpers/stripe/javascript_helper.rb +1 -1
- data/gemfiles/rails4.gemfile +15 -0
- data/gemfiles/rails5.gemfile +15 -0
- data/lib/stripe/callbacks.rb +52 -20
- data/lib/stripe/plans.rb +10 -4
- data/lib/stripe/rails/version.rb +1 -1
- data/stripe-rails.gemspec +1 -1
- data/test/callbacks_spec.rb +6 -2
- data/test/event.json +19 -0
- data/test/invoice.json +81 -0
- data/test/javascript_helper_spec.rb +10 -14
- data/test/plan_builder_spec.rb +30 -2
- data/test/spec_helper.rb +3 -0
- metadata +13 -9
- data/test/invoice_payment_succeeded.json +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b07e6ff640777c2280d2dd29d46ddb72f8412ffb
|
4
|
+
data.tar.gz: 952adfc0b8538e40e53b0eaf59b1c6620c7c418e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caeda4e7f70ed9b564abaf7f065dd25591aaedf8cf57f7b95a71274b5a10bd269c6a55ab60ebe0487de8ed6941b7dd5f154981f4e7d4b7b87b4ba8f4c42112c5
|
7
|
+
data.tar.gz: c2f965d400379c69d80c02055f30d288630793142aa02736fad46ba4cf33dd201b6f546248301e6d6bd43b361aff613ddae81b1b7a22e13b6b321783813ff30b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,8 +1,36 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
3
|
+
- 2.4.1
|
4
|
+
- 2.3.4
|
5
|
+
- 2.2.7
|
6
|
+
- 2.1.9
|
4
7
|
notifications:
|
5
8
|
email:
|
6
9
|
recipients:
|
7
10
|
- cowboyd@thefrontside.net
|
8
|
-
|
11
|
+
env:
|
12
|
+
global:
|
13
|
+
- GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
|
14
|
+
before_script:
|
15
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
+
- chmod +x ./cc-test-reporter
|
17
|
+
- ./cc-test-reporter before-build
|
18
|
+
script:
|
19
|
+
- bundle exec rake
|
20
|
+
# Preferably you will run test-reporter on branch update events. But
|
21
|
+
# if you setup travis to build PR updates only, you don't need to run
|
22
|
+
# the line below
|
23
|
+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ `basename $BUNDLE_GEMFILE` == "Gemfile" ] && [ ${RUBY_VERSION:5:3} == "2.4" ] ; then echo "Sending Coverage..."; ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
|
24
|
+
# In the case where travis is setup to build PR updates only,
|
25
|
+
# uncomment the line below
|
26
|
+
# - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
27
|
+
gemfile:
|
28
|
+
- Gemfile
|
29
|
+
- gemfiles/rails4.gemfile
|
30
|
+
- gemfiles/rails5.gemfile
|
31
|
+
matrix:
|
32
|
+
exclude:
|
33
|
+
- rvm: 2.1.9
|
34
|
+
gemfile: Gemfile
|
35
|
+
- rvm: 2.1.9
|
36
|
+
gemfile: gemfiles/rails5.gemfile
|
data/Changelog.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.0.0 (2017-07-24 - Breaky McBreakface)
|
2
|
+
|
3
|
+
* [BREAKING] Update to latest stripe events (thanks @hopsoft). Note that if you are using the `after_customer_card_created`, `after_customer_card_updated` or `after_customer_card_deleted` callbacks, you MUST update them to `after_customer_source_created`, `after_customer_source_updated` or `after_customer_source_deleted` respectively. You also need to start using [Stripe API Version > 2015-02-18](https://stripe.com/docs/upgrades#2015-02-18) or else the webhook might not work as expected.
|
4
|
+
* [BREAKING] Updates to the [latest version of Stripe JS](https://github.com/Everapps/stripe-rails/pull/69). If you were using `stripe_javascript_tag` without specifying the version number, note that it will now default to Stripe JS v3. This version is incompatible with the previous default.
|
5
|
+
* The gem will only be tested on Rails 4 and 5 [from now on](https://github.com/Everapps/stripe-rails/pull/62).
|
6
|
+
* Gem will henceforth only [be tested](https://github.com/Everapps/stripe-rails/pull/68) on Ruby >= 2.1.9.
|
7
|
+
* add statement descriptor to plan attributes (thanks @jbender)
|
8
|
+
* Relax version constraint on the responders gem
|
9
|
+
|
1
10
|
## 0.4.1 (2017-06-01)
|
2
11
|
|
3
12
|
* Support for api_version header parameter (thanks @kiddrew)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Stripe::Rails: A Rails Engine for use with [stripe.com](https://stripe.com)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/stripe-rails.png)](http://badge.fury.io/rb/stripe-rails)
|
3
3
|
[![Build Status](https://travis-ci.org/Everapps/stripe-rails.png?branch=master)](https://travis-ci.org/Everapps/stripe-rails)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/Everapps/stripe-rails/badges/gpa.svg)](https://codeclimate.com/github/Everapps/stripe-rails)
|
4
5
|
[![Dependency Status](https://gemnasium.com/thefrontside/stripe-rails.png)](https://gemnasium.com/thefrontside/stripe-rails)
|
5
6
|
|
6
7
|
|
@@ -44,11 +45,11 @@ config.stripe.debug_js = true # use stripe-debug.js
|
|
44
45
|
config.stripe.debug_js = false # use stripe.js
|
45
46
|
```
|
46
47
|
|
47
|
-
By default the helper renders the `
|
48
|
+
By default the helper renders the `v3` version of `stripe.js`. You can provide an
|
48
49
|
alternate version to the helper to generate the appropriate tag:
|
49
50
|
|
50
51
|
```erb
|
51
|
-
<%= stripe_javascript_tag(:
|
52
|
+
<%= stripe_javascript_tag(:v2) %>
|
52
53
|
```
|
53
54
|
|
54
55
|
### Setup your API keys.
|
@@ -190,7 +191,7 @@ parameter. E.g.
|
|
190
191
|
config.stripe.endpoint = '/payment/stripe-integration'
|
191
192
|
```
|
192
193
|
|
193
|
-
Your new
|
194
|
+
Your new webhook URL would then be `http://myproductionapp/payment/stripe-integration/events`
|
194
195
|
|
195
196
|
### Disabling auto mount
|
196
197
|
|
@@ -333,7 +334,7 @@ its parameter:
|
|
333
334
|
module StagingOnly
|
334
335
|
include Stripe::Callbacks
|
335
336
|
|
336
|
-
|
337
|
+
after_charge_succeeded! :only => proc {|charge, evt| unless evt.livemode} do |charge|
|
337
338
|
puts "FAKE DATA, PLEASE IGNORE!"
|
338
339
|
end
|
339
340
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'rails', '~> 4'
|
4
|
+
|
5
|
+
gem "bundler", ">= 1.3.0"
|
6
|
+
gem "rake"
|
7
|
+
gem 'tzinfo'
|
8
|
+
gem 'mocha'
|
9
|
+
gem 'pry'
|
10
|
+
gem 'responders', '~> 2.0' # to support Rails 4.2
|
11
|
+
gem 'stripe'
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'simplecov', require: false
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'rails', '~> 5'
|
4
|
+
|
5
|
+
gem "bundler", ">= 1.3.0"
|
6
|
+
gem "rake"
|
7
|
+
gem 'tzinfo'
|
8
|
+
gem 'mocha'
|
9
|
+
gem 'pry'
|
10
|
+
gem 'responders', '~> 2.0' # to support Rails 4.2
|
11
|
+
gem 'stripe'
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'simplecov', require: false
|
15
|
+
end
|
data/lib/stripe/callbacks.rb
CHANGED
@@ -6,44 +6,76 @@ module Stripe
|
|
6
6
|
|
7
7
|
callback 'account.updated'
|
8
8
|
callback 'account.application.deauthorized'
|
9
|
+
callback 'account.external_account.created'
|
10
|
+
callback 'account.external_account.deleted'
|
11
|
+
callback 'account.external_account.updated'
|
12
|
+
callback 'application_fee.created'
|
13
|
+
callback 'application_fee.refunded'
|
14
|
+
callback 'application_fee.refund.updated'
|
9
15
|
callback 'balance.available'
|
10
|
-
callback '
|
16
|
+
callback 'bitcoin.receiver.created'
|
17
|
+
callback 'bitcoin.receiver.filled'
|
18
|
+
callback 'bitcoin.receiver.updated'
|
19
|
+
callback 'bitcoin.receiver.transaction.created'
|
20
|
+
callback 'charge.captured'
|
11
21
|
callback 'charge.failed'
|
22
|
+
callback 'charge.pending'
|
12
23
|
callback 'charge.refunded'
|
13
|
-
callback 'charge.
|
24
|
+
callback 'charge.succeeded'
|
25
|
+
callback 'charge.updated'
|
26
|
+
callback 'charge.dispute.closed'
|
14
27
|
callback 'charge.dispute.created'
|
28
|
+
callback 'charge.dispute.funds_reinstated'
|
29
|
+
callback 'charge.dispute.funds_withdrawn'
|
15
30
|
callback 'charge.dispute.updated'
|
16
|
-
callback '
|
31
|
+
callback 'coupon.created'
|
32
|
+
callback 'coupon.deleted'
|
33
|
+
callback 'coupon.updated'
|
17
34
|
callback 'customer.created'
|
18
|
-
callback 'customer.updated'
|
19
35
|
callback 'customer.deleted'
|
20
|
-
callback 'customer.
|
21
|
-
callback 'customer.
|
22
|
-
callback 'customer.
|
36
|
+
callback 'customer.updated'
|
37
|
+
callback 'customer.discount.created'
|
38
|
+
callback 'customer.discount.deleted'
|
39
|
+
callback 'customer.discount.updated'
|
40
|
+
callback 'customer.source.created'
|
41
|
+
callback 'customer.source.deleted'
|
42
|
+
callback 'customer.source.updated'
|
23
43
|
callback 'customer.subscription.created'
|
24
|
-
callback 'customer.subscription.updated'
|
25
44
|
callback 'customer.subscription.deleted'
|
26
45
|
callback 'customer.subscription.trial_will_end'
|
27
|
-
callback 'customer.
|
28
|
-
callback 'customer.discount.updated'
|
29
|
-
callback 'customer.discount.deleted'
|
46
|
+
callback 'customer.subscription.updated'
|
30
47
|
callback 'invoice.created'
|
31
|
-
callback 'invoice.updated'
|
32
|
-
callback 'invoice.payment_succeeded'
|
33
48
|
callback 'invoice.payment_failed'
|
49
|
+
callback 'invoice.payment_succeeded'
|
50
|
+
callback 'invoice.updated'
|
34
51
|
callback 'invoiceitem.created'
|
35
|
-
callback 'invoiceitem.updated'
|
36
52
|
callback 'invoiceitem.deleted'
|
53
|
+
callback 'invoiceitem.updated'
|
54
|
+
callback 'order.created'
|
55
|
+
callback 'order.payment_failed'
|
56
|
+
callback 'order.payment_succeeded'
|
57
|
+
callback 'order.updated'
|
58
|
+
callback 'order_return.created'
|
37
59
|
callback 'plan.created'
|
38
|
-
callback 'plan.updated'
|
39
60
|
callback 'plan.deleted'
|
40
|
-
callback '
|
41
|
-
callback '
|
42
|
-
callback '
|
61
|
+
callback 'plan.updated'
|
62
|
+
callback 'product.created'
|
63
|
+
callback 'product.deleted'
|
64
|
+
callback 'product.updated'
|
65
|
+
callback 'recipient.created'
|
66
|
+
callback 'recipient.deleted'
|
67
|
+
callback 'recipient.updated'
|
68
|
+
callback 'sku.created'
|
69
|
+
callback 'sku.deleted'
|
70
|
+
callback 'sku.updated'
|
71
|
+
callback 'source.canceled'
|
72
|
+
callback 'source.chargeable'
|
73
|
+
callback 'source.failed'
|
43
74
|
callback 'transfer.created'
|
44
|
-
callback 'transfer.updated'
|
45
|
-
callback 'transfer.paid'
|
46
75
|
callback 'transfer.failed'
|
76
|
+
callback 'transfer.paid'
|
77
|
+
callback 'transfer.reversed'
|
78
|
+
callback 'transfer.updated'
|
47
79
|
callback 'ping'
|
48
80
|
callback 'stripe.event'
|
49
81
|
|
data/lib/stripe/plans.rb
CHANGED
@@ -3,10 +3,15 @@ module Stripe
|
|
3
3
|
include ConfigurationBuilder
|
4
4
|
|
5
5
|
configuration_for :plan do
|
6
|
-
attr_accessor :name, :amount, :interval, :interval_count, :trial_period_days,
|
6
|
+
attr_accessor :name, :amount, :interval, :interval_count, :trial_period_days,
|
7
|
+
:currency, :metadata, :statement_descriptor
|
7
8
|
|
8
|
-
validates_presence_of :id, :
|
9
|
-
|
9
|
+
validates_presence_of :id, :amount, :currency, :name
|
10
|
+
|
11
|
+
validates_inclusion_of :interval, :in => %w(week month year),
|
12
|
+
:message => "'%{value}' is not one of 'week', 'month' or 'year'"
|
13
|
+
|
14
|
+
validates :statement_descriptor, :length => { :maximum => 22 }
|
10
15
|
|
11
16
|
def initialize(*args)
|
12
17
|
super(*args)
|
@@ -23,7 +28,8 @@ module Stripe
|
|
23
28
|
:interval => @interval,
|
24
29
|
:interval_count => @interval_count,
|
25
30
|
:trial_period_days => @trial_period_days,
|
26
|
-
:metadata => @metadata
|
31
|
+
:metadata => @metadata,
|
32
|
+
:statement_descriptor => @statement_descriptor
|
27
33
|
}
|
28
34
|
end
|
29
35
|
end
|
data/lib/stripe/rails/version.rb
CHANGED
data/stripe-rails.gemspec
CHANGED
data/test/callbacks_spec.rb
CHANGED
@@ -16,9 +16,13 @@ describe Stripe::Callbacks do
|
|
16
16
|
include Stripe::Callbacks
|
17
17
|
end
|
18
18
|
end
|
19
|
-
@content = JSON.parse(File.read File.expand_path('../invoice_payment_succeeded.json', __FILE__))
|
20
|
-
self.type = @content['type']
|
21
19
|
|
20
|
+
event = JSON.parse(File.read File.expand_path('../event.json', __FILE__))
|
21
|
+
invoice = JSON.parse(File.read File.expand_path('../invoice.json', __FILE__))
|
22
|
+
event['data']['object'] = invoice
|
23
|
+
|
24
|
+
@content = event
|
25
|
+
self.type = @content['type']
|
22
26
|
end
|
23
27
|
|
24
28
|
def type=(type)
|
data/test/event.json
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"api_version": "2017-02-14",
|
3
|
+
"created": 1234567890,
|
4
|
+
"customer_email": "",
|
5
|
+
"data": {
|
6
|
+
"object": {
|
7
|
+
}
|
8
|
+
},
|
9
|
+
"id": "evt_19tLKfDSlTMT26MkKD3pohqX",
|
10
|
+
"livemode": false,
|
11
|
+
"object": "event",
|
12
|
+
"pending_webhooks": 0,
|
13
|
+
"recipient_best_description": "",
|
14
|
+
"request": {
|
15
|
+
"id": "req_ArJ9y3DcEShbw2",
|
16
|
+
"idempotency_key": null
|
17
|
+
},
|
18
|
+
"type": "invoice.payment_succeeded"
|
19
|
+
}
|
data/test/invoice.json
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
{
|
2
|
+
"amount_due": 0,
|
3
|
+
"application_fee": 0,
|
4
|
+
"attempt_count": 0,
|
5
|
+
"attempted": true,
|
6
|
+
"billing": "",
|
7
|
+
"charge": "",
|
8
|
+
"closed": true,
|
9
|
+
"currency": "usd",
|
10
|
+
"customer": "cus_ADmuABetLS15eF",
|
11
|
+
"date": 1234567890,
|
12
|
+
"description": "",
|
13
|
+
"discount": {
|
14
|
+
},
|
15
|
+
"due_date": 1234567890,
|
16
|
+
"ending_balance": 0,
|
17
|
+
"forgiven": false,
|
18
|
+
"id": "in_19zuuiDSlTMT26Mk1XitxqCb",
|
19
|
+
"lines": {
|
20
|
+
"data": [
|
21
|
+
{
|
22
|
+
"amount": 2000,
|
23
|
+
"currency": "usd",
|
24
|
+
"description": null,
|
25
|
+
"discountable": true,
|
26
|
+
"id": "sub_AKa4uss8vCMAZC",
|
27
|
+
"livemode": true,
|
28
|
+
"metadata": {
|
29
|
+
},
|
30
|
+
"object": "line_item",
|
31
|
+
"period": {
|
32
|
+
"end": 1495403592,
|
33
|
+
"start": 1492811592
|
34
|
+
},
|
35
|
+
"plan": {
|
36
|
+
"amount": 2000,
|
37
|
+
"created": 1488566449,
|
38
|
+
"currency": "usd",
|
39
|
+
"id": "gold",
|
40
|
+
"interval": "month",
|
41
|
+
"interval_count": 1,
|
42
|
+
"livemode": false,
|
43
|
+
"metadata": {
|
44
|
+
},
|
45
|
+
"name": "Gold Special",
|
46
|
+
"object": "plan",
|
47
|
+
"statement_descriptor": null,
|
48
|
+
"trial_period_days": null
|
49
|
+
},
|
50
|
+
"proration": false,
|
51
|
+
"quantity": 1,
|
52
|
+
"subscription": null,
|
53
|
+
"subscription_item": "si_19zuuiDSlTMT26Mk9HayBPe9",
|
54
|
+
"type": "subscription"
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"object": "list",
|
58
|
+
"total_count": 1,
|
59
|
+
"url": "/v1/invoices/in_19zuuiDSlTMT26Mk1XitxqCb/lines"
|
60
|
+
},
|
61
|
+
"livemode": false,
|
62
|
+
"metadata": {
|
63
|
+
},
|
64
|
+
"next_payment_attempt": 1234567890,
|
65
|
+
"number": "",
|
66
|
+
"object": "invoice",
|
67
|
+
"paid": true,
|
68
|
+
"period_end": 1234567890,
|
69
|
+
"period_start": 1234567890,
|
70
|
+
"receipt_number": "",
|
71
|
+
"send_next_at": 1234567890,
|
72
|
+
"starting_balance": 0,
|
73
|
+
"statement_descriptor": "",
|
74
|
+
"subscription": "",
|
75
|
+
"subscription_proration_date": 0,
|
76
|
+
"subtotal": 0,
|
77
|
+
"tax": 0,
|
78
|
+
"tax_percent": 0.0,
|
79
|
+
"total": 6999,
|
80
|
+
"webhooks_delivered_at": 1234567890
|
81
|
+
}
|
@@ -2,36 +2,32 @@ require 'minitest/autorun'
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Stripe::JavascriptHelper do
|
5
|
-
before
|
6
|
-
|
7
|
-
|
8
|
-
@controller = ActionView::TestCase::TestController.new
|
9
|
-
@view = @controller.view_context
|
10
|
-
@view.singleton_class.include(Stripe::JavascriptHelper)
|
11
|
-
end
|
5
|
+
before { Rails.application.config.stripe.publishable_key = 'pub_xxxx' }
|
6
|
+
let(:controller) { ActionView::TestCase::TestController.new }
|
7
|
+
let(:view) { controller.view_context }
|
12
8
|
|
13
9
|
describe '#stripe_javascript_tag' do
|
14
10
|
describe 'when no options are passed' do
|
15
|
-
it 'should default to
|
16
|
-
|
11
|
+
it 'should default to v3' do
|
12
|
+
view.stripe_javascript_tag.must_include 'https://js.stripe.com/v3/'
|
17
13
|
end
|
18
14
|
end
|
19
15
|
|
20
|
-
describe 'when the
|
21
|
-
it 'should default to
|
22
|
-
|
16
|
+
describe 'when the v2 option is passed' do
|
17
|
+
it 'should default to v2' do
|
18
|
+
view.stripe_javascript_tag(:v2).must_include 'https://js.stripe.com/v2/'
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
22
|
describe 'when the debug flag is enabled' do
|
27
23
|
before { Rails.application.config.stripe.debug_js = true }
|
28
24
|
it 'should render the debug js' do
|
29
|
-
|
25
|
+
view.stripe_javascript_tag(:v1).must_include 'https://js.stripe.com/v1/stripe-debug.js'
|
30
26
|
end
|
31
27
|
|
32
28
|
describe 'when v3 is selected' do
|
33
29
|
it 'should not render debug js' do
|
34
|
-
|
30
|
+
view.stripe_javascript_tag(:v3).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
data/test/plan_builder_spec.rb
CHANGED
@@ -11,8 +11,10 @@ describe 'building plans' do
|
|
11
11
|
plan.interval_count = 3
|
12
12
|
plan.trial_period_days = 30
|
13
13
|
plan.metadata = {:number_of_awesome_things => 5}
|
14
|
+
plan.statement_descriptor = 'Acme Primo'
|
14
15
|
end
|
15
16
|
end
|
17
|
+
|
16
18
|
after do
|
17
19
|
Stripe::Plans.send(:remove_const, :PRIMO)
|
18
20
|
end
|
@@ -70,6 +72,28 @@ describe 'building plans' do
|
|
70
72
|
}.must_raise Stripe::InvalidConfigurationError
|
71
73
|
end
|
72
74
|
|
75
|
+
it 'accepts a statement descriptor' do
|
76
|
+
Stripe.plan :described do |plan|
|
77
|
+
plan.name = 'Acme as a service'
|
78
|
+
plan.amount = 999
|
79
|
+
plan.interval = 'month'
|
80
|
+
plan.statement_descriptor = 'ACME Monthly'
|
81
|
+
end
|
82
|
+
|
83
|
+
Stripe::Plans::DESCRIBED.wont_be_nil
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'denies statement descriptors that are too long' do
|
87
|
+
lambda {
|
88
|
+
Stripe.plan :described do |plan|
|
89
|
+
plan.name = 'Acme as a service'
|
90
|
+
plan.amount = 999
|
91
|
+
plan.interval = 'month'
|
92
|
+
plan.statement_descriptor = 'ACME as a Service Monthly'
|
93
|
+
end
|
94
|
+
}.must_raise Stripe::InvalidConfigurationError
|
95
|
+
end
|
96
|
+
|
73
97
|
describe 'uploading' do
|
74
98
|
describe 'when none exists on stripe.com' do
|
75
99
|
before do
|
@@ -85,7 +109,8 @@ describe 'building plans' do
|
|
85
109
|
:interval => 'month',
|
86
110
|
:interval_count => 1,
|
87
111
|
:trial_period_days => 0,
|
88
|
-
:metadata => nil
|
112
|
+
:metadata => nil,
|
113
|
+
:statement_descriptor => nil
|
89
114
|
)
|
90
115
|
Stripe::Plans::GOLD.put!
|
91
116
|
end
|
@@ -99,12 +124,14 @@ describe 'building plans' do
|
|
99
124
|
:interval => 'month',
|
100
125
|
:interval_count => 1,
|
101
126
|
:trial_period_days => 0,
|
102
|
-
:metadata => nil
|
127
|
+
:metadata => nil,
|
128
|
+
:statement_descriptor => nil
|
103
129
|
)
|
104
130
|
Stripe::Plans::ALTERNATIVE_CURRENCY.put!
|
105
131
|
end
|
106
132
|
|
107
133
|
end
|
134
|
+
|
108
135
|
describe 'when it is already present on stripe.com' do
|
109
136
|
before do
|
110
137
|
Stripe::Plan.stubs(:retrieve).returns(Stripe::Plan.construct_from({
|
@@ -112,6 +139,7 @@ describe 'building plans' do
|
|
112
139
|
:name => 'Solid Gold'
|
113
140
|
}))
|
114
141
|
end
|
142
|
+
|
115
143
|
it 'is a no-op' do
|
116
144
|
Stripe::Plan.expects(:create).never
|
117
145
|
Stripe::Plans::GOLD.put!
|
data/test/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: responders
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0'
|
56
56
|
description: A gem to integrate stripe into your rails app
|
57
57
|
email:
|
58
58
|
- cowboyd@frontside.io
|
@@ -76,6 +76,8 @@ files:
|
|
76
76
|
- app/models/stripe/ping.rb
|
77
77
|
- app/views/stripe/_js.html.erb
|
78
78
|
- config/routes.rb
|
79
|
+
- gemfiles/rails4.gemfile
|
80
|
+
- gemfiles/rails5.gemfile
|
79
81
|
- lib/generators/stripe/install_generator.rb
|
80
82
|
- lib/generators/templates/coupons.rb
|
81
83
|
- lib/generators/templates/plans.rb
|
@@ -128,7 +130,8 @@ files:
|
|
128
130
|
- test/dummy/public/500.html
|
129
131
|
- test/dummy/public/favicon.ico
|
130
132
|
- test/dummy/script/rails
|
131
|
-
- test/
|
133
|
+
- test/event.json
|
134
|
+
- test/invoice.json
|
132
135
|
- test/javascript_helper_spec.rb
|
133
136
|
- test/plan_builder_spec.rb
|
134
137
|
- test/spec_helper.rb
|
@@ -153,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
156
|
version: '0'
|
154
157
|
requirements: []
|
155
158
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.6.8
|
157
160
|
signing_key:
|
158
161
|
specification_version: 4
|
159
162
|
summary: A gem to integrate stripe into your rails app
|
@@ -196,7 +199,8 @@ test_files:
|
|
196
199
|
- test/dummy/public/500.html
|
197
200
|
- test/dummy/public/favicon.ico
|
198
201
|
- test/dummy/script/rails
|
199
|
-
- test/
|
202
|
+
- test/event.json
|
203
|
+
- test/invoice.json
|
200
204
|
- test/javascript_helper_spec.rb
|
201
205
|
- test/plan_builder_spec.rb
|
202
206
|
- test/spec_helper.rb
|
@@ -1,65 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"type": "invoice.payment_succeeded",
|
3
|
-
"livemode": false,
|
4
|
-
"pending_webhooks": 0,
|
5
|
-
"created": 1352910508,
|
6
|
-
"object": "event",
|
7
|
-
"id": "evt_0jcGFxHNsrDTj4",
|
8
|
-
"data": {
|
9
|
-
"object": {
|
10
|
-
"starting_balance": 0,
|
11
|
-
"ending_balance": 0,
|
12
|
-
"paid": true,
|
13
|
-
"attempted": true,
|
14
|
-
"total": 6999,
|
15
|
-
"lines": {
|
16
|
-
"object": "list",
|
17
|
-
"count": 1,
|
18
|
-
"data": [
|
19
|
-
{
|
20
|
-
"type": "subscription",
|
21
|
-
"plan": {
|
22
|
-
"livemode": false,
|
23
|
-
"object": "plan",
|
24
|
-
"interval_count": 1,
|
25
|
-
"amount": 6999,
|
26
|
-
"name": "BandFrame PRO Annual",
|
27
|
-
"currency": "usd",
|
28
|
-
"id": "yearly",
|
29
|
-
"interval": "year",
|
30
|
-
"trial_period_days": null
|
31
|
-
},
|
32
|
-
"livemode": false,
|
33
|
-
"object": "line_item",
|
34
|
-
"description": null,
|
35
|
-
"amount": 6999,
|
36
|
-
"currency": "usd",
|
37
|
-
"period": {
|
38
|
-
"end": 1384446507,
|
39
|
-
"start": 1352910507
|
40
|
-
},
|
41
|
-
"id": "su_0jcGpDYAkeNj0a",
|
42
|
-
"proration": false,
|
43
|
-
"quantity": 1
|
44
|
-
}
|
45
|
-
],
|
46
|
-
"url": "/v1/invoices/in_0jcG7zz2RtscPB/lines"
|
47
|
-
},
|
48
|
-
"subtotal": 6999,
|
49
|
-
"livemode": false,
|
50
|
-
"period_start": 1352910503,
|
51
|
-
"charge": "ch_0jcGRmThyuRYyh",
|
52
|
-
"object": "invoice",
|
53
|
-
"customer": "cus_0jcFnB3UIIiicv",
|
54
|
-
"period_end": 1352910507,
|
55
|
-
"discount": null,
|
56
|
-
"next_payment_attempt": null,
|
57
|
-
"currency": "usd",
|
58
|
-
"date": 1352910507,
|
59
|
-
"closed": true,
|
60
|
-
"id": "in_0jcG7zz2RtscPB",
|
61
|
-
"attempt_count": 0,
|
62
|
-
"amount_due": 6999
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|