simonmenke-active_merchant_ogone 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jan De Poorter
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.rdoc ADDED
@@ -0,0 +1,61 @@
1
+ = ActiveMerchantOgone
2
+
3
+ A plugin for Ogone support in ActiveRecord.
4
+
5
+ == Installation
6
+
7
+ === Requirements
8
+
9
+ First you need the ActiveMerchant gem / rails-plugin installed. More info about ActiveMerchant installation can be found at http://activemerchant.rubyforge.org/.
10
+
11
+ === As a Rails plugin
12
+
13
+ To install ActiveMerchantOgone in your rails app you can just do:
14
+
15
+ > ./script/plugin install git://github.com/DefV/active_merchant_ogone.git
16
+
17
+
18
+ == Configuration
19
+
20
+ As Ogone works with in and out signatures, you will have to set these as constants in your configuration file.
21
+
22
+ OGONE_ACCOUNT = 'account_name'
23
+ OGONE_SHA1_SIGNATURE_OUT = '094598439859385938958398494' # Item 3.2 of the technical information
24
+ OGONE_SHA1_SIGNATURE_IN = '094598439859385938958398494' # Item 4.4 of the technical information
25
+
26
+
27
+ == Example Usage
28
+
29
+ Once you've configured the Ogone settings you need to set up a leaving page with in your view:
30
+
31
+ <% payment_service_for @order.ogone_id, OGONE_ACCOUNT,
32
+ :amount => @order.price * 100 # needs to be in cents
33
+ :currency => 'EUR',
34
+ :service => :ogone do |service| %>
35
+
36
+ <% service.redirect :accepturl => checkout_url(@order),
37
+ :cancelurl => checkout_url(@order),
38
+ :declineurl => checkout_url(@order),
39
+ :exceptionurl => checkout_url(@order)
40
+ %>
41
+
42
+ <%= submit_tag "Pay with Ogone!" %>
43
+ <% end %>
44
+
45
+ And in your controller you should have an enter path:
46
+ class CheckoutsController < ApplicationController
47
+ include ActiveMerchant::Billing::Integrations
48
+
49
+ def show
50
+ @notification = Ogone::Notification.new(request.query_string, :signature => OGONE_SHA1_SIGNATURE_IN)
51
+
52
+ @order = Order.find_by_ogone_id(@notification.order_id)
53
+ if @notification.complete?
54
+ @order.paid!
55
+ else
56
+ @order.failed!
57
+ end
58
+ end
59
+ end
60
+
61
+ Copyright (c) 2009 Openminds BVBVA, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the active_merchant_ogone plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the active_merchant_ogone plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'ActiveMerchantOgone'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ begin
26
+ require 'jeweler'
27
+ Jeweler::Tasks.new do |gemspec|
28
+ gemspec.name = "active_merchant_ogone"
29
+ gemspec.summary = "A plugin for Ogone support in ActiveRecord."
30
+ gemspec.description = "A plugin for Ogone support in ActiveRecord. "
31
+ gemspec.email = "github@defv.be"
32
+ gemspec.homepage = "http://github.com/DefV/active_merchant_ogone/tree/master"
33
+ gemspec.authors = ["Jan De Poorter", "Simon Menke"]
34
+ end
35
+ rescue LoadError
36
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
37
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 0
3
+ :major: 0
4
+ :minor: 1
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'active_merchant_ogone'
@@ -0,0 +1,53 @@
1
+ # Ogone Integration developed by Openminds (www.openminds.be)
2
+ # For problems contact us at ogone@openminds.be
3
+ require 'active_merchant'
4
+ require 'active_merchant_ogone/helper.rb'
5
+ require 'active_merchant_ogone/notification.rb'
6
+
7
+ module ActiveMerchant #:nodoc:
8
+ module Billing #:nodoc:
9
+ module Integrations #:nodoc:
10
+ module Ogone
11
+
12
+ mattr_accessor :test_service_url
13
+ mattr_accessor :live_service_url
14
+
15
+ self.test_service_url = 'https://secure.ogone.com/ncol/test/orderstandard.asp'
16
+ self.live_service_url = 'https://secure.ogone.com/ncol/prod/orderstandard.asp'
17
+
18
+
19
+ def self.service_url
20
+ mode = ActiveMerchant::Billing::Base.integration_mode
21
+ case mode
22
+ when :production then self.live_service_url
23
+ when :test then self.test_service_url
24
+ else
25
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
26
+ end
27
+ end
28
+
29
+ def self.notification(post, options={})
30
+ Notification.new(post, options={})
31
+ end
32
+
33
+ def self.outbound_message_signature(fields, signature)
34
+ keys = %w( orderID amount currency PSPID )
35
+ datastring = keys.inject('') { |m,key| m.concat(fields[key].to_s) ; m }
36
+ datastring.concat(signature)
37
+ Digest::SHA1.hexdigest(datastring).upcase
38
+ end
39
+
40
+ def self.inbound_message_signature(fields, signature)
41
+ keys = %w( orderID currency amount PM ACCEPTANCE STATUS CARDNO PAYID NCERROR BRAND )
42
+ datastring = keys.inject('') { |m,key| m.concat(fields[key].to_s) ; m }
43
+ datastring.concat(signature)
44
+ Digest::SHA1.hexdigest(datastring).upcase
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+
51
+ class OgoneError < ActiveMerchantError; end
52
+ end
53
+
@@ -0,0 +1,51 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Ogone
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+
7
+ # required
8
+ mapping :order, 'orderID'
9
+ mapping :account, 'PSPID'
10
+ mapping :amount, 'amount'
11
+ mapping :currency, 'currency'
12
+
13
+ # optional - TODO
14
+ mapping :billing_address, :city => 'ownertown',
15
+ :address1 => 'owneraddress',
16
+ :zip => 'ownerZIP',
17
+ :country => 'ownercty'
18
+
19
+ # mapping :description, 'COM'
20
+ # mapping :tax, ''
21
+ # mapping :shipping, ''
22
+
23
+ # redirection
24
+ mapping :redirect, :accepturl => 'accepturl',
25
+ :declineurl => 'declineurl',
26
+ :cancelurl => 'cancelurl',
27
+ :exceptionurl => 'exceptionurl'
28
+
29
+ def customer(mapping = {})
30
+ add_field('ownertelno', mapping[:phone])
31
+ add_field('EMAIL', mapping[:email])
32
+ add_field('CN', "#{mapping[:first_name]} #{mapping[:last_name]}")
33
+ end
34
+
35
+ # return the fields
36
+ def form_fields
37
+ add_field('SHASign', outbound_message_signature)
38
+ super
39
+ end
40
+
41
+ private
42
+
43
+ def outbound_message_signature
44
+ Ogone.outbound_message_signature(@fields, OGONE_SHA1_SIGNATURE_OUT)
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,125 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Ogone
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+
9
+ # params on a successfull payment
10
+ # orderID=order_342
11
+ # currency=EUR
12
+ # amount=50
13
+ # PM=CreditCard
14
+ # ACCEPTANCE=test123
15
+ # STATUS=9
16
+ # CARDNO=XXXXXXXXXXXX1111
17
+ # PAYID=2396925
18
+ # NCERROR=0
19
+ # BRAND=VISA
20
+ # IPCTY=BE
21
+ # CCCTY=US
22
+ # ECI=7
23
+ # CVCCheck=NO
24
+ # AAVCheck=NO
25
+ # VC=NO
26
+ # SHASIGN=FE220C6F4492165533488E35F47F231D6BC357FC
27
+ # IP=82.146.99.233
28
+
29
+ STATUS_MAPPING = {
30
+ 0 => 'Incomplete or invalid',
31
+ 1 => 'Cancelled by client',
32
+ 2 => 'Authorization refused',
33
+ 4 => 'Order stored',
34
+ 41 => 'Waiting client payment',
35
+ 5 => 'Authorized',
36
+ 51 => 'Authorization waiting',
37
+ 52 => 'Authorization not known',
38
+ 55 => 'Stand-by',
39
+ 59 => 'Authoriz. to get manually',
40
+ 6 => 'Authorized and cancelled',
41
+ 61 => 'Author. deletion waiting',
42
+ 62 => 'Author. deletion uncertain',
43
+ 63 => 'Author. deletion refused',
44
+ 64 => 'Authorized and cancelled',
45
+ 7 => 'Payment deleted',
46
+ 71 => 'Payment deletion pending',
47
+ 72 => 'Payment deletion uncertain',
48
+ 73 => 'Payment deletion refused',
49
+ 74 => 'Payment deleted',
50
+ 75 => 'Deletion processed by merchant',
51
+ 8 => 'Refund',
52
+ 81 => 'Refund pending',
53
+ 82 => 'Refund uncertain',
54
+ 83 => 'Refund refused',
55
+ 84 => 'Payment declined by the acquirer',
56
+ 85 => 'Refund processed by merchant',
57
+ 9 => 'Payment requested',
58
+ 91 => 'Payment processing',
59
+ 92 => 'Payment uncertain',
60
+ 93 => 'Payment refused',
61
+ 94 => 'Refund declined by the acquirer',
62
+ 95 => 'Payment processed by merchant',
63
+ 99 => 'Being processed'
64
+ }
65
+
66
+ OK_STATUSSES = [4,5,9]
67
+
68
+ def initialize(post, options={})
69
+ super
70
+
71
+ unless params['STATUS'].match(/^\d+$/)
72
+ raise OgoneError, "Faulty Ogone result: '#{params['STATUS']}'"
73
+ end
74
+
75
+ sign = Ogone::inbound_message_signature(params, options[:signature])
76
+ unless params['SHASIGN'] == sign
77
+ raise OgoneError, "Faulty Ogone SHA1 signature: '#{params['SHASIGN']}' != '#{sign}'"
78
+ end
79
+ end
80
+
81
+ def status
82
+ OK_STATUSSES.include?(params['STATUS'].to_i) ? 'Completed' : 'Failed'
83
+ end
84
+
85
+ def status_message # needed?
86
+ STATUS_MAPPING[params['STATUS'].to_i]
87
+ end
88
+
89
+ def gross
90
+ params['amount'].to_f
91
+ end
92
+
93
+ def complete?
94
+ status == 'Completed'
95
+ end
96
+
97
+ def payment_method
98
+ params['PM']
99
+ end
100
+
101
+ def order_id
102
+ params['orderID']
103
+ end
104
+
105
+ def transaction_id
106
+ params['PAYID']
107
+ end
108
+
109
+ def brand
110
+ params['BRAND']
111
+ end
112
+
113
+ def currency
114
+ params['currency']
115
+ end
116
+
117
+ def acknowledge
118
+ true
119
+ end
120
+
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+
3
+ class OgoneHelperTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def setup
7
+ @helper = Ogone::Helper.new('order-500','openminds', :amount => 900, :currency => 'EUR')
8
+ end
9
+
10
+ def test_basic_helper_fields
11
+ assert_field 'PSPID', 'openminds'
12
+
13
+ assert_field 'orderID', 'order-500'
14
+ assert_field 'amount', '900'
15
+ assert_field 'currency', 'EUR'
16
+ end
17
+
18
+ def test_customer_fields
19
+ @helper.customer :first_name => 'Jan', :last_name => 'De Poorter', :email => 'ogone@openminds.be'
20
+ assert_field 'CN', 'Jan De Poorter'
21
+ assert_field 'EMAIL', 'ogone@openminds.be'
22
+ end
23
+
24
+ def test_address_mapping
25
+ @helper.billing_address :address1 => 'Zilverenberg 39',
26
+ :address2 => '',
27
+ :city => 'Ghent',
28
+ :zip => '9000',
29
+ :country => 'BE'
30
+
31
+ assert_field 'owneraddress', 'Zilverenberg 39'
32
+ assert_field 'ownertown', 'Ghent'
33
+ assert_field 'ownerZIP', '9000'
34
+ assert_field 'ownercty', 'BE'
35
+ end
36
+
37
+ def test_unknown_mapping
38
+ assert_nothing_raised do
39
+ @helper.company_address :address => 'Zilverenberg 39'
40
+ end
41
+ end
42
+
43
+ def test_setting_invalid_address_field
44
+ fields = @helper.fields.dup
45
+ @helper.billing_address :street => 'Zilverenberg'
46
+ assert_equal fields, @helper.fields
47
+ end
48
+ end
@@ -0,0 +1,40 @@
1
+ require 'test_helper'
2
+
3
+ class OgoneNotificationTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ OGONE_SHA1_SIGNATURE_IN = '08445a31a78661b5c746feff39a9db6e4e2cc5cf'
7
+
8
+ SUCCESSFULL_HTTP_RAW_DATA = "orderID=order_342&currency=EUR&amount=50&PM=CreditCard&ACCEPTANCE=test123&STATUS=9&CARDNO=XXXXXXXXXXXX1111&PAYID=2396925&NCERROR=0&BRAND=VISA&IPCTY=BE&CCCTY=US&ECI=7&CVCCheck=NO&AAVCheck=NO&VC=NO&SHASIGN=FE220C6F4492165533488E35F47F231D6BC357FC&IP=82.146.99.233"
9
+
10
+ FAULTY_HTTP_RAW_DATA = "orderID=order_342&currency=EUR&amount=50&PM=CreditCard&ACCEPTANCE=test123&STATUS=abc&CARDNO=XXXXXXXXXXXX1111&PAYID=2396925&NCERROR=0&BRAND=VISA&IPCTY=BE&CCCTY=US&ECI=7&CVCCheck=NO&AAVCheck=NO&VC=NO&SHASIGN=FE220C6F4492165533488E35F47F231D6BC357FC&IP=82.146.99.233"
11
+
12
+ def setup
13
+ @ogone = Ogone::Notification.new(SUCCESSFULL_HTTP_RAW_DATA,
14
+ :signature => OGONE_SHA1_SIGNATURE_IN)
15
+ end
16
+
17
+ def test_accessors
18
+ assert @ogone.complete?
19
+ assert_equal "Completed", @ogone.status
20
+ assert_equal "2396925", @ogone.transaction_id
21
+ assert_equal 50.0, @ogone.gross
22
+ assert_equal "EUR", @ogone.currency
23
+ end
24
+
25
+ def test_status_completed
26
+ assert_equal "Completed", @ogone.status
27
+ end
28
+
29
+ def test_compositions
30
+ assert_equal Money.new(5000, 'EUR'), @ogone.amount
31
+ end
32
+
33
+ def test_invalid_status_should_raise_an_error
34
+ assert_raise(ActiveMerchant::OgoneError) do
35
+ Ogone::Notification.new(FAULTY_HTTP_RAW_DATA,
36
+ :signature => OGONE_SHA1_SIGNATURE_IN)
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class ActiveMerchantOgoneTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def test_sha1_signature_out
7
+ # input values and return value taken from BASIC documentation
8
+ data = {'orderID' => '1234',
9
+ 'currency' => 'EUR',
10
+ 'amount' => 1500,
11
+ 'PSPID' => 'MyPSPID' }
12
+
13
+ signature = 'Mysecretsig'
14
+
15
+ assert_equal 'CC88E974F684C0804FD98BEA2FE403E9D11534BB',
16
+ Ogone.outbound_message_signature(data, signature)
17
+ end
18
+
19
+ def test_sha1_signature_in
20
+ # input values and return value taken from BASIC documentation
21
+ data = {'orderID' => '12',
22
+ 'currency' => 'EUR',
23
+ 'amount' => '15',
24
+ 'PM' => 'CreditCard',
25
+ 'ACCEPTANCE' => '1234',
26
+ 'STATUS' => '9',
27
+ 'CARDNO' => 'xxxxxxxxxxxx1111',
28
+ 'PAYID' => '32100123',
29
+ 'NCERROR' => '0',
30
+ 'BRAND' => 'VISA'}
31
+
32
+ signature = 'Mysecretsig'
33
+
34
+ assert_equal '6DDD8C4538ACD0462837DB66F5EAB39C58086A29',
35
+ Ogone.inbound_message_signature(data, signature)
36
+ end
37
+ end
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'rubygems'
5
+ require 'active_merchant'
6
+ require 'money'
7
+ require 'test/unit'
8
+ require 'mocha'
9
+ require 'yaml'
10
+
11
+ begin
12
+ gem 'actionpack'
13
+ rescue LoadError
14
+ raise StandardError, "The view tests need ActionPack installed as gem to run"
15
+ end
16
+
17
+ require 'action_controller'
18
+ require 'action_controller/test_process'
19
+ require 'active_merchant/billing/integrations/action_view_helper'
20
+
21
+ require 'active_merchant_ogone'
22
+
23
+ ActiveMerchant::Billing::Base.mode = :test
24
+
25
+ # Test gateways
26
+ class SimpleTestGateway < ActiveMerchant::Billing::Gateway
27
+ end
28
+
29
+ class SubclassGateway < SimpleTestGateway
30
+ end
31
+
32
+
33
+ module ActiveMerchant
34
+ module Assertions
35
+ def assert_field(field, value)
36
+ clean_backtrace do
37
+ assert_equal value, @helper.fields[field]
38
+ end
39
+ end
40
+
41
+ # Allows the testing of you to check for negative assertions:
42
+ #
43
+ # # Instead of
44
+ # assert !something_that_is_false
45
+ #
46
+ # # Do this
47
+ # assert_false something_that_should_be_false
48
+ #
49
+ # An optional +msg+ parameter is available to help you debug.
50
+ def assert_false(boolean, message = nil)
51
+ message = build_message message, '<?> is not false or nil.', boolean
52
+
53
+ clean_backtrace do
54
+ assert_block message do
55
+ not boolean
56
+ end
57
+ end
58
+ end
59
+
60
+ # A handy little assertion to check for a successful response:
61
+ #
62
+ # # Instead of
63
+ # assert_success response
64
+ #
65
+ # # DRY that up with
66
+ # assert_success response
67
+ #
68
+ # A message will automatically show the inspection of the response
69
+ # object if things go afoul.
70
+ def assert_success(response)
71
+ clean_backtrace do
72
+ assert response.success?, "Response failed: #{response.inspect}"
73
+ end
74
+ end
75
+
76
+ # The negative of +assert_success+
77
+ def assert_failure(response)
78
+ clean_backtrace do
79
+ assert_false response.success?, "Response expected to fail: #{response.inspect}"
80
+ end
81
+ end
82
+
83
+ def assert_valid(validateable)
84
+ clean_backtrace do
85
+ assert validateable.valid?, "Expected to be valid"
86
+ end
87
+ end
88
+
89
+ def assert_not_valid(validateable)
90
+ clean_backtrace do
91
+ assert_false validateable.valid?, "Expected to not be valid"
92
+ end
93
+ end
94
+
95
+ private
96
+ def clean_backtrace(&block)
97
+ yield
98
+ rescue Test::Unit::AssertionFailedError => e
99
+ path = File.expand_path(__FILE__)
100
+ raise Test::Unit::AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
101
+ end
102
+ end
103
+
104
+ module Fixtures
105
+ HOME_DIR = RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'] unless defined?(HOME_DIR)
106
+ LOCAL_CREDENTIALS = File.join(HOME_DIR.to_s, '.active_merchant/fixtures.yml') unless defined?(LOCAL_CREDENTIALS)
107
+ DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
108
+
109
+ private
110
+ def credit_card(number = '4242424242424242', options = {})
111
+ defaults = {
112
+ :number => number,
113
+ :month => 9,
114
+ :year => Time.now.year + 1,
115
+ :first_name => 'Longbob',
116
+ :last_name => 'Longsen',
117
+ :verification_value => '123',
118
+ :type => 'visa'
119
+ }.update(options)
120
+
121
+ Billing::CreditCard.new(defaults)
122
+ end
123
+
124
+ def check(options = {})
125
+ defaults = {
126
+ :name => 'Jim Smith',
127
+ :routing_number => '244183602',
128
+ :account_number => '15378535',
129
+ :account_holder_type => 'personal',
130
+ :account_type => 'checking',
131
+ :number => '1'
132
+ }.update(options)
133
+
134
+ Billing::Check.new(defaults)
135
+ end
136
+
137
+ def address(options = {})
138
+ {
139
+ :name => 'Jim Smith',
140
+ :address1 => '1234 My Street',
141
+ :address2 => 'Apt 1',
142
+ :company => 'Widgets Inc',
143
+ :city => 'Ottawa',
144
+ :state => 'ON',
145
+ :zip => 'K1C2N6',
146
+ :country => 'CA',
147
+ :phone => '(555)555-5555',
148
+ :fax => '(555)555-6666'
149
+ }.update(options)
150
+ end
151
+
152
+ def all_fixtures
153
+ @@fixtures ||= load_fixtures
154
+ end
155
+
156
+ def fixtures(key)
157
+ data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
158
+
159
+ data.dup
160
+ end
161
+
162
+ def load_fixtures
163
+ file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
164
+ yaml_data = YAML.load(File.read(file))
165
+ symbolize_keys(yaml_data)
166
+
167
+ yaml_data
168
+ end
169
+
170
+ def symbolize_keys(hash)
171
+ return unless hash.is_a?(Hash)
172
+
173
+ hash.symbolize_keys!
174
+ hash.each{|k,v| symbolize_keys(v)}
175
+ end
176
+ end
177
+ end
178
+
179
+ Test::Unit::TestCase.class_eval do
180
+ include ActiveMerchant::Billing
181
+ include ActiveMerchant::Assertions
182
+ include ActiveMerchant::Utils
183
+ include ActiveMerchant::Fixtures
184
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simonmenke-active_merchant_ogone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan De Poorter
8
+ - Simon Menke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-09-01 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: A plugin for Ogone support in ActiveRecord.
18
+ email: github@defv.be
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README.rdoc
25
+ files:
26
+ - MIT-LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION.yml
30
+ - init.rb
31
+ - lib/active_merchant_ogone.rb
32
+ - lib/active_merchant_ogone/helper.rb
33
+ - lib/active_merchant_ogone/notification.rb
34
+ - test/active_merchant_ogone/helper_test.rb
35
+ - test/active_merchant_ogone/notification_test.rb
36
+ - test/active_merchant_ogone_test.rb
37
+ - test/test_helper.rb
38
+ has_rdoc: false
39
+ homepage: http://github.com/DefV/active_merchant_ogone/tree/master
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.2.0
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: A plugin for Ogone support in ActiveRecord.
64
+ test_files:
65
+ - test/active_merchant_ogone/helper_test.rb
66
+ - test/active_merchant_ogone/notification_test.rb
67
+ - test/active_merchant_ogone_test.rb
68
+ - test/test_helper.rb