stripe_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.textile +101 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/stripe_rails/application.js +15 -0
- data/app/assets/javascripts/stripe_rails/callbacks.js +2 -0
- data/app/assets/stylesheets/stripe_rails/application.css +13 -0
- data/app/assets/stylesheets/stripe_rails/callbacks.css +4 -0
- data/app/controllers/stripe_rails/application_controller.rb +4 -0
- data/app/controllers/stripe_rails/callbacks_controller.rb +21 -0
- data/app/helpers/stripe_rails/application_helper.rb +4 -0
- data/app/helpers/stripe_rails/callbacks_helper.rb +4 -0
- data/app/models/stripe_rails/charge.rb +27 -0
- data/app/models/stripe_rails/customer.rb +135 -0
- data/app/models/stripe_rails/invoice.rb +5 -0
- data/app/stripe_callbacks/ping_callback.rb +7 -0
- data/app/views/layouts/stripe_rails/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20120608044024_create_stripe_rails_customers.rb +10 -0
- data/lib/generators/stripe_callback/USAGE +8 -0
- data/lib/generators/stripe_callback/stripe_callback_generator.rb +24 -0
- data/lib/stripe_rails.rb +7 -0
- data/lib/stripe_rails/acts_as_customer.rb +43 -0
- data/lib/stripe_rails/autoload_const_defined.rb +5 -0
- data/lib/stripe_rails/callback.rb +20 -0
- data/lib/stripe_rails/engine.rb +16 -0
- data/lib/stripe_rails/errors.rb +45 -0
- data/lib/stripe_rails/pci_compliance.rb +5 -0
- data/lib/stripe_rails/version.rb +3 -0
- data/lib/tasks/stripe_rails_tasks.rake +4 -0
- metadata +160 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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.textile
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
h1. StripeRails
|
2
|
+
|
3
|
+
Stripe Rails was built on top of the official stripe gem to bring ease of use of stripe in your models. The gem also caches the stripe customer response so that if you often use it to check a customers subscription status, it wont have to reach the stripe API on every page load. Lastly, this gem has built in responses for stripe webhooks/callbacks.
|
4
|
+
|
5
|
+
h3. Installation
|
6
|
+
|
7
|
+
Add the following to your gemfile and run bundle install.
|
8
|
+
|
9
|
+
<pre>
|
10
|
+
gem 'stripe_rails'
|
11
|
+
</pre>
|
12
|
+
|
13
|
+
h3. Compatibility
|
14
|
+
|
15
|
+
The gem works with rails 3.2.x and mongoid 3.0.0, support for active record will be coming in the very next release.
|
16
|
+
|
17
|
+
h2. Usage
|
18
|
+
|
19
|
+
h3. Models
|
20
|
+
|
21
|
+
Stripe Rails is easily used in your model and some configuration can be added to provide some additional functionality.
|
22
|
+
|
23
|
+
1. First, add the following module to your model. This will automatically create the stripe customer when a new model instance is created. Future functionality will be provided to add old models to stripe via a rake task, or you can do this manually by calling: MyModel.stripe.create_customer
|
24
|
+
|
25
|
+
<pre>
|
26
|
+
class MyModel
|
27
|
+
include Mongoid::Document
|
28
|
+
include StripeRails::ActsLikeCustomer
|
29
|
+
...
|
30
|
+
end
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
2. Secondly some configuration can be added to the model to add some additional functionality
|
34
|
+
|
35
|
+
<pre>
|
36
|
+
class MyModel
|
37
|
+
include Mongoid::Document
|
38
|
+
include StripeRails::ActsLikeCustomer
|
39
|
+
|
40
|
+
stripe_description :title # allows you to provide a method to tell stripe a description for the customer.
|
41
|
+
stripe_subscription_plan :monthly_subscription # will automatically add the customer to the subscription.
|
42
|
+
stripe_unit_price 45 # allows the usage of a per unit price which can be used later in callbacks.
|
43
|
+
stripe_units :users # specifies the units to be counted for per unit pricing.
|
44
|
+
|
45
|
+
...
|
46
|
+
end
|
47
|
+
</pre>
|
48
|
+
|
49
|
+
h3. Callbacks
|
50
|
+
|
51
|
+
Stripe rails provides a generator that will create a callback in your main application. Use:
|
52
|
+
|
53
|
+
<pre>
|
54
|
+
rails g stripe_callback charge.succeeded
|
55
|
+
</pre>
|
56
|
+
|
57
|
+
**Note: A list of callbacks can be found in stripes API documentation.
|
58
|
+
|
59
|
+
This will generate a file like this:
|
60
|
+
|
61
|
+
<pre>
|
62
|
+
class ChargeSucceededCallback < StripeRails::Callback
|
63
|
+
|
64
|
+
# Some logic to process during the callback
|
65
|
+
def actions
|
66
|
+
|
67
|
+
# The response hash
|
68
|
+
@response = {success: true}
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
</pre>
|
74
|
+
|
75
|
+
if you choose to send a response it must be set in the actions method with the instance variable of response. It will expect a hash that will be later be converted into JSON to give back to stripe.
|
76
|
+
|
77
|
+
h4. Unused callbacks
|
78
|
+
|
79
|
+
Unused callbacks will respond with the proper 501 (Not Implemented) response.
|
80
|
+
|
81
|
+
h2. How to contribute
|
82
|
+
|
83
|
+
* Fork the project on Github
|
84
|
+
* Create a topic branch for your changes
|
85
|
+
* Ensure that you provide test coverage for your changes
|
86
|
+
* Ensure that all tests pass (`bundle exec rake`)
|
87
|
+
* Create a pull request on Github
|
88
|
+
|
89
|
+
h2. Project Info
|
90
|
+
|
91
|
+
StripeRails was created by "Jason Waldrip":http://www.jasonwaldrip.com/
|
92
|
+
|
93
|
+
The project is hosted on Github: "http://github.com/jwaldrip/stripe_rails":http://github.com/jwaldrip/stripe_rails, where your contributions, forkings, comments, issues and feedback are greatly welcomed.
|
94
|
+
|
95
|
+
Copyright (c) 2012 Jason Waldrip, released under the MIT license.
|
96
|
+
|
97
|
+
h4. More to documentation to come in the next versions!
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'StripeRails'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -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 vendor/assets/javascripts of plugins, if any, 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
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_dependency "stripe_rails/application_controller"
|
2
|
+
|
3
|
+
module StripeRails
|
4
|
+
class CallbacksController < ApplicationController
|
5
|
+
def post
|
6
|
+
data = JSON.parse(request.body.read)
|
7
|
+
callback_class = (data['type'].gsub(/\./,'_') + '_callback').camelize
|
8
|
+
|
9
|
+
# Render not implemented (501) if the callback does not exist.
|
10
|
+
|
11
|
+
return head :not_implemented unless Object.autoload_const_defined?(callback_class) && callback_class.constantize.superclass == StripeRails::Callback
|
12
|
+
|
13
|
+
callback = callback_class.constantize.new(data)
|
14
|
+
|
15
|
+
callback.actions
|
16
|
+
|
17
|
+
render json: callback.response
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module StripeRails
|
2
|
+
class Charge
|
3
|
+
|
4
|
+
def initialize(customer)
|
5
|
+
@customer = customer
|
6
|
+
raise Stripe::InvalidObjectError, 'Object is not a stripe customer!' unless @customer.kind_of? Stripe::Customer
|
7
|
+
end
|
8
|
+
|
9
|
+
def all(options = {})
|
10
|
+
Stripe::Charge.all(options.merge({ customer: @customer.id }))
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(amount, options = {})
|
14
|
+
Stripe::Charge.create(options.merge({ amount: amount, customer: @customer.id }))
|
15
|
+
end
|
16
|
+
|
17
|
+
def retrieve(id)
|
18
|
+
charge = Stripe::Charge.retrieve(id)
|
19
|
+
raise Stripe::ChargeAssociationError, 'The charge does not belong to this customer!' unless charge.customer == @customer.id
|
20
|
+
end
|
21
|
+
|
22
|
+
def refund(id)
|
23
|
+
retrieve(id).refund
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module StripeRails
|
2
|
+
class Customer
|
3
|
+
|
4
|
+
# Support for mongoid
|
5
|
+
include Mongoid::Document
|
6
|
+
include Mongoid::Timestamps
|
7
|
+
|
8
|
+
store_in collection: "stripe_customers"
|
9
|
+
|
10
|
+
field :data, type: String, default: -> { nil }
|
11
|
+
field :unit_price, type: Float
|
12
|
+
field :_id, type: String, default: -> { nil }
|
13
|
+
|
14
|
+
attr_readonly :_id
|
15
|
+
|
16
|
+
def charges
|
17
|
+
StripeRails::Charge.new(@customer)
|
18
|
+
end
|
19
|
+
|
20
|
+
ActionDispatch::Session::CookieStore
|
21
|
+
|
22
|
+
def invoices
|
23
|
+
StripeRails::Invoice.new(@customer)
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(attributes={}, options={})
|
27
|
+
attributes = { data: attributes.to_json.to_a.pack('m') } if self.new_record?
|
28
|
+
super(attributes,options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# All returns items from the stripe API
|
32
|
+
def self.all(*args)
|
33
|
+
return super(nil) if args.first && args.first[:local] == true
|
34
|
+
Stripe::Customer.all(*args)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.find(id)
|
38
|
+
customer = self.find_or_initialize_by(_id: id)
|
39
|
+
customer.save if customer.new_record?
|
40
|
+
customer
|
41
|
+
end
|
42
|
+
|
43
|
+
# Privatize methods that can potential break caching and updating
|
44
|
+
class << self
|
45
|
+
alias :retrieve :find
|
46
|
+
private :find_by
|
47
|
+
end
|
48
|
+
|
49
|
+
private :attributes=, :update_attributes, :update_attributes!
|
50
|
+
|
51
|
+
def method_missing(meth, *args, &block)
|
52
|
+
if @customer.respond_to?(meth.to_sym)
|
53
|
+
value = @customer.send meth, *args
|
54
|
+
refresh_from @customer
|
55
|
+
value
|
56
|
+
elsif meth =~ /=$/ && %w(card= description= coupon= email=).include?(meth.to_s)
|
57
|
+
value = @customer.send meth, *args
|
58
|
+
refresh_from @customer
|
59
|
+
value
|
60
|
+
else
|
61
|
+
super
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Callbacks
|
66
|
+
after_initialize :stripe_read
|
67
|
+
before_update :stripe_update
|
68
|
+
before_destroy :stripe_destroy
|
69
|
+
|
70
|
+
def delete(options={})
|
71
|
+
@customer.delete
|
72
|
+
super(options)
|
73
|
+
end
|
74
|
+
|
75
|
+
def refresh!
|
76
|
+
@customer = Stripe::Customer.retrieve(id)
|
77
|
+
send :data=, @customer.to_json.to_a.pack('m')
|
78
|
+
save
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
def days_remaining_in_trial
|
83
|
+
if subscription && subscription.status == 'trialing'
|
84
|
+
((Time.at(subscription.trial_end) - Time.now) / 24 / 60 / 60).ceil
|
85
|
+
elsif subscription
|
86
|
+
0
|
87
|
+
else
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Using a callback so that we can call create and save on a new record
|
93
|
+
def create_customer
|
94
|
+
params = {}
|
95
|
+
params['description'] = stripe_customer.stripe_description if stripe_customer.respond_to? :stripe_description
|
96
|
+
refresh_from Stripe::Customer.create(params)
|
97
|
+
|
98
|
+
if stripe_customer.respond_to? :stripe_subscription_plan
|
99
|
+
@customer.update_subscription({ plan: stripe_customer.stripe_subscription_plan })
|
100
|
+
refresh_from @customer
|
101
|
+
end
|
102
|
+
|
103
|
+
self._id = @customer.id
|
104
|
+
self.unit_price = stripe_customer.stripe_unit_price
|
105
|
+
|
106
|
+
save
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def refresh_from(stripe_object)
|
112
|
+
raise Stripe::InvalidObjectError, "Is not a stripe customer!" unless stripe_object.kind_of? Stripe::Customer
|
113
|
+
@customer = stripe_object
|
114
|
+
send :data=, @customer.to_json.to_a.pack('m')
|
115
|
+
self
|
116
|
+
end
|
117
|
+
|
118
|
+
def stripe_read
|
119
|
+
if !new_record? && updated_at && updated_at < 1.day.ago
|
120
|
+
self.refresh!
|
121
|
+
else
|
122
|
+
@customer = Stripe::Customer.construct_from(JSON.parse data.unpack('m').first ) if data && data.unpack('m').first.present?
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def stripe_update
|
127
|
+
refresh_from @customer.save
|
128
|
+
end
|
129
|
+
|
130
|
+
def stripe_destroy
|
131
|
+
@customer.delete
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>StripeRails</title>
|
5
|
+
<%= stylesheet_link_tag "stripe_rails/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "stripe_rails/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class StripeCallbackGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def initialize(args, *options) #:nodoc:
|
5
|
+
args[0] = args[0].gsub(/\./,'_')
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_callback_file
|
10
|
+
create_file "app/stripe_callbacks/#{file_name}_callback.rb", <<-FILE
|
11
|
+
class #{class_name}Callback < StripeRails::Callback
|
12
|
+
|
13
|
+
# Some logic to process during the callback
|
14
|
+
def actions
|
15
|
+
|
16
|
+
# The response hash
|
17
|
+
@response = {success: true}
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
FILE
|
23
|
+
end
|
24
|
+
end
|
data/lib/stripe_rails.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module StripeRails::ActsAsCustomer
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_one :stripe, class_name: 'StripeRails::Customer', autobuild: true, dependent: :destroy, as: :stripe_customer
|
6
|
+
before_create :create_stripe_customer
|
7
|
+
|
8
|
+
StripeRails::Customer.send :belongs_to, :stripe_customer, class_name: self.to_s, polymorphic: true
|
9
|
+
StripeRails::Customer.send :validates_presence_of, :stripe_customer_id
|
10
|
+
|
11
|
+
def self.stripe_description(method)
|
12
|
+
send :define_method, :stripe_description do
|
13
|
+
send(method)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.stripe_subscription_plan(plan)
|
18
|
+
send :define_method, :stripe_subscription_plan do
|
19
|
+
plan.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.stripe_unit_price(price)
|
24
|
+
send :define_method, :stripe_unit_price do
|
25
|
+
raise Stripe::PriceInvalidError, 'Price is not a number!' unless price.kind_of?(Integer) || price.kind_of?(Float)
|
26
|
+
price
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.stripe_units(collection)
|
31
|
+
send :define_method, :stripe_units do
|
32
|
+
raise Stripe::CollectionInvalidError, 'Must be a collection!' unless send(collection.to_sym).respond_to?(:count)
|
33
|
+
send(collection.to_sym).count
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_stripe_customer
|
40
|
+
self.stripe.create_customer
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module StripeRails
|
2
|
+
class Callback
|
3
|
+
|
4
|
+
def initialize(data_hash)
|
5
|
+
data_hash = OpenStruct.new data_hash
|
6
|
+
event = Stripe::Event.retrieve(data_hash.id)
|
7
|
+
raise Stripe::InvalidEventError unless event
|
8
|
+
@response = {}
|
9
|
+
self.actions
|
10
|
+
end
|
11
|
+
|
12
|
+
def actions
|
13
|
+
end
|
14
|
+
|
15
|
+
def response
|
16
|
+
@response
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module StripeRails
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
isolate_namespace StripeRails
|
4
|
+
|
5
|
+
config.app_generators.stripe_callback :stripe_callback
|
6
|
+
|
7
|
+
config.autoload_paths += Dir["#{config.root}/lib**/"]
|
8
|
+
config.autoload_paths += Dir["#{config.root}/stripe_callbacks/**"]
|
9
|
+
|
10
|
+
initializer "Pci Compliance" do
|
11
|
+
::Stripe::Token.send(:include, Stripe::PciCompliance) if Rails.application.config.respond_to?(:stripe_pci_compliance) && Rails.application.config.stripe_pci_compliance
|
12
|
+
Rails.application.config.autoload_paths += Dir["#{Rails.root.to_s}/app/stripe_callbacks/**"]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Stripe
|
2
|
+
|
3
|
+
class PciComplianceError < StandardError
|
4
|
+
def initialize(msg)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class InvalidObjectError < StandardError
|
10
|
+
def initialize(msg)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class CollectionInvalidError < StandardError
|
16
|
+
def initialize(msg)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class PriceInvalidError < StandardError
|
22
|
+
def initialize(msg)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ChargeAssociationError < StandardError
|
28
|
+
def initialize(msg)
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class InvalidEventError < StandardError
|
34
|
+
def initialize(msg='Event is invalid!')
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class InvalidCallbackResponseError < StandardError
|
40
|
+
def initialize(msg='Response must be a hash!')
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stripe_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Waldrip
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.5
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jquery-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: stripe
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mongoid
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.0.0.rc
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.0.rc
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Stripe Rails was built on top of the official stripe gem to bring ease
|
95
|
+
of use of stripe in your models. The gem also caches the stripe customer response
|
96
|
+
so that if you often use it to check a customers subscription status, it wont have
|
97
|
+
to reach the stripe API on every page load. Lastly, this gem has built in responses
|
98
|
+
for stripe webhooks/callbacks.
|
99
|
+
email:
|
100
|
+
- jason@waldrip.net
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- app/assets/javascripts/stripe_rails/application.js
|
106
|
+
- app/assets/javascripts/stripe_rails/callbacks.js
|
107
|
+
- app/assets/stylesheets/stripe_rails/application.css
|
108
|
+
- app/assets/stylesheets/stripe_rails/callbacks.css
|
109
|
+
- app/controllers/stripe_rails/application_controller.rb
|
110
|
+
- app/controllers/stripe_rails/callbacks_controller.rb
|
111
|
+
- app/helpers/stripe_rails/application_helper.rb
|
112
|
+
- app/helpers/stripe_rails/callbacks_helper.rb
|
113
|
+
- app/models/stripe_rails/charge.rb
|
114
|
+
- app/models/stripe_rails/customer.rb
|
115
|
+
- app/models/stripe_rails/invoice.rb
|
116
|
+
- app/stripe_callbacks/ping_callback.rb
|
117
|
+
- app/views/layouts/stripe_rails/application.html.erb
|
118
|
+
- config/routes.rb
|
119
|
+
- db/migrate/20120608044024_create_stripe_rails_customers.rb
|
120
|
+
- lib/generators/stripe_callback/stripe_callback_generator.rb
|
121
|
+
- lib/generators/stripe_callback/USAGE
|
122
|
+
- lib/stripe_rails/acts_as_customer.rb
|
123
|
+
- lib/stripe_rails/autoload_const_defined.rb
|
124
|
+
- lib/stripe_rails/callback.rb
|
125
|
+
- lib/stripe_rails/engine.rb
|
126
|
+
- lib/stripe_rails/errors.rb
|
127
|
+
- lib/stripe_rails/pci_compliance.rb
|
128
|
+
- lib/stripe_rails/version.rb
|
129
|
+
- lib/stripe_rails.rb
|
130
|
+
- lib/tasks/stripe_rails_tasks.rake
|
131
|
+
- MIT-LICENSE
|
132
|
+
- Rakefile
|
133
|
+
- README.textile
|
134
|
+
homepage: https://github.com/jwaldrip/stripe_rails
|
135
|
+
licenses: []
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 1.8.21
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: Stripe Rails was built on top of the official stripe gem for easier integration
|
158
|
+
into a rails project.
|
159
|
+
test_files: []
|
160
|
+
has_rdoc:
|