filly 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1a60c45679c9d08a6e6ad582af5ceedc786b7ea
4
+ data.tar.gz: c7a0eba3d382cbcde283b0db84c8448ef36b7d51
5
+ SHA512:
6
+ metadata.gz: 23d9959e814534c58eaa5e1a343fa4412a6b5e9f81d5771ff94d4d2eeb9c15fe8aee8a0db519e8ef7b5267012dc02495d1dda159f7c76df66c34de3a563ef5bc
7
+ data.tar.gz: c86e482586933ea4fd1f9786bcd913653b44dac449a72d47e3e1df45ef79cecae6fb1ab883c15f21b2d450ffa31589a547b2bd0e4395aec33654a97f926b53dc
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in filly.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Bala Paranj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Filly
2
+
3
+ Filly is a micro gem used 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
8
+
9
+ ## Features:
10
+
11
+ 1. Create a new credit card for a customer (creating credit card for the first time)
12
+ 2. Add a new credit card as the default credit card
13
+ 2. Update credit card expiration date
14
+ 3. Stripe credentials checker
15
+
16
+ ## Version
17
+
18
+ Ruby : 2.2.3
19
+ Stripe Gem : 1.25
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'filly'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install filly
36
+
37
+ ## Usage
38
+
39
+ TODO: Write usage instructions here
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ```ruby
48
+ $ruby -rminitest/pride test/credential_test.rb --verbose
49
+ $ruby -rminitest/pride test/credit_card_test.rb --verbose
50
+ ```
51
+
52
+ or run rake:
53
+
54
+ ```ruby
55
+ rake
56
+ ```
57
+
58
+ to run all the tests.
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://bitbucket.org/bparanj/filly.
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
67
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "filly"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/filly.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'filly/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "filly"
8
+ spec.version = Filly::VERSION
9
+ spec.authors = ["Bala Paranj"]
10
+ spec.email = ["bparanj@gmail.com"]
11
+
12
+ spec.summary = %q{Credit card and credential check for Stripe API.}
13
+ spec.description = %q{This gem implements the credit card related functionality and credential check using Stripe API.}
14
+ spec.homepage = "http://www.rubyplus.com"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'stripe', "~> 1.25"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.8"
27
+ spec.add_development_dependency "rubycritic", "~> 1.4"
28
+ end
@@ -0,0 +1,32 @@
1
+ module Filly
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
+
15
+ in your code.
16
+ ERROR
17
+ begin
18
+ ::Stripe::Account.retrieve
19
+ true
20
+ rescue ::Stripe::AuthenticationError => exception
21
+ puts message
22
+ puts "*" * 40
23
+ puts "Stripe publishable key : #{ENV['STRIPE_PUBLISHABLE_KEY']}"
24
+ puts "Stripe secret key : #{ENV['STRIPE_SECRET_KEY']} "
25
+ puts "Stripe.api_key : #{Stripe.api_key}"
26
+ puts "*" * 40
27
+ false
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,51 @@
1
+ module Filly
2
+
3
+ class CreditCard
4
+ #
5
+ # Adds a new credit card as the active default card for an existing customer
6
+ #
7
+ # stripe_customer_id : Stripe customer to add a new credit card
8
+ # stripe_token : Token representing the credit card
9
+ #
10
+ # Returns : Stripe::Card object
11
+ #
12
+ def self.add(stripe_customer_id, stripe_token)
13
+ customer = Stripe::Customer.retrieve(stripe_customer_id)
14
+ card = customer.sources.create(source: stripe_token)
15
+ customer.default_card = card.id
16
+ customer.save
17
+ card
18
+ end
19
+
20
+ #
21
+ # Create a new credit card for a customer
22
+ #
23
+ # stripe_token : Token representing the credit card
24
+ # description : The description for the transaction
25
+ #
26
+ # Returns : Stripe::Customer
27
+ #
28
+ def self.save(stripe_token, description)
29
+ Stripe::Customer.create(card: stripe_token, description: description)
30
+ end
31
+
32
+ #
33
+ # Update expiration date of an existing credit card for a customer
34
+ #
35
+ # stripe_customer_id : Stripe customer to update the credit card expiration date
36
+ # card_month : The credit card expiration month
37
+ # card_year : The credit card expiration year
38
+ #
39
+ # Returns : Stripe::Card object
40
+ #
41
+ def self.update_expiration_date(stripe_customer_id, card_month, card_year)
42
+ customer = Stripe::Customer.retrieve(stripe_customer_id)
43
+ card = customer.sources.first
44
+ card.exp_month = card_month
45
+ card.exp_year = card_year
46
+ card.save
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,3 @@
1
+ module Filly
2
+ VERSION = "0.1.0"
3
+ end
data/lib/filly.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "stripe"
2
+
3
+ require "filly/version"
4
+ require "filly/credit_card"
5
+ require "filly/credential"
6
+
7
+ module Filly
8
+ STRIPE_API_VERSION = '2015-09-03 (latest)'
9
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: filly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bala Paranj
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: stripe
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.25'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.25'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubycritic
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
83
+ description: This gem implements the credit card related functionality and credential
84
+ check using Stripe API.
85
+ email:
86
+ - bparanj@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - filly.gemspec
100
+ - lib/filly.rb
101
+ - lib/filly/credential.rb
102
+ - lib/filly/credit_card.rb
103
+ - lib/filly/version.rb
104
+ homepage: http://www.rubyplus.com
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5.1
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Credit card and credential check for Stripe API.
128
+ test_files: []