colt 0.1.1 → 0.2.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: 3c5d73e891b2f0412d78739cd323dbe5167419e7
4
- data.tar.gz: e36a531b53218467ce3b134a1e7db8422a60295a
3
+ metadata.gz: 842801f1d168922fe2f2201ad94bc93c36b4abcb
4
+ data.tar.gz: 0f877d8a333285a4e88c554aa961a232ae79bbf7
5
5
  SHA512:
6
- metadata.gz: 902ac8b8b55891534b648911eaeb93c40bf68b9948f64f8fdc5728f3f24f5ab0fd83e53501e43ee4129fc34d465f8201c07c75740dad432c17de537eb0c4018e
7
- data.tar.gz: 97c12932a77cd8d4d63177153536619e449799e85e953164f9725c065cfbacd552c87883d0c10b0fd342388a7315a16516ba7d1400f813818923aa5481eeeb64
6
+ metadata.gz: 6a3592adefad2ec2ed3d8e2dde33b10770b709322bf2b786fe8ef34dd86bed1f3c127c51be761e9bf93de790c0c289a850a70fb1ce63afad1ed8765d34dcb2cc
7
+ data.tar.gz: ea28a8e785b98d3ce473a50cfe9a3403b2ea489c90327b64877b46253b9ccc4d707f4149bf29e33337badc74a43ae4cbff53c3083c405002bbcb37338f1d3649
data/lib/colt.rb CHANGED
@@ -1,28 +1,8 @@
1
1
  require "colt/version"
2
2
  require "stripe"
3
+ require "colt/credential"
4
+ require "colt/subscription"
3
5
 
4
6
  module Colt
5
- STRIPE_API_VERSION = '2015-06-15 (latest)'
6
-
7
- class Credential
8
- def self.check
9
- message = <<ERROR
10
- Stripe credentials is not set properly or it is incorrect.
11
- Define the following Stripe environment variables.
12
-
13
- export STRIPE_PUBLISHABLE_KEY='pk_test your publishable key'
14
- export STRIPE_SECRET_KEY='sk_test your secret key'
15
-
16
- and define:
17
-
18
- Stripe.api_key = 'sk_test your secret key'
19
- ERROR
20
- begin
21
- ::Stripe::Account.retrieve
22
- rescue ::Stripe::AuthenticationError => e
23
- raise Exception.new(message)
24
- end
25
- end
26
- end
27
-
7
+ STRIPE_API_VERSION = '2015-06-15 (latest)'
28
8
  end
@@ -0,0 +1,22 @@
1
+ module Colt
2
+ class Credential
3
+ def self.check
4
+ message = <<ERROR
5
+ Stripe credentials is not set properly or it is incorrect.
6
+ Define the following Stripe environment variables.
7
+
8
+ export STRIPE_PUBLISHABLE_KEY='pk_test your publishable key'
9
+ export STRIPE_SECRET_KEY='sk_test your secret key'
10
+
11
+ and define:
12
+
13
+ Stripe.api_key = 'sk_test your secret key'
14
+ ERROR
15
+ begin
16
+ ::Stripe::Account.retrieve
17
+ rescue ::Stripe::AuthenticationError => e
18
+ raise Exception.new(message)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'stripe'
2
+
3
+ module Colt
4
+ class Subscription
5
+ def self.create(email, stripe_token, plan_id, description='none')
6
+ Stripe::Customer.create(email: email,
7
+ description: description,
8
+ card: stripe_token,
9
+ plan: plan_id)
10
+ end
11
+
12
+ def self.update(customer_id, plan_id)
13
+ customer = Stripe::Customer.retrieve(customer_id)
14
+ customer.update_subscription(plan: plan_id)
15
+ end
16
+
17
+ def self.cancel(customer_id)
18
+ customer = Stripe::Customer.retrieve(customer_id)
19
+ customer.cancel_subscription
20
+ end
21
+ end
22
+
23
+ end
data/lib/colt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Colt
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bala Paranj
@@ -87,6 +87,8 @@ files:
87
87
  - bin/setup
88
88
  - colt.gemspec
89
89
  - lib/colt.rb
90
+ - lib/colt/credential.rb
91
+ - lib/colt/subscription.rb
90
92
  - lib/colt/version.rb
91
93
  homepage: http://www.rubyplus.com
92
94
  licenses: