activemerchant 1.2.1 → 1.3.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 +310 -294
- data/CONTRIBUTERS +13 -0
- data/README +55 -31
- data/Rakefile +21 -13
- data/lib/active_merchant.rb +7 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +8 -3
- data/lib/active_merchant/billing/check.rb +61 -0
- data/lib/active_merchant/billing/credit_card.rb +104 -80
- data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
- data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +28 -0
- data/lib/active_merchant/billing/gateway.rb +47 -111
- data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
- data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
- data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
- data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
- data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
- data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
- data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
- data/lib/active_merchant/billing/gateways/eway.rb +8 -19
- data/lib/active_merchant/billing/gateways/exact.rb +17 -25
- data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
- data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
- data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
- data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
- data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
- data/lib/active_merchant/billing/gateways/protx.rb +24 -25
- data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
- data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
- data/lib/active_merchant/billing/gateways/realex.rb +7 -19
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
- data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
- data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
- data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
- data/lib/active_merchant/billing/integrations.rb +2 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +12 -8
- data/lib/active_merchant/lib/posts_data.rb +39 -7
- data/lib/active_merchant/lib/requires_parameters.rb +2 -3
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +3 -3
- data/lib/support/gateway_support.rb +22 -9
- data/script/destroy +14 -0
- data/script/generate +7 -7
- data/test/fixtures.yml +25 -3
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
- data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
- data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
- data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
- data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
- data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
- data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
- data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
- data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
- data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
- data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
- data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
- data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
- data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
- data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
- data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
- data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
- data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
- data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +102 -61
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +33 -39
- data/test/unit/check_test.rb +76 -0
- data/test/unit/credit_card_formatting_test.rb +10 -15
- data/test/unit/credit_card_methods_test.rb +132 -17
- data/test/unit/credit_card_test.rb +157 -228
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +21 -0
- data/test/unit/gateways/authorize_net_test.rb +180 -40
- data/test/unit/gateways/bogus_test.rb +2 -3
- data/test/unit/gateways/brain_tree_test.rb +63 -29
- data/test/unit/gateways/card_stream_test.rb +59 -6
- data/test/unit/gateways/cyber_source_test.rb +59 -40
- data/test/unit/gateways/data_cash_test.rb +82 -1
- data/test/unit/gateways/efsnet_test.rb +97 -44
- data/test/unit/gateways/eway_test.rb +55 -42
- data/test/unit/gateways/exact_test.rb +93 -55
- data/test/unit/gateways/gateway_test.rb +7 -0
- data/test/unit/gateways/linkpoint_test.rb +60 -58
- data/test/unit/gateways/moneris_test.rb +67 -76
- data/test/unit/gateways/net_registry_test.rb +351 -419
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/pay_junction_test.rb +108 -46
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +0 -8
- data/test/unit/gateways/payflow_test.rb +136 -65
- data/test/unit/gateways/payflow_uk_test.rb +0 -38
- data/test/unit/gateways/payment_express_test.rb +31 -51
- data/test/unit/gateways/paypal_express_test.rb +8 -2
- data/test/unit/gateways/paypal_test.rb +213 -54
- data/test/unit/gateways/plugnpay_test.rb +39 -32
- data/test/unit/gateways/protx_test.rb +45 -33
- data/test/unit/gateways/psigate_test.rb +146 -87
- data/test/unit/gateways/psl_card_test.rb +37 -24
- data/test/unit/gateways/quickpay_test.rb +33 -46
- data/test/unit/gateways/realex_test.rb +32 -31
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +35 -26
- data/test/unit/gateways/skip_jack_test.rb +125 -0
- data/test/unit/gateways/trans_first_test.rb +24 -37
- data/test/unit/gateways/trust_commerce_test.rb +47 -26
- data/test/unit/gateways/usa_epay_test.rb +52 -41
- data/test/unit/gateways/verifi_test.rb +41 -35
- data/test/unit/gateways/viaklix_test.rb +38 -32
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +7 -14
- data/test/unit/integrations/bogus_module_test.rb +4 -0
- data/test/unit/integrations/chronopay_module_test.rb +4 -0
- data/test/unit/integrations/gestpay_module_test.rb +4 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +4 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
- data/test/unit/integrations/paypal_module_test.rb +4 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +4 -0
- data/test/unit/posts_data_test.rb +86 -0
- data/test/unit/response_test.rb +15 -1
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +10 -6
- metadata +180 -142
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
- data/script/generator/base.rb +0 -45
- data/script/generator/generator.rb +0 -24
- data/script/generator/generators/gateway/gateway_generator.rb +0 -14
- data/script/generator/generators/gateway/templates/gateway.rb +0 -73
- data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
- data/script/generator/generators/integration/integration_generator.rb +0 -25
- data/script/generator/generators/integration/templates/helper.rb +0 -34
- data/script/generator/generators/integration/templates/helper_test.rb +0 -54
- data/script/generator/generators/integration/templates/integration.rb +0 -18
- data/script/generator/generators/integration/templates/module_test.rb +0 -9
- data/script/generator/generators/integration/templates/notification.rb +0 -100
- data/script/generator/generators/integration/templates/notification_test.rb +0 -41
- data/script/generator/manifest.rb +0 -20
- data/test/remote_tests/remote_authorize_net_test.rb +0 -113
- data/test/remote_tests/remote_brain_tree_test.rb +0 -78
- data/test/remote_tests/remote_moneris_test.rb +0 -110
- data/test/remote_tests/remote_psigate_test.rb +0 -87
- data/test/remote_tests/remote_secure_pay_test.rb +0 -36
- data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
require 'net/http'
|
|
2
|
-
|
|
3
|
-
module ActiveMerchant #:nodoc:
|
|
4
|
-
module Billing #:nodoc:
|
|
5
|
-
module Integrations #:nodoc:
|
|
6
|
-
module <%= class_name %>
|
|
7
|
-
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
|
8
|
-
def complete?
|
|
9
|
-
params['']
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def item_id
|
|
13
|
-
params['']
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def transaction_id
|
|
17
|
-
params['']
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# When was this payment received by the client.
|
|
21
|
-
def received_at
|
|
22
|
-
params['']
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def payer_email
|
|
26
|
-
params['']
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def receiver_email
|
|
30
|
-
params['']
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def security_key
|
|
34
|
-
params['']
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# the money amount we received in X.2 decimal.
|
|
38
|
-
def gross
|
|
39
|
-
params['']
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Was this a test transaction?
|
|
43
|
-
def test?
|
|
44
|
-
params[''] == 'test'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def status
|
|
48
|
-
params['']
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Acknowledge the transaction to <%= class_name %>. This method has to be called after a new
|
|
52
|
-
# apc arrives. <%= class_name %> will verify that all the information we received are correct and will return a
|
|
53
|
-
# ok or a fail.
|
|
54
|
-
#
|
|
55
|
-
# Example:
|
|
56
|
-
#
|
|
57
|
-
# def ipn
|
|
58
|
-
# notify = <%= class_name %>Notification.new(request.raw_post)
|
|
59
|
-
#
|
|
60
|
-
# if notify.acknowledge
|
|
61
|
-
# ... process order ... if notify.complete?
|
|
62
|
-
# else
|
|
63
|
-
# ... log possible hacking attempt ...
|
|
64
|
-
# end
|
|
65
|
-
def acknowledge
|
|
66
|
-
payload = raw
|
|
67
|
-
|
|
68
|
-
uri = URI.parse(<%= class_name %>.notification_confirmation_url)
|
|
69
|
-
|
|
70
|
-
request = Net::HTTP::Post.new(uri.path)
|
|
71
|
-
|
|
72
|
-
request['Content-Length'] = "#{payload.size}"
|
|
73
|
-
request['User-Agent'] = "Active Merchant -- http://home.leetsoft.com/am"
|
|
74
|
-
request['Content-Type'] = "application/x-www-form-urlencoded"
|
|
75
|
-
|
|
76
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
77
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict
|
|
78
|
-
http.use_ssl = true
|
|
79
|
-
|
|
80
|
-
response = http.request(request, payload)
|
|
81
|
-
|
|
82
|
-
# Replace with the appropriate codes
|
|
83
|
-
raise StandardError.new("Faulty <%= class_name %> result: #{response.body}") unless ["AUTHORISED", "DECLINED"].include?(response.body)
|
|
84
|
-
response.body == "AUTHORISED"
|
|
85
|
-
end
|
|
86
|
-
private
|
|
87
|
-
|
|
88
|
-
# Take the posted data and move the relevant data into a hash
|
|
89
|
-
def parse(post)
|
|
90
|
-
@raw = post
|
|
91
|
-
for line in post.split('&')
|
|
92
|
-
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
|
93
|
-
params[key] = value
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../../test_helper'
|
|
2
|
-
|
|
3
|
-
class <%= class_name %>NotificationTest < Test::Unit::TestCase
|
|
4
|
-
include ActiveMerchant::Billing::Integrations
|
|
5
|
-
|
|
6
|
-
def setup
|
|
7
|
-
@<%= file_name %> = <%= class_name %>::Notification.new(http_raw_data)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def test_accessors
|
|
11
|
-
assert @<%= file_name %>.complete?
|
|
12
|
-
assert_equal "", @<%= file_name %>.status
|
|
13
|
-
assert_equal "", @<%= file_name %>.transaction_id
|
|
14
|
-
assert_equal "", @<%= file_name %>.item_id
|
|
15
|
-
assert_equal "", @<%= file_name %>.gross
|
|
16
|
-
assert_equal "", @<%= file_name %>.currency
|
|
17
|
-
assert_equal "", @<%= file_name %>.received_at
|
|
18
|
-
assert @<%= file_name %>.test?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_compositions
|
|
22
|
-
assert_equal Money.new(3166, 'USD'), @<%= file_name %>.amount
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Replace with real successful acknowledgement code
|
|
26
|
-
def test_acknowledgement
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_send_acknowledgement
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_respond_to_acknowledge
|
|
34
|
-
assert @<%= file_name %>.respond_to?(:acknowledge)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
def http_raw_data
|
|
39
|
-
""
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module ActiveMerchant #:nodoc:
|
|
2
|
-
module Generator
|
|
3
|
-
class Manifest
|
|
4
|
-
attr_reader :templates, :directories
|
|
5
|
-
|
|
6
|
-
def initialize
|
|
7
|
-
@templates, @directories = [], []
|
|
8
|
-
yield self if block_given?
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def template(input, output)
|
|
12
|
-
@templates << { :input => input, :output => output }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def directory(dir)
|
|
16
|
-
@directories << dir
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
-
|
|
3
|
-
class AuthorizeNetTest < Test::Unit::TestCase
|
|
4
|
-
def setup
|
|
5
|
-
Base.mode = :test
|
|
6
|
-
|
|
7
|
-
@gateway = AuthorizeNetGateway.new(fixtures(:authorize_net))
|
|
8
|
-
|
|
9
|
-
@creditcard = credit_card('4242424242424242')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_successful_purchase
|
|
13
|
-
assert response = @gateway.purchase(100, @creditcard,
|
|
14
|
-
:order_id => generate_order_id,
|
|
15
|
-
:description => 'Store purchase'
|
|
16
|
-
)
|
|
17
|
-
assert_success response
|
|
18
|
-
assert response.test?
|
|
19
|
-
assert_equal 'This transaction has been approved', response.message
|
|
20
|
-
assert response.authorization
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_expired_credit_card
|
|
24
|
-
@creditcard.year = 2004
|
|
25
|
-
assert response = @gateway.purchase(100, @creditcard, :order_id => generate_order_id)
|
|
26
|
-
assert_failure response
|
|
27
|
-
assert response.test?
|
|
28
|
-
assert_equal 'The credit card has expired', response.message
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_forced_test_mode_purchase
|
|
32
|
-
gateway = AuthorizeNetGateway.new(
|
|
33
|
-
:login => @login,
|
|
34
|
-
:password => @password,
|
|
35
|
-
:test => true
|
|
36
|
-
)
|
|
37
|
-
assert response = gateway.purchase(100, @creditcard, :order_id => generate_order_id)
|
|
38
|
-
assert_success response
|
|
39
|
-
assert response.test?
|
|
40
|
-
assert_match /TESTMODE/, response.message
|
|
41
|
-
assert response.authorization
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_successful_authorization
|
|
45
|
-
assert response = @gateway.authorize(100, @creditcard, :order_id => generate_order_id)
|
|
46
|
-
assert_success response
|
|
47
|
-
assert_equal 'This transaction has been approved', response.message
|
|
48
|
-
assert response.authorization
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def test_authorization_and_capture
|
|
52
|
-
assert authorization = @gateway.authorize(100, @creditcard, :order_id => generate_order_id)
|
|
53
|
-
assert_success authorization
|
|
54
|
-
assert authorization
|
|
55
|
-
assert capture = @gateway.capture(100, authorization.authorization)
|
|
56
|
-
assert_success capture
|
|
57
|
-
assert_equal 'This transaction has been approved', capture.message
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def test_authorization_and_void
|
|
61
|
-
assert authorization = @gateway.authorize(100, @creditcard, :order_id => generate_order_id)
|
|
62
|
-
assert_success authorization
|
|
63
|
-
assert authorization
|
|
64
|
-
assert void = @gateway.void(authorization.authorization)
|
|
65
|
-
assert_success void
|
|
66
|
-
assert_equal 'This transaction has been approved', void.message
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_bad_login
|
|
70
|
-
gateway = AuthorizeNetGateway.new(
|
|
71
|
-
:login => 'X',
|
|
72
|
-
:password => 'Y'
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
assert response = gateway.purchase(100, @creditcard)
|
|
77
|
-
|
|
78
|
-
assert_equal Response, response.class
|
|
79
|
-
assert_equal ["avs_message",
|
|
80
|
-
"avs_result_code",
|
|
81
|
-
"card_code",
|
|
82
|
-
"response_code",
|
|
83
|
-
"response_reason_code",
|
|
84
|
-
"response_reason_text",
|
|
85
|
-
"transaction_id"], response.params.keys.sort
|
|
86
|
-
|
|
87
|
-
assert_match /The merchant login ID or password is invalid/, response.message
|
|
88
|
-
|
|
89
|
-
assert_equal false, response.success?
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def test_using_test_request
|
|
93
|
-
gateway = AuthorizeNetGateway.new(
|
|
94
|
-
:login => 'X',
|
|
95
|
-
:password => 'Y'
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
assert response = gateway.purchase(100, @creditcard)
|
|
99
|
-
|
|
100
|
-
assert_equal Response, response.class
|
|
101
|
-
assert_equal ["avs_message",
|
|
102
|
-
"avs_result_code",
|
|
103
|
-
"card_code",
|
|
104
|
-
"response_code",
|
|
105
|
-
"response_reason_code",
|
|
106
|
-
"response_reason_text",
|
|
107
|
-
"transaction_id"], response.params.keys.sort
|
|
108
|
-
|
|
109
|
-
assert_match /The merchant login ID or password is invalid/, response.message
|
|
110
|
-
|
|
111
|
-
assert_equal false, response.success?
|
|
112
|
-
end
|
|
113
|
-
end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
-
|
|
3
|
-
class RemoteBrainTreeTest < Test::Unit::TestCase
|
|
4
|
-
AMOUNT = 10000
|
|
5
|
-
|
|
6
|
-
def setup
|
|
7
|
-
@gateway = BrainTreeGateway.new(fixtures(:brain_tree))
|
|
8
|
-
|
|
9
|
-
@creditcard = credit_card('4111111111111111')
|
|
10
|
-
|
|
11
|
-
@declined_amount = rand(99)
|
|
12
|
-
@amount = rand(10000)+1001
|
|
13
|
-
|
|
14
|
-
@options = { :order_id => generate_order_id,
|
|
15
|
-
:address => { :address1 => '1234 Shady Brook Lane',
|
|
16
|
-
:zip => '90210'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_successful_purchase
|
|
22
|
-
assert response = @gateway.purchase(@amount, @creditcard, @options)
|
|
23
|
-
assert_equal 'This transaction has been approved', response.message
|
|
24
|
-
assert_success response
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_successful_add_to_vault
|
|
28
|
-
@options[:store] = true
|
|
29
|
-
assert response = @gateway.purchase(@amount, @creditcard, @options)
|
|
30
|
-
assert_equal 'This transaction has been approved', response.message
|
|
31
|
-
assert_success response
|
|
32
|
-
assert_not_nil response.params["customer_vault_id"]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_successful_add_to_vault_and_use
|
|
36
|
-
@options[:store] = true
|
|
37
|
-
assert response = @gateway.purchase(@amount, @creditcard, @options)
|
|
38
|
-
assert_equal 'This transaction has been approved', response.message
|
|
39
|
-
assert_success response
|
|
40
|
-
assert_not_nil customer_id = response.params["customer_vault_id"]
|
|
41
|
-
|
|
42
|
-
assert second_response = @gateway.purchase(@amount*2, customer_id, @options)
|
|
43
|
-
assert_equal 'This transaction has been approved', second_response.message
|
|
44
|
-
assert second_response.success?
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_declined_purchase
|
|
48
|
-
assert response = @gateway.purchase(@declined_amount, @creditcard, @options)
|
|
49
|
-
assert_equal 'This transaction has been declined', response.message
|
|
50
|
-
assert_failure response
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_authorize_and_capture
|
|
54
|
-
assert auth = @gateway.authorize(@amount, @creditcard, @options)
|
|
55
|
-
assert_success auth
|
|
56
|
-
assert_equal 'This transaction has been approved', auth.message
|
|
57
|
-
assert auth.authorization
|
|
58
|
-
assert capture = @gateway.capture(@amount, auth.authorization)
|
|
59
|
-
assert_equal 'This transaction has been approved', capture.message
|
|
60
|
-
assert_success capture
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def test_failed_capture
|
|
64
|
-
assert response = @gateway.capture(@amount, '')
|
|
65
|
-
assert_failure response
|
|
66
|
-
assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_invalid_login
|
|
70
|
-
gateway = BrainTreeGateway.new(
|
|
71
|
-
:login => '',
|
|
72
|
-
:password => ''
|
|
73
|
-
)
|
|
74
|
-
assert response = gateway.purchase(@amount, @creditcard, @options)
|
|
75
|
-
assert_equal 'Invalid Username', response.message
|
|
76
|
-
assert_failure response
|
|
77
|
-
end
|
|
78
|
-
end
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
-
|
|
3
|
-
class MonerisRemoteTest < Test::Unit::TestCase
|
|
4
|
-
def setup
|
|
5
|
-
Base.gateway_mode = :test
|
|
6
|
-
|
|
7
|
-
@gateway = MonerisGateway.new(fixtures(:moneris))
|
|
8
|
-
@creditcard = credit_card('4242424242424242')
|
|
9
|
-
@expected_response_headers = [
|
|
10
|
-
"auth_code",
|
|
11
|
-
"bank_totals",
|
|
12
|
-
"card_type",
|
|
13
|
-
"complete",
|
|
14
|
-
"iso",
|
|
15
|
-
"message",
|
|
16
|
-
"receipt_id",
|
|
17
|
-
"reference_num",
|
|
18
|
-
"response_code",
|
|
19
|
-
"ticket",
|
|
20
|
-
"timed_out",
|
|
21
|
-
"trans_amount",
|
|
22
|
-
"trans_date",
|
|
23
|
-
"trans_id",
|
|
24
|
-
"trans_time",
|
|
25
|
-
"trans_type"
|
|
26
|
-
]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_should_be_a_successful_remote_purchase
|
|
30
|
-
order_id = generate_order_id
|
|
31
|
-
assert response = @gateway.purchase(100, @creditcard, :order_id => order_id)
|
|
32
|
-
assert_equal Response, response.class
|
|
33
|
-
assert_equal @expected_response_headers, response.params.keys.sort
|
|
34
|
-
assert_match /APPROVED/, response.params['message']
|
|
35
|
-
assert_equal 'Approved', response.message
|
|
36
|
-
assert_equal true, response.params['complete']
|
|
37
|
-
assert_equal true, response.success? # Checking for type-casting of XML, not actual success
|
|
38
|
-
assert_equal order_id, response.params['receipt_id']
|
|
39
|
-
assert_equal "#{response.params['trans_id']};#{response.params['receipt_id']}", response.authorization
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_should_be_a_successful_authorization
|
|
43
|
-
response = @gateway.authorize(100, @creditcard, :order_id => generate_order_id)
|
|
44
|
-
assert_success response
|
|
45
|
-
assert response.authorization
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_should_not_be_a_successful_authorization
|
|
49
|
-
response = @gateway.authorize(105, @creditcard, :order_id => generate_order_id)
|
|
50
|
-
assert_failure response
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_should_be_a_successful_authorization_and_capture
|
|
54
|
-
response = @gateway.authorize(100, @creditcard, :order_id => generate_order_id)
|
|
55
|
-
assert_success response
|
|
56
|
-
assert response.authorization
|
|
57
|
-
|
|
58
|
-
response = @gateway.capture(100, response.authorization)
|
|
59
|
-
assert_success response
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_should_be_a_successful_capture_and_void
|
|
63
|
-
# First perform a successful authorization and capture
|
|
64
|
-
response = @gateway.authorize(100, @creditcard, :order_id => generate_order_id)
|
|
65
|
-
assert_success response
|
|
66
|
-
assert response.authorization
|
|
67
|
-
|
|
68
|
-
capture = @gateway.capture(100, response.authorization)
|
|
69
|
-
assert_success capture
|
|
70
|
-
assert capture.authorization
|
|
71
|
-
|
|
72
|
-
# Now void it
|
|
73
|
-
void = @gateway.void(capture.authorization)
|
|
74
|
-
assert_success void
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def test_should_be_a_successful_purchase_and_void
|
|
78
|
-
purchase = @gateway.purchase(100, @creditcard, :order_id => generate_order_id)
|
|
79
|
-
assert_success purchase
|
|
80
|
-
|
|
81
|
-
void = @gateway.void(purchase.authorization)
|
|
82
|
-
assert_success void
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def test_should_not_be_a_successful_purchase_and_void
|
|
86
|
-
purchase = @gateway.purchase(101, @creditcard, :order_id => generate_order_id)
|
|
87
|
-
assert_failure purchase
|
|
88
|
-
|
|
89
|
-
void = @gateway.void(purchase.authorization)
|
|
90
|
-
assert_failure void
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def test_should_be_a_successful_purchase_and_refund
|
|
94
|
-
purchase = @gateway.purchase(100, @creditcard, :order_id => generate_order_id)
|
|
95
|
-
assert_success purchase
|
|
96
|
-
|
|
97
|
-
credit = @gateway.credit(100, purchase.authorization)
|
|
98
|
-
assert_success credit
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def test_should_be_a_remote_error
|
|
102
|
-
assert response = @gateway.purchase(150, @creditcard, :order_id => generate_order_id)
|
|
103
|
-
assert_equal Response, response.class
|
|
104
|
-
assert_equal @expected_response_headers, response.params.keys.sort
|
|
105
|
-
assert_match /DECLINED/, response.params['message']
|
|
106
|
-
assert_equal 'Declined', response.message
|
|
107
|
-
assert_equal true, response.params['complete']
|
|
108
|
-
assert_equal false, response.success? # Checking for XML type-casting, not failure
|
|
109
|
-
end
|
|
110
|
-
end
|