fiat_stripe 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +91 -0
- data/Rakefile +32 -0
- data/app/assets/config/fiat_stripe_manifest.js +2 -0
- data/app/assets/javascripts/fiat_stripe/application.js +15 -0
- data/app/assets/stylesheets/fiat_stripe/application.css +15 -0
- data/app/controllers/fiat_stripe/application_controller.rb +5 -0
- data/app/controllers/fiat_stripe/stripe_controller.rb +18 -0
- data/app/controllers/fiat_stripe/subscriptions_controller.rb +8 -0
- data/app/helpers/card_helper.rb +30 -0
- data/app/helpers/fiat_stripe/application_helper.rb +4 -0
- data/app/jobs/fiat_stripe/application_job.rb +4 -0
- data/app/jobs/fiat_stripe/subscription/cancel_stripe_subscription_job.rb +10 -0
- data/app/jobs/fiat_stripe/subscription/create_stripe_subscription_job.rb +24 -0
- data/app/jobs/fiat_stripe/subscription/update_stripe_subscription_job.rb +28 -0
- data/app/mailers/fiat_stripe/application_mailer.rb +6 -0
- data/app/models/concerns/stripeable.rb +111 -0
- data/app/models/fiat_stripe/application_record.rb +5 -0
- data/app/models/fiat_stripe/subscription.rb +44 -0
- data/app/views/layouts/fiat_stripe/application.html.erb +16 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20181004213428_create_fiat_stripe_subscriptions.rb +12 -0
- data/lib/fiat_stripe.rb +6 -0
- data/lib/fiat_stripe/engine.rb +12 -0
- data/lib/fiat_stripe/version.rb +3 -0
- data/lib/tasks/fiat_stripe_tasks.rake +4 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 39405774aeb607ed7423c0c565206a0d988821fb
|
4
|
+
data.tar.gz: 47e62f40fa50ab1f1465e240cc177e064f254fa6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f04ddec88aea2b6a59708354849ea6688dc83f998733d141099e66e97d073ddffb172c3b6443c7216150107f35a1352e7ec2a9d110d3ca1c241a92154012132
|
7
|
+
data.tar.gz: e3a197a8b208a6f1e9736055f3bee59baeafffe77d97f84b3ab32253f2f6f7156922201c94d3557fe91fc4b5d056a8d8e4928af282a5b5e23ac7dd6c19af73c9
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Andrew Haines
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Fiat Stripe
|
2
|
+
|
3
|
+
This gem is designed to be used by Fiat Insight developers on Rails projects that need to connect paying entities with Stripe.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fiat_stripe'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fiat_stripe
|
20
|
+
|
21
|
+
## Setup
|
22
|
+
|
23
|
+
You'll need to configure the `stripe` and `stripe_event` gems like normal.
|
24
|
+
|
25
|
+
Create an initializer at `config/initializers/fiat_stripe.rb` to set some global configs:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
FiatStripe.live_default_plan_id = "plan_id"
|
29
|
+
FiatStripe.test_default_plan_id = "plan_id"
|
30
|
+
```
|
31
|
+
|
32
|
+
Install the migrations in your app root folder by running:
|
33
|
+
|
34
|
+
$ rails fiat_stripe:install:migrations
|
35
|
+
$ rake db:migrate
|
36
|
+
|
37
|
+
To include all the helpers, add this line in your `ApplicationController`:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
helper FiatStripe::Engine.helpers
|
41
|
+
```
|
42
|
+
|
43
|
+
### Stripeable
|
44
|
+
|
45
|
+
The `Stripeable` concern for models does the work of ensuring a class is able to act as a Stripe customer. Call it using `include Stripeable`. You'll also need to make sure that any classes in your application that will connect as Stripe customers have the following database fields: `name`, `stripe_customer_id`, `stripe_card_token`, and `remove_card`.
|
46
|
+
|
47
|
+
Here is a sample migration generation for this:
|
48
|
+
|
49
|
+
$ rails g migration add_stripe_fields_to_xyz name:string stripe_customer_id:string stripe_card_token:string remove_card:boolean
|
50
|
+
|
51
|
+
### Subscriptions
|
52
|
+
|
53
|
+
Subscriptions handle the records and logic for controlling Stripe subscriptions in your app. And they connect directly to Stripe subscriptions to actively manage pricing.
|
54
|
+
|
55
|
+
You can choose how to initiate a subscription. They're not automatically created when a new Stripe customer ID is created. So, for example, on a `Stripeable` class, you could run:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
after_commit :create_subscription, on: :create
|
59
|
+
|
60
|
+
def create_subscription
|
61
|
+
FiatStripe::Subscription.create(subscriber_type: "ClassName", subscriber_id: self.id)
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
Or you could manually create subscriptions using a separate controller action, etc.
|
66
|
+
|
67
|
+
Extend the `Subscription` model to include `rate` logic by adding a file at `app/decorators/models/fiat_stripe/subscription_decorator.rb`:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
FiatStripe::Subscription.class_eval do
|
71
|
+
def rate
|
72
|
+
# Put logic here to calculate rate per payment period
|
73
|
+
# Note: monthly vs annual payment periods are determined by the plan_id that's active
|
74
|
+
# E.g., self.subscriber.rate
|
75
|
+
end
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
## Development
|
80
|
+
|
81
|
+
To build this gem for the first time, run `gem build fiat_stripe.gemspec` from the project folder.
|
82
|
+
|
83
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fiatinsight/fiat_stripe.
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'FiatStripe'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module FiatStripe
|
2
|
+
class StripeController < ActionController::Base
|
3
|
+
|
4
|
+
def create_stripe_customer_id
|
5
|
+
customer = Stripe::Customer.create(
|
6
|
+
description: params[:name],
|
7
|
+
email: params[:email]
|
8
|
+
)
|
9
|
+
|
10
|
+
# TODO: Figure out how to handle this
|
11
|
+
object_class = params[:object_class].constantize
|
12
|
+
object_id = params[:object_id].to_i
|
13
|
+
object_class.find(object_id).update_attributes(stripe_customer_id: customer.id)
|
14
|
+
redirect_back(fallback_location: nil, notice: 'Your payment profile was created.')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module CardHelper
|
2
|
+
def stripe_card_months
|
3
|
+
[
|
4
|
+
['01', '01'],
|
5
|
+
['02', '02'],
|
6
|
+
['03', '03'],
|
7
|
+
['04', '04'],
|
8
|
+
['05', '05'],
|
9
|
+
['06', '06'],
|
10
|
+
['07', '07'],
|
11
|
+
['08', '08'],
|
12
|
+
['09', '09'],
|
13
|
+
['10', '10'],
|
14
|
+
['11', '11'],
|
15
|
+
['12', '12']
|
16
|
+
]
|
17
|
+
end
|
18
|
+
def stripe_card_years
|
19
|
+
[
|
20
|
+
['2018', '2018'],
|
21
|
+
['2019', '2019'],
|
22
|
+
['2020', '2020'],
|
23
|
+
['2021', '2021'],
|
24
|
+
['2022', '2022'],
|
25
|
+
['2023', '2023'],
|
26
|
+
['2024', '2024'],
|
27
|
+
['2025', '2025']
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class FiatStripe::Subscription::CreateStripeSubscriptionJob < ApplicationJob
|
2
|
+
queue_as :default
|
3
|
+
|
4
|
+
def perform(subscription)
|
5
|
+
|
6
|
+
# Find the Stripe pricing plan for $0/mo on the Monthly Subscription product
|
7
|
+
if Rails.env.development?
|
8
|
+
plan = FiatStripe.test_default_plan_id.to_s
|
9
|
+
elsif Rails.env.production?
|
10
|
+
plan = FiatStripe.live_default_plan_id.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
stripe_subscription = Stripe::Subscription.create(
|
14
|
+
customer: subscription.subscriber.stripe_customer_id,
|
15
|
+
trial_period_days: 14,
|
16
|
+
items: [
|
17
|
+
{
|
18
|
+
plan: plan
|
19
|
+
}
|
20
|
+
]
|
21
|
+
)
|
22
|
+
subscription.update_attributes(stripe_subscription_id: stripe_subscription.id)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class FiatStripe::Subscription::UpdateStripeSubscriptionJob < ApplicationJob
|
2
|
+
queue_as :default
|
3
|
+
|
4
|
+
def perform(subscription)
|
5
|
+
if subscription.stripe_subscription_id?
|
6
|
+
product = subscription.stripe_product
|
7
|
+
|
8
|
+
correct_plan = Stripe::Plan.list(product: product, amount: (subscription.monthly_rate * 100)).first
|
9
|
+
|
10
|
+
if correct_plan
|
11
|
+
item = subscription.stripe_subscription.items.first
|
12
|
+
item.plan = correct_plan.id
|
13
|
+
item.save
|
14
|
+
else
|
15
|
+
new_plan = Stripe::Plan.create(
|
16
|
+
amount: subscription.monthly_rate * 100,
|
17
|
+
interval: "month",
|
18
|
+
product: product,
|
19
|
+
currency: "usd",
|
20
|
+
nickname: "$#{subscription.monthly_rate}/mo"
|
21
|
+
)
|
22
|
+
item = subscription.stripe_subscription.items.first
|
23
|
+
item.plan = new_plan.id
|
24
|
+
item.save
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Stripeable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
after_commit :create_stripe_customer_id, on: :create
|
6
|
+
before_commit :update_stripe, on: :update
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_stripe_customer_id
|
10
|
+
customer = Stripe::Customer.create(
|
11
|
+
:description => self.name
|
12
|
+
#:email => @agency.email
|
13
|
+
)
|
14
|
+
self.update_attributes(stripe_customer_id: customer.id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_stripe
|
18
|
+
# TODO: Update this method to work w/ bank accounts
|
19
|
+
if self.saved_change_to_stripe_card_token? && self.stripe_card_token? && self.stripe_customer_id?
|
20
|
+
token = self.stripe_card_token
|
21
|
+
customer = Stripe::Customer.retrieve(self.stripe_customer_id)
|
22
|
+
customer.sources.create(source: self.stripe_card_token)
|
23
|
+
customer.save
|
24
|
+
elsif saved_change_to_remove_card? && remove_card && stripe_customer_id
|
25
|
+
customer = Stripe::Customer.retrieve(self.stripe_customer_id)
|
26
|
+
customer.sources.retrieve(customer.sources.data.first.id).delete
|
27
|
+
customer.save
|
28
|
+
self.update_attributes(remove_card: nil, stripe_card_token: nil)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def has_source?
|
33
|
+
if self.stripe_customer_id?
|
34
|
+
if Stripe::Customer.retrieve(self.stripe_customer_id).sources.any?
|
35
|
+
true
|
36
|
+
else
|
37
|
+
false
|
38
|
+
end
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def has_card?
|
45
|
+
if self.stripe_customer_id?
|
46
|
+
if Stripe::Customer.retrieve(self.stripe_customer_id).sources.data.first.object == "card"
|
47
|
+
true
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
51
|
+
else
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def has_bank_account?
|
57
|
+
if self.stripe_customer_id?
|
58
|
+
if Stripe::Customer.retrieve(self.stripe_customer_id).sources.data.first.object == "bank_account"
|
59
|
+
true
|
60
|
+
else
|
61
|
+
false
|
62
|
+
end
|
63
|
+
else
|
64
|
+
false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def is_billable?
|
69
|
+
if self.stripe_customer_id? && self.has_source?
|
70
|
+
true
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def payment_name
|
77
|
+
if self.is_billable?
|
78
|
+
Rails.cache.fetch("#{cache_key}/payment_name", expires_in: 7.days) do
|
79
|
+
if self.has_card?
|
80
|
+
name = Stripe::Customer.retrieve(self.stripe_customer_id).sources.data.first.brand
|
81
|
+
"#{name}"
|
82
|
+
elsif self.has_bank_account?
|
83
|
+
# Something...
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def payment_last4
|
90
|
+
if self.is_billable?
|
91
|
+
Rails.cache.fetch("#{cache_key}/payment_last4", expires_in: 7.days) do
|
92
|
+
if self.has_card?
|
93
|
+
last4 = Stripe::Customer.retrieve(self.stripe_customer_id).sources.data.first.last4
|
94
|
+
"#{last4}"
|
95
|
+
elsif self.has_bank_account?
|
96
|
+
# Something...
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def card_expiration # TODO: Redo this to accommodate banks?
|
103
|
+
if self.stripe_customer_id? && self.stripe_card_token?
|
104
|
+
Rails.cache.fetch("#{cache_key}/card_expiration", expires_in: 7.days) do
|
105
|
+
exp_month = Stripe::Customer.retrieve(self.stripe_customer_id).sources.data.first.exp_month
|
106
|
+
exp_year = Stripe::Customer.retrieve(self.stripe_customer_id).sources.data.first.exp_year
|
107
|
+
"#{exp_month}/#{exp_year}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module FiatStripe
|
2
|
+
class Subscription < ApplicationRecord
|
3
|
+
include Tokenable
|
4
|
+
|
5
|
+
belongs_to :subscriber, polymorphic: true
|
6
|
+
|
7
|
+
validates :subscriber, presence: true
|
8
|
+
|
9
|
+
after_touch :save
|
10
|
+
after_commit -> { FiatStripe::Subscription::CreateStripeSubscriptionJob.set(wait: 5.seconds).perform_later(self) }, on: :create
|
11
|
+
after_commit -> { FiatStripe::Subscription::UpdateStripeSubscriptionJob.set(wait: 5.seconds).perform_later(self) }, on: :update, if: :is_stripe_pricing_inaccurate? # This runs when an associated support plan is updated, too, b/c of touch
|
12
|
+
after_commit -> { FiatStripe::Subscription::CancelStripeSubscriptionJob.set(wait: 5.seconds).perform_later(self.stripe_subscription_id) }, on: :destroy
|
13
|
+
|
14
|
+
def stripe_subscription
|
15
|
+
if self.stripe_subscription_id?
|
16
|
+
Rails.cache.fetch("#{cache_key}/stripe_subscription", expires_in: 30.days) do
|
17
|
+
subscription = Stripe::Subscription.retrieve(self.stripe_subscription_id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def stripe_plan
|
23
|
+
if self.stripe_subscription
|
24
|
+
self.stripe_subscription.items.first.plan.id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def stripe_product
|
29
|
+
if self.stripe_subscription
|
30
|
+
self.stripe_subscription.items.first.plan.product
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def is_stripe_pricing_inaccurate?
|
35
|
+
if self.stripe_subscription
|
36
|
+
if self.stripe_subscription.items.first.plan.amount != (self.rate * 100)
|
37
|
+
true
|
38
|
+
else
|
39
|
+
false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Fiat stripe</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag "fiat_stripe/application", media: "all" %>
|
9
|
+
<%= javascript_include_tag "fiat_stripe/application" %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
|
15
|
+
</body>
|
16
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateFiatStripeSubscriptions < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :fiat_stripe_subscriptions do |t|
|
4
|
+
t.string :subscriber_type
|
5
|
+
t.integer :subscriber_id
|
6
|
+
t.string :stripe_subscription_id
|
7
|
+
t.string :token
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/fiat_stripe.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module FiatStripe
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace FiatStripe
|
4
|
+
|
5
|
+
# This allows an app to override model / controller code using decorator pattern: https://edgeguides.rubyonrails.org/engines.html#a-note-on-decorators-and-loading-code
|
6
|
+
config.to_prepare do
|
7
|
+
Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
|
8
|
+
require_dependency(c)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fiat_stripe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Haines
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: stripe
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: stripe_event
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: This gem is designed to be used by Fiat Insight developers on Rails projects
|
70
|
+
that need to connect paying entities with Stripe.
|
71
|
+
email:
|
72
|
+
- andrew@fiatinsight.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- MIT-LICENSE
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- app/assets/config/fiat_stripe_manifest.js
|
81
|
+
- app/assets/javascripts/fiat_stripe/application.js
|
82
|
+
- app/assets/stylesheets/fiat_stripe/application.css
|
83
|
+
- app/controllers/fiat_stripe/application_controller.rb
|
84
|
+
- app/controllers/fiat_stripe/stripe_controller.rb
|
85
|
+
- app/controllers/fiat_stripe/subscriptions_controller.rb
|
86
|
+
- app/helpers/card_helper.rb
|
87
|
+
- app/helpers/fiat_stripe/application_helper.rb
|
88
|
+
- app/jobs/fiat_stripe/application_job.rb
|
89
|
+
- app/jobs/fiat_stripe/subscription/cancel_stripe_subscription_job.rb
|
90
|
+
- app/jobs/fiat_stripe/subscription/create_stripe_subscription_job.rb
|
91
|
+
- app/jobs/fiat_stripe/subscription/update_stripe_subscription_job.rb
|
92
|
+
- app/mailers/fiat_stripe/application_mailer.rb
|
93
|
+
- app/models/concerns/stripeable.rb
|
94
|
+
- app/models/fiat_stripe/application_record.rb
|
95
|
+
- app/models/fiat_stripe/subscription.rb
|
96
|
+
- app/views/layouts/fiat_stripe/application.html.erb
|
97
|
+
- config/routes.rb
|
98
|
+
- db/migrate/20181004213428_create_fiat_stripe_subscriptions.rb
|
99
|
+
- lib/fiat_stripe.rb
|
100
|
+
- lib/fiat_stripe/engine.rb
|
101
|
+
- lib/fiat_stripe/version.rb
|
102
|
+
- lib/tasks/fiat_stripe_tasks.rake
|
103
|
+
homepage: https://github.com/fiatinsight/fiat_stripe
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.6.14
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Fiat Insight handling for Stripe
|
127
|
+
test_files: []
|