forked from activemerchant/active_merchant
/
remote_moneris_test.rb
129 lines (106 loc) · 3.77 KB
/
remote_moneris_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
require 'test_helper'
class MonerisRemoteTest < Test::Unit::TestCase
def setup
Base.mode = :test
@gateway = MonerisGateway.new(fixtures(:moneris))
@amount = 100
@credit_card = credit_card('4242424242424242')
@options = {
:order_id => generate_unique_id,
:customer => generate_unique_id
}
end
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'Approved', response.message
assert_false response.authorization.blank?
end
def test_successful_authorization
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert_false response.authorization.blank?
end
def test_failed_authorization
response = @gateway.authorize(105, @credit_card, @options)
assert_failure response
end
def test_successful_authorization_and_capture
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert response.authorization
response = @gateway.capture(@amount, response.authorization)
assert_success response
end
def test_successful_authorization_and_void
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert response.authorization
# Moneris cannot void a preauthorization
# You must capture the auth transaction with an amount of $0.00
void = @gateway.capture(0, response.authorization)
assert_success void
end
def test_successful_purchase_and_void
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
void = @gateway.void(purchase.authorization)
assert_success void
end
def test_failed_purchase_and_void
purchase = @gateway.purchase(101, @credit_card, @options)
assert_failure purchase
void = @gateway.void(purchase.authorization)
assert_failure void
end
def test_successful_purchase_and_credit
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
credit = @gateway.credit(@amount, purchase.authorization)
assert_success credit
end
def test_failed_purchase_from_error
assert response = @gateway.purchase(150, @credit_card, @options)
assert_failure response
assert_equal 'Declined', response.message
end
def test_successful_store
assert response = @gateway.store(@credit_card)
assert_success response
assert_equal "Successfully registered cc details", response.message
assert response.params["data_key"].present?
@data_key = response.params["data_key"]
end
def test_successful_unstore
test_successful_store
assert response = @gateway.unstore(@data_key)
assert_success response
assert_equal "Successfully deleted cc details", response.message
assert response.params["data_key"].present?
end
def test_update
test_successful_store
assert response = @gateway.update(@data_key, @credit_card)
assert_success response
assert_equal "Successfully updated cc details", response.message
assert response.params["data_key"].present?
end
def test_successful_purchase_with_vault
test_successful_store
assert response = @gateway.purchase(@amount, @data_key, @options)
assert_success response
assert_equal "Approved", response.message
assert_false response.authorization.blank?
end
def test_successful_authorization_with_vault
test_successful_store
assert response = @gateway.authorize(@amount, @data_key, @options)
assert_success response
assert_false response.authorization.blank?
end
def test_failed_authorization_with_vault
test_successful_store
response = @gateway.authorize(105, @data_key, @options)
assert_failure response
end
end