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
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class BeanstreamInteracTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@gateway = BeanstreamInteracGateway.new(
|
6
|
+
:login => 'login',
|
7
|
+
:password => 'password'
|
8
|
+
)
|
9
|
+
|
10
|
+
@amount = 100
|
11
|
+
|
12
|
+
@options = {
|
13
|
+
:order_id => '1',
|
14
|
+
:billing_address => address,
|
15
|
+
:description => 'Store Purchase'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_successful_purchase
|
20
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
21
|
+
response = @gateway.purchase(@amount, @options)
|
22
|
+
|
23
|
+
assert_success response
|
24
|
+
assert_equal "R", response.params["responseType"]
|
25
|
+
assert response.params["pageContents"]
|
26
|
+
assert_equal response.params["pageContents"], response.redirect
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_successful_confirmation
|
30
|
+
@gateway.expects(:ssl_post).returns(successful_confirmation_response)
|
31
|
+
|
32
|
+
response = @gateway.confirm(successful_return_from_interac_online)
|
33
|
+
assert response.success?
|
34
|
+
assert_equal "Approved", response.message
|
35
|
+
assert_equal "10000029;5.00;P", response.authorization
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def successful_purchase_response
|
41
|
+
"responseType=R&pageContents=%3CHTML%3E%3CHEAD%3E%3C%2FHEAD%3E%3CBODY%3E%3CFORM%20action%3D%22https%3A%2F%2Fpayments%2Ebeanstream%2Ecom%2FiOnlineEmulator%2Fgateway%2Easp%22%20method%3DPOST%20id%3DfrmIOnline%20name%3DfrmIOnline%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHNUM%22%20%20value%3D%2210010162199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FAMOUNT%22%20%20value%3D%221500%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FTERMID%22%20value%3D%2262199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FCURRENCY%22%20value%3D%22CAD%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FINVOICE%22%20value%3D%221be7db7a129b07ac5f7e%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHDATA%22%20value%3D%226CE36AF7%2D5013%2D4B94%2DB740153714A41962%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D1%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FNOTFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D0%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22merchant%5Fname%22%20value%3D%22Cody%20Fauser%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost2%22%20value%3D%22https%3A%2F%2Fwww%2Ecatnrose%2Ecom%2Fioxml%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost3%22%20value%3D%22%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHLANG%22%20value%3D%22en%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FVERSION%22%20value%3D%221%22%3E%3C%2FFORM%3E%3CSCRIPT%20language%3D%22JavaScript%22%3Edocument%2EfrmIOnline%2Esubmit%28%29%3B%3C%2FSCRIPT%3E%3C%2FBODY%3E%3C%2FHTML%3E"
|
42
|
+
end
|
43
|
+
|
44
|
+
def successful_return_from_interac_online
|
45
|
+
"bank_choice=1&merchant_name=Billing+Boss+IO+SB&confirmValue=&headerText=&IDEBIT_MERCHDATA=C4B50A48-6E11-4C21-A31EF4A602BC0099&IDEBIT_INVOICE=18face21593b59c7bb7e&IDEBIT_AMOUNT=1500&IDEBIT_FUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Ffunded%3Ffunded%3D1&IDEBIT_NOTFUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Fnotfunded%3Ffunded%3D0&IDEBIT_ISSLANG=en&IDEBIT_TRACK2=3728024906540591214%3D12010123456789XYZ&IDEBIT_ISSCONF=CONF%23TEST&IDEBIT_ISSNAME=TestBank1&IDEBIT_VERSION=1&accountType=Chequing"
|
46
|
+
end
|
47
|
+
|
48
|
+
def successful_confirmation_response
|
49
|
+
"trnApproved=1&trnId=10000029&messageId=1&messageText=Approved&trnOrderNumber=f29d2406b49b239b6dfb5db1f642b2&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=5%2E00&trnDate=6%2F8%2F2008+3%3A17%3A12+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=P&paymentMethod=IO&ioConfCode=CONF%23TEST&ioInstName=TestBank1&ref1=reference+one&ref2=&ref3=&ref4=&ref5="
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class BeanstreamTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Base.mode = :test
|
6
|
+
|
7
|
+
@gateway = BeanstreamGateway.new(
|
8
|
+
:login => 'merchant id',
|
9
|
+
:user => 'username',
|
10
|
+
:password => 'password'
|
11
|
+
)
|
12
|
+
|
13
|
+
@credit_card = credit_card
|
14
|
+
|
15
|
+
@check = check(
|
16
|
+
:institution_number => '001',
|
17
|
+
:transit_number => '26729'
|
18
|
+
)
|
19
|
+
|
20
|
+
@amount = 1000
|
21
|
+
|
22
|
+
@options = {
|
23
|
+
:order_id => '1234',
|
24
|
+
:billing_address => {
|
25
|
+
:name => 'xiaobo zzz',
|
26
|
+
:phone => '555-555-5555',
|
27
|
+
:address1 => '1234 Levesque St.',
|
28
|
+
:address2 => 'Apt B',
|
29
|
+
:city => 'Montreal',
|
30
|
+
:state => 'QC',
|
31
|
+
:country => 'CA',
|
32
|
+
:zip => 'H2C1X8'
|
33
|
+
},
|
34
|
+
:email => 'xiaobozzz@example.com',
|
35
|
+
:subtotal => 800,
|
36
|
+
:shipping => 100,
|
37
|
+
:tax1 => 100,
|
38
|
+
:tax2 => 100,
|
39
|
+
:custom => 'reference one'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_successful_purchase
|
44
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
45
|
+
|
46
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
47
|
+
assert_success response
|
48
|
+
assert_equal '10000028;15.00;P', response.authorization
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_successful_test_request_in_production_environment
|
52
|
+
Base.mode = :production
|
53
|
+
@gateway.expects(:ssl_post).returns(successful_test_purchase_response)
|
54
|
+
|
55
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
56
|
+
assert_success response
|
57
|
+
assert response.test?
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_unsuccessful_request
|
61
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
62
|
+
|
63
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
64
|
+
assert_failure response
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_avs_result
|
68
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
69
|
+
|
70
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
71
|
+
assert_equal 'R', response.avs_result['code']
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_ccv_result
|
75
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
76
|
+
|
77
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
78
|
+
assert_equal 'M', response.cvv_result['code']
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_successful_check_purchase
|
82
|
+
@gateway.expects(:ssl_post).returns(successful_check_purchase_response)
|
83
|
+
|
84
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
85
|
+
|
86
|
+
assert_success response
|
87
|
+
assert_equal '10000072;15.00;D', response.authorization
|
88
|
+
assert_equal 'Approved', response.message
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def successful_purchase_response
|
94
|
+
"cvdId=1&trnType=P&trnApproved=1&trnId=10000028&messageId=1&messageText=Approved&trnOrderNumber=df5e88232a61dc1d0058a20d5b5c0e&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F5%2F2008+5%3A26%3A53+AM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+f"
|
95
|
+
end
|
96
|
+
|
97
|
+
def successful_test_purchase_response
|
98
|
+
"merchant_id=100200000&trnId=11011067&authCode=TEST&trnApproved=1&avsId=M&cvdId=1&messageId=1&messageText=Approved&trnOrderNumber=1234"
|
99
|
+
end
|
100
|
+
|
101
|
+
def unsuccessful_purchase_response
|
102
|
+
"merchant_id=100200000&trnId=11011069&authCode=&trnApproved=0&avsId=0&cvdId=6&messageId=16&messageText=Duplicate+transaction&trnOrderNumber=1234"
|
103
|
+
end
|
104
|
+
|
105
|
+
def successful_check_purchase_response
|
106
|
+
"trnApproved=1&trnId=10000072&messageId=1&messageText=Approved&trnOrderNumber=5d9f511363a0f35d37de53b4d74f5b&authCode=&errorType=N&errorFields=&responseType=T&trnAmount=15%2E00&trnDate=6%2F4%2F2008+6%3A33%3A55+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=D&paymentMethod=EFT&ref1=reference+one&ref2=&ref3=&ref4=&ref5="
|
107
|
+
end
|
108
|
+
end
|
@@ -8,10 +8,7 @@ class BraintreeTest < Test::Unit::TestCase
|
|
8
8
|
:password => 'PASSWORD'
|
9
9
|
)
|
10
10
|
|
11
|
-
@credit_card = credit_card
|
12
|
-
:type => 'visa'
|
13
|
-
)
|
14
|
-
|
11
|
+
@credit_card = credit_card
|
15
12
|
@amount = 100
|
16
13
|
|
17
14
|
@options = { :billing_address => address }
|
@@ -50,7 +47,7 @@ class BraintreeTest < Test::Unit::TestCase
|
|
50
47
|
end
|
51
48
|
|
52
49
|
def test_supported_card_types
|
53
|
-
assert_equal [:visa, :master, :american_express], BraintreeGateway.supported_cardtypes
|
50
|
+
assert_equal [:visa, :master, :american_express, :discover], BraintreeGateway.supported_cardtypes
|
54
51
|
end
|
55
52
|
|
56
53
|
def test_adding_store_adds_vault_id_flag
|
@@ -126,6 +126,16 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
126
126
|
assert_equal 'M', response.cvv_result['code']
|
127
127
|
end
|
128
128
|
|
129
|
+
def test_successful_credit_request
|
130
|
+
@gateway.stubs(:ssl_post).returns(successful_capture_response, successful_credit_response)
|
131
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
132
|
+
assert response.success?
|
133
|
+
assert response.test?
|
134
|
+
assert response_capture = @gateway.credit(@amount, response.authorization)
|
135
|
+
assert response_capture.success?
|
136
|
+
assert response_capture.test?
|
137
|
+
end
|
138
|
+
|
129
139
|
private
|
130
140
|
|
131
141
|
def successful_purchase_response
|
@@ -167,4 +177,12 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
167
177
|
XML
|
168
178
|
end
|
169
179
|
|
180
|
+
def successful_credit_response
|
181
|
+
<<-XML
|
182
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
183
|
+
<soap:Header>
|
184
|
+
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-5589339"><wsu:Created>2008-01-21T16:00:38.927Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.32"><c:merchantReferenceCode>TEST11111111111</c:merchantReferenceCode><c:requestID>2009312387810008401927</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>Af/vj7OzPmut/eogHFCrBiwYsWTJy1r127CpCn0KdOgyTZnzKwVYCmzPmVgr9ID5H1WGTSTKuj0i30IE4+zsz2d/QNzwBwAACCPA</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccCreditReply><c:reasonCode>100</c:reasonCode><c:requestDateTime>2008-01-21T16:00:38Z</c:requestDateTime><c:amount>1.00</c:amount><c:reconciliationID>010112295WW70TBOPSSP2</c:reconciliationID></c:ccCreditReply></c:replyMessage></soap:Body></soap:Envelope>
|
185
|
+
XML
|
186
|
+
end
|
187
|
+
|
170
188
|
end
|
@@ -37,7 +37,7 @@ class DataCashTest < Test::Unit::TestCase
|
|
37
37
|
assert_success response
|
38
38
|
assert response.test?
|
39
39
|
assert_equal 'The transaction was successful', response.message
|
40
|
-
assert_equal '4400200050664928;123456789', response.authorization
|
40
|
+
assert_equal '4400200050664928;123456789;', response.authorization
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_unsuccessful_purchase
|
@@ -50,7 +50,7 @@ class DataCashTest < Test::Unit::TestCase
|
|
50
50
|
assert_equal 'Invalid reference number', response.message
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def test_error_response
|
54
54
|
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
55
55
|
|
56
56
|
response = @gateway.purchase(@amount, @credit_card, @options)
|
@@ -68,6 +68,34 @@ class DataCashTest < Test::Unit::TestCase
|
|
68
68
|
assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
|
69
69
|
end
|
70
70
|
|
71
|
+
def test_purchase_with_missing_order_id_option
|
72
|
+
assert_raise(ArgumentError){ @gateway.purchase(100, @credit_card, {}) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_authorize_with_missing_order_id_option
|
76
|
+
assert_raise(ArgumentError){ @gateway.authorize(100, @credit_card, {}) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_purchase_does_not_raise_exception_with_missing_billing_address
|
80
|
+
assert @gateway.authorize(100, @credit_card, {:order_id => generate_unique_id }).is_a?(ActiveMerchant::Billing::Response)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_continuous_authority_purchase_with_missing_continuous_authority_reference
|
84
|
+
assert_raise(ArgumentError) do
|
85
|
+
@gateway.authorize(100, "a;b;", @options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_successful_continuous_authority_purchase
|
90
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
91
|
+
|
92
|
+
response = @gateway.purchase(@amount, '4400200050664928;123456789;10000000', @options)
|
93
|
+
assert_instance_of Response, response
|
94
|
+
assert_success response
|
95
|
+
assert response.test?
|
96
|
+
assert_equal 'The transaction was successful', response.message
|
97
|
+
end
|
98
|
+
|
71
99
|
private
|
72
100
|
def failed_purchase_response
|
73
101
|
<<-XML
|
@@ -100,5 +128,5 @@ class DataCashTest < Test::Unit::TestCase
|
|
100
128
|
<authcode>123456789</authcode>
|
101
129
|
</Response>
|
102
130
|
XML
|
103
|
-
end
|
104
|
-
end
|
131
|
+
end
|
132
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class GatewayTest < Test::Unit::TestCase
|
4
4
|
def test_should_detect_if_a_card_is_supported
|
5
5
|
Gateway.supported_cardtypes = [:visa, :bogus]
|
6
6
|
assert [:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) }
|
@@ -38,4 +38,11 @@ class Gateway < Test::Unit::TestCase
|
|
38
38
|
credit_card = stub(:type => "String", :brand => "visa")
|
39
39
|
assert_equal "visa", Gateway.card_brand(credit_card)
|
40
40
|
end
|
41
|
+
|
42
|
+
def test_setting_application_id_outside_the_class_definition
|
43
|
+
assert_equal SimpleTestGateway.application_id, SubclassGateway.application_id
|
44
|
+
SimpleTestGateway.application_id = "New Application ID"
|
45
|
+
|
46
|
+
assert_equal SimpleTestGateway.application_id, SubclassGateway.application_id
|
47
|
+
end
|
41
48
|
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class ModernPaymentsCimTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Base.mode = :test
|
6
|
+
|
7
|
+
@gateway = ModernPaymentsCimGateway.new(
|
8
|
+
:login => 'login',
|
9
|
+
:password => 'password'
|
10
|
+
)
|
11
|
+
|
12
|
+
@credit_card = credit_card
|
13
|
+
@amount = 100
|
14
|
+
|
15
|
+
@options = {
|
16
|
+
:order_id => '1',
|
17
|
+
:billing_address => address,
|
18
|
+
:description => 'Store Purchase'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_create_customer
|
23
|
+
@gateway.expects(:ssl_post).returns(successful_create_customer_response)
|
24
|
+
|
25
|
+
assert response = @gateway.create_customer(@options)
|
26
|
+
assert_instance_of Response, response
|
27
|
+
assert response.test?
|
28
|
+
assert_success response
|
29
|
+
assert_equal "6677348", response.params["create_customer_result"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_modify_customer_credit_card
|
33
|
+
@gateway.expects(:ssl_post).returns(successful_modify_customer_credit_card_response)
|
34
|
+
|
35
|
+
assert response = @gateway.modify_customer_credit_card("10001", @credit_card)
|
36
|
+
assert_instance_of Response, response
|
37
|
+
assert response.test?
|
38
|
+
assert_success response
|
39
|
+
assert_equal "6677757", response.params["modify_customer_credit_card_result"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_successful_credit_card_authorization
|
43
|
+
@gateway.expects(:ssl_post).returns(successful_credit_card_authorization_response)
|
44
|
+
|
45
|
+
assert response = @gateway.authorize_credit_card_payment("10001", @amount)
|
46
|
+
assert_instance_of Response, response
|
47
|
+
assert response.test?
|
48
|
+
|
49
|
+
assert_success response
|
50
|
+
assert_equal "999", response.params["trans_id"]
|
51
|
+
assert_equal "RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX", response.params["auth_string"]
|
52
|
+
assert_equal "RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX", response.params["message_text"]
|
53
|
+
assert_equal "false", response.params["approved"]
|
54
|
+
assert_equal nil, response.params["avs_code"]
|
55
|
+
assert_equal nil, response.params["auth_code"]
|
56
|
+
assert_equal nil, response.params["trans_code"]
|
57
|
+
assert_equal "999", response.authorization
|
58
|
+
assert_match /RESPONSECODE=A/, response.params["message_text"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_unsuccessful_credit_card_authorization
|
62
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_credit_card_authorization_response)
|
63
|
+
|
64
|
+
assert response = @gateway.authorize_credit_card_payment("10001", @amount)
|
65
|
+
assert_instance_of Response, response
|
66
|
+
assert response.test?
|
67
|
+
assert_success response
|
68
|
+
assert_equal "999", response.authorization
|
69
|
+
assert_match /RESPONSECODE=D/, response.params["message_text"]
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_soap_fault_response
|
73
|
+
@gateway.expects(:ssl_post).returns(soap_fault_response)
|
74
|
+
|
75
|
+
assert response = @gateway.create_customer(@options)
|
76
|
+
assert_instance_of Response, response
|
77
|
+
assert response.test?
|
78
|
+
assert_failure response
|
79
|
+
assert_equal "soap:Client", response.params["faultcode"]
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def successful_create_customer_response
|
85
|
+
<<-XML
|
86
|
+
<?xml version="1.0" encoding="utf-8"?>
|
87
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
88
|
+
<soap:Body>
|
89
|
+
<CreateCustomerResponse xmlns="http://secure.modpay.com:81/ws/">
|
90
|
+
<CreateCustomerResult>6677348</CreateCustomerResult>
|
91
|
+
</CreateCustomerResponse>
|
92
|
+
</soap:Body>
|
93
|
+
</soap:Envelope>
|
94
|
+
XML
|
95
|
+
end
|
96
|
+
|
97
|
+
def successful_modify_customer_credit_card_response
|
98
|
+
<<-XML
|
99
|
+
<?xml version="1.0" encoding="utf-8"?>
|
100
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
101
|
+
<soap:Body>
|
102
|
+
<ModifyCustomerCreditCardResponse xmlns="http://secure.modpay.com:81/ws/">
|
103
|
+
<ModifyCustomerCreditCardResult>6677757</ModifyCustomerCreditCardResult>
|
104
|
+
</ModifyCustomerCreditCardResponse>
|
105
|
+
</soap:Body>
|
106
|
+
</soap:Envelope>
|
107
|
+
XML
|
108
|
+
end
|
109
|
+
|
110
|
+
def successful_credit_card_authorization_response
|
111
|
+
<<-XML
|
112
|
+
<?xml version="1.0" encoding="utf-8"?>
|
113
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
114
|
+
<soap:Body>
|
115
|
+
<AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/netservices/test/">
|
116
|
+
<AuthorizeCreditCardPaymentResult>
|
117
|
+
<transId>999</transId>
|
118
|
+
<authCode/>
|
119
|
+
<avsCode/>
|
120
|
+
<transCode/>
|
121
|
+
<authString>RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX</authString>
|
122
|
+
<messageText>RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX</messageText>
|
123
|
+
<approved>false</approved>
|
124
|
+
</AuthorizeCreditCardPaymentResult>
|
125
|
+
</AuthorizeCreditCardPaymentResponse>
|
126
|
+
</soap:Body>
|
127
|
+
</soap:Envelope>
|
128
|
+
XML
|
129
|
+
end
|
130
|
+
|
131
|
+
def unsuccessful_credit_card_authorization_response
|
132
|
+
<<-XML
|
133
|
+
<?xml version="1.0" encoding="utf-8"?>
|
134
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
135
|
+
<soap:Body>
|
136
|
+
<AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/netservices/test/">
|
137
|
+
<AuthorizeCreditCardPaymentResult>
|
138
|
+
<transId>999</transId>
|
139
|
+
<authCode/>
|
140
|
+
<avsCode/>
|
141
|
+
<transCode/>
|
142
|
+
<authString>RESPONSECODE=D,AUTHCODE=,DECLINEREASON.1.TAG=,DECLINEREASON.1.ERRORCLASS=card declined,DECLINEREASON.1.PARAM1=05:DECLINE,DECLINEREASON.1.PARAM2=The authorization is declined,DECLINEREASON.1.MESSAGE=Card was declined: The authorization is declined,AVSDATA</authString>
|
143
|
+
<messageText>RESPONSECODE=D,AUTHCODE=,DECLINEREASON.1.TAG=,DECLINEREASON.1.ERRORCLASS=card declined,DECLINEREASON.1.PARAM1=05:DECLINE,DECLINEREASON.1.PARAM2=The authorization is declined,DECLINEREASON.1.MESSAGE=Card was declined: The authorization is declined,AVSDATA</messageText>
|
144
|
+
<approved>false</approved>
|
145
|
+
</AuthorizeCreditCardPaymentResult>
|
146
|
+
</AuthorizeCreditCardPaymentResponse>
|
147
|
+
</soap:Body>
|
148
|
+
</soap:Envelope>
|
149
|
+
XML
|
150
|
+
end
|
151
|
+
|
152
|
+
def soap_fault_response
|
153
|
+
<<-XML
|
154
|
+
<?xml version="1.0" encoding="utf-8"?>
|
155
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
156
|
+
<soap:Body>
|
157
|
+
<soap:Fault>
|
158
|
+
<faultcode>soap:Client</faultcode>
|
159
|
+
<faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: h heheheh http://secure.modpay.com:81/ws/CreateCustomer.
|
160
|
+
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
|
161
|
+
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
|
162
|
+
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
|
163
|
+
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring>
|
164
|
+
<detail/>
|
165
|
+
</soap:Fault>
|
166
|
+
</soap:Body>
|
167
|
+
</soap:Envelope>
|
168
|
+
XML
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|