activemerchant 1.3.2 → 1.4.0
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.tar.gz.sig +0 -0
- data/CHANGELOG +58 -0
- data/CONTRIBUTERS +25 -0
- data/MIT-LICENSE +3 -3
- data/README +16 -10
- data/Rakefile +4 -3
- data/lib/active_merchant.rb +7 -1
- data/lib/active_merchant/billing/check.rb +16 -9
- data/lib/active_merchant/billing/gateway.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +702 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +10 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +26 -2
- data/lib/active_merchant/billing/gateways/data_cash.rb +255 -59
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +1 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow_express.rb +3 -11
- data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +39 -21
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +3 -12
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/protx.rb +25 -25
- data/lib/active_merchant/billing/gateways/sage.rb +145 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -1
- data/lib/active_merchant/billing/gateways/wirecard.rb +304 -0
- data/lib/active_merchant/billing/integrations.rb +8 -2
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +18 -4
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +4 -2
- data/lib/active_merchant/billing/integrations/notification.rb +10 -1
- data/lib/active_merchant/lib/posts_data.rb +12 -3
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/test/extra/binding_of_caller.rb +0 -0
- data/test/extra/breakpoint.rb +0 -0
- data/test/fixtures.yml +24 -0
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
- data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
- data/test/remote/gateways/remote_beanstream_test.rb +150 -0
- data/test/remote/gateways/remote_braintree_test.rb +22 -0
- data/test/remote/gateways/remote_cyber_source_test.rb +28 -3
- data/test/remote/gateways/remote_data_cash_test.rb +250 -48
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
- data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
- data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
- data/test/remote/gateways/remote_sage_test.rb +87 -0
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
- data/test/remote/gateways/remote_wirecard_test.rb +76 -0
- data/test/remote/integrations/remote_paypal_integration_test.rb +15 -3
- data/test/test_helper.rb +31 -13
- data/test/unit/check_test.rb +14 -2
- data/test/unit/credit_card_methods_test.rb +18 -0
- data/test/unit/gateways/authorize_net_cim_test.rb +641 -0
- data/test/unit/gateways/beanstream_interac_test.rb +51 -0
- data/test/unit/gateways/beanstream_test.rb +108 -0
- data/test/unit/gateways/braintree_test.rb +2 -5
- data/test/unit/gateways/cyber_source_test.rb +18 -0
- data/test/unit/gateways/data_cash_test.rb +32 -4
- data/test/unit/gateways/gateway_test.rb +8 -1
- data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
- data/test/unit/gateways/net_registry_test.rb +6 -0
- data/test/unit/gateways/payflow_express_test.rb +18 -2
- data/test/unit/gateways/paypal_express_test.rb +154 -0
- data/test/unit/gateways/paypal_test.rb +140 -0
- data/test/unit/gateways/sage_bankcard_test.rb +162 -0
- data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
- data/test/unit/gateways/secure_pay_au_test.rb +58 -1
- data/test/unit/gateways/skip_jack_test.rb +8 -0
- data/test/unit/gateways/verifi_test.rb +0 -1
- data/test/unit/gateways/wirecard_test.rb +232 -0
- data/test/unit/integrations/action_view_helper_test.rb +3 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +23 -2
- data/test/unit/integrations/notifications/notification_test.rb +13 -0
- data/test/unit/posts_data_test.rb +20 -6
- metadata +40 -5
- metadata.gz.sig +0 -0
data/test/test_helper.rb
CHANGED
@@ -18,11 +18,7 @@ require 'digest/md5'
|
|
18
18
|
require File.dirname(__FILE__) + '/../lib/active_merchant'
|
19
19
|
|
20
20
|
begin
|
21
|
-
|
22
|
-
gem 'actionpack'
|
23
|
-
else
|
24
|
-
require_gem 'actionpack'
|
25
|
-
end
|
21
|
+
gem 'actionpack'
|
26
22
|
rescue LoadError
|
27
23
|
raise StandardError, "The view tests need ActionPack installed as gem to run"
|
28
24
|
end
|
@@ -33,6 +29,14 @@ require 'active_merchant/billing/integrations/action_view_helper'
|
|
33
29
|
|
34
30
|
ActiveMerchant::Billing::Base.mode = :test
|
35
31
|
|
32
|
+
# Test gateways
|
33
|
+
class SimpleTestGateway < ActiveMerchant::Billing::Gateway
|
34
|
+
end
|
35
|
+
|
36
|
+
class SubclassGateway < SimpleTestGateway
|
37
|
+
end
|
38
|
+
|
39
|
+
|
36
40
|
module ActiveMerchant
|
37
41
|
module Assertions
|
38
42
|
def assert_field(field, value)
|
@@ -127,20 +131,34 @@ module Test
|
|
127
131
|
:type => 'visa'
|
128
132
|
}.update(options)
|
129
133
|
|
130
|
-
|
134
|
+
CreditCard.new(defaults)
|
135
|
+
end
|
136
|
+
|
137
|
+
def check(options = {})
|
138
|
+
defaults = {
|
139
|
+
:name => 'Jim Smith',
|
140
|
+
:routing_number => '244183602',
|
141
|
+
:account_number => '15378535',
|
142
|
+
:account_holder_type => 'personal',
|
143
|
+
:account_type => 'checking',
|
144
|
+
:number => '1'
|
145
|
+
}.update(options)
|
146
|
+
|
147
|
+
Check.new(defaults)
|
131
148
|
end
|
132
149
|
|
133
150
|
def address(options = {})
|
134
151
|
{
|
135
|
-
:name
|
152
|
+
:name => 'Jim Smith',
|
136
153
|
:address1 => '1234 My Street',
|
137
154
|
:address2 => 'Apt 1',
|
138
|
-
:company
|
139
|
-
:city
|
140
|
-
:state
|
141
|
-
:zip
|
142
|
-
:country
|
143
|
-
:phone
|
155
|
+
:company => 'Widgets Inc',
|
156
|
+
:city => 'Ottawa',
|
157
|
+
:state => 'ON',
|
158
|
+
:zip => 'K1C2N6',
|
159
|
+
:country => 'CA',
|
160
|
+
:phone => '(555)555-5555',
|
161
|
+
:fax => '(555)555-6666'
|
144
162
|
}.update(options)
|
145
163
|
end
|
146
164
|
|
data/test/unit/check_test.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
3
|
class CheckTest < Test::Unit::TestCase
|
4
|
-
include ActiveMerchant::Billing
|
5
|
-
|
6
4
|
VALID_ABA = '111000025'
|
7
5
|
INVALID_ABA = '999999999'
|
8
6
|
MALFORMED_ABA = 'I like fish'
|
@@ -15,6 +13,20 @@ class CheckTest < Test::Unit::TestCase
|
|
15
13
|
assert !c.errors.empty?
|
16
14
|
end
|
17
15
|
|
16
|
+
def test_first_name_last_name
|
17
|
+
check = Check.new(:name => 'Fred Bloggs')
|
18
|
+
assert_equal 'Fred', check.first_name
|
19
|
+
assert_equal 'Bloggs', check.last_name
|
20
|
+
assert_equal 'Fred Bloggs', check.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_nil_name
|
24
|
+
check = Check.new(:name => nil)
|
25
|
+
assert_nil check.first_name
|
26
|
+
assert_nil check.last_name
|
27
|
+
assert_equal "", check.name
|
28
|
+
end
|
29
|
+
|
18
30
|
def test_valid
|
19
31
|
c = Check.new(:name => 'Fred Bloggs',
|
20
32
|
:routing_number => VALID_ABA,
|
@@ -149,4 +149,22 @@ class CreditCardMethodsTest < Test::Unit::TestCase
|
|
149
149
|
assert_false CreditCard.matching_type?('6010000000000000', 'discover')
|
150
150
|
assert_false CreditCard.matching_type?('6600000000000000', 'discover')
|
151
151
|
end
|
152
|
+
|
153
|
+
def test_16_digit_maestro_uk
|
154
|
+
number = '6759000000000000'
|
155
|
+
assert_equal 16, number.length
|
156
|
+
assert_equal 'switch', CreditCard.type?(number)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_18_digit_maestro_uk
|
160
|
+
number = '675900000000000000'
|
161
|
+
assert_equal 18, number.length
|
162
|
+
assert_equal 'switch', CreditCard.type?(number)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_19_digit_maestro_uk
|
166
|
+
number = '6759000000000000000'
|
167
|
+
assert_equal 19, number.length
|
168
|
+
assert_equal 'switch', CreditCard.type?(number)
|
169
|
+
end
|
152
170
|
end
|
@@ -0,0 +1,641 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class AuthorizeNetCimTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@gateway = AuthorizeNetCimGateway.new(
|
6
|
+
:login => 'X',
|
7
|
+
:password => 'Y'
|
8
|
+
)
|
9
|
+
@amount = 100
|
10
|
+
@credit_card = credit_card
|
11
|
+
@address = address
|
12
|
+
@customer_profile_id = '3187'
|
13
|
+
@customer_payment_profile_id = '7813'
|
14
|
+
@customer_address_id = '4321'
|
15
|
+
@payment = {
|
16
|
+
:credit_card => @credit_card
|
17
|
+
}
|
18
|
+
@profile = {
|
19
|
+
:merchant_customer_id => 'Up to 20 chars', # Optional
|
20
|
+
:description => 'Up to 255 Characters', # Optional
|
21
|
+
:email => 'Up to 255 Characters', # Optional
|
22
|
+
:payment_profiles => { # Optional
|
23
|
+
:customer_type => 'individual or business', # Optional
|
24
|
+
:bill_to => @address,
|
25
|
+
:payment => @payment
|
26
|
+
},
|
27
|
+
:ship_to_list => {
|
28
|
+
:first_name => 'John',
|
29
|
+
:last_name => 'Doe',
|
30
|
+
:company => 'Widgets, Inc',
|
31
|
+
:address1 => '1234 Fake Street',
|
32
|
+
:city => 'Anytown',
|
33
|
+
:state => 'MD',
|
34
|
+
:zip => '12345',
|
35
|
+
:country => 'USA',
|
36
|
+
:phone_number => '(123)123-1234', # Optional - Up to 25 digits (no letters)
|
37
|
+
:fax_number => '(123)123-1234' # Optional - Up to 25 digits (no letters)
|
38
|
+
}
|
39
|
+
}
|
40
|
+
@options = {
|
41
|
+
:ref_id => '1234', # Optional
|
42
|
+
:profile => @profile
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_expdate_formatting
|
47
|
+
assert_equal '2009-09', @gateway.send(:expdate, @credit_card)
|
48
|
+
|
49
|
+
assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111',
|
50
|
+
:month => 11,
|
51
|
+
:year => 2013))
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_should_create_customer_profile_request
|
55
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_profile_response)
|
56
|
+
|
57
|
+
assert response = @gateway.create_customer_profile(@options)
|
58
|
+
assert_instance_of Response, response
|
59
|
+
assert_success response
|
60
|
+
assert_equal @customer_profile_id, response.authorization
|
61
|
+
assert_equal "Successful.", response.message
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_should_create_customer_payment_profile_request
|
65
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_payment_profile_response)
|
66
|
+
|
67
|
+
assert response = @gateway.create_customer_payment_profile(
|
68
|
+
:customer_profile_id => @customer_profile_id,
|
69
|
+
:payment_profile => {
|
70
|
+
:customer_type => 'individual',
|
71
|
+
:bill_to => @address,
|
72
|
+
:payment => @payment
|
73
|
+
},
|
74
|
+
:validation_mode => :test
|
75
|
+
)
|
76
|
+
assert_instance_of Response, response
|
77
|
+
assert_success response
|
78
|
+
assert_equal @customer_payment_profile_id, response.params['customer_payment_profile_id']
|
79
|
+
assert_equal "This output is only present if the ValidationMode input parameter is passed with a value of testMode or liveMode", response.params['validation_direct_response']
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_should_create_customer_shipping_address_request
|
83
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_shipping_address_response)
|
84
|
+
|
85
|
+
assert response = @gateway.create_customer_shipping_address(
|
86
|
+
:customer_profile_id => @customer_profile_id,
|
87
|
+
:address => {
|
88
|
+
:first_name => 'John',
|
89
|
+
:last_name => 'Doe',
|
90
|
+
:company => 'Widgets, Inc',
|
91
|
+
:address1 => '1234 Fake Street',
|
92
|
+
:city => 'Anytown',
|
93
|
+
:state => 'MD',
|
94
|
+
:country => 'USA',
|
95
|
+
:phone_number => '(123)123-1234',
|
96
|
+
:fax_number => '(123)123-1234'
|
97
|
+
}
|
98
|
+
)
|
99
|
+
assert_instance_of Response, response
|
100
|
+
assert_success response
|
101
|
+
assert_nil response.authorization
|
102
|
+
assert_equal 'customerAddressId', response.params['customer_address_id']
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_should_create_customer_profile_transaction_auth_only_and_then_capture_only_requests
|
106
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:auth_only))
|
107
|
+
|
108
|
+
assert response = @gateway.create_customer_profile_transaction(
|
109
|
+
:transaction => {
|
110
|
+
:customer_profile_id => @customer_profile_id,
|
111
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
112
|
+
:type => :auth_only,
|
113
|
+
:amount => @amount
|
114
|
+
}
|
115
|
+
)
|
116
|
+
assert_instance_of Response, response
|
117
|
+
assert_success response
|
118
|
+
assert_nil response.authorization
|
119
|
+
assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
|
120
|
+
assert_equal 'auth_only', response.params['direct_response']['transaction_type']
|
121
|
+
assert_equal 'Gw4NGI', approval_code = response.params['direct_response']['approval_code']
|
122
|
+
|
123
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:capture_only))
|
124
|
+
|
125
|
+
assert response = @gateway.create_customer_profile_transaction(
|
126
|
+
:transaction => {
|
127
|
+
:customer_profile_id => @customer_profile_id,
|
128
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
129
|
+
:type => :capture_only,
|
130
|
+
:amount => @amount,
|
131
|
+
:approval_code => approval_code
|
132
|
+
}
|
133
|
+
)
|
134
|
+
assert_instance_of Response, response
|
135
|
+
assert_success response
|
136
|
+
assert_nil response.authorization
|
137
|
+
assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_should_create_customer_profile_transaction_auth_capture_request
|
141
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:auth_capture))
|
142
|
+
|
143
|
+
assert response = @gateway.create_customer_profile_transaction(
|
144
|
+
:transaction => {
|
145
|
+
:customer_profile_id => @customer_profile_id,
|
146
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
147
|
+
:type => :auth_capture,
|
148
|
+
:order => {
|
149
|
+
:invoice_number => '1234',
|
150
|
+
:description => 'Test Order Description',
|
151
|
+
:purchase_order_number => '4321'
|
152
|
+
},
|
153
|
+
:amount => @amount
|
154
|
+
}
|
155
|
+
)
|
156
|
+
assert_instance_of Response, response
|
157
|
+
assert_success response
|
158
|
+
assert_nil response.authorization
|
159
|
+
assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_should_delete_customer_profile_request
|
163
|
+
@gateway.expects(:ssl_post).returns(successful_delete_customer_profile_response)
|
164
|
+
|
165
|
+
assert response = @gateway.delete_customer_profile(:customer_profile_id => @customer_profile_id)
|
166
|
+
assert_instance_of Response, response
|
167
|
+
assert_success response
|
168
|
+
assert_equal @customer_profile_id, response.authorization
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_should_delete_customer_payment_profile_request
|
172
|
+
@gateway.expects(:ssl_post).returns(successful_delete_customer_payment_profile_response)
|
173
|
+
|
174
|
+
assert response = @gateway.delete_customer_payment_profile(:customer_profile_id => @customer_profile_id, :customer_payment_profile_id => @customer_payment_profile_id)
|
175
|
+
assert_instance_of Response, response
|
176
|
+
assert_success response
|
177
|
+
assert_nil response.authorization
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_should_delete_customer_shipping_address_request
|
181
|
+
@gateway.expects(:ssl_post).returns(successful_delete_customer_shipping_address_response)
|
182
|
+
|
183
|
+
assert response = @gateway.delete_customer_shipping_address(:customer_profile_id => @customer_profile_id, :customer_address_id => @customer_address_id)
|
184
|
+
assert_instance_of Response, response
|
185
|
+
assert_success response
|
186
|
+
assert_nil response.authorization
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_should_get_customer_profile_request
|
190
|
+
@gateway.expects(:ssl_post).returns(successful_get_customer_profile_response)
|
191
|
+
|
192
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
193
|
+
assert_instance_of Response, response
|
194
|
+
assert_success response
|
195
|
+
assert_equal @customer_profile_id, response.authorization
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_should_get_customer_profile_request_with_multiple_payment_profiles
|
199
|
+
@gateway.expects(:ssl_post).returns(successful_get_customer_profile_response_with_multiple_payment_profiles)
|
200
|
+
|
201
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
202
|
+
assert_instance_of Response, response
|
203
|
+
assert_success response
|
204
|
+
|
205
|
+
assert_equal @customer_profile_id, response.authorization
|
206
|
+
assert_equal 2, response.params['profile']['payment_profiles'].size
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_should_get_customer_payment_profile_request
|
210
|
+
@gateway.expects(:ssl_post).returns(successful_get_customer_payment_profile_response)
|
211
|
+
|
212
|
+
assert response = @gateway.get_customer_payment_profile(
|
213
|
+
:customer_profile_id => @customer_profile_id,
|
214
|
+
:customer_payment_profile_id => @customer_payment_profile_id
|
215
|
+
)
|
216
|
+
assert_instance_of Response, response
|
217
|
+
assert_success response
|
218
|
+
assert_nil response.authorization
|
219
|
+
assert_equal @customer_payment_profile_id, response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_should_get_customer_shipping_address_request
|
223
|
+
@gateway.expects(:ssl_post).returns(successful_get_customer_shipping_address_response)
|
224
|
+
|
225
|
+
assert response = @gateway.get_customer_shipping_address(
|
226
|
+
:customer_profile_id => @customer_profile_id,
|
227
|
+
:customer_address_id => @customer_address_id
|
228
|
+
)
|
229
|
+
assert_instance_of Response, response
|
230
|
+
assert_success response
|
231
|
+
assert_nil response.authorization
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_should_update_customer_profile_request
|
235
|
+
@gateway.expects(:ssl_post).returns(successful_update_customer_profile_response)
|
236
|
+
|
237
|
+
assert response = @gateway.update_customer_profile(
|
238
|
+
:profile => {
|
239
|
+
:customer_profile_id => @customer_profile_id,
|
240
|
+
:email => 'new email address'
|
241
|
+
}
|
242
|
+
)
|
243
|
+
assert_instance_of Response, response
|
244
|
+
assert_success response
|
245
|
+
assert_equal @customer_profile_id, response.authorization
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_should_update_customer_payment_profile_request
|
249
|
+
@gateway.expects(:ssl_post).returns(successful_update_customer_payment_profile_response)
|
250
|
+
|
251
|
+
assert response = @gateway.update_customer_payment_profile(
|
252
|
+
:customer_profile_id => @customer_profile_id,
|
253
|
+
:payment_profile => {
|
254
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
255
|
+
:customer_type => 'business'
|
256
|
+
}
|
257
|
+
)
|
258
|
+
assert_instance_of Response, response
|
259
|
+
assert_success response
|
260
|
+
assert_nil response.authorization
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_should_update_customer_shipping_address_request
|
264
|
+
@gateway.expects(:ssl_post).returns(successful_update_customer_shipping_address_response)
|
265
|
+
|
266
|
+
assert response = @gateway.update_customer_shipping_address(
|
267
|
+
:customer_profile_id => @customer_profile_id,
|
268
|
+
:address => {
|
269
|
+
:customer_address_id => @customer_address_id,
|
270
|
+
:city => 'New City'
|
271
|
+
}
|
272
|
+
)
|
273
|
+
assert_instance_of Response, response
|
274
|
+
assert_success response
|
275
|
+
assert_nil response.authorization
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_should_validate_customer_payment_profile_request
|
279
|
+
@gateway.expects(:ssl_post).returns(successful_validate_customer_payment_profile_response)
|
280
|
+
|
281
|
+
assert response = @gateway.validate_customer_payment_profile(
|
282
|
+
:customer_profile_id => @customer_profile_id,
|
283
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
284
|
+
:customer_address_id => @customer_address_id,
|
285
|
+
:validation_mode => :live
|
286
|
+
)
|
287
|
+
assert_instance_of Response, response
|
288
|
+
assert_success response
|
289
|
+
assert_nil response.authorization
|
290
|
+
assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
|
291
|
+
end
|
292
|
+
|
293
|
+
private
|
294
|
+
|
295
|
+
def successful_create_customer_profile_response
|
296
|
+
<<-XML
|
297
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
298
|
+
<createCustomerProfileResponse
|
299
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
300
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
301
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
302
|
+
<refId>refid1</refId>
|
303
|
+
<messages>
|
304
|
+
<resultCode>Ok</resultCode>
|
305
|
+
<message>
|
306
|
+
<code>I00001</code>
|
307
|
+
<text>Successful.</text>
|
308
|
+
</message>
|
309
|
+
</messages>
|
310
|
+
<customerProfileId>#{@customer_profile_id}</customerProfileId>
|
311
|
+
</createCustomerProfileResponse>
|
312
|
+
XML
|
313
|
+
end
|
314
|
+
|
315
|
+
def successful_create_customer_payment_profile_response
|
316
|
+
<<-XML
|
317
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
318
|
+
<createCustomerPaymentProfileResponse
|
319
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
320
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
321
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
322
|
+
<refId>refid1</refId>
|
323
|
+
<messages>
|
324
|
+
<resultCode>Ok</resultCode>
|
325
|
+
<message>
|
326
|
+
<code>I00001</code>
|
327
|
+
<text>Successful.</text>
|
328
|
+
</message>
|
329
|
+
</messages>
|
330
|
+
<customerPaymentProfileId>#{@customer_payment_profile_id}</customerPaymentProfileId>
|
331
|
+
<validationDirectResponse>This output is only present if the ValidationMode input parameter is passed with a value of testMode or liveMode</validationDirectResponse>
|
332
|
+
</createCustomerPaymentProfileResponse>
|
333
|
+
XML
|
334
|
+
end
|
335
|
+
|
336
|
+
def successful_create_customer_shipping_address_response
|
337
|
+
<<-XML
|
338
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
339
|
+
<createCustomerShippingAddressResponse
|
340
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
341
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
342
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
343
|
+
<refId>refid1</refId>
|
344
|
+
<messages>
|
345
|
+
<resultCode>Ok</resultCode>
|
346
|
+
<message>
|
347
|
+
<code>I00001</code>
|
348
|
+
<text>Successful.</text>
|
349
|
+
</message>
|
350
|
+
</messages>
|
351
|
+
<customerAddressId>customerAddressId</customerAddressId>
|
352
|
+
</createCustomerShippingAddressResponse>
|
353
|
+
XML
|
354
|
+
end
|
355
|
+
|
356
|
+
def successful_delete_customer_profile_response
|
357
|
+
<<-XML
|
358
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
359
|
+
<deleteCustomerProfileResponse
|
360
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
361
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
362
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
363
|
+
<refId>refid1</refId>
|
364
|
+
<messages>
|
365
|
+
<resultCode>Ok</resultCode>
|
366
|
+
<message>
|
367
|
+
<code>I00001</code>
|
368
|
+
<text>Successful.</text>
|
369
|
+
</message>
|
370
|
+
</messages>
|
371
|
+
<customerProfileId>#{@customer_profile_id}</customerProfileId>
|
372
|
+
</deleteCustomerProfileResponse>
|
373
|
+
XML
|
374
|
+
end
|
375
|
+
|
376
|
+
def successful_delete_customer_payment_profile_response
|
377
|
+
<<-XML
|
378
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
379
|
+
<deleteCustomerPaymentProfileResponse
|
380
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
381
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
382
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
383
|
+
<refId>refid1</refId>
|
384
|
+
<messages>
|
385
|
+
<resultCode>Ok</resultCode>
|
386
|
+
<message>
|
387
|
+
<code>I00001</code>
|
388
|
+
<text>Successful.</text>
|
389
|
+
</message>
|
390
|
+
</messages>
|
391
|
+
</deleteCustomerPaymentProfileResponse>
|
392
|
+
XML
|
393
|
+
end
|
394
|
+
|
395
|
+
def successful_delete_customer_shipping_address_response
|
396
|
+
<<-XML
|
397
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
398
|
+
<deleteCustomerShippingAddressResponse
|
399
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
400
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
401
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
402
|
+
<refId>refid1</refId>
|
403
|
+
<messages>
|
404
|
+
<resultCode>Ok</resultCode>
|
405
|
+
<message>
|
406
|
+
<code>I00001</code>
|
407
|
+
<text>Successful.</text>
|
408
|
+
</message>
|
409
|
+
</messages>
|
410
|
+
</deleteCustomerShippingAddressResponse>
|
411
|
+
XML
|
412
|
+
end
|
413
|
+
|
414
|
+
def successful_get_customer_profile_response
|
415
|
+
<<-XML
|
416
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
417
|
+
<getCustomerProfileResponse
|
418
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
419
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
420
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
421
|
+
<refId>refid1</refId>
|
422
|
+
<messages>
|
423
|
+
<resultCode>Ok</resultCode>
|
424
|
+
<message>
|
425
|
+
<code>I00001</code>
|
426
|
+
<text>Successful.</text>
|
427
|
+
</message>
|
428
|
+
</messages>
|
429
|
+
<customerProfileId>#{@customer_profile_id}</customerProfileId>
|
430
|
+
<profile>
|
431
|
+
<paymentProfiles>
|
432
|
+
<customerPaymentProfileId>123456</customerPaymentProfileId>
|
433
|
+
<payment>
|
434
|
+
<creditCard>
|
435
|
+
<cardNumber>#{@credit_card.number}</cardNumber>
|
436
|
+
<expirationDate>#{@gateway.send(:expdate, @credit_card)}</expirationDate>
|
437
|
+
</creditCard>
|
438
|
+
</payment>
|
439
|
+
</paymentProfiles>
|
440
|
+
</profile>
|
441
|
+
</getCustomerProfileResponse>
|
442
|
+
XML
|
443
|
+
end
|
444
|
+
|
445
|
+
def successful_get_customer_profile_response_with_multiple_payment_profiles
|
446
|
+
<<-XML
|
447
|
+
<?xml version="1.0" encoding="utf-8"?>
|
448
|
+
<getCustomerProfileResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
449
|
+
<messages>
|
450
|
+
<resultCode>Ok</resultCode>
|
451
|
+
<message>
|
452
|
+
<code>I00001</code>
|
453
|
+
<text>Successful.</text>
|
454
|
+
</message>
|
455
|
+
</messages>
|
456
|
+
<profile>
|
457
|
+
<merchantCustomerId>Up to 20 chars</merchantCustomerId>
|
458
|
+
<description>Up to 255 Characters</description>
|
459
|
+
<email>Up to 255 Characters</email>
|
460
|
+
<customerProfileId>#{@customer_profile_id}</customerProfileId>
|
461
|
+
<paymentProfiles>
|
462
|
+
<customerPaymentProfileId>1000</customerPaymentProfileId>
|
463
|
+
<payment>
|
464
|
+
<creditCard>
|
465
|
+
<cardNumber>#{@credit_card.number}</cardNumber>
|
466
|
+
<expirationDate>#{@gateway.send(:expdate, @credit_card)}</expirationDate>
|
467
|
+
</creditCard>
|
468
|
+
</payment>
|
469
|
+
</paymentProfiles>
|
470
|
+
<paymentProfiles>
|
471
|
+
<customerType>individual</customerType>
|
472
|
+
<customerPaymentProfileId>1001</customerPaymentProfileId>
|
473
|
+
<payment>
|
474
|
+
<creditCard>
|
475
|
+
<cardNumber>XXXX1234</cardNumber>
|
476
|
+
<expirationDate>XXXX</expirationDate>
|
477
|
+
</creditCard>
|
478
|
+
</payment>
|
479
|
+
</paymentProfiles>
|
480
|
+
</profile>
|
481
|
+
</getCustomerProfileResponse>
|
482
|
+
XML
|
483
|
+
end
|
484
|
+
|
485
|
+
def successful_get_customer_payment_profile_response
|
486
|
+
<<-XML
|
487
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
488
|
+
<getCustomerPaymentProfileResponse
|
489
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
490
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
491
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
492
|
+
<refId>refid1</refId>
|
493
|
+
<messages>
|
494
|
+
<resultCode>Ok</resultCode>
|
495
|
+
<message>
|
496
|
+
<code>I00001</code>
|
497
|
+
<text>Successful.</text>
|
498
|
+
</message>
|
499
|
+
</messages>
|
500
|
+
<profile>
|
501
|
+
<paymentProfiles>
|
502
|
+
<customerPaymentProfileId>#{@customer_payment_profile_id}</customerPaymentProfileId>
|
503
|
+
<payment>
|
504
|
+
<creditCard>
|
505
|
+
<cardNumber>#{@credit_card.number}</cardNumber>
|
506
|
+
<expirationDate>#{@gateway.send(:expdate, @credit_card)}</expirationDate>
|
507
|
+
</creditCard>
|
508
|
+
</payment>
|
509
|
+
</paymentProfiles>
|
510
|
+
</profile>
|
511
|
+
</getCustomerPaymentProfileResponse>
|
512
|
+
XML
|
513
|
+
end
|
514
|
+
|
515
|
+
def successful_get_customer_shipping_address_response
|
516
|
+
<<-XML
|
517
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
518
|
+
<getCustomerShippingAddressResponse
|
519
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
520
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
521
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
522
|
+
<refId>refid1</refId>
|
523
|
+
<messages>
|
524
|
+
<resultCode>Ok</resultCode>
|
525
|
+
<message>
|
526
|
+
<code>I00001</code>
|
527
|
+
<text>Successful.</text>
|
528
|
+
</message>
|
529
|
+
</messages>
|
530
|
+
<address>
|
531
|
+
<customerAddressId>#{@customer_address_id}</customerAddressId>
|
532
|
+
</address>
|
533
|
+
</getCustomerShippingAddressResponse>
|
534
|
+
XML
|
535
|
+
end
|
536
|
+
|
537
|
+
def successful_update_customer_profile_response
|
538
|
+
<<-XML
|
539
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
540
|
+
<updateCustomerProfileResponse
|
541
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
542
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
543
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
544
|
+
<refId>refid1</refId>
|
545
|
+
<messages>
|
546
|
+
<resultCode>Ok</resultCode>
|
547
|
+
<message>
|
548
|
+
<code>I00001</code>
|
549
|
+
<text>Successful.</text>
|
550
|
+
</message>
|
551
|
+
</messages>
|
552
|
+
<customerProfileId>#{@customer_profile_id}</customerProfileId>
|
553
|
+
</updateCustomerProfileResponse>
|
554
|
+
XML
|
555
|
+
end
|
556
|
+
|
557
|
+
def successful_update_customer_payment_profile_response
|
558
|
+
<<-XML
|
559
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
560
|
+
<updateCustomerPaymentProfileResponse
|
561
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
562
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
563
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
564
|
+
<refId>refid1</refId>
|
565
|
+
<messages>
|
566
|
+
<resultCode>Ok</resultCode>
|
567
|
+
<message>
|
568
|
+
<code>I00001</code>
|
569
|
+
<text>Successful.</text>
|
570
|
+
</message>
|
571
|
+
</messages>
|
572
|
+
</updateCustomerPaymentProfileResponse>
|
573
|
+
XML
|
574
|
+
end
|
575
|
+
|
576
|
+
def successful_update_customer_shipping_address_response
|
577
|
+
<<-XML
|
578
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
579
|
+
<updateCustomerShippingAddressResponse
|
580
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
581
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
582
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
583
|
+
<refId>refid1</refId>
|
584
|
+
<messages>
|
585
|
+
<resultCode>Ok</resultCode>
|
586
|
+
<message>
|
587
|
+
<code>I00001</code>
|
588
|
+
<text>Successful.</text>
|
589
|
+
</message>
|
590
|
+
</messages>
|
591
|
+
</updateCustomerShippingAddressResponse>
|
592
|
+
XML
|
593
|
+
end
|
594
|
+
|
595
|
+
SUCCESSFUL_DIRECT_RESPONSE = {
|
596
|
+
:auth_only => '1,1,1,This transaction has been approved.,Gw4NGI,Y,508223659,,,100.00,CC,auth_only,Up to 20 chars,,,,,,,,,,,Up to 255 Characters,,,,,,,,,,,,,,6E5334C13C78EA078173565FD67318E4,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
|
597
|
+
:capture_only => '1,1,1,This transaction has been approved.,,Y,508223660,,,100.00,CC,capture_only,Up to 20 chars,,,,,,,,,,,Up to 255 Characters,,,,,,,,,,,,,,6E5334C13C78EA078173565FD67318E4,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
|
598
|
+
:auth_capture => '1,1,1,This transaction has been approved.,d1GENk,Y,508223661,32968c18334f16525227,Store purchase,1.00,CC,auth_capture,,Longbob,Longsen,,,,,,,,,,,,,,,,,,,,,,,269862C030129C1173727CC10B1935ED,P,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,'
|
599
|
+
}
|
600
|
+
|
601
|
+
def successful_create_customer_profile_transaction_response(transaction_type)
|
602
|
+
<<-XML
|
603
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
604
|
+
<createCustomerProfileTransactionResponse
|
605
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
606
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
607
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
608
|
+
<refId>refid1</refId>
|
609
|
+
<messages>
|
610
|
+
<resultCode>Ok</resultCode>
|
611
|
+
<message>
|
612
|
+
<code>I00001</code>
|
613
|
+
<text>Successful.</text>
|
614
|
+
</message>
|
615
|
+
</messages>
|
616
|
+
<directResponse>#{SUCCESSFUL_DIRECT_RESPONSE[transaction_type]}</directResponse>
|
617
|
+
</createCustomerProfileTransactionResponse>
|
618
|
+
XML
|
619
|
+
end
|
620
|
+
|
621
|
+
def successful_validate_customer_payment_profile_response
|
622
|
+
<<-XML
|
623
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
624
|
+
<validateCustomerPaymentProfileResponse
|
625
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
626
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
627
|
+
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
628
|
+
<refId>refid1</refId>
|
629
|
+
<messages>
|
630
|
+
<resultCode>Ok</resultCode>
|
631
|
+
<message>
|
632
|
+
<code>I00001</code>
|
633
|
+
<text>Successful.</text>
|
634
|
+
</message>
|
635
|
+
</messages>
|
636
|
+
<directResponse>1,1,1,This transaction has been approved.,DEsVh8,Y,508276300,none,Test transaction for ValidateCustomerPaymentProfile.,0.01,CC,auth_only,Up to 20 chars,,,,,,,,,,,Up to 255 Characters,John,Doe,Widgets, Inc,1234 Fake Street,Anytown,MD,12345,USA,0.0000,0.0000,0.0000,TRUE,none,7EB3A44624C0C10FAAE47E276B48BF17,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,</directResponse>
|
637
|
+
</validateCustomerPaymentProfileResponse>
|
638
|
+
XML
|
639
|
+
end
|
640
|
+
|
641
|
+
end
|