colt 0.2.1 → 0.3.0

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: 2ccd36761db8fa25cefb1fe19181c6fdc96cc83c
4
- data.tar.gz: 18c6da6242eda2b1995777d9045ea8f33db4d175
3
+ metadata.gz: a588447640e1d5a4bdff0cb62bffe356f9daf8fa
4
+ data.tar.gz: 5a7550b66d057035970b0dd3f4200428f93dd0e7
5
5
  SHA512:
6
- metadata.gz: c0a1265527d2fb6c2275a127f5c11e6c4066a9f234e6a2e55cc2de1ee7959afec750005d684dd26831ebd35f9588c3b079b791f210baa8526d58952adec43d3a
7
- data.tar.gz: 5f88f27a28445d95ae6dbfeac2989a2e02a3af84eb768c03fb1996da093ba840bf605d555d8cc8fc236402160074e306c42322c797b89105c0fe3a31521eef6e
6
+ metadata.gz: c22bb1942f1cfeeaba26bca0b8b44c962d4057ab4eed2c7cd4634b1242cee869fe178959fd6e5035c2420fa4700260d4c05f751c7d9694d09d9b5b91d339c495
7
+ data.tar.gz: 0147be4eae7428651c4756093a6823ff85948d688b3e260e248934f4597e25ddadd3f7bd59a277cd7a91281c1554443e1805189c676ad0f1d3a19c69457d1e2c
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Colt
2
2
 
3
- Colt is a micro gem used to subscribe to a given plan using the Stripe API. The plans must already exist in your account. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Colt is a micro gem used to subscribe to a given plan using the Stripe API. The plans must already exist in your account. It provides methods to add, update and save credit cards on Stripe servers. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Our Sponsor
6
+
7
+ This project is sponsored by Zepho Inc. If you are interested in learning TDD in Ruby, you can redeem the coupon here: https://www.udemy.com/learn-test-driven-development-in-ruby/?couponCode=svr
4
8
 
5
9
  ## Version
6
10
 
@@ -37,6 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
37
41
  $ruby -rminitest/pride test/credential_test.rb --verbose
38
42
  $ruby -rminitest/pride test/colt_integration_test.rb --verbose
39
43
  $ruby -rminitest/pride test/subscription_test.rb --verbose
44
+ $ruby -rminitest/pride test/credit_card_test.rb --verbose
40
45
  ```
41
46
 
42
47
  or
@@ -0,0 +1,35 @@
1
+ module Colt
2
+
3
+ class CreditCard
4
+ #
5
+ # Adds a new credit card as the active default card for an existing customer
6
+ #
7
+ def self.add(stripe_customer_id, stripe_token)
8
+ customer = Stripe::Customer.retrieve(stripe_customer_id)
9
+ card = customer.sources.create(source: stripe_token)
10
+ customer.default_card = card.id
11
+ customer.save
12
+ card
13
+ end
14
+
15
+ #
16
+ # Create a new credit card for a customer
17
+ #
18
+ def self.save(stripe_token, description)
19
+ Stripe::Customer.create(card: stripe_token, description: description)
20
+ end
21
+
22
+ #
23
+ # Update expiration date of an existing credit card for a customer
24
+ #
25
+ def self.update_expiration_date(stripe_customer_id, card_month, card_year)
26
+ customer = Stripe::Customer.retrieve(stripe_customer_id)
27
+ card = customer.sources.first
28
+ card.exp_month = card_month
29
+ card.exp_year = card_year
30
+ card.save
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -3,10 +3,10 @@ require 'stripe'
3
3
  module Colt
4
4
  class Subscription
5
5
  def self.create(email, stripe_token, plan_id, description='none')
6
- Stripe::Customer.create(email: email,
6
+ Stripe::Customer.create(email: email,
7
7
  description: description,
8
- card: stripe_token,
9
- plan: plan_id)
8
+ card: stripe_token,
9
+ plan: plan_id)
10
10
  end
11
11
 
12
12
  def self.update(customer_id, plan_id)
data/lib/colt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Colt
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/colt.rb CHANGED
@@ -4,5 +4,5 @@ require "colt/credential"
4
4
  require "colt/subscription"
5
5
 
6
6
  module Colt
7
- STRIPE_API_VERSION = '2015-06-15 (latest)'
7
+ STRIPE_API_VERSION = '2015-06-15 (latest)'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bala Paranj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stripe
@@ -88,6 +88,7 @@ files:
88
88
  - colt.gemspec
89
89
  - lib/colt.rb
90
90
  - lib/colt/credential.rb
91
+ - lib/colt/credit_card.rb
91
92
  - lib/colt/subscription.rb
92
93
  - lib/colt/version.rb
93
94
  homepage: http://www.rubyplus.com
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  version: '0'
111
112
  requirements: []
112
113
  rubyforge_project:
113
- rubygems_version: 2.4.7
114
+ rubygems_version: 2.2.2
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: A micro gem to subscribe to a plan using stripe gem.