tomriley-active_merchant 1.4.2.3 → 1.4.2.4
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/CHANGELOG +14 -0
- data/CONTRIBUTERS +12 -0
- data/active_merchant.gemspec +3 -2
- data/init.rb +0 -1
- data/lib/active_merchant/billing/credit_card_methods.rb +1 -1
- data/lib/active_merchant/billing/expiry_date.rb +10 -4
- data/lib/active_merchant/billing/gateway.rb +4 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +12 -1
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -1
- data/lib/active_merchant/billing/gateways/bogus.rb +19 -0
- data/lib/active_merchant/billing/gateways/eway.rb +6 -1
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +259 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
- data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +45 -12
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
- data/lib/active_merchant/billing/response.rb +9 -1
- data/test/fixtures.yml +16 -1
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_ogone_test.rb +108 -0
- data/test/remote/gateways/remote_paypal_test.rb +12 -1
- data/test/remote/gateways/remote_protx_three_d_secure_test.rb +259 -0
- data/test/remote/gateways/{remote_protx_test.rb → remote_sage_pay_test.rb} +8 -8
- data/test/unit/credit_card_methods_test.rb +9 -0
- data/test/unit/expiry_date_test.rb +12 -1
- data/test/unit/gateways/bogus_test.rb +31 -0
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +6 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/ogone_test.rb +256 -0
- data/test/unit/gateways/paypal_test.rb +49 -0
- data/test/unit/gateways/sage_pay_test.rb +183 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +1 -1
- data/test/unit/response_test.rb +16 -0
- metadata +16 -5
- data/test/unit/gateways/protx_test.rb +0 -139
|
@@ -5,7 +5,7 @@ module ActiveMerchant #:nodoc:
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
class Response
|
|
8
|
-
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result
|
|
8
|
+
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result, :pa_req, :md, :acs_url
|
|
9
9
|
|
|
10
10
|
def success?
|
|
11
11
|
@success
|
|
@@ -19,6 +19,10 @@ module ActiveMerchant #:nodoc:
|
|
|
19
19
|
@fraud_review
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def three_d_secure?
|
|
23
|
+
@three_d_secure
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
def initialize(success, message, params = {}, options = {})
|
|
23
27
|
@success, @message, @params = success, message, params.stringify_keys
|
|
24
28
|
@test = options[:test] || false
|
|
@@ -26,6 +30,10 @@ module ActiveMerchant #:nodoc:
|
|
|
26
30
|
@fraud_review = options[:fraud_review]
|
|
27
31
|
@avs_result = AVSResult.new(options[:avs_result]).to_hash
|
|
28
32
|
@cvv_result = CVVResult.new(options[:cvv_result]).to_hash
|
|
33
|
+
@three_d_secure = options[:three_d_secure]
|
|
34
|
+
@pa_req = options[:pa_req]
|
|
35
|
+
@md = options[:md]
|
|
36
|
+
@acs_url = options[:acs_url]
|
|
29
37
|
end
|
|
30
38
|
end
|
|
31
39
|
end
|
data/test/fixtures.yml
CHANGED
|
@@ -53,6 +53,10 @@ exact:
|
|
|
53
53
|
login: "A00427-01"
|
|
54
54
|
password: testus
|
|
55
55
|
|
|
56
|
+
first_pay:
|
|
57
|
+
login:
|
|
58
|
+
password:
|
|
59
|
+
|
|
56
60
|
ideal_ing_postbank:
|
|
57
61
|
login: LOGIN
|
|
58
62
|
password: PASSWORD
|
|
@@ -68,6 +72,11 @@ linkpoint:
|
|
|
68
72
|
pem: |--
|
|
69
73
|
PASTE YOUR PEM FILE HERE
|
|
70
74
|
|
|
75
|
+
merchant_ware:
|
|
76
|
+
login:
|
|
77
|
+
password:
|
|
78
|
+
name:
|
|
79
|
+
|
|
71
80
|
modern_payments:
|
|
72
81
|
login: login
|
|
73
82
|
password: password
|
|
@@ -86,6 +95,12 @@ net_registry:
|
|
|
86
95
|
login: X
|
|
87
96
|
password: Y
|
|
88
97
|
|
|
98
|
+
ogone:
|
|
99
|
+
login: LOGIN
|
|
100
|
+
user: USER
|
|
101
|
+
password: PASSWORD
|
|
102
|
+
signature: SIGNATURE
|
|
103
|
+
|
|
89
104
|
payflow:
|
|
90
105
|
login: LOGIN
|
|
91
106
|
password: PASSWORD
|
|
@@ -126,7 +141,7 @@ plugnpay:
|
|
|
126
141
|
login: LOGIN
|
|
127
142
|
password: PASSWORD
|
|
128
143
|
|
|
129
|
-
|
|
144
|
+
sage_pay:
|
|
130
145
|
login: LOGIN
|
|
131
146
|
|
|
132
147
|
# Working credentials, no need to replace
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteFirstPayTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = FirstPayGateway.new(fixtures(:first_pay))
|
|
6
|
+
|
|
7
|
+
@amount = 100
|
|
8
|
+
@credit_card = credit_card('4111111111111111', {:first_name => 'Test', :last_name => 'Person'})
|
|
9
|
+
@declined_card = credit_card('4111111111111111')
|
|
10
|
+
|
|
11
|
+
@options = {
|
|
12
|
+
:order_id => '1',
|
|
13
|
+
:billing_address => address({:name => 'Test Person', :city => 'New York', :state => 'NY', :zip => '10002', :country => 'US'}),
|
|
14
|
+
:description => 'Test Purchase'
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_successful_purchase
|
|
19
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
20
|
+
assert_success response
|
|
21
|
+
assert_equal('CAPTURED', response.message)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_unsuccessful_purchase
|
|
25
|
+
# > $500 results in decline
|
|
26
|
+
@amount = 51000
|
|
27
|
+
assert response = @gateway.purchase(@amount, @declined_card, @options)
|
|
28
|
+
assert_failure response
|
|
29
|
+
assert_equal("51-INSUFFICIENT FUNDS", response.message)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_invalid_login
|
|
33
|
+
gateway = FirstPayGateway.new(:login => '', :password => '')
|
|
34
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
|
35
|
+
assert_failure response
|
|
36
|
+
assert_equal '703-INVALID VENDOR ID AND PASS CODE', response.message
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_successful_credit
|
|
40
|
+
# purchase first
|
|
41
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
42
|
+
assert_success response
|
|
43
|
+
assert_equal('CAPTURED', response.message)
|
|
44
|
+
assert_not_nil(response.params["auth"])
|
|
45
|
+
assert_not_nil(response.authorization)
|
|
46
|
+
|
|
47
|
+
@options[:credit_card] = @credit_card
|
|
48
|
+
|
|
49
|
+
assert response = @gateway.credit(@amount, response.authorization, @options)
|
|
50
|
+
assert_success response
|
|
51
|
+
assert_not_nil(response.authorization)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_failed_credit
|
|
55
|
+
@options[:credit_card] = @credit_card
|
|
56
|
+
|
|
57
|
+
assert response = @gateway.credit(@amount, '000000', @options)
|
|
58
|
+
assert_failure response
|
|
59
|
+
assert_nil(response.authorization)
|
|
60
|
+
assert_equal('PARENT TRANSACTION NOT FOUND', response.message)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_failed_unlinked_credit
|
|
64
|
+
assert_raise ArgumentError do
|
|
65
|
+
@gateway.credit(@amount, @credit_card)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_successful_void
|
|
70
|
+
# purchase first
|
|
71
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
72
|
+
assert_success response
|
|
73
|
+
assert_equal('CAPTURED', response.message)
|
|
74
|
+
assert_not_nil(response.params["auth"])
|
|
75
|
+
assert_not_nil(response.authorization)
|
|
76
|
+
|
|
77
|
+
assert_success response
|
|
78
|
+
assert_not_nil(response.authorization)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_failed_void
|
|
82
|
+
assert response = @gateway.void(@amount, @credit_card, @options)
|
|
83
|
+
assert_failure response
|
|
84
|
+
assert_equal('PARENT TRANSACTION NOT FOUND', response.message)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteMerchantWareTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = MerchantWareGateway.new(fixtures(:merchant_ware))
|
|
6
|
+
|
|
7
|
+
@amount = rand(100) + 100
|
|
8
|
+
|
|
9
|
+
@credit_card = credit_card('5105105105105100')
|
|
10
|
+
|
|
11
|
+
@options = {
|
|
12
|
+
:order_id => generate_unique_id,
|
|
13
|
+
:billing_address => address
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_successful_authorization
|
|
18
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
19
|
+
assert_success response
|
|
20
|
+
assert_equal 'APPROVED', response.message
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_unsuccessful_authorization
|
|
24
|
+
@credit_card.number = "1234567890123"
|
|
25
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
26
|
+
assert_failure response
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_successful_purchase
|
|
30
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
31
|
+
assert_success response
|
|
32
|
+
assert_equal 'APPROVED', response.message
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_unsuccessful_purchase
|
|
36
|
+
@credit_card.number = "1234567890123"
|
|
37
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
38
|
+
assert_failure response
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_authorize_and_capture
|
|
42
|
+
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
|
43
|
+
assert_success auth
|
|
44
|
+
|
|
45
|
+
assert auth.authorization
|
|
46
|
+
assert capture = @gateway.capture(@amount, auth.authorization, @options)
|
|
47
|
+
assert_success capture
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_authorize_and_credit
|
|
51
|
+
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
|
52
|
+
assert_success auth
|
|
53
|
+
assert auth.authorization
|
|
54
|
+
|
|
55
|
+
assert credit = @gateway.credit(@amount, @credit_card, @options)
|
|
56
|
+
assert_success credit
|
|
57
|
+
assert_not_nil credit.authorization
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_purchase_and_credit
|
|
61
|
+
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
|
|
62
|
+
assert_success purchase
|
|
63
|
+
assert purchase.authorization
|
|
64
|
+
|
|
65
|
+
assert credit = @gateway.credit(@amount, @credit_card, @options)
|
|
66
|
+
assert_success credit
|
|
67
|
+
assert_not_nil credit.authorization
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_purchase_and_reference_credit
|
|
71
|
+
assert auth = @gateway.purchase(@amount, @credit_card, @options)
|
|
72
|
+
assert_success auth
|
|
73
|
+
assert auth.authorization
|
|
74
|
+
|
|
75
|
+
assert credit = @gateway.credit(@amount, auth.authorization, @options)
|
|
76
|
+
assert_success credit
|
|
77
|
+
assert_not_nil credit.authorization
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_purchase_and_void
|
|
81
|
+
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
|
|
82
|
+
assert_success purchase
|
|
83
|
+
|
|
84
|
+
assert void = @gateway.void(purchase.authorization)
|
|
85
|
+
assert_success void
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# seems as though only purchases can be voided
|
|
89
|
+
def test_authorization_and_failed_void
|
|
90
|
+
assert authorization = @gateway.authorize(@amount, @credit_card, @options)
|
|
91
|
+
assert_success authorization
|
|
92
|
+
|
|
93
|
+
assert void = @gateway.void(authorization.authorization)
|
|
94
|
+
assert_failure void
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_failed_capture
|
|
98
|
+
assert response = @gateway.capture(@amount, '', @options)
|
|
99
|
+
assert_failure response
|
|
100
|
+
assert_equal 'Server was unable to process request. ---> strReferenceCode should be at least 1 to at most 100 characters in size. Parameter name: strReferenceCode', response.message
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_invalid_login
|
|
104
|
+
gateway = MerchantWareGateway.new(
|
|
105
|
+
:login => '',
|
|
106
|
+
:password => '',
|
|
107
|
+
:name => ''
|
|
108
|
+
)
|
|
109
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
|
110
|
+
assert_failure response
|
|
111
|
+
assert_equal 'Server was unable to process request. ---> Invalid Credentials.', response.message
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteOgoneTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@gateway = OgoneGateway.new(fixtures(:ogone))
|
|
7
|
+
@amount = 100
|
|
8
|
+
@credit_card = credit_card('4000100011112224')
|
|
9
|
+
@declined_card = credit_card('1111111111111111')
|
|
10
|
+
@options = {
|
|
11
|
+
:order_id => generate_unique_id[0...30],
|
|
12
|
+
:billing_address => address,
|
|
13
|
+
:description => 'Store Purchase'
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_successful_purchase
|
|
18
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
19
|
+
assert_success response
|
|
20
|
+
assert_equal OgoneGateway::SUCCESS_MESSAGE, response.message
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_successful_purchase_without_order_id
|
|
24
|
+
@options.delete(:order_id)
|
|
25
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
26
|
+
assert_success response
|
|
27
|
+
assert_equal OgoneGateway::SUCCESS_MESSAGE, response.message
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_unsuccessful_purchase
|
|
31
|
+
assert response = @gateway.purchase(@amount, @declined_card, @options)
|
|
32
|
+
assert_failure response
|
|
33
|
+
assert_equal 'no brand', response.message
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_authorize_and_capture
|
|
37
|
+
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
|
38
|
+
assert_success auth
|
|
39
|
+
assert_equal OgoneGateway::SUCCESS_MESSAGE, auth.message
|
|
40
|
+
assert auth.authorization
|
|
41
|
+
assert capture = @gateway.capture(@amount, auth.authorization)
|
|
42
|
+
assert_success capture
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_unsuccessful_capture
|
|
46
|
+
assert response = @gateway.capture(@amount, '')
|
|
47
|
+
assert_failure response
|
|
48
|
+
assert_equal 'no card no, no exp date, no brand', response.message
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_successful_void
|
|
52
|
+
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
|
53
|
+
assert_success auth
|
|
54
|
+
assert auth.authorization
|
|
55
|
+
assert void = @gateway.void(auth.authorization)
|
|
56
|
+
assert_equal OgoneGateway::SUCCESS_MESSAGE, auth.message
|
|
57
|
+
assert_success void
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_successful_referenced_credit
|
|
61
|
+
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
|
|
62
|
+
assert_success purchase
|
|
63
|
+
assert credit = @gateway.credit(@amount, purchase.authorization, @options)
|
|
64
|
+
assert_success credit
|
|
65
|
+
assert credit.authorization
|
|
66
|
+
assert_equal OgoneGateway::SUCCESS_MESSAGE, credit.message
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_unsuccessful_referenced_credit
|
|
70
|
+
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
|
|
71
|
+
assert_success purchase
|
|
72
|
+
assert credit = @gateway.credit(@amount+1, purchase.authorization, @options) # too much refund requested
|
|
73
|
+
assert_failure credit
|
|
74
|
+
assert credit.authorization
|
|
75
|
+
assert_equal 'Overflow in refunds requests/1/1', credit.message
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_successful_unreferenced_credit
|
|
79
|
+
assert credit = @gateway.credit(@amount, @credit_card, @options)
|
|
80
|
+
assert_success credit
|
|
81
|
+
assert credit.authorization
|
|
82
|
+
assert_equal OgoneGateway::SUCCESS_MESSAGE, credit.message
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_reference_transactions
|
|
86
|
+
# Setting an alias
|
|
87
|
+
assert response = @gateway.purchase(@amount, credit_card('4000100011112224'), @options.merge(:store => "awesomeman", :order_id=>Time.now.to_i.to_s+"1"))
|
|
88
|
+
assert_success response
|
|
89
|
+
# Updating an alias
|
|
90
|
+
assert response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(:store => "awesomeman", :order_id=>Time.now.to_i.to_s+"2"))
|
|
91
|
+
assert_success response
|
|
92
|
+
# Using an alias (i.e. don't provide the credit card)
|
|
93
|
+
assert response = @gateway.purchase(@amount, "awesomeman", @options.merge(:order_id=>Time.now.to_i.to_s+"3"))
|
|
94
|
+
assert_success response
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_invalid_login
|
|
98
|
+
gateway = OgoneGateway.new(
|
|
99
|
+
:login => '',
|
|
100
|
+
:user => '',
|
|
101
|
+
:password => ''
|
|
102
|
+
)
|
|
103
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
|
104
|
+
assert_failure response
|
|
105
|
+
assert_equal 'no pspid', response.message
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
@@ -164,4 +164,15 @@ class PaypalTest < Test::Unit::TestCase
|
|
|
164
164
|
response = @gateway.transfer(*recipients)
|
|
165
165
|
assert_failure response
|
|
166
166
|
end
|
|
167
|
-
|
|
167
|
+
|
|
168
|
+
# Makes a purchase then makes another purchase adding $1.00 using just a reference id (transaction id)
|
|
169
|
+
def test_successful_referenced_id_purchase
|
|
170
|
+
response = @gateway.purchase(@amount, @creditcard, @params)
|
|
171
|
+
assert_success response
|
|
172
|
+
id_for_reference = response.params['transaction_id']
|
|
173
|
+
|
|
174
|
+
@params.delete(:order_id)
|
|
175
|
+
response2 = @gateway.purchase(@amount + 100, id_for_reference, @params)
|
|
176
|
+
assert_success response2
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
require 'mechanize'
|
|
3
|
+
|
|
4
|
+
class RemoteProtxThreeDSecureTest < Test::Unit::TestCase
|
|
5
|
+
# Run the tests in the test environment and ensure 3D Secure is enabled on your ProTX account settings
|
|
6
|
+
# set to true to run the tests in the simulated environment
|
|
7
|
+
ProtxGateway.simulate = false
|
|
8
|
+
|
|
9
|
+
TEST_3D_PASSWORD = 'password'
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
@gateway = ProtxGateway.new(fixtures(:protx).merge(:enable_3d_secure => true))
|
|
13
|
+
|
|
14
|
+
@amex = CreditCard.new(
|
|
15
|
+
:number => '374200000000004',
|
|
16
|
+
:month => 12,
|
|
17
|
+
:year => next_year,
|
|
18
|
+
:verification_value => 4887,
|
|
19
|
+
:first_name => 'Tekin',
|
|
20
|
+
:last_name => 'Suleyman',
|
|
21
|
+
:type => 'american_express'
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
@visa = CreditCard.new(
|
|
25
|
+
:number => '4929000000006',
|
|
26
|
+
:month => 6,
|
|
27
|
+
:year => next_year,
|
|
28
|
+
:verification_value => 123,
|
|
29
|
+
:first_name => 'Tekin',
|
|
30
|
+
:last_name => 'Suleyman',
|
|
31
|
+
:type => 'visa'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
@maestro = CreditCard.new(
|
|
35
|
+
:number => '300000000000000004',
|
|
36
|
+
:month => 12,
|
|
37
|
+
:year => next_year,
|
|
38
|
+
:start_month => 12,
|
|
39
|
+
:start_year => next_year - 2,
|
|
40
|
+
:verification_value => 123,
|
|
41
|
+
:first_name => 'Tekin',
|
|
42
|
+
:last_name => 'Suleyman',
|
|
43
|
+
:type => 'maestro'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
@solo = CreditCard.new(
|
|
47
|
+
:number => '6334900000000005',
|
|
48
|
+
:month => 6,
|
|
49
|
+
:year => next_year,
|
|
50
|
+
:issue_number => 1,
|
|
51
|
+
:start_month => 12,
|
|
52
|
+
:start_year => next_year - 2,
|
|
53
|
+
:verification_value => 227,
|
|
54
|
+
:first_name => 'Tekin',
|
|
55
|
+
:last_name => 'Suleyman',
|
|
56
|
+
:type => 'solo'
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
@mastercard = CreditCard.new(
|
|
60
|
+
:number => '5404000000000001',
|
|
61
|
+
:month => 12,
|
|
62
|
+
:year => next_year,
|
|
63
|
+
:verification_value => 419,
|
|
64
|
+
:first_name => 'Tekin',
|
|
65
|
+
:last_name => 'Suleyman',
|
|
66
|
+
:type => 'master'
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
@electron = CreditCard.new(
|
|
70
|
+
:number => '4917300000000008',
|
|
71
|
+
:month => 12,
|
|
72
|
+
:year => next_year,
|
|
73
|
+
:verification_value => 123,
|
|
74
|
+
:first_name => 'Tekin',
|
|
75
|
+
:last_name => 'Suleyman',
|
|
76
|
+
:type => 'electron'
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
@declined_card = CreditCard.new(
|
|
80
|
+
:number => '4111111111111111',
|
|
81
|
+
:month => 9,
|
|
82
|
+
:year => next_year,
|
|
83
|
+
:first_name => 'Tekin',
|
|
84
|
+
:last_name => 'Suleyman',
|
|
85
|
+
:type => 'visa'
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
@options = {
|
|
89
|
+
:billing_address => {
|
|
90
|
+
:name => 'Tekin Suleyman',
|
|
91
|
+
:address1 => 'Flat 10 Lapwing Court',
|
|
92
|
+
:address2 => 'West Didsbury',
|
|
93
|
+
:city => "Manchester",
|
|
94
|
+
:county => 'Greater Manchester',
|
|
95
|
+
:country => 'GB',
|
|
96
|
+
:zip => 'M20 2PS'
|
|
97
|
+
},
|
|
98
|
+
:shipping_address => {
|
|
99
|
+
:name => 'Tekin Suleyman',
|
|
100
|
+
:address1 => '120 Grosvenor St',
|
|
101
|
+
:city => "Manchester",
|
|
102
|
+
:county => 'Greater Manchester',
|
|
103
|
+
:country => 'GB',
|
|
104
|
+
:zip => 'M1 7QW'
|
|
105
|
+
},
|
|
106
|
+
:order_id => generate_unique_id,
|
|
107
|
+
:description => 'Store purchase',
|
|
108
|
+
:ip => '86.150.65.37',
|
|
109
|
+
:email => 'tekin@tekin.co.uk',
|
|
110
|
+
:phone => '0161 123 4567'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@amount = 100
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_successful_three_d_secure_mastercard_purchase
|
|
117
|
+
response = @gateway.purchase(@amount, @mastercard, @options)
|
|
118
|
+
|
|
119
|
+
assert_failure response
|
|
120
|
+
assert_3d_secure response
|
|
121
|
+
|
|
122
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
123
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
124
|
+
|
|
125
|
+
assert_success three_d_secure_response
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_successful_purchase_with_3d_secure_override
|
|
129
|
+
@options = @options.merge(:skip_3d_secure => true)
|
|
130
|
+
response = @gateway.purchase(@amount, @mastercard, @options)
|
|
131
|
+
|
|
132
|
+
assert_success response
|
|
133
|
+
assert !response.authorization.blank?
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_successful_authorization_with_3d_secure_override
|
|
137
|
+
@options = @options.merge(:skip_3d_secure => true)
|
|
138
|
+
response = @gateway.authorize(@amount, @mastercard, @options)
|
|
139
|
+
|
|
140
|
+
assert_success response
|
|
141
|
+
assert !response.authorization.blank?
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_successful_three_d_secure_mastercard_authorization
|
|
145
|
+
response = @gateway.authorize(@amount, @mastercard, @options)
|
|
146
|
+
|
|
147
|
+
assert_failure response
|
|
148
|
+
assert_3d_secure response
|
|
149
|
+
|
|
150
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
151
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
152
|
+
|
|
153
|
+
assert_success three_d_secure_response
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_successful_three_d_secure_visa_purchase
|
|
157
|
+
response = @gateway.purchase(@amount, @visa, @options)
|
|
158
|
+
|
|
159
|
+
assert_failure response
|
|
160
|
+
assert_3d_secure response
|
|
161
|
+
|
|
162
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
163
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
164
|
+
|
|
165
|
+
assert_success three_d_secure_response
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def test_successful_three_d_secure_maestro_purchase
|
|
169
|
+
response = @gateway.purchase(@amount, @maestro, @options)
|
|
170
|
+
|
|
171
|
+
assert_failure response
|
|
172
|
+
assert_3d_secure response
|
|
173
|
+
|
|
174
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
175
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
176
|
+
|
|
177
|
+
assert_success three_d_secure_response
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def test_successful_three_d_secure_amex_purchase
|
|
181
|
+
response = @gateway.purchase(@amount, @amex, @options)
|
|
182
|
+
|
|
183
|
+
assert_failure response
|
|
184
|
+
assert_3d_secure response
|
|
185
|
+
|
|
186
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
187
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
188
|
+
|
|
189
|
+
assert_success three_d_secure_response
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def test_successful_three_d_secure_solo_purchase
|
|
193
|
+
response = @gateway.purchase(@amount, @solo, @options)
|
|
194
|
+
|
|
195
|
+
assert_failure response
|
|
196
|
+
assert_3d_secure response
|
|
197
|
+
|
|
198
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
199
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
200
|
+
|
|
201
|
+
assert_success three_d_secure_response
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def test_successful_three_d_secure_electron_purchase
|
|
206
|
+
response = @gateway.purchase(@amount, @electron, @options)
|
|
207
|
+
|
|
208
|
+
assert_failure response
|
|
209
|
+
assert_3d_secure response
|
|
210
|
+
|
|
211
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, TEST_3D_PASSWORD)
|
|
212
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
213
|
+
|
|
214
|
+
assert_success three_d_secure_response
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def test_failed_three_d_secure_purchase
|
|
219
|
+
response = @gateway.purchase(@amount, @mastercard, @options)
|
|
220
|
+
|
|
221
|
+
assert_failure response
|
|
222
|
+
assert_3d_secure response
|
|
223
|
+
|
|
224
|
+
pa_res, md = retrieve_and_submit_three_d_secure_form(response, 'wrong password')
|
|
225
|
+
three_d_secure_response = @gateway.three_d_complete(pa_res,md)
|
|
226
|
+
|
|
227
|
+
assert_failure three_d_secure_response
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def test_invalid_login
|
|
231
|
+
message = ProtxGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.'
|
|
232
|
+
|
|
233
|
+
gateway = ProtxGateway.new(
|
|
234
|
+
:login => ''
|
|
235
|
+
)
|
|
236
|
+
assert response = gateway.purchase(@amount, @mastercard, @options)
|
|
237
|
+
assert_equal message, response.message
|
|
238
|
+
assert_failure response
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
private
|
|
242
|
+
|
|
243
|
+
def assert_3d_secure(response)
|
|
244
|
+
assert response.three_d_secure?, "Response not 3D secure: #{response.inspect}"
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Uses mechanize to retrieve 3D secure page, fill in password, submit and retrieve the pa_res and md
|
|
248
|
+
def retrieve_and_submit_three_d_secure_form(response, password)
|
|
249
|
+
agent = WWW::Mechanize.new
|
|
250
|
+
page = agent.post(response.acs_url, :MD => response.md, :PaReq => response.pa_req, :TermUrl => 'http://localhost')
|
|
251
|
+
page.forms[0].password = password
|
|
252
|
+
result = agent.submit(page.forms[0])
|
|
253
|
+
[result.forms[0].PaRes,result.forms[0].MD]
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def next_year
|
|
257
|
+
Date.today.year + 1
|
|
258
|
+
end
|
|
259
|
+
end
|