activemerchant 1.1.0 → 1.2.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 +226 -0
- data/CONTRIBUTERS +52 -0
- data/README +34 -24
- data/Rakefile +152 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +3 -1
- data/lib/active_merchant/billing/credit_card.rb +21 -17
- data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
- data/lib/active_merchant/billing/gateway.rb +160 -44
- data/lib/active_merchant/billing/gateways.rb +2 -15
- data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
- data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
- data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
- data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
- data/lib/active_merchant/billing/gateways/eway.rb +77 -29
- data/lib/active_merchant/billing/gateways/exact.rb +230 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
- data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
- data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
- data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
- data/lib/active_merchant/billing/gateways/protx.rb +285 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
- data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
- data/lib/active_merchant/billing/gateways/realex.rb +212 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
- data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
- data/lib/active_merchant/billing/integrations/helper.rb +8 -1
- data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
- data/lib/active_merchant/billing/integrations/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +23 -5
- data/lib/active_merchant/lib/requires_parameters.rb +2 -2
- data/lib/active_merchant/lib/validateable.rb +1 -1
- data/lib/support/gateway_support.rb +45 -0
- data/lib/tasks/cia.rb +1 -1
- data/script/generate +14 -0
- data/script/generator/base.rb +45 -0
- data/script/generator/generator.rb +24 -0
- data/script/generator/generators/gateway/gateway_generator.rb +14 -0
- data/script/generator/generators/gateway/templates/gateway.rb +73 -0
- data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
- data/script/generator/generators/integration/integration_generator.rb +25 -0
- data/script/generator/generators/integration/templates/helper.rb +34 -0
- data/script/generator/generators/integration/templates/helper_test.rb +54 -0
- data/script/generator/generators/integration/templates/integration.rb +18 -0
- data/script/generator/generators/integration/templates/module_test.rb +9 -0
- data/script/generator/generators/integration/templates/notification.rb +100 -0
- data/script/generator/generators/integration/templates/notification_test.rb +41 -0
- data/script/generator/manifest.rb +20 -0
- data/test/extra/binding_of_caller.rb +80 -0
- data/test/extra/breakpoint.rb +547 -0
- data/test/fixtures.yml +251 -0
- data/test/remote_tests/remote_authorize_net_test.rb +113 -0
- data/test/remote_tests/remote_brain_tree_test.rb +78 -0
- data/test/remote_tests/remote_card_stream_test.rb +160 -0
- data/test/remote_tests/remote_cyber_source_test.rb +130 -0
- data/test/remote_tests/remote_data_cash_test.rb +155 -0
- data/test/remote_tests/remote_efsnet_test.rb +93 -0
- data/test/remote_tests/remote_eway_test.rb +71 -0
- data/test/remote_tests/remote_exact_test.rb +59 -0
- data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
- data/test/remote_tests/remote_linkpoint_test.rb +144 -0
- data/test/remote_tests/remote_moneris_test.rb +110 -0
- data/test/remote_tests/remote_net_registry_test.rb +120 -0
- data/test/remote_tests/remote_pay_junction_test.rb +162 -0
- data/test/remote_tests/remote_payflow_express_test.rb +50 -0
- data/test/remote_tests/remote_payflow_test.rb +241 -0
- data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
- data/test/remote_tests/remote_payment_express_test.rb +136 -0
- data/test/remote_tests/remote_paypal_express_test.rb +49 -0
- data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
- data/test/remote_tests/remote_paypal_test.rb +163 -0
- data/test/remote_tests/remote_plugnpay_test.rb +70 -0
- data/test/remote_tests/remote_protx_test.rb +184 -0
- data/test/remote_tests/remote_psigate_test.rb +87 -0
- data/test/remote_tests/remote_psl_card_test.rb +105 -0
- data/test/remote_tests/remote_quickpay_test.rb +182 -0
- data/test/remote_tests/remote_realex_test.rb +227 -0
- data/test/remote_tests/remote_secure_pay_test.rb +36 -0
- data/test/remote_tests/remote_trans_first_test.rb +37 -0
- data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
- data/test/remote_tests/remote_usa_epay_test.rb +57 -0
- data/test/remote_tests/remote_verifi_test.rb +107 -0
- data/test/remote_tests/remote_viaklix_test.rb +53 -0
- data/test/test_helper.rb +132 -0
- data/test/unit/base_test.rb +61 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +24 -0
- data/test/unit/credit_card_methods_test.rb +37 -0
- data/test/unit/credit_card_test.rb +365 -0
- data/test/unit/gateways/authorize_net_test.rb +140 -0
- data/test/unit/gateways/bogus_test.rb +43 -0
- data/test/unit/gateways/brain_tree_test.rb +77 -0
- data/test/unit/gateways/card_stream_test.rb +37 -0
- data/test/unit/gateways/cyber_source_test.rb +151 -0
- data/test/unit/gateways/data_cash_test.rb +23 -0
- data/test/unit/gateways/efsnet_test.rb +70 -0
- data/test/unit/gateways/eway_test.rb +105 -0
- data/test/unit/gateways/exact_test.rb +118 -0
- data/test/unit/gateways/gateway_test.rb +24 -0
- data/test/unit/gateways/linkpoint_test.rb +165 -0
- data/test/unit/gateways/moneris_test.rb +167 -0
- data/test/unit/gateways/net_registry_test.rb +478 -0
- data/test/unit/gateways/pay_junction_test.rb +61 -0
- data/test/unit/gateways/payflow_express_test.rb +165 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
- data/test/unit/gateways/payflow_test.rb +230 -0
- data/test/unit/gateways/payflow_uk_test.rb +68 -0
- data/test/unit/gateways/payment_express_test.rb +215 -0
- data/test/unit/gateways/paypal_express_test.rb +222 -0
- data/test/unit/gateways/paypal_test.rb +241 -0
- data/test/unit/gateways/plugnpay_test.rb +79 -0
- data/test/unit/gateways/protx_test.rb +110 -0
- data/test/unit/gateways/psigate_test.rb +110 -0
- data/test/unit/gateways/psl_card_test.rb +51 -0
- data/test/unit/gateways/quickpay_test.rb +125 -0
- data/test/unit/gateways/realex_test.rb +150 -0
- data/test/unit/gateways/secure_pay_test.rb +78 -0
- data/test/unit/gateways/trans_first_test.rb +125 -0
- data/test/unit/gateways/trust_commerce_test.rb +57 -0
- data/test/unit/gateways/usa_epay_test.rb +117 -0
- data/test/unit/gateways/verifi_test.rb +91 -0
- data/test/unit/gateways/viaklix_test.rb +72 -0
- data/test/unit/integrations/action_view_helper_test.rb +54 -0
- data/test/unit/integrations/bogus_module_test.rb +16 -0
- data/test/unit/integrations/chronopay_module_test.rb +9 -0
- data/test/unit/integrations/gestpay_module_test.rb +10 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/nochex_module_test.rb +9 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +41 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +9 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/response_test.rb +14 -0
- data/test/unit/validateable_test.rb +56 -0
- metadata +160 -7
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class TrustCommerceTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = TrustCommerceGateway.new(fixtures(:trust_commerce))
|
|
6
|
+
|
|
7
|
+
@creditcard = credit_card('4111111111111111')
|
|
8
|
+
|
|
9
|
+
@valid_verification_value = '123'
|
|
10
|
+
@invalid_verification_value = '1234'
|
|
11
|
+
|
|
12
|
+
@valid_address = {:address1 => '123 Test St.', :address2 => nil, :city => 'Somewhere', :state => 'CA', :zip => '90001'}
|
|
13
|
+
@invalid_address = {:address1 => '187 Apple Tree Lane.', :address2 => nil, :city => 'Woodside', :state => 'CA', :zip => '94062'}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_bad_login
|
|
17
|
+
@gateway.options[:login] = 'X'
|
|
18
|
+
assert response = @gateway.purchase(100, @creditcard)
|
|
19
|
+
|
|
20
|
+
assert_equal Response, response.class
|
|
21
|
+
assert_equal ["error",
|
|
22
|
+
"offenders",
|
|
23
|
+
"status"], response.params.keys.sort
|
|
24
|
+
|
|
25
|
+
assert_match /A field was improperly formatted, such as non-digit characters in a number field/, response.message
|
|
26
|
+
|
|
27
|
+
assert_equal false, response.success?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_successful_purchase
|
|
31
|
+
assert response = @gateway.purchase(100, @creditcard)
|
|
32
|
+
|
|
33
|
+
assert_equal Response, response.class
|
|
34
|
+
assert_match /The transaction was successful/, response.message
|
|
35
|
+
|
|
36
|
+
assert_equal true, response.success?
|
|
37
|
+
assert !response.authorization.blank?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_unsuccessful_purchase_with_invalid_cvv
|
|
41
|
+
@creditcard.verification_value = @invalid_verification_value
|
|
42
|
+
assert response = @gateway.purchase(100, @creditcard)
|
|
43
|
+
|
|
44
|
+
assert_equal Response, response.class
|
|
45
|
+
assert_match /CVV failed; the number provided is not the correct verification number for the card/, response.message
|
|
46
|
+
assert_equal false, response.success?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_successful_purchase_with_avs
|
|
50
|
+
assert response = @gateway.purchase(100, @creditcard, :address => @valid_address)
|
|
51
|
+
assert_equal 'Y', response.params["avs"]
|
|
52
|
+
assert_match /The transaction was successful/, response.message
|
|
53
|
+
|
|
54
|
+
assert_equal true, response.success?
|
|
55
|
+
assert !response.authorization.blank?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_purchase_with_avs_for_invalid_address
|
|
59
|
+
assert response = @gateway.purchase(100, @creditcard, :address => @invalid_address)
|
|
60
|
+
assert_equal "N", response.params["avs"]
|
|
61
|
+
assert_match /The transaction was successful/, response.message
|
|
62
|
+
assert_success response
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_successful_authorize
|
|
66
|
+
@creditcard.verification_value = @valid_verification_value
|
|
67
|
+
assert response = @gateway.authorize(100, @creditcard)
|
|
68
|
+
assert_match /The transaction was successful/, response.message
|
|
69
|
+
assert_equal true, response.success?
|
|
70
|
+
assert !response.authorization.blank?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_unsuccessful_authorize_with_invalid_cvv
|
|
74
|
+
@creditcard.verification_value = @invalid_verification_value
|
|
75
|
+
assert response = @gateway.authorize(100, @creditcard)
|
|
76
|
+
assert_match /CVV failed; the number provided is not the correct verification number for the card/, response.message
|
|
77
|
+
assert_equal false, response.success?
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_successful_authorize_with_avs
|
|
81
|
+
assert response = @gateway.authorize(100, @creditcard, {:address => @valid_address})
|
|
82
|
+
|
|
83
|
+
assert_equal "Y", response.params["avs"]
|
|
84
|
+
assert_match /The transaction was successful/, response.message
|
|
85
|
+
|
|
86
|
+
assert_equal true, response.success?
|
|
87
|
+
assert !response.authorization.blank?
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_authorization_with_avs_for_invalid_address
|
|
91
|
+
assert response = @gateway.authorize(100, @creditcard, {:address => @invalid_address})
|
|
92
|
+
assert_equal "N", response.params["avs"]
|
|
93
|
+
assert_match /The transaction was successful/, response.message
|
|
94
|
+
assert_success response
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_successful_capture
|
|
98
|
+
auth = @gateway.authorize(300, @creditcard)
|
|
99
|
+
assert_success auth
|
|
100
|
+
response = @gateway.capture(300, auth.authorization)
|
|
101
|
+
|
|
102
|
+
assert_success response
|
|
103
|
+
assert_equal 'The transaction was successful', response.message
|
|
104
|
+
assert_equal 'accepted', response.params['status']
|
|
105
|
+
assert response.params['transid']
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_successful_credit
|
|
109
|
+
assert response = @gateway.credit(100, '011-0022698151')
|
|
110
|
+
|
|
111
|
+
assert_match /The transaction was successful/, response.message
|
|
112
|
+
assert_success response
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_store_failure
|
|
116
|
+
assert response = @gateway.store(@creditcard)
|
|
117
|
+
|
|
118
|
+
assert_equal Response, response.class
|
|
119
|
+
assert_match /The merchant can't accept data passed in this field/, response.message
|
|
120
|
+
assert_failure response
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_unstore_failure
|
|
124
|
+
assert response = @gateway.unstore('testme')
|
|
125
|
+
|
|
126
|
+
assert_match /The merchant can't accept data passed in this field/, response.message
|
|
127
|
+
assert_equal false, response.success?
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def test_recurring_failure
|
|
131
|
+
assert response = @gateway.recurring(100, @creditcard, :periodicity => :weekly)
|
|
132
|
+
|
|
133
|
+
assert_match /The merchant can't accept data passed in this field/, response.message
|
|
134
|
+
assert_equal false, response.success?
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoveUsaEpayTest < Test::Unit::TestCase
|
|
4
|
+
# This key does not work in test mode. I believe test mode is designed
|
|
5
|
+
# to work with real credit card numbers, but not charge them.
|
|
6
|
+
def setup
|
|
7
|
+
ActiveMerchant::Billing::Base.gateway_mode = :production
|
|
8
|
+
|
|
9
|
+
@gateway = UsaEpayGateway.new(fixtures(:usa_epay))
|
|
10
|
+
|
|
11
|
+
@creditcard = credit_card('4000100011112224')
|
|
12
|
+
|
|
13
|
+
@declined_card = credit_card('4000300011112220')
|
|
14
|
+
|
|
15
|
+
@options = { :address => { :address1 => '1234 Shady Brook Lane',
|
|
16
|
+
:zip => '90210'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_successful_purchase
|
|
22
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
23
|
+
assert_equal 'Success', response.message
|
|
24
|
+
assert_success response
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_unsuccessful_purchase
|
|
28
|
+
assert response = @gateway.purchase(100, @declined_card, @options)
|
|
29
|
+
assert_equal 'Card Declined', response.message
|
|
30
|
+
assert_failure response
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_authorize_and_capture
|
|
34
|
+
amount = 100
|
|
35
|
+
assert auth = @gateway.authorize(amount, @creditcard, @options)
|
|
36
|
+
assert_success auth
|
|
37
|
+
assert_equal 'Success', auth.message
|
|
38
|
+
assert auth.authorization
|
|
39
|
+
assert capture = @gateway.capture(amount, auth.authorization)
|
|
40
|
+
assert_success capture
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_failed_capture
|
|
44
|
+
assert response = @gateway.capture(100, '')
|
|
45
|
+
assert_failure response
|
|
46
|
+
assert_equal 'Unable to find original transaciton.', response.message
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_invalid_key
|
|
50
|
+
gateway = UsaEpayGateway.new({
|
|
51
|
+
:login => ''
|
|
52
|
+
})
|
|
53
|
+
assert response = gateway.purchase(100, @creditcard, @options)
|
|
54
|
+
assert_equal 'Specified source key not found.', response.message
|
|
55
|
+
assert_failure response
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class VerifiTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@gateway = VerifiGateway.new(fixtures(:verify))
|
|
8
|
+
|
|
9
|
+
@creditcard = credit_card('4111111111111111')
|
|
10
|
+
|
|
11
|
+
# Replace with your login and password for the Verifi test environment
|
|
12
|
+
@options = {
|
|
13
|
+
:order_id => 37,
|
|
14
|
+
:email => "test@domain.com",
|
|
15
|
+
:address => {
|
|
16
|
+
:address1 => '164 Waverley Street',
|
|
17
|
+
:address2 => 'APT #7',
|
|
18
|
+
:country => 'US',
|
|
19
|
+
:city => 'Boulder',
|
|
20
|
+
:state => 'CO',
|
|
21
|
+
:zip => 12345
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_successful_purchase
|
|
27
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
28
|
+
assert_success response
|
|
29
|
+
assert_equal 'Transaction was Approved', response.message
|
|
30
|
+
assert !response.authorization.blank?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# FOR SOME REASON Verify DOESN'T MIND EXPIRED CARDS
|
|
34
|
+
# I talked to support and they said that they are loose on expiration dates being expired.
|
|
35
|
+
def test_expired_credit_card
|
|
36
|
+
@creditcard.year = (Time.now.year - 3)
|
|
37
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
38
|
+
assert_success response
|
|
39
|
+
assert_equal 'Transaction was Approved', response.message
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_successful_authorization
|
|
43
|
+
assert response = @gateway.authorize(100, @creditcard, @options)
|
|
44
|
+
assert_success response
|
|
45
|
+
assert_equal 'Transaction was Approved', response.message
|
|
46
|
+
assert response.authorization
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_authorization_and_capture
|
|
50
|
+
amount = 100
|
|
51
|
+
assert authorization = @gateway.authorize(amount, @creditcard, @options)
|
|
52
|
+
assert_success authorization
|
|
53
|
+
assert authorization
|
|
54
|
+
assert capture = @gateway.capture(amount, authorization.authorization, @options)
|
|
55
|
+
assert_success capture
|
|
56
|
+
assert_equal 'Transaction was Approved', capture.message
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_authorization_and_void
|
|
60
|
+
assert authorization = @gateway.authorize(100, @creditcard, @options)
|
|
61
|
+
assert_success authorization
|
|
62
|
+
assert authorization
|
|
63
|
+
assert void = @gateway.void(authorization.authorization, @options)
|
|
64
|
+
assert_success void
|
|
65
|
+
assert_equal 'Transaction was Approved', void.message
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Credits are not enabled on test accounts, so this should always fail
|
|
69
|
+
def test_credit
|
|
70
|
+
assert response = @gateway.credit(100, @creditcard, @options)
|
|
71
|
+
assert_match /Credits are not enabled/, response.params['responsetext']
|
|
72
|
+
assert_failure response
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_authorization_and_void
|
|
76
|
+
amount = 100
|
|
77
|
+
assert authorization = @gateway.authorize(amount, @creditcard, @options)
|
|
78
|
+
assert_success authorization
|
|
79
|
+
assert void = @gateway.void(authorization.authorization, @options)
|
|
80
|
+
assert_success void
|
|
81
|
+
assert_equal 'Transaction was Approved', void.message
|
|
82
|
+
assert_match /Transaction Void Successful/, void.params['responsetext']
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_purchase_and_credit
|
|
86
|
+
amount = 100
|
|
87
|
+
assert purchase = @gateway.purchase(amount, @creditcard, @options)
|
|
88
|
+
assert_success purchase
|
|
89
|
+
|
|
90
|
+
assert credit = @gateway.credit(amount, purchase.authorization, @options)
|
|
91
|
+
assert_success credit
|
|
92
|
+
assert_equal 'Transaction was Approved', credit.message
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_bad_login
|
|
96
|
+
gateway = VerifiGateway.new(
|
|
97
|
+
:login => 'X',
|
|
98
|
+
:password => 'Y'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
assert response = gateway.purchase(100, @creditcard, @options)
|
|
102
|
+
assert_equal 'Transaction was Rejected by Gateway', response.message
|
|
103
|
+
assert_equal 'Authentication Failed', response.params['responsetext']
|
|
104
|
+
|
|
105
|
+
assert_failure response
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteViaklixTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@gateway = ViaklixGateway.new(fixtures(:viaklix))
|
|
9
|
+
|
|
10
|
+
@credit_card = credit_card('4242424242424242')
|
|
11
|
+
|
|
12
|
+
@bad_credit_card = credit_card('invalid')
|
|
13
|
+
|
|
14
|
+
@options = {
|
|
15
|
+
:order_id => '#1000.1',
|
|
16
|
+
:email => "paul@domain.com",
|
|
17
|
+
:description => 'Test Transaction',
|
|
18
|
+
:address => {
|
|
19
|
+
:address1 => '164 Waverley Street',
|
|
20
|
+
:address2 => 'APT #7',
|
|
21
|
+
:country => 'US',
|
|
22
|
+
:city => 'Boulder',
|
|
23
|
+
:state => 'CO',
|
|
24
|
+
:zip => '12345'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_successful_purchase
|
|
30
|
+
assert response = @gateway.purchase(100, @credit_card, @options)
|
|
31
|
+
|
|
32
|
+
assert_success response
|
|
33
|
+
assert response.test?
|
|
34
|
+
assert_equal 'APPROVED', response.message
|
|
35
|
+
assert response.authorization
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_failed_purchase
|
|
39
|
+
assert response = @gateway.purchase(100, @bad_credit_card, @options)
|
|
40
|
+
|
|
41
|
+
assert_failure response
|
|
42
|
+
assert response.test?
|
|
43
|
+
assert_equal 'The Credit Card Number supplied in the authorization request appears invalid.', response.message
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_credit
|
|
47
|
+
assert purchase = @gateway.purchase(100, @credit_card, @options)
|
|
48
|
+
assert_success purchase
|
|
49
|
+
|
|
50
|
+
assert credit = @gateway.credit(100, @credit_card)
|
|
51
|
+
assert_success credit
|
|
52
|
+
end
|
|
53
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
3
|
+
$:.unshift(File.dirname(__FILE__) + '/mocks')
|
|
4
|
+
$:.unshift(File.dirname(__FILE__) + '/extra')
|
|
5
|
+
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
require 'money'
|
|
8
|
+
require 'yaml'
|
|
9
|
+
require 'net/http'
|
|
10
|
+
require 'net/https'
|
|
11
|
+
require 'test/unit'
|
|
12
|
+
require 'binding_of_caller'
|
|
13
|
+
require 'breakpoint'
|
|
14
|
+
require 'openssl'
|
|
15
|
+
require 'mocha'
|
|
16
|
+
require 'digest/md5'
|
|
17
|
+
|
|
18
|
+
require File.dirname(__FILE__) + '/../lib/active_merchant'
|
|
19
|
+
|
|
20
|
+
ActiveMerchant::Billing::Base.mode = :test
|
|
21
|
+
|
|
22
|
+
module Test
|
|
23
|
+
module Unit
|
|
24
|
+
class TestCase
|
|
25
|
+
LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
|
|
26
|
+
DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
|
|
27
|
+
|
|
28
|
+
include ActiveMerchant::Billing
|
|
29
|
+
|
|
30
|
+
# Allows the testing of you to check for negative assertions:
|
|
31
|
+
#
|
|
32
|
+
# # Instead of
|
|
33
|
+
# assert !something_that_is_false
|
|
34
|
+
#
|
|
35
|
+
# # Do this
|
|
36
|
+
# assert_false something_that_should_be_false
|
|
37
|
+
#
|
|
38
|
+
# An optional +msg+ parameter is available to help you debug.
|
|
39
|
+
def assert_false(boolean, message = nil)
|
|
40
|
+
message = build_message message, '<?> is not false or nil.', boolean
|
|
41
|
+
assert_block message do
|
|
42
|
+
not boolean
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# A handy little assertion to check for a successful response:
|
|
47
|
+
#
|
|
48
|
+
# # Instead of
|
|
49
|
+
# assert_success response
|
|
50
|
+
#
|
|
51
|
+
# # DRY that up with
|
|
52
|
+
# assert_success response
|
|
53
|
+
#
|
|
54
|
+
# A message will automatically show the inspection of the response
|
|
55
|
+
# object if things go afoul.
|
|
56
|
+
def assert_success(response)
|
|
57
|
+
assert response.success?, "Response failed: #{response.inspect}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The negative of +assert_success+
|
|
61
|
+
def assert_failure(response)
|
|
62
|
+
assert_false response.success?, "Response expected to fail: #{response.inspect}"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
def generate_order_id
|
|
67
|
+
md5 = Digest::MD5.new
|
|
68
|
+
now = Time.now
|
|
69
|
+
md5 << now.to_s
|
|
70
|
+
md5 << String(now.usec)
|
|
71
|
+
md5 << String(rand(0))
|
|
72
|
+
md5 << String($$)
|
|
73
|
+
md5 << self.class.name
|
|
74
|
+
md5.hexdigest
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def credit_card(number, options = {})
|
|
78
|
+
defaults = {
|
|
79
|
+
:number => number,
|
|
80
|
+
:month => 9,
|
|
81
|
+
:year => Time.now.year + 1,
|
|
82
|
+
:first_name => 'Longbob',
|
|
83
|
+
:last_name => 'Longsen',
|
|
84
|
+
:verification_value => '123'
|
|
85
|
+
}.update(options)
|
|
86
|
+
|
|
87
|
+
ActiveMerchant::Billing::CreditCard.new(defaults)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def all_fixtures
|
|
91
|
+
@@fixtures ||= load_fixtures
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def fixtures(key)
|
|
95
|
+
data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
|
|
96
|
+
|
|
97
|
+
data.dup
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def load_fixtures
|
|
101
|
+
file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
|
|
102
|
+
yaml_data = YAML.load(File.read(file))
|
|
103
|
+
symbolize_keys(yaml_data)
|
|
104
|
+
|
|
105
|
+
yaml_data
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def symbolize_keys(hash)
|
|
109
|
+
return unless hash.is_a?(Hash)
|
|
110
|
+
|
|
111
|
+
hash.symbolize_keys!
|
|
112
|
+
hash.each{|k,v| symbolize_keys(v)}
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
module Assertions
|
|
117
|
+
def assert_field(field, value)
|
|
118
|
+
clean_backtrace do
|
|
119
|
+
assert_equal value, @helper.fields[field]
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
def clean_backtrace(&block)
|
|
125
|
+
yield
|
|
126
|
+
rescue AssertionFailedError => e
|
|
127
|
+
path = File.expand_path(__FILE__)
|
|
128
|
+
raise AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|