bank_teller 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -0
- data/README.md +8 -2
- data/Rakefile +8 -0
- data/bank_teller.gemspec +6 -0
- data/lib/bank_teller.rb +1 -17
- data/lib/bank_teller/version.rb +1 -1
- data/lib/subscription_builder.rb +26 -21
- metadata +92 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb496c9378d4db4a6bca7e4f4caeb9ac13d431c
|
4
|
+
data.tar.gz: 2663cfd3a46ddcc2639d43f95ffec5e6e57ca545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e91fb29bdac4942584ea649c11b48c271288ce6a17eee5c4910884a0bd992d6e055bffc4e66c7cdbc8d91c64577c40fba3a0cc3204cfbd6899993a64a3f82fc0
|
7
|
+
data.tar.gz: b81bdff9f22d68b2e3884500188527c5e922527cf06f19848511926e7c1732d4608ddde1c485bec9ad19936527428c3413873968c4e67e5b7833c8a320db07a2
|
data/README.md
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
# Bank Teller
|
2
2
|
[![Code Climate](https://codeclimate.com/repos/572c190b20916e00680030b0/badges/df6d434fec0219cc1364/gpa.svg)](https://codeclimate.com/repos/572c190b20916e00680030b0/feed)
|
3
3
|
|
4
|
-
Bank Teller is a Ruby on Rails interface for interacting with Stripe. It is an implementation the Laravel library, [Cashier](http://github.com/laravel/cashier). Major
|
4
|
+
Bank Teller is a Ruby on Rails interface for interacting with Stripe. It is an implementation of the Laravel library, [Cashier](http://github.com/laravel/cashier). Major kudos to Taylor Otwell and all of the contributors to Cashier, it's amazing. Bank Teller has some minor API differences from Cashier, mostly to match the Ruby style. To quote the Cashier project: "It handles almost all of the boilerplate subscription billing code you are dreading writing... coupons, swapping subscription, subscription 'quantities', cancellation grace periods, and <strike>invoice PDFs</strike> (coming soon)."
|
5
5
|
|
6
6
|
This gem cannot be used as a stand-alone gem. It is very tightly integrated with ActiveSupport and ActiveRecord. This gem is best used in a Ruby on Rails application.
|
7
7
|
|
8
|
+
## Still to Come
|
9
|
+
- Finish Tests
|
10
|
+
- Add Webhooks
|
11
|
+
- Invoice PDFs
|
12
|
+
- One Off Charges
|
13
|
+
|
8
14
|
## Installation
|
9
15
|
|
10
16
|
Add this line to your application's Gemfile:
|
@@ -18,7 +24,7 @@ And then execute:
|
|
18
24
|
$ bundle
|
19
25
|
|
20
26
|
Bank Teller comes with a couple of migrations:
|
21
|
-
1. A migration to add fields to a `users` table. `users` should already exist.
|
27
|
+
1. A migration to add fields to a `users` table. A `users` should already exist.
|
22
28
|
2. A migration to create a `subscriptions` table.
|
23
29
|
|
24
30
|
To add these migrations to your application, run:
|
data/Rakefile
CHANGED
data/bank_teller.gemspec
CHANGED
@@ -28,5 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 1.11"
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "minitest", "~> 5.8"
|
32
|
+
spec.add_development_dependency "activesupport", "~> 4.2.6"
|
33
|
+
spec.add_development_dependency "activerecord", "~> 4.2.6"
|
34
|
+
spec.add_development_dependency 'dotenv', '~> 2.1', '>= 2.1.1'
|
35
|
+
spec.add_development_dependency 'stripe-ruby-mock', '~> 2.2.3'
|
36
|
+
spec.add_development_dependency 'activerecord-nulldb-adapter', '~> 0.3.2'
|
31
37
|
spec.add_runtime_dependency 'stripe', "~> 1.42.0"
|
32
38
|
end
|
data/lib/bank_teller.rb
CHANGED
@@ -2,26 +2,10 @@ require "bank_teller/version"
|
|
2
2
|
require 'bank_teller/engine' if defined?(Rails)
|
3
3
|
|
4
4
|
module BankTeller
|
5
|
-
# The current currency.
|
6
|
-
#
|
7
|
-
# @return [String]
|
8
5
|
@@currency = 'usd'
|
9
|
-
|
10
|
-
# The current currency symbol.
|
11
|
-
#
|
12
|
-
# @return [String]
|
13
6
|
@@currency_symbol = '$'
|
14
|
-
|
15
|
-
# The custom currency formatter.
|
16
|
-
#
|
17
|
-
# @return [Lambda]
|
18
7
|
@@format_currency_using = nil
|
19
8
|
|
20
|
-
# Set the currency to be used when billing users.
|
21
|
-
#
|
22
|
-
# @param currency [Integer]
|
23
|
-
# @param symbol [String]
|
24
|
-
# @return [Boolean]
|
25
9
|
def self.use_currency(currency, symbol = nil)
|
26
10
|
@@currency = currency
|
27
11
|
symbol = self.guess_currency_symbol(currency) if symbol.nil?
|
@@ -53,7 +37,7 @@ module BankTeller
|
|
53
37
|
@@currency_symbol
|
54
38
|
end
|
55
39
|
|
56
|
-
def self.
|
40
|
+
def self.format_currency_using(callback)
|
57
41
|
@@format_currency_using = callback
|
58
42
|
end
|
59
43
|
|
data/lib/bank_teller/version.rb
CHANGED
data/lib/subscription_builder.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
class SubscriptionBuilder
|
2
|
+
attr_accessor :user, :name, :plan
|
3
|
+
attr_accessor :quantity, :coupon, :metadata
|
4
|
+
attr_accessor :trial_days, :skip_trial
|
5
|
+
|
2
6
|
def initialize(user, name, plan, *args)
|
3
7
|
@user = user
|
4
8
|
@name = name
|
5
9
|
@plan = plan
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
if args[0]
|
11
|
+
set_instance_vars_for_args(args[0])
|
12
|
+
else
|
13
|
+
@trial_days = 0
|
14
|
+
@quantity = 1
|
15
|
+
@skip_trial = false
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def add(options = {})
|
@@ -24,26 +30,17 @@ class SubscriptionBuilder
|
|
24
30
|
trial_ends_at = trial_days ? trial_days.days.from_now.to_time.to_i : nil
|
25
31
|
end
|
26
32
|
|
27
|
-
user.subscriptions.create
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
user.subscriptions.create(
|
34
|
+
name: name,
|
35
|
+
stripe_id: stripe_subscription.id,
|
36
|
+
stripe_plan: plan,
|
37
|
+
quantity: quantity,
|
38
|
+
trial_ends_at: trial_ends_at
|
39
|
+
)
|
34
40
|
end
|
35
41
|
|
36
42
|
protected
|
37
43
|
|
38
|
-
attr_accessor :user
|
39
|
-
attr_accessor :name
|
40
|
-
attr_accessor :plan
|
41
|
-
attr_accessor :quantity
|
42
|
-
attr_accessor :trial_days
|
43
|
-
attr_accessor :skip_trial
|
44
|
-
attr_accessor :coupon
|
45
|
-
attr_accessor :metadata
|
46
|
-
|
47
44
|
def get_stripe_customer(token = nil, options = {})
|
48
45
|
if !user.stripe_id.nil?
|
49
46
|
customer = user.as_stripe_customer
|
@@ -76,4 +73,12 @@ class SubscriptionBuilder
|
|
76
73
|
def get_tax_percent_for_pay_load
|
77
74
|
user.try(:tax_percentage)
|
78
75
|
end
|
76
|
+
|
77
|
+
def set_instance_vars_for_args(args)
|
78
|
+
@trial_days = args[:trial_days] || 0
|
79
|
+
@quantity = args[:quantity] || 1
|
80
|
+
@skip_trial = args[:skip_trial] || false
|
81
|
+
@coupon = args[:coupon]
|
82
|
+
@metadata = args[:metadata]
|
83
|
+
end
|
79
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bank_teller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
@@ -38,6 +38,96 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.2.6
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.2.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 4.2.6
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.2.6
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dotenv
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.1'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.1.1
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.1'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.1.1
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: stripe-ruby-mock
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.2.3
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 2.2.3
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: activerecord-nulldb-adapter
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 0.3.2
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.3.2
|
41
131
|
- !ruby/object:Gem::Dependency
|
42
132
|
name: stripe
|
43
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +149,7 @@ executables: []
|
|
59
149
|
extensions: []
|
60
150
|
extra_rdoc_files: []
|
61
151
|
files:
|
152
|
+
- ".env"
|
62
153
|
- ".gitignore"
|
63
154
|
- Gemfile
|
64
155
|
- README.html
|