colt 0.2.1 → 0.3.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 +4 -4
- data/README.md +6 -1
- data/lib/colt/credit_card.rb +35 -0
- data/lib/colt/subscription.rb +3 -3
- data/lib/colt/version.rb +1 -1
- data/lib/colt.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a588447640e1d5a4bdff0cb62bffe356f9daf8fa
|
4
|
+
data.tar.gz: 5a7550b66d057035970b0dd3f4200428f93dd0e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/colt/subscription.rb
CHANGED
@@ -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:
|
6
|
+
Stripe::Customer.create(email: email,
|
7
7
|
description: description,
|
8
|
-
card:
|
9
|
-
plan:
|
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
data/lib/colt.rb
CHANGED
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.
|
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-
|
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.
|
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.
|