active_merchant_ogone 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -18,7 +18,7 @@ To install ActiveMerchantOgone in your rails app you can just do:
18
18
 
19
19
  To install ActiveMerchantOgone in your rails app you can just do:
20
20
 
21
- config.gem 'simonmenke-active_merchant_ogone', :lib => 'active_merchant_ogone', :source => 'http://gems.github.com'
21
+ config.gem 'active_merchant_ogone'
22
22
 
23
23
  == Configuration
24
24
 
@@ -26,10 +26,13 @@ As Ogone works with in and out signatures, you will have to set these as constan
26
26
 
27
27
  OGONE_ACCOUNT = 'account_name'
28
28
  Ogone.setup do |c|
29
- c.outbound_signature = '094598439859385938958398494' # Item 3.2 of the technical information
30
- c.inbound_signature = '094598439859385938958398494' # Item 4.4 of the technical information
29
+ c.outbound_signature = '094598439859385938958398494' # You can find this under "Data and origin verification" tab
30
+ c.inbound_signature = '094598439859385938958398494' # You can find this under "Data and origin verification" tab
31
31
  end
32
32
 
33
+ Make sure that Ogone is set to "Each parameter followed by the pass phrase." as hashed value (under "Global security parameters").
34
+ If you don't see this setting, then you're probably already in that mode.
35
+
33
36
  == Example Usage
34
37
 
35
38
  Once you've configured the Ogone settings you need to set up a leaving page with in your view:
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 0
3
3
  :major: 0
4
- :minor: 1
4
+ :minor: 2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_merchant_ogone}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan De Poorter", "Simon Menke"]
12
- s.date = %q{2009-12-15}
12
+ s.date = %q{2010-08-26}
13
13
  s.description = %q{A plugin for Ogone support in ActiveRecord. }
14
14
  s.email = %q{github@defv.be}
15
15
  s.extra_rdoc_files = [
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.homepage = %q{http://github.com/DefV/active_merchant_ogone/tree/master}
34
34
  s.rdoc_options = ["--charset=UTF-8"]
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.5}
36
+ s.rubygems_version = %q{1.3.7}
37
37
  s.summary = %q{A plugin for Ogone support in ActiveRecord.}
38
38
  s.test_files = [
39
39
  "test/active_merchant_ogone/helper_test.rb",
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
46
46
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
47
  s.specification_version = 3
48
48
 
49
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
50
  s.add_runtime_dependency(%q<activemerchant>, [">= 1.4.2"])
51
51
  else
52
52
  s.add_dependency(%q<activemerchant>, [">= 1.4.2"])
@@ -25,12 +25,22 @@ module ActiveMerchant #:nodoc:
25
25
  :declineurl => 'declineurl',
26
26
  :cancelurl => 'cancelurl',
27
27
  :exceptionurl => 'exceptionurl'
28
-
28
+
29
29
  def customer(mapping = {})
30
30
  add_field('ownertelno', mapping[:phone])
31
31
  add_field('EMAIL', mapping[:email])
32
32
  add_field('CN', "#{mapping[:first_name]} #{mapping[:last_name]}")
33
33
  end
34
+
35
+ def operation operation
36
+ op = case operation
37
+ when :authorization, :auth; 'RES'
38
+ when :payment, :pay; 'SAL'
39
+ else; operation
40
+ end
41
+
42
+ add_field('operation', op)
43
+ end
34
44
 
35
45
  # return the fields
36
46
  def form_fields
@@ -118,6 +118,19 @@ module ActiveMerchant #:nodoc:
118
118
  true
119
119
  end
120
120
 
121
+ def scoring
122
+ params['SCORING'].to_i if params['SCORING']
123
+ end
124
+
125
+ def scoring_category
126
+ case params['SCO_CATEGORY']
127
+ when 'G' then :green
128
+ when 'O' then :orange
129
+ when 'R' then :red
130
+ else nil
131
+ end
132
+ end
133
+
121
134
  end
122
135
  end
123
136
  end
@@ -9,6 +9,8 @@ module ActiveMerchant #:nodoc:
9
9
  module Integrations #:nodoc:
10
10
  module Ogone
11
11
 
12
+ INBOUND_ENCRYPTED_VARIABLES = %w(AAVADDRESS AAVCHECK AAVZIP ACCEPTANCE ALIAS AMOUNT BRAND CARDNO CCCTY SHA-OUT CN COMPLUS CURRENCY CVCCHECK DCC_COMMPERCENTAGE DCC_CONVAMOUNT DCC_CONVCCY DCC_EXCHRATE DCC_EXCHRATESOURCE DCC_EXCHRATETS DCC_INDICATOR DCC_MARGINPERCENTAGE DCC_VALIDHOUS DIGESTCARDNO ECI ED ENCCARDNO IP IPCTY NBREMAILUSAGE NBRIPUSAGE NBRIPUSAGE_ALLTX NBRUSAGE NCERROR ORDERID PAYID PM SCO_CATEGORY SCORING STATUS TRXDATE VC)
13
+
12
14
  mattr_accessor :inbound_signature
13
15
  mattr_accessor :outbound_signature
14
16
 
@@ -38,16 +40,20 @@ module ActiveMerchant #:nodoc:
38
40
 
39
41
  def self.outbound_message_signature(fields, signature=nil)
40
42
  signature ||= self.outbound_signature
41
- keys = %w( orderID amount currency PSPID )
42
- datastring = keys.collect{|key| fields[key]}.join('')
43
- Digest::SHA1.hexdigest("#{datastring}#{signature}").upcase
43
+ datastring = fields.select {|k, v| !v.blank? }.
44
+ sort_by {|k, v| k.upcase }.
45
+ collect{|key, value| "#{key.upcase}=#{value}#{signature}"}.join
46
+
47
+ Digest::SHA1.hexdigest(datastring).upcase
44
48
  end
45
49
 
46
50
  def self.inbound_message_signature(fields, signature=nil)
47
51
  signature ||= self.inbound_signature
48
- keys = %w( orderID currency amount PM ACCEPTANCE STATUS CARDNO PAYID NCERROR BRAND )
49
- datastring = keys.collect{|key| fields[key]}.join('')
50
- Digest::SHA1.hexdigest("#{datastring}#{signature}").upcase
52
+ datastring = fields.select {|k, v| !v.blank? && INBOUND_ENCRYPTED_VARIABLES.include?(k.upcase) }.
53
+ sort_by {|k, v| k.upcase }.
54
+ collect {|key, value| "#{key.upcase}=#{value}#{signature}"}.join
55
+
56
+ Digest::SHA1.hexdigest(datastring).upcase
51
57
  end
52
58
  end
53
59
  end
@@ -20,6 +20,17 @@ class OgoneHelperTest < Test::Unit::TestCase
20
20
  assert_field 'CN', 'Jan De Poorter'
21
21
  assert_field 'EMAIL', 'ogone@openminds.be'
22
22
  end
23
+
24
+ def test_operation
25
+ @helper.operation :payment
26
+ assert_field 'operation', 'SAL'
27
+
28
+ @helper.operation :auth
29
+ assert_field 'operation', 'RES'
30
+
31
+ @helper.operation 'SAL'
32
+ assert_field 'operation', 'SAL'
33
+ end
23
34
 
24
35
  def test_address_mapping
25
36
  @helper.billing_address :address1 => 'Zilverenberg 39',
@@ -5,9 +5,9 @@ class OgoneNotificationTest < Test::Unit::TestCase
5
5
 
6
6
  Ogone.inbound_signature = '08445a31a78661b5c746feff39a9db6e4e2cc5cf'
7
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"
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=0B5DB4D379C32331939DA40DCCA16B1556FB6256&IP=82.146.99.233"
9
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"
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=0B5DB4D379C32331939DA40DCCA16B1556FB6256&IP=82.146.99.233"
11
11
 
12
12
  def setup
13
13
  @ogone = Ogone::Notification.new(SUCCESSFULL_HTTP_RAW_DATA)
@@ -8,11 +8,12 @@ class ActiveMerchantOgoneTest < Test::Unit::TestCase
8
8
  data = {'orderID' => '1234',
9
9
  'currency' => 'EUR',
10
10
  'amount' => 1500,
11
- 'PSPID' => 'MyPSPID' }
11
+ 'PSPID' => 'MyPSPID',
12
+ 'operation' => 'RES' }
12
13
 
13
- signature = 'Mysecretsig'
14
+ signature = 'Mysecretsig1875!?'
14
15
 
15
- assert_equal 'CC88E974F684C0804FD98BEA2FE403E9D11534BB',
16
+ assert_equal 'EB52902BCC4B50DC1250E5A7C1068ECF97751256',
16
17
  Ogone.outbound_message_signature(data, signature)
17
18
  end
18
19
 
@@ -29,9 +30,9 @@ class ActiveMerchantOgoneTest < Test::Unit::TestCase
29
30
  'NCERROR' => '0',
30
31
  'BRAND' => 'VISA'}
31
32
 
32
- signature = 'Mysecretsig'
33
+ signature = 'Mysecretsig1875!?'
33
34
 
34
- assert_equal '6DDD8C4538ACD0462837DB66F5EAB39C58086A29',
35
+ assert_equal 'B209960D5703DD1047F95A0F97655FFE5AC8BD52',
35
36
  Ogone.inbound_message_signature(data, signature)
36
37
  end
37
38
  end
data/test/test_helper.rb CHANGED
@@ -2,18 +2,19 @@
2
2
  $:.unshift(File.dirname(__FILE__) + '/../lib')
3
3
 
4
4
  require 'rubygems'
5
- require 'active_merchant'
6
- require 'money'
7
- require 'test/unit'
8
- require 'mocha'
9
- require 'yaml'
10
5
 
11
6
  begin
12
- gem 'actionpack'
7
+ gem 'actionpack', '2.3.8'
13
8
  rescue LoadError
14
9
  raise StandardError, "The view tests need ActionPack installed as gem to run"
15
10
  end
16
11
 
12
+ require 'active_merchant'
13
+ require 'money'
14
+ require 'test/unit'
15
+ require 'mocha'
16
+ require 'yaml'
17
+
17
18
  require 'action_controller'
18
19
  require 'action_controller/test_process'
19
20
  require 'active_merchant/billing/integrations/action_view_helper'
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_merchant_ogone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Jan De Poorter
@@ -10,19 +16,25 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2009-12-15 00:00:00 +01:00
19
+ date: 2010-08-26 00:00:00 +02:00
14
20
  default_executable:
15
21
  dependencies:
16
22
  - !ruby/object:Gem::Dependency
17
23
  name: activemerchant
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
21
27
  requirements:
22
28
  - - ">="
23
29
  - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 1
33
+ - 4
34
+ - 2
24
35
  version: 1.4.2
25
- version:
36
+ type: :runtime
37
+ version_requirements: *id001
26
38
  description: "A plugin for Ogone support in ActiveRecord. "
27
39
  email: github@defv.be
28
40
  executables: []
@@ -55,21 +67,27 @@ rdoc_options:
55
67
  require_paths:
56
68
  - lib
57
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
58
71
  requirements:
59
72
  - - ">="
60
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
61
77
  version: "0"
62
- version:
63
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
64
80
  requirements:
65
81
  - - ">="
66
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
67
86
  version: "0"
68
- version:
69
87
  requirements: []
70
88
 
71
89
  rubyforge_project:
72
- rubygems_version: 1.3.5
90
+ rubygems_version: 1.3.7
73
91
  signing_key:
74
92
  specification_version: 3
75
93
  summary: A plugin for Ogone support in ActiveRecord.