payme 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'jeweler'
4
+
5
+ gem 'rdiscount'
6
+ gem 'sdoc'
7
+ gem 'sdoc-helpers'
8
+
9
+ group :test do
10
+ gem "rspec"
11
+ gem "mocha"
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 LIM SAS
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Sogenactif
2
+
3
+ A ruby library to easily do and process online payments using the Sogenactif API.
4
+
5
+ **Disclaimer** : This is still under heavy development and shouldn't be used in production.
6
+
7
+
8
+
9
+ Contributing
10
+ ------------
11
+
12
+ If you think Sogenactif is great but can be improved, feel free to contribute.
13
+ To do so, you can :
14
+
15
+ * [Fork](http://help.github.com/forking/) the project
16
+ * Do your changes and commit them to your repository
17
+ * Test your changes. We won't accept any untested contributions (except if they're not testable).
18
+ * Create an [issue](http://github.com/LIMSAS/sogenactif/issues) with a link to your commits.
19
+
20
+ And that's it! We'll soon take a look at your issue and review your changes.
21
+
22
+
23
+ # Credits
24
+
25
+ Developped and maintained by [LIM SAS](http://lim.eu)
26
+
27
+
28
+ Damien MATHIEU :: damien.mathieu (AT|CHEZ) lim.eu
29
+
30
+ Julien SANCHEZ :: julien.sanchez (AT|CHEZ) lim.eu
31
+
32
+ Hervé GAUCHER :: herve.gaucher (AT|CHEZ) lim.eu
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require 'spec/rake/spectask'
6
+ #
7
+ # The rspec tasks
8
+ #
9
+ task :default => :spec
10
+
11
+ desc "Run all specs"
12
+ Spec::Rake::SpecTask.new('spec') do |t|
13
+ t.spec_files = FileList['spec/**/*.rb']
14
+ t.spec_opts = ['-cfs']
15
+ end
16
+
17
+ #
18
+ # Jeweler
19
+ #
20
+ begin
21
+ require 'jeweler'
22
+ Jeweler::Tasks.new do |gemspec|
23
+ gemspec.name = "payme"
24
+ gemspec.summary = "Process online payments through the Atos Worldline gateway"
25
+ gemspec.description = "Need online payment?"
26
+ gemspec.email = "damien.mathieu@lim.eu"
27
+ gemspec.homepage = "http://github.com/LIMSAS/payme"
28
+ gemspec.authors = ["LIM SAS", "Damien MATHIEU", "Julien SANCHEZ", "Hervé GAUCHER"]
29
+ end
30
+ rescue LoadError
31
+ puts "Jeweler not available. Install it with: gem install jeweler"
32
+ end
33
+
34
+ #
35
+ # SDoc
36
+ #
37
+ begin
38
+ require 'sdoc_helpers'
39
+ rescue LoadError
40
+ puts "sdoc support not enabled. Please gem install sdoc-helpers."
41
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,52 @@
1
+ module Payme
2
+ class Config
3
+ @@config_path = nil
4
+ @@config_env = nil
5
+
6
+ def self.default
7
+ self.new.default
8
+ end
9
+
10
+ def default
11
+ yaml_default || hard_default
12
+ end
13
+
14
+ def self.set_config(file_path, env)
15
+ @@config_path, @@config_env = file_path, env
16
+ end
17
+
18
+ def self.config_path
19
+ @@config_path
20
+ end
21
+
22
+
23
+ private
24
+ def hard_default
25
+ {
26
+ :pathfile => '/',
27
+ :bin_path => '/',
28
+ :debug => true
29
+ }
30
+ end
31
+
32
+ def yaml_default
33
+ @config ||= symbolize_keys YAML::load(File.open(@@config_path))[@@config_env] unless @@config_path.nil? or @@config_env.nil?
34
+ end
35
+
36
+ def symbolize_keys arg
37
+ case arg
38
+ when Array
39
+ arg.map { |elem| symbolize_keys elem }
40
+ when Hash
41
+ Hash[
42
+ arg.map { |key, value|
43
+ k = key.is_a?(String) ? key.to_sym : key
44
+ v = symbolize_keys value
45
+ [k,v]
46
+ }]
47
+ else
48
+ arg
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ module Payme
2
+ module Errors
3
+
4
+ class MissingPath < RuntimeError; end
5
+ class InvalidFieldsNumber < RuntimeError; end
6
+ class ApiCall < RuntimeError
7
+ attr_reader :code, :error
8
+ def initialize(code, error)
9
+ @code, @error = code, error
10
+ super("The error code ##{code} occured when making the request - #{error}")
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ module Payme
2
+ module RequestBinary
3
+ def self.included(klass)
4
+ klass.class_eval do
5
+
6
+ #
7
+ # Executes the binary call, gets the datas
8
+ # Validates that the the code is correct
9
+ # And returns the form
10
+ #
11
+ def launch
12
+ result = exec.split('!')
13
+
14
+ raise Payme::Errors::MissingPath if result.empty? or (result[1].empty? && result[2].empty?)
15
+ raise Payme::Errors::ApiCall.new(result[1], result[2]) unless result[1].to_i == 0
16
+ result
17
+ end
18
+
19
+ private
20
+ #
21
+ # Executes the binary call
22
+ #
23
+ def exec
24
+ path = File.join(options[:bin_path], 'request')
25
+ `#{path} #{parse_params}`
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ Payme::Request.send(:include, Payme::RequestBinary)
@@ -0,0 +1,27 @@
1
+ module Payme
2
+ module Params
3
+ def self.included(klass)
4
+ klass.class_eval do
5
+
6
+ #
7
+ # Parse the provided parameters before to make a binary call
8
+ #
9
+ def parse_params
10
+ options.reject do |k,v|
11
+ !valid_params.include?(k.to_s)
12
+ end.to_a.collect do |a|
13
+ a.join('=')
14
+ end.join(' ') + " amount=#{amount}"
15
+ end
16
+ end
17
+
18
+
19
+ private
20
+ def valid_params
21
+ ['merchant_id', 'merchant_country', 'amount', 'currency_code', 'pathfile']
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ Payme::Request.send(:include, Payme::Params)
@@ -0,0 +1,23 @@
1
+ module Payme
2
+ class Request
3
+ attr_reader :amount, :options
4
+
5
+ def initialize(amount, options = {})
6
+ @amount, @options = amount, default_options.merge(options)
7
+
8
+ end
9
+
10
+
11
+ private
12
+ def default_options
13
+ {
14
+ :merchant_id => '014213245611111',
15
+ :merchant_country => 'fr',
16
+ :currency_code => 978,
17
+ }.merge Payme::Config.default
18
+ end
19
+ end
20
+ end
21
+
22
+ require 'payme/request/params'
23
+ require 'payme/request/binary'
@@ -0,0 +1,49 @@
1
+ module Payme
2
+ module ResponseBinary
3
+ def self.included(klass)
4
+ klass.class_eval do
5
+
6
+ #
7
+ # Executes the binary call, gets the datas
8
+ # Validates that the the code is correct
9
+ # And returns the form
10
+ #
11
+ def launch
12
+ result = exec.split('!')
13
+
14
+ raise Payme::Errors::MissingPath if result.empty? or (result[1].empty? && result[2].empty?)
15
+ raise Payme::Errors::ApiCall.new(result[1], result[2]) unless result[1].to_i == 0
16
+ parse_result result
17
+ end
18
+
19
+ private
20
+ #
21
+ # Executes the binary call
22
+ #
23
+ def exec
24
+ path = File.join(options[:bin_path], 'response')
25
+ `#{path} pathfile=#{options[:pathfile]} message=#{message}`
26
+ end
27
+
28
+ def parse_result(result)
29
+ parsed = Hash.new
30
+ result.each_index do |i|
31
+ parsed[fields[i-1].to_sym] = result[i]
32
+ end
33
+ parsed
34
+ end
35
+
36
+ def fields
37
+ ['code', 'error', 'merchant_id', 'merchant_country', 'amount', 'transaction_id', 'payment_means',
38
+ 'transmission_date', 'payment_time', 'payment_date', 'response_code', 'payment_certificate',
39
+ 'authorisation_id', 'currency_code', 'card_number', 'cvv_flag', 'cvv_response_code',
40
+ 'bank_response_code', 'complementary_code', 'complementary_info', 'return_context',
41
+ 'caddie', 'receipt_complement', 'merchant_language', 'language', 'customer_id',
42
+ 'order_id', 'customer_email', 'customer_ip_address', 'capture_day', 'capture_mode', 'data']
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ Payme::Response.send(:include, Payme::ResponseBinary)
@@ -0,0 +1,12 @@
1
+ module Payme
2
+ class Response
3
+ attr_reader :message, :options
4
+
5
+ def initialize(message, options = {})
6
+ @message, @options = message, Payme::Config.default.merge(options)
7
+
8
+ end
9
+ end
10
+ end
11
+
12
+ require 'payme/response/binary'
data/lib/payme.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require 'payme/config'
6
+ require 'payme/errors'
7
+ require 'payme/request'
8
+ require 'payme/response'
data/payme.gemspec ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{payme}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["LIM SAS", "Damien MATHIEU", "Julien SANCHEZ", "Herv\303\251 GAUCHER"]
12
+ s.date = %q{2010-07-02}
13
+ s.description = %q{Need online payment?}
14
+ s.email = %q{damien.mathieu@lim.eu}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "Gemfile",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/payme.rb",
27
+ "lib/payme/config.rb",
28
+ "lib/payme/errors.rb",
29
+ "lib/payme/request.rb",
30
+ "lib/payme/request/binary.rb",
31
+ "lib/payme/request/params.rb",
32
+ "lib/payme/response.rb",
33
+ "lib/payme/response/binary.rb",
34
+ "payme.gemspec",
35
+ "sogenactif.gemspec",
36
+ "spec/fixtures/config.yml",
37
+ "spec/payme/config_spec.rb",
38
+ "spec/payme/request/binary_spec.rb",
39
+ "spec/payme/request/params_spec.rb",
40
+ "spec/payme/request_spec.rb",
41
+ "spec/payme/response/binary_spec.rb",
42
+ "spec/payme/response_spec.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+ s.homepage = %q{http://github.com/LIMSAS/payme}
46
+ s.rdoc_options = ["--charset=UTF-8"]
47
+ s.require_paths = ["lib"]
48
+ s.rubygems_version = %q{1.3.7}
49
+ s.summary = %q{Process online payments through the Atos Worldline gateway}
50
+ s.test_files = [
51
+ "spec/spec_helper.rb",
52
+ "spec/payme/request_spec.rb",
53
+ "spec/payme/response/binary_spec.rb",
54
+ "spec/payme/response_spec.rb",
55
+ "spec/payme/request/params_spec.rb",
56
+ "spec/payme/request/binary_spec.rb",
57
+ "spec/payme/config_spec.rb"
58
+ ]
59
+
60
+ if s.respond_to? :specification_version then
61
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
62
+ s.specification_version = 3
63
+
64
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
+ else
66
+ end
67
+ else
68
+ end
69
+ end
70
+
@@ -0,0 +1,61 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sogenactif}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["LIM SAS", "Damien MATHIEU", "Julien SANCHEZ", "Herv\303\251 GAUCHER"]
12
+ s.date = %q{2010-07-01}
13
+ s.description = %q{Need online payment?}
14
+ s.email = %q{damien.mathieu@lim.eu}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "README.md",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/sogenactif.rb",
24
+ "lib/sogenactif/errors.rb",
25
+ "lib/sogenactif/request.rb",
26
+ "lib/sogenactif/request/binary.rb",
27
+ "lib/sogenactif/request/params.rb",
28
+ "lib/sogenactif/response.rb",
29
+ "lib/sogenactif/response/binary.rb",
30
+ "spec/sogenactif/request/binary_spec.rb",
31
+ "spec/sogenactif/request/params_spec.rb",
32
+ "spec/sogenactif/request_spec.rb",
33
+ "spec/sogenactif/response/binary_spec.rb",
34
+ "spec/sogenactif/response_spec.rb",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/LIMSAS/sogenactif}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.7}
41
+ s.summary = %q{Process online payments through the Sogenactif gateway}
42
+ s.test_files = [
43
+ "spec/sogenactif/request_spec.rb",
44
+ "spec/sogenactif/response/binary_spec.rb",
45
+ "spec/sogenactif/response_spec.rb",
46
+ "spec/sogenactif/request/params_spec.rb",
47
+ "spec/sogenactif/request/binary_spec.rb",
48
+ "spec/spec_helper.rb"
49
+ ]
50
+
51
+ if s.respond_to? :specification_version then
52
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ else
57
+ end
58
+ else
59
+ end
60
+ end
61
+
@@ -0,0 +1,2 @@
1
+ test:
2
+ merchant_id: 123456789
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payme::Config do
4
+
5
+ describe 'default' do
6
+ it 'should return a hash' do
7
+ Payme::Config.default.should be_kind_of Hash
8
+ end
9
+
10
+ it 'should not be empty' do
11
+ Payme::Config.default.should_not be_empty
12
+ end
13
+ end
14
+
15
+ describe 'set and get config' do
16
+ it 'should define the config file path' do
17
+ Payme::Config.config_path.should be_nil
18
+ Payme::Config.set_config('/tmp/test', 'test')
19
+ Payme::Config.config_path.should eql('/tmp/test')
20
+ end
21
+
22
+ it 'should load the appropriate config when defined' do
23
+ Payme::Config.set_config('spec/fixtures/config.yml', 'test')
24
+ Payme::Request.new(300).options[:merchant_id].should eql(123456789)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payme::RequestBinary do
4
+
5
+ describe 'launch' do
6
+
7
+ it 'should raise an error api call error if the result is an empty string' do
8
+ request = Payme::Request.new(300)
9
+ request.expects(:exec).once.returns('')
10
+ lambda do
11
+ request.launch
12
+ end.should raise_error Payme::Errors::MissingPath
13
+ end
14
+
15
+ it 'should raise an error api call if there is no error and no code' do
16
+ request = Payme::Request.new(300)
17
+ request.expects(:exec).once.returns('!!!')
18
+ lambda do
19
+ request.launch
20
+ end.should raise_error Payme::Errors::MissingPath
21
+ end
22
+
23
+ it 'should raise an error' do
24
+ request = Payme::Request.new(300)
25
+ request.expects(:exec).once.returns('!15!My Error!')
26
+ lambda do
27
+ request.launch
28
+ end.should raise_error Payme::Errors::ApiCall
29
+ end
30
+
31
+ it 'should return the form' do
32
+ request = Payme::Request.new(300)
33
+ request.expects(:exec).once.returns('!0!!Some Form')
34
+ request.launch.should eql(['', '0', '', 'Some Form'])
35
+ end
36
+ end
37
+
38
+ describe 'exec' do
39
+ it 'should execute the binary with basic options' do
40
+ request = Payme::Request.new(300)
41
+ request.expects(:`).with("/request #{request.parse_params}").once
42
+ request.send(:exec)
43
+ end
44
+
45
+ it 'should execute the binary with a defined path' do
46
+ request = Payme::Request.new(300, :bin_path => '/bin')
47
+ request.expects(:`).with("/bin/request #{request.parse_params}").once
48
+ request.send(:exec)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payme::Params do
4
+
5
+ describe 'parse_params' do
6
+ it 'should parse the default params' do
7
+ Payme::Request.new(300).parse_params.should match(/([a-z\_]+)=([0-z]+)/)
8
+ end
9
+
10
+ it 'should parse defined params' do
11
+ Payme::Request.new(300, {
12
+ :merchant_id => '0000',
13
+ :amount => 15,
14
+ :merchant_country => 'uk',
15
+ :currency_code => 42
16
+ }).parse_params.should match(/([a-z\_]+)=([0-z]+)/)
17
+ end
18
+
19
+ it 'should have the merchant id' do
20
+ Payme::Request.new(300).parse_params.should match(/merchant_id=014213245611111/)
21
+ end
22
+
23
+ it 'should have the merchant country' do
24
+ Payme::Request.new(300).parse_params.should match(/merchant_country=fr/)
25
+ end
26
+
27
+ it 'should have the currency code' do
28
+ Payme::Request.new(300).parse_params.should match(/currency_code=978/)
29
+ end
30
+
31
+ it 'should have the pathfile' do
32
+ Payme::Request.new(300).parse_params.should match(/pathfile=\//)
33
+ end
34
+
35
+ it 'should have the amount' do
36
+ Payme::Request.new(300).parse_params.should match(/amount=300/)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payme::Request do
4
+
5
+ describe 'initialize' do
6
+ it 'should be able to initialize without options' do
7
+ Payme::Request.new(150).options[:bin_path].should eql('/')
8
+ end
9
+
10
+ it 'should be able to initialize with options' do
11
+ Payme::Request.new(150, :bin_path => '/bin').options[:bin_path].should eql('/bin')
12
+ end
13
+
14
+ it 'should initialize the amount' do
15
+ Payme::Request.new(300).amount.should eql(300)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payme::ResponseBinary do
4
+
5
+ describe 'launch' do
6
+ it 'should raise an error api call error if the result is an empty string' do
7
+ response = Payme::Response.new('testing')
8
+ response.expects(:exec).once.returns('')
9
+ lambda do
10
+ response.launch
11
+ end.should raise_error Payme::Errors::MissingPath
12
+ end
13
+
14
+ it 'should raise an error api call if there is no error and no code' do
15
+ response = Payme::Response.new('testing')
16
+ response.expects(:exec).once.returns('!!!')
17
+ lambda do
18
+ response.launch
19
+ end.should raise_error Payme::Errors::MissingPath
20
+ end
21
+
22
+ it 'should raise an error' do
23
+ response = Payme::Response.new('testing')
24
+ response.expects(:exec).once.returns('!15!My Error!')
25
+ lambda do
26
+ response.launch
27
+ end.should raise_error Payme::Errors::ApiCall
28
+ end
29
+
30
+ it 'should not raise an error if the number of elements is not equal to the number of fields' do
31
+ response = Payme::Response.new('testing')
32
+ response.expects(:exec).once.returns('!0!!!!!')
33
+ response.launch.should be_kind_of Hash
34
+ end
35
+
36
+ it 'should get the response elements' do
37
+ response = Payme::Response.new('testing')
38
+ fields = Payme::Response.new('testing').send(:fields)
39
+ response.expects(:exec).once.returns("!#{fields.join('!')}")
40
+
41
+ launched = response.launch
42
+ launched.should be_kind_of Hash
43
+ launched.should_not be_empty
44
+ end
45
+ end
46
+
47
+ describe 'exec' do
48
+ it 'should execute the binary with basic options' do
49
+ response = Payme::Response.new('testing')
50
+ response.expects(:`).with("/response pathfile=/ message=testing").once
51
+ response.send(:exec)
52
+ end
53
+
54
+ it 'should execute the binary with a different message' do
55
+ response = Payme::Response.new('42')
56
+ response.expects(:`).with("/response pathfile=/ message=42").once
57
+ response.send(:exec)
58
+ end
59
+
60
+ it 'should execute the binary with a defined path' do
61
+ response = Payme::Response.new('testing', :bin_path => '/bin')
62
+ response.expects(:`).with("/bin/response pathfile=/ message=testing").once
63
+ response.send(:exec)
64
+ end
65
+
66
+ it 'should execute the binary with a defined file' do
67
+ response = Payme::Response.new('testing', :pathfile => '/file')
68
+ response.expects(:`).with("/response pathfile=/file message=testing").once
69
+ response.send(:exec)
70
+ end
71
+ end
72
+
73
+ describe 'parse_result' do
74
+ it 'should parse the results array' do
75
+ fields = Payme::Response.new('testing').send(:fields)
76
+ result = Payme::Response.new('testing').send(:parse_result, fields)
77
+ result.should be_kind_of Hash
78
+ result.should_not be_empty
79
+ end
80
+ end
81
+
82
+ describe 'fields' do
83
+ it 'should be an array' do
84
+ Payme::Response.new('testing').send(:fields).should be_kind_of Array
85
+ end
86
+
87
+ it 'should not be empty' do
88
+ Payme::Response.new('testing').send(:fields).should_not be_empty
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payme::Response do
4
+
5
+ describe 'initialize' do
6
+ it 'should be able to initialize without options' do
7
+ Payme::Response.new('test').options[:bin_path].should eql('/')
8
+ end
9
+
10
+ it 'should be able to initialize with options' do
11
+ Payme::Response.new('test', :bin_path => '/bin').options[:bin_path].should eql('/bin')
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ require 'payme'
2
+
3
+ require 'spec'
4
+ require 'mocha'
5
+ require 'spec/autorun'
6
+ require 'spec/interop/test'
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: payme
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - LIM SAS
14
+ - Damien MATHIEU
15
+ - Julien SANCHEZ
16
+ - "Herv\xC3\xA9 GAUCHER"
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2010-07-02 00:00:00 +02:00
22
+ default_executable:
23
+ dependencies: []
24
+
25
+ description: Need online payment?
26
+ email: damien.mathieu@lim.eu
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.md
34
+ files:
35
+ - .gitignore
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - VERSION
41
+ - lib/payme.rb
42
+ - lib/payme/config.rb
43
+ - lib/payme/errors.rb
44
+ - lib/payme/request.rb
45
+ - lib/payme/request/binary.rb
46
+ - lib/payme/request/params.rb
47
+ - lib/payme/response.rb
48
+ - lib/payme/response/binary.rb
49
+ - payme.gemspec
50
+ - sogenactif.gemspec
51
+ - spec/fixtures/config.yml
52
+ - spec/payme/config_spec.rb
53
+ - spec/payme/request/binary_spec.rb
54
+ - spec/payme/request/params_spec.rb
55
+ - spec/payme/request_spec.rb
56
+ - spec/payme/response/binary_spec.rb
57
+ - spec/payme/response_spec.rb
58
+ - spec/spec_helper.rb
59
+ has_rdoc: true
60
+ homepage: http://github.com/LIMSAS/payme
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.7
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Process online payments through the Atos Worldline gateway
93
+ test_files:
94
+ - spec/spec_helper.rb
95
+ - spec/payme/request_spec.rb
96
+ - spec/payme/response/binary_spec.rb
97
+ - spec/payme/response_spec.rb
98
+ - spec/payme/request/params_spec.rb
99
+ - spec/payme/request/binary_spec.rb
100
+ - spec/payme/config_spec.rb