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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f379f31acff0bd4d6126e0bc90b10342241fc163
4
- data.tar.gz: 7d3995c6f09c90032f7daa79cd44f45f0c2910dd
3
+ metadata.gz: 0cb496c9378d4db4a6bca7e4f4caeb9ac13d431c
4
+ data.tar.gz: 2663cfd3a46ddcc2639d43f95ffec5e6e57ca545
5
5
  SHA512:
6
- metadata.gz: 84b24701ea4a184ba9127e49ac5f967c57e1d0b658f2b4500c7a95c25baaa679762b0dcfa5d509621a30b60e9bf64eee5254b5db810b7a1e57b70f913ecefbfa
7
- data.tar.gz: fe41f4bef8125dd0a4e7c65bae31a47bf672b3affee897f8e81487e4bce963addbc4119962ef90a3cefe9099b6d462b7aa1e8de03e1fd147f48513cc43d65522
6
+ metadata.gz: e91fb29bdac4942584ea649c11b48c271288ce6a17eee5c4910884a0bd992d6e055bffc4e66c7cdbc8d91c64577c40fba3a0cc3204cfbd6899993a64a3f82fc0
7
+ data.tar.gz: b81bdff9f22d68b2e3884500188527c5e922527cf06f19848511926e7c1732d4608ddde1c485bec9ad19936527428c3413873968c4e67e5b7833c8a320db07a2
data/.env ADDED
@@ -0,0 +1 @@
1
+ STRIPE_API_KEY=sk_test_0pv3P596EgAUvH5hA4YgYswS
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 props 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 invoice PDFs."
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
@@ -1,2 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.pattern = 'test/**/*_test.rb'
8
+ end
9
+
2
10
  task :default => :spec
@@ -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
@@ -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.formatCurrencyUsing(callback)
40
+ def self.format_currency_using(callback)
57
41
  @@format_currency_using = callback
58
42
  end
59
43
 
@@ -1,3 +1,3 @@
1
1
  module BankTeller
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- @trial_days = args[0][:trial_days] || 0
7
- @quantity = args[0][:quantity] || 1
8
- @skip_trial = args[0][:skip_trial] || false
9
- @coupon = args[0][:coupon]
10
- @metadata = args[0][:metadata]
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 do |subscription|
28
- subscription.name = name
29
- subscription.stripe_id = stripe_subscription.id
30
- subscription.stripe_plan = plan
31
- subscription.quantity = quantity
32
- subscription.trial_ends_at = trial_ends_at
33
- end
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.0
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