cardia 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +28 -0
- data/README.txt +8 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/lib/cardia/credit_card_transaction.rb +207 -0
- data/lib/cardia/customer.rb +15 -0
- data/lib/cardia/merchant.rb +23 -0
- data/lib/cardia/order.rb +37 -0
- data/lib/cardia/transaction_status.rb +60 -0
- data/lib/cardia/version.rb +9 -0
- data/lib/cardia.rb +19 -0
- data/lib/credit_card.rb +189 -0
- data/lib/enum.rb +78 -0
- data/lib/validateable.rb +80 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +27 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_cardia.rb +11 -0
- data/test/test_credit_card_transaction.rb +76 -0
- data/test/test_helper.rb +33 -0
- data/test/test_transaction_status.rb +15 -0
- metadata +80 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{RUBYFORGE_USERNAME}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{RUBYFORGE_USERNAME}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{RUBYFORGE_USERNAME}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
data/test/test_cardia.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
class TestCreditCardTransaction < Test::Unit::TestCase
|
2
|
+
def invalid_card
|
3
|
+
return ActiveMerchant::Billing::CreditCard.invalid_card_for_testing
|
4
|
+
end
|
5
|
+
|
6
|
+
def valid_card
|
7
|
+
return ActiveMerchant::Billing::CreditCard.valid_card_for_testing
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def create_order
|
12
|
+
order = Cardia::Order.new(10000, "Stuff from Juks&Bedrag AS")
|
13
|
+
order.customer = Cardia::Customer.new("Jens","Jap")
|
14
|
+
return order
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_transaction
|
18
|
+
order = create_order
|
19
|
+
trans = Cardia::CreditCardTransaction.new(order, nil)
|
20
|
+
trans.merchant = Cardia::Merchant.test_merchant
|
21
|
+
return trans
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_valid_card
|
25
|
+
assert valid_card.valid?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_invalid_card
|
29
|
+
assert !invalid_card.valid?
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_payment_with_invalid_card
|
33
|
+
assert_raises RuntimeError do
|
34
|
+
trans = create_transaction
|
35
|
+
trans.register(invalid_card)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_payment_with_valid_card
|
40
|
+
trans = create_transaction
|
41
|
+
assert trans
|
42
|
+
assert_equal 1, trans.register(valid_card)
|
43
|
+
assert_equal Cardia::TransactionStatus.approved, trans.check_status
|
44
|
+
assert_equal "|RegisterCardTransaction|ReturnTransactionStatus|", trans.log
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_transaction_responds_to_refund
|
48
|
+
trans = create_transaction
|
49
|
+
assert trans.respond_to?(:refund)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_verification_value_required_for_3d_transactions
|
53
|
+
card = valid_card
|
54
|
+
card.verification_value = nil
|
55
|
+
trans = create_transaction
|
56
|
+
assert_raises RuntimeError do
|
57
|
+
trans.register_3d(card, "success", "failure")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_register_3d
|
62
|
+
trans = create_transaction
|
63
|
+
card = valid_card
|
64
|
+
card.verification_value = "081"
|
65
|
+
assert_equal "http://TheHost/TheAddress?preparationGuid=TheGuid", trans.register_3d(card, "success", "failure")
|
66
|
+
assert_equal "|PrepareTransaction|", trans.log
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_wait_until_approved
|
70
|
+
trans = create_transaction
|
71
|
+
trans.register(valid_card)
|
72
|
+
var = false
|
73
|
+
trans.wait_until_approved { var = true }
|
74
|
+
assert var
|
75
|
+
end
|
76
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/cardia'
|
3
|
+
|
4
|
+
|
5
|
+
# Mocking stuff out
|
6
|
+
class Cardia::CreditCardTransaction
|
7
|
+
attr_reader :log
|
8
|
+
@@response_code = 0
|
9
|
+
|
10
|
+
def self.response_code
|
11
|
+
@@response_code
|
12
|
+
end
|
13
|
+
|
14
|
+
def log_method(method)
|
15
|
+
@log ||= String.new("|")
|
16
|
+
@log << method << "|"
|
17
|
+
end
|
18
|
+
|
19
|
+
def invoke_transaction_web_service(method, values)
|
20
|
+
log_method(method)
|
21
|
+
status_code = 1
|
22
|
+
return status_code, REXML::Document.new("<root><StatusCode>#{status_code}</StatusCode><ResponseCode>#{@@response_code}</ResponseCode><CurrencyCode>3</CurrencyCode><RecurringCode>4</RecurringCode></root>")
|
23
|
+
end
|
24
|
+
|
25
|
+
def invoke_teller_web_service(method, values)
|
26
|
+
log_method(method)
|
27
|
+
return 1, REXML::Document.new("<root><Address>http://TheHost/TheAddress</Address><ReferenceGuid>TheGuid</ReferenceGuid></root>")
|
28
|
+
end
|
29
|
+
|
30
|
+
def wait_until_approved
|
31
|
+
yield
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class TestTransactionStatus < Test::Unit::TestCase
|
2
|
+
def test_status_failure_message
|
3
|
+
status = Cardia::TransactionStatus.not_approved
|
4
|
+
status.response_code = 17
|
5
|
+
assert_equal "Card is expired, Transaction not approved", status.explanation
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_response_success
|
9
|
+
status = Cardia::TransactionStatus.not_approved
|
10
|
+
status.response_code = 17
|
11
|
+
assert !status.response_success?
|
12
|
+
status.response_code = 0
|
13
|
+
assert status.response_success?
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: cardia
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-09-01 00:00:00 +02:00
|
8
|
+
summary: provides credit card payments through Cardia
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: marius.mathiesen@gmail.com
|
12
|
+
homepage: http://cardia.rubyforge.org
|
13
|
+
rubyforge_project: cardia
|
14
|
+
description: provides credit card payments through Cardia
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- "Marius M\xC3\xA5rnes Mathiesen"
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- License.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- Rakefile
|
37
|
+
- config/hoe.rb
|
38
|
+
- config/requirements.rb
|
39
|
+
- lib/cardia.rb
|
40
|
+
- lib/cardia/credit_card_transaction.rb
|
41
|
+
- lib/cardia/customer.rb
|
42
|
+
- lib/cardia/merchant.rb
|
43
|
+
- lib/cardia/order.rb
|
44
|
+
- lib/cardia/transaction_status.rb
|
45
|
+
- lib/cardia/version.rb
|
46
|
+
- lib/credit_card.rb
|
47
|
+
- lib/enum.rb
|
48
|
+
- lib/validateable.rb
|
49
|
+
- log/debug.log
|
50
|
+
- script/destroy
|
51
|
+
- script/generate
|
52
|
+
- setup.rb
|
53
|
+
- tasks/deployment.rake
|
54
|
+
- tasks/environment.rake
|
55
|
+
- tasks/website.rake
|
56
|
+
- test/test_cardia.rb
|
57
|
+
- test/test_credit_card_transaction.rb
|
58
|
+
- test/test_helper.rb
|
59
|
+
- test/test_transaction_status.rb
|
60
|
+
test_files:
|
61
|
+
- test/test_cardia.rb
|
62
|
+
- test/test_credit_card_transaction.rb
|
63
|
+
- test/test_helper.rb
|
64
|
+
- test/test_transaction_status.rb
|
65
|
+
rdoc_options:
|
66
|
+
- --main
|
67
|
+
- README.txt
|
68
|
+
extra_rdoc_files:
|
69
|
+
- History.txt
|
70
|
+
- License.txt
|
71
|
+
- Manifest.txt
|
72
|
+
- README.txt
|
73
|
+
executables: []
|
74
|
+
|
75
|
+
extensions: []
|
76
|
+
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
dependencies: []
|
80
|
+
|