skroutz_pay 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +13 -0
- data/Rakefile +1 -0
- data/lib/skroutz_pay.rb +9 -0
- data/lib/skroutz_pay/gateways/american_express.rb +49 -0
- data/lib/skroutz_pay/gateways/mastercard.rb +49 -0
- data/lib/skroutz_pay/gateways/visa.rb +47 -0
- data/lib/skroutz_pay/version.rb +3 -0
- data/skroutz_pay.gemspec +23 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NTFkOGE3YmMwYmFiMDg1ZWUyZjhiZDVjYWU2NWRhMTk2N2ZmNmVkYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWUwOGE0NWFkZDEwZWUzZTgwZGYzMDdiNmUyMGFkZmFjYjE2MGRmYQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2YwMjRjNjY4ODBjOGI2MzZkYmYyY2UyNzkyNmQzNDlmNmYwZWJhZmIzNTNl
|
10
|
+
MGU0YWViNzZkYzBhOGJkZDA3MmY4ZDFmZTVhNTczZDZiYTIyYWZiZWZiNzg0
|
11
|
+
N2VmOGMwNjY5NWFlNGM4YjhmYmQ4YzM3MGRkOWQwOWMyN2RkOTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YjFjODVhOWNhOWE3NDY4ODVhZTE2ZDAyNTRjNzJjY2UyYmYyNzUyMGE2MjI1
|
14
|
+
ODQ2N2Q5MThiMzdiZmRiY2U3YjU1YjAzM2Q2NmE2ZTg5Y2FlNjEzNDBlMDA3
|
15
|
+
Mzg5N2ZlYzFkYjYxZjMwYTZjYjU1MzQ1N2M2MWRlNDc4N2ZiYjM=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 George Chatzigeorgiou
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/skroutz_pay.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "skroutz_pay/version"
|
2
|
+
require "skroutz_pay/gateways/visa"
|
3
|
+
require "skroutz_pay/gateways/mastercard"
|
4
|
+
require "skroutz_pay/gateways/american_express"
|
5
|
+
|
6
|
+
module SkroutzPay
|
7
|
+
class InvalidCreditCardData < Exception; end
|
8
|
+
class InvalidChargeAmount < Exception; end
|
9
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module SkroutzPay
|
2
|
+
module Gateways
|
3
|
+
module AmericanExpress
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# Authorizes a payment
|
7
|
+
# The auth sequence will approve or not the payment for this credit card but
|
8
|
+
# will not make any actual transation.
|
9
|
+
#
|
10
|
+
# @param [String] ccn, the credit card number
|
11
|
+
# @param [Date] expiration date
|
12
|
+
# @param [String] cvv2
|
13
|
+
# @param [Integer] amount to preauth in cents
|
14
|
+
def authorize(ccn, expiration_date, cvv2, amount)
|
15
|
+
request(ccn, expiration_date, cvv2, amount)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Captures a payment by charging actual money
|
19
|
+
#
|
20
|
+
# @param [String] ccn, the credit card number
|
21
|
+
# @param [String] expiration date in "mm/yy" format
|
22
|
+
# @param [String] cvv2
|
23
|
+
# @param [Integer] amount to preauth in euros
|
24
|
+
def capture(ccn, expiration_date, cvv2, amount)
|
25
|
+
request(ccn, expiration_date, cvv2, amount, :capture)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def request(ccn, year, month, cvv2, amount, type = :auth)
|
31
|
+
if expiration_date < Date.today
|
32
|
+
raise SkroutzPay::InvalidCreditCardData
|
33
|
+
end
|
34
|
+
|
35
|
+
if !amount.is_a?(Integer)
|
36
|
+
raise SkroutzPay::InvalidChargeAmount
|
37
|
+
end
|
38
|
+
|
39
|
+
if type == :auth
|
40
|
+
# actual code should be here
|
41
|
+
rand(100) % 8 != 0
|
42
|
+
else type == :capture
|
43
|
+
# actual code should be here
|
44
|
+
rand(100) % 8 != 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module SkroutzPay
|
2
|
+
module Gateways
|
3
|
+
module Mastercard
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# Authorizes a payment
|
7
|
+
# The auth sequence will approve or not the payment for this credit card but
|
8
|
+
# will not make any actual transation.
|
9
|
+
#
|
10
|
+
# @param [String] ccn, the credit card number
|
11
|
+
# @param [String] expiration date in "mm/yy" format
|
12
|
+
# @param [String] cvv2
|
13
|
+
# @param [Integer] amount to preauth in cents
|
14
|
+
def auth(ccn, expiration_date, cvv2, amount)
|
15
|
+
request(ccn, expiration_date, cvv2, amount)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Captures a payment by charging actual money
|
19
|
+
#
|
20
|
+
# @param [String] ccn, the credit card number
|
21
|
+
# @param [String] expiration date in "mm/yy" format
|
22
|
+
# @param [String] cvv2
|
23
|
+
# @param [Integer] amount to preauth in euros
|
24
|
+
def capture(ccn, expiration_date, cvv2, amount)
|
25
|
+
request(ccn, expiration_date, cvv2, amount, :capture)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def request(ccn, expiration_date, cvv2, amount, type = :auth)
|
31
|
+
if expiration_date !~ /\A[0-1]\d\/\d{2}\Z/
|
32
|
+
raise SkroutzPay::InvalidCreditCardData
|
33
|
+
end
|
34
|
+
|
35
|
+
if !amount.is_a?(Integer)
|
36
|
+
raise SkroutzPay::InvalidChargeAmount
|
37
|
+
end
|
38
|
+
|
39
|
+
if type == :auth
|
40
|
+
# actual code should be here
|
41
|
+
rand(100) % 8 != 0
|
42
|
+
else type == :capture
|
43
|
+
# actual code should be here
|
44
|
+
rand(100) % 8 != 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module SkroutzPay
|
2
|
+
module Gateways
|
3
|
+
module Visa
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# Preauthorizes a payment
|
7
|
+
# The preauth sequence will approve or not the payment for this credit card but
|
8
|
+
# will not make any actual transation.
|
9
|
+
#
|
10
|
+
# @param [String] ccn, the credit card number
|
11
|
+
# @param [Integer] year (expiration year)
|
12
|
+
# @param [Integer] month (expiration month)
|
13
|
+
# @param [String] cvv2
|
14
|
+
# @param [Float] amount to preauth in euros
|
15
|
+
def preauth(ccn, year, month, cvv2, amount)
|
16
|
+
request(ccn, year, month, cvv2, amount)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Captures a payment by charging actual money
|
20
|
+
#
|
21
|
+
# @param [String] ccn, the credit card number
|
22
|
+
# @param [Integer] year (expiration year)
|
23
|
+
# @param [Integer] month (expiration month)
|
24
|
+
# @param [String] cvv2
|
25
|
+
# @param [Float] amount to preauth in euros
|
26
|
+
def capture(ccn, year, month, cvv2, amount)
|
27
|
+
request(ccn, year, month, cvv2, amount, :capture)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def request(ccn, year, month, cvv2, amount, type = :preauth)
|
33
|
+
if year < Time.now.year
|
34
|
+
raise SkroutzPay::InvalidCreditCardData
|
35
|
+
end
|
36
|
+
|
37
|
+
if type == :preauth
|
38
|
+
# actual code should be here
|
39
|
+
rand(100) % 8 != 0
|
40
|
+
else type == :capture
|
41
|
+
# actual code should be here
|
42
|
+
rand(100) % 8 != 0
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/skroutz_pay.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'skroutz_pay/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "skroutz_pay"
|
8
|
+
spec.version = SkroutzPay::VERSION
|
9
|
+
spec.authors = ["George Chatzigeorgiou"]
|
10
|
+
spec.email = ["george@skroutz.gr"]
|
11
|
+
spec.description = %q{Mock payment framework}
|
12
|
+
spec.summary = %q{Mock payment framework}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skroutz_pay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- George Chatzigeorgiou
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Mock payment framework
|
42
|
+
email:
|
43
|
+
- george@skroutz.gr
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/skroutz_pay.rb
|
54
|
+
- lib/skroutz_pay/gateways/american_express.rb
|
55
|
+
- lib/skroutz_pay/gateways/mastercard.rb
|
56
|
+
- lib/skroutz_pay/gateways/visa.rb
|
57
|
+
- lib/skroutz_pay/version.rb
|
58
|
+
- skroutz_pay.gemspec
|
59
|
+
homepage: ''
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.1.9
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Mock payment framework
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|