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
|
@@ -35,11 +35,6 @@ module ActiveMerchant
|
|
|
35
35
|
# Datacash success code
|
|
36
36
|
DATACASH_SUCCESS = '1'
|
|
37
37
|
|
|
38
|
-
# Class attributes
|
|
39
|
-
attr_reader :url
|
|
40
|
-
attr_reader :response
|
|
41
|
-
attr_reader :options
|
|
42
|
-
|
|
43
38
|
# Creates a new DataCashGateway
|
|
44
39
|
#
|
|
45
40
|
# The gateway requires that a valid login and password be passed
|
|
@@ -65,13 +60,7 @@ module ActiveMerchant
|
|
|
65
60
|
# * <tt>credit_card</tt> -- The CreditCard details for the transaction.
|
|
66
61
|
# * <tt>options</tt> -- A hash of optional parameters.
|
|
67
62
|
def purchase(money, credit_card, options = {})
|
|
68
|
-
|
|
69
|
-
return result
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
request = build_purchase_or_authorization_request(AUTH_TYPE, money, credit_card, options)
|
|
73
|
-
|
|
74
|
-
commit(request)
|
|
63
|
+
commit(build_purchase_or_authorization_request(AUTH_TYPE, money, credit_card, options))
|
|
75
64
|
end
|
|
76
65
|
|
|
77
66
|
# Performs an authorization, which reserves the funds on the customer's credit card, but does not
|
|
@@ -83,13 +72,7 @@ module ActiveMerchant
|
|
|
83
72
|
# * <tt>credit_card</tt> -- The CreditCard details for the transaction.
|
|
84
73
|
# * <tt>options</tt> -- A hash of optional parameters.
|
|
85
74
|
def authorize(money, credit_card, options = {})
|
|
86
|
-
|
|
87
|
-
return result
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
request = build_purchase_or_authorization_request(PRE_TYPE, money, credit_card, options)
|
|
91
|
-
|
|
92
|
-
commit(request)
|
|
75
|
+
commit(build_purchase_or_authorization_request(PRE_TYPE, money, credit_card, options))
|
|
93
76
|
end
|
|
94
77
|
|
|
95
78
|
# Captures the funds from an authorized transaction.
|
|
@@ -99,9 +82,7 @@ module ActiveMerchant
|
|
|
99
82
|
# * <tt>money</tt> -- The amount to be captured. Either an Integer value in cents or a Money object.
|
|
100
83
|
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
|
|
101
84
|
def capture(money, authorization, options = {})
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
commit(request)
|
|
85
|
+
commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
|
|
105
86
|
end
|
|
106
87
|
|
|
107
88
|
# Void a previous transaction
|
|
@@ -117,7 +98,7 @@ module ActiveMerchant
|
|
|
117
98
|
|
|
118
99
|
# Is the gateway running in test mode?
|
|
119
100
|
def test?
|
|
120
|
-
@options[:test] ||
|
|
101
|
+
@options[:test] || super
|
|
121
102
|
end
|
|
122
103
|
|
|
123
104
|
private
|
|
@@ -286,6 +267,7 @@ module ActiveMerchant
|
|
|
286
267
|
# -none: The results is stored in the passed xml document
|
|
287
268
|
#
|
|
288
269
|
def add_credit_card(xml, credit_card, address)
|
|
270
|
+
|
|
289
271
|
xml.tag! :Card do
|
|
290
272
|
|
|
291
273
|
# DataCash calls the CC number 'pan'
|
|
@@ -304,11 +286,13 @@ module ActiveMerchant
|
|
|
304
286
|
|
|
305
287
|
xml.tag! :Cv2Avs do
|
|
306
288
|
xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
289
|
+
if address
|
|
290
|
+
xml.tag! :street_address1, address[:address1] unless address[:address1].blank?
|
|
291
|
+
xml.tag! :street_address2, address[:address2] unless address[:address2].blank?
|
|
292
|
+
xml.tag! :street_address3, address[:address3] unless address[:address3].blank?
|
|
293
|
+
xml.tag! :street_address4, address[:address4] unless address[:address4].blank?
|
|
294
|
+
xml.tag! :postcode, address[:zip] unless address[:zip].blank?
|
|
295
|
+
end
|
|
312
296
|
|
|
313
297
|
# The ExtendedPolicy defines what to do when the passed data
|
|
314
298
|
# matches, or not...
|
|
@@ -349,15 +333,11 @@ module ActiveMerchant
|
|
|
349
333
|
# - ActiveMerchant::Billing::Response object
|
|
350
334
|
#
|
|
351
335
|
def commit(request)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
Response.new(success, message, @response,
|
|
359
|
-
:test => test?,
|
|
360
|
-
:authorization => "#{@response[:datacash_reference]};#{@response[:authcode]}"
|
|
336
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request))
|
|
337
|
+
|
|
338
|
+
Response.new(response[:status] == DATACASH_SUCCESS, response[:reason], response,
|
|
339
|
+
:test => test?,
|
|
340
|
+
:authorization => "#{response[:datacash_reference]};#{response[:authcode]}"
|
|
361
341
|
)
|
|
362
342
|
end
|
|
363
343
|
|
|
@@ -412,7 +392,7 @@ module ActiveMerchant
|
|
|
412
392
|
end
|
|
413
393
|
|
|
414
394
|
def format_reference_number(number)
|
|
415
|
-
number.to_s.gsub(/[^A-Za-z0-9]/, '').rjust(6, "0")
|
|
395
|
+
number.to_s.gsub(/[^A-Za-z0-9]/, '').rjust(6, "0").first(30)
|
|
416
396
|
end
|
|
417
397
|
end
|
|
418
398
|
end
|
|
@@ -4,10 +4,6 @@ module ActiveMerchant #:nodoc:
|
|
|
4
4
|
module Billing #:nodoc:
|
|
5
5
|
|
|
6
6
|
class EfsnetGateway < Gateway
|
|
7
|
-
attr_reader :url
|
|
8
|
-
attr_reader :response
|
|
9
|
-
attr_reader :options
|
|
10
|
-
|
|
11
7
|
self.supported_countries = ['US']
|
|
12
8
|
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
|
13
9
|
self.homepage_url = 'http://www.concordefsnet.com/'
|
|
@@ -20,15 +16,12 @@ module ActiveMerchant #:nodoc:
|
|
|
20
16
|
# password is your Store Key
|
|
21
17
|
def initialize(options = {})
|
|
22
18
|
requires!(options, :login, :password)
|
|
23
|
-
|
|
24
19
|
@options = options
|
|
25
|
-
@url = test? ? TEST_URL : LIVE_URL
|
|
26
|
-
|
|
27
20
|
super
|
|
28
21
|
end
|
|
29
22
|
|
|
30
23
|
def test?
|
|
31
|
-
@options[:test] ||
|
|
24
|
+
@options[:test] || super
|
|
32
25
|
end
|
|
33
26
|
|
|
34
27
|
def authorize(money, creditcard, options = {})
|
|
@@ -61,7 +54,7 @@ module ActiveMerchant #:nodoc:
|
|
|
61
54
|
def void(identification, options = {})
|
|
62
55
|
requires!(options, :order_id)
|
|
63
56
|
original_transaction_id, original_transaction_amount = identification.split(";")
|
|
64
|
-
commit(:void_transaction, {:reference_number => options[:order_id], :transaction_ID => original_transaction_id})
|
|
57
|
+
commit(:void_transaction, {:reference_number => format_reference_number(options[:order_id]), :transaction_ID => original_transaction_id})
|
|
65
58
|
end
|
|
66
59
|
|
|
67
60
|
def voice_authorize(money, authorization_code, creditcard, options = {})
|
|
@@ -88,7 +81,7 @@ module ActiveMerchant #:nodoc:
|
|
|
88
81
|
requires!(options, :order_id)
|
|
89
82
|
|
|
90
83
|
post = {
|
|
91
|
-
:reference_number => options[:order_id],
|
|
84
|
+
:reference_number => format_reference_number(options[:order_id]),
|
|
92
85
|
:transaction_amount => amount(money),
|
|
93
86
|
:original_transaction_amount => original_transaction_amount,
|
|
94
87
|
:original_transaction_ID => original_transaction_id,
|
|
@@ -100,7 +93,7 @@ module ActiveMerchant #:nodoc:
|
|
|
100
93
|
requires!(options, :order_id)
|
|
101
94
|
|
|
102
95
|
post = {
|
|
103
|
-
:reference_number => options[:order_id],
|
|
96
|
+
:reference_number => format_reference_number(options[:order_id]),
|
|
104
97
|
:authorization_number => options[:authorization_number],
|
|
105
98
|
:transaction_amount => amount(money),
|
|
106
99
|
:client_ip_address => options[:ip]
|
|
@@ -110,6 +103,10 @@ module ActiveMerchant #:nodoc:
|
|
|
110
103
|
add_address(post,options)
|
|
111
104
|
post
|
|
112
105
|
end
|
|
106
|
+
|
|
107
|
+
def format_reference_number(number)
|
|
108
|
+
number.to_s.slice(0,12)
|
|
109
|
+
end
|
|
113
110
|
|
|
114
111
|
def add_address(post,options)
|
|
115
112
|
if address = options[:billing_address] || options[:address]
|
|
@@ -146,49 +143,26 @@ module ActiveMerchant #:nodoc:
|
|
|
146
143
|
end
|
|
147
144
|
|
|
148
145
|
|
|
149
|
-
def commit(action, parameters)
|
|
150
|
-
|
|
151
|
-
return result
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
parameters.delete_if {|key,value| value.blank?}
|
|
155
|
-
|
|
156
|
-
headers = { 'Content-Type' => 'text/xml' }
|
|
157
|
-
data = ssl_post @url, post_data(action, parameters), headers
|
|
158
|
-
|
|
159
|
-
@response = parse(data)
|
|
146
|
+
def commit(action, parameters)
|
|
147
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(action, parameters), 'Content-Type' => 'text/xml'))
|
|
160
148
|
|
|
161
|
-
success
|
|
162
|
-
message = message_form(response[:result_message])
|
|
163
|
-
|
|
164
|
-
authorization = [ response[:transaction_id], parameters[:transaction_amount] ].compact.join(';')
|
|
165
|
-
|
|
166
|
-
Response.new(success, message, @response,
|
|
149
|
+
Response.new(success?(response), message_from(response[:result_message]), response,
|
|
167
150
|
:test => test?,
|
|
168
|
-
:authorization =>
|
|
151
|
+
:authorization => authorization_from(response, parameters),
|
|
152
|
+
:avs_result => { :code => response[:avs_response_code] },
|
|
153
|
+
:cvv_result => response[:cvv_response_code]
|
|
169
154
|
)
|
|
170
155
|
end
|
|
156
|
+
|
|
157
|
+
def success?(response)
|
|
158
|
+
response[:response_code] == '0'
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def authorization_from(response, params)
|
|
162
|
+
[ response[:transaction_id], params[:transaction_amount] ].compact.join(';')
|
|
163
|
+
end
|
|
171
164
|
|
|
172
|
-
# Parse response xml into a convinient hash
|
|
173
165
|
def parse(xml)
|
|
174
|
-
#<Reply>
|
|
175
|
-
#<TransactionReply>
|
|
176
|
-
#<ResponseCode>0</ResponseCode>
|
|
177
|
-
#<ResultCode>00</ResultCode>
|
|
178
|
-
#<ResultMessage>APPROVED</ResultMessage>
|
|
179
|
-
#<TransactionID>200011125443</TransactionID>
|
|
180
|
-
#<AVSResponseCode>N</AVSResponseCode>
|
|
181
|
-
#<CVVResponseCode></CVVResponseCode>
|
|
182
|
-
#<ApprovalNumber>123456</ApprovalNumber>
|
|
183
|
-
#<AuthorizationNumber>123456</AuthorizationNumber>
|
|
184
|
-
#<TransactionDate>070728</TransactionDate>
|
|
185
|
-
#<TransactionTime>024734</TransactionTime>
|
|
186
|
-
#<ReferenceNumber>19786</ReferenceNumber>
|
|
187
|
-
#<AccountNumber>XXXXXXXXXXXX5454</AccountNumber>
|
|
188
|
-
#<TransactionAmount>1.00</TransactionAmount>
|
|
189
|
-
#</TransactionReply>
|
|
190
|
-
#</Reply>
|
|
191
|
-
|
|
192
166
|
response = {}
|
|
193
167
|
|
|
194
168
|
xml = REXML::Document.new(xml)
|
|
@@ -217,7 +191,7 @@ module ActiveMerchant #:nodoc:
|
|
|
217
191
|
xml.to_s
|
|
218
192
|
end
|
|
219
193
|
|
|
220
|
-
def
|
|
194
|
+
def message_from(message)
|
|
221
195
|
return 'Unspecified error' if message.blank?
|
|
222
196
|
message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
|
|
223
197
|
end
|
|
@@ -237,7 +211,6 @@ module ActiveMerchant #:nodoc:
|
|
|
237
211
|
ACTIONS
|
|
238
212
|
end
|
|
239
213
|
|
|
240
|
-
|
|
241
214
|
CREDIT_CARD_FIELDS = [:authorization_number, :client_ip_address, :billing_address, :billing_city, :billing_state, :billing_postal_code, :billing_country, :billing_name, :card_verification_value, :expiration_month, :expiration_year, :reference_number, :transaction_amount, :account_number ]
|
|
242
215
|
|
|
243
216
|
ACTIONS = {
|
|
@@ -129,10 +129,6 @@ module ActiveMerchant #:nodoc:
|
|
|
129
129
|
"96" => "System Error"
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
attr_reader :url
|
|
133
|
-
attr_reader :response
|
|
134
|
-
attr_reader :options
|
|
135
|
-
|
|
136
132
|
self.money_format = :cents
|
|
137
133
|
self.supported_countries = ['AU']
|
|
138
134
|
self.supported_cardtypes = [:visa, :master]
|
|
@@ -195,27 +191,20 @@ module ActiveMerchant #:nodoc:
|
|
|
195
191
|
post[:Option3] = nil
|
|
196
192
|
end
|
|
197
193
|
|
|
198
|
-
def commit(money, parameters)
|
|
199
|
-
|
|
194
|
+
def commit(money, parameters)
|
|
200
195
|
parameters[:TotalAmount] = amount(money)
|
|
201
|
-
|
|
202
|
-
if result = test_result_from_cc_number(parameters[:CardNumber])
|
|
203
|
-
return result
|
|
204
|
-
end
|
|
205
196
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
@response = parse(data)
|
|
197
|
+
response = parse( ssl_post(gateway_url(parameters[:CVN], test?), post_data(parameters)) )
|
|
209
198
|
|
|
210
|
-
success
|
|
211
|
-
message = message_from(response[:ewaytrxnerror])
|
|
212
|
-
test = /\(Test( CVN)? Gateway\)/ === response[:ewaytrxnerror]
|
|
213
|
-
|
|
214
|
-
Response.new(success, message, @response,
|
|
199
|
+
Response.new(success?(response), message_from(response[:ewaytrxnerror]), response,
|
|
215
200
|
:authorization => response[:ewayauthcode],
|
|
216
|
-
:test =>
|
|
201
|
+
:test => /\(Test( CVN)? Gateway\)/ === response[:ewaytrxnerror]
|
|
217
202
|
)
|
|
218
203
|
end
|
|
204
|
+
|
|
205
|
+
def success?(response)
|
|
206
|
+
response[:ewaytrxnstatus] == "True"
|
|
207
|
+
end
|
|
219
208
|
|
|
220
209
|
# Parse eway response xml into a convinient hash
|
|
221
210
|
def parse(xml)
|
|
@@ -39,11 +39,7 @@ module ActiveMerchant #:nodoc:
|
|
|
39
39
|
self.supported_countries = ['CA', 'US']
|
|
40
40
|
self.homepage_url = 'http://www.e-xact.com'
|
|
41
41
|
self.display_name = 'E-xact'
|
|
42
|
-
|
|
43
|
-
attr_reader :url
|
|
44
|
-
attr_reader :response
|
|
45
|
-
attr_reader :options
|
|
46
|
-
|
|
42
|
+
|
|
47
43
|
def initialize(options = {})
|
|
48
44
|
requires!(options, :login, :password)
|
|
49
45
|
@options = options
|
|
@@ -60,18 +56,10 @@ module ActiveMerchant #:nodoc:
|
|
|
60
56
|
end
|
|
61
57
|
|
|
62
58
|
def authorize(money, credit_card, options = {})
|
|
63
|
-
if result = test_result_from_cc_number(credit_card.number)
|
|
64
|
-
return result
|
|
65
|
-
end
|
|
66
|
-
|
|
67
59
|
commit(:authorization, build_sale_or_authorization_request(money, credit_card, options))
|
|
68
60
|
end
|
|
69
61
|
|
|
70
62
|
def purchase(money, credit_card, options = {})
|
|
71
|
-
if result = test_result_from_cc_number(credit_card.number)
|
|
72
|
-
return result
|
|
73
|
-
end
|
|
74
|
-
|
|
75
63
|
commit(:sale, build_sale_or_authorization_request(money, credit_card, options))
|
|
76
64
|
end
|
|
77
65
|
|
|
@@ -176,22 +164,26 @@ module ActiveMerchant #:nodoc:
|
|
|
176
164
|
end
|
|
177
165
|
|
|
178
166
|
def commit(action, request)
|
|
179
|
-
|
|
167
|
+
response = parse(ssl_post(URL, build_request(action, request), POST_HEADERS))
|
|
168
|
+
|
|
169
|
+
Response.new(successful?(response), message_from(response), response,
|
|
170
|
+
:test => test?,
|
|
171
|
+
:authorization => authorization_from(response),
|
|
172
|
+
:avs_result => { :code => response[:avs] },
|
|
173
|
+
:cvv_result => response[:cvv2]
|
|
174
|
+
)
|
|
175
|
+
end
|
|
180
176
|
|
|
181
|
-
|
|
177
|
+
def successful?(response)
|
|
178
|
+
response[:transaction_approved] == SUCCESS
|
|
179
|
+
end
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
authorization = if @response[:authorization_num] && @response[:transaction_tag]
|
|
181
|
+
def authorization_from(response)
|
|
182
|
+
if response[:authorization_num] && response[:transaction_tag]
|
|
186
183
|
"#{response[:authorization_num]};#{response[:transaction_tag]}"
|
|
187
|
-
|
|
184
|
+
else
|
|
188
185
|
''
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Response.new(success, message_from(@response), @response,
|
|
192
|
-
:test => test?,
|
|
193
|
-
:authorization => authorization
|
|
194
|
-
)
|
|
186
|
+
end
|
|
195
187
|
end
|
|
196
188
|
|
|
197
189
|
def message_from(response)
|
|
@@ -90,9 +90,6 @@ module ActiveMerchant #:nodoc:
|
|
|
90
90
|
# LinkPoint's Items entity is not yet supported in this module.
|
|
91
91
|
#
|
|
92
92
|
class LinkpointGateway < Gateway
|
|
93
|
-
attr_reader :response
|
|
94
|
-
attr_reader :options
|
|
95
|
-
|
|
96
93
|
# Your global PEM file. This will be assigned to you by linkpoint
|
|
97
94
|
#
|
|
98
95
|
# Example:
|
|
@@ -216,34 +213,30 @@ module ActiveMerchant #:nodoc:
|
|
|
216
213
|
end
|
|
217
214
|
|
|
218
215
|
def test?
|
|
219
|
-
@options[:test] ||
|
|
216
|
+
@options[:test] || super
|
|
220
217
|
end
|
|
221
218
|
|
|
222
219
|
private
|
|
223
220
|
# Commit the transaction by posting the XML file to the LinkPoint server
|
|
224
221
|
def commit(money, creditcard, options = {})
|
|
225
|
-
|
|
226
|
-
url = test? ? TEST_URL : LIVE_URL
|
|
227
|
-
|
|
228
|
-
if creditcard and result = test_result_from_cc_number(parameters[:creditcard][:cardnumber])
|
|
229
|
-
return result
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
data = ssl_post(url, post_data(parameters))
|
|
233
|
-
|
|
234
|
-
@response = parse(data)
|
|
222
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(money, creditcard, options)))
|
|
235
223
|
|
|
236
|
-
|
|
237
|
-
message = response[:message]
|
|
238
|
-
|
|
239
|
-
Response.new(success, message, @response,
|
|
224
|
+
Response.new(successful?(response), response[:message], response,
|
|
240
225
|
:test => test?,
|
|
241
|
-
:authorization => response[:ordernum]
|
|
226
|
+
:authorization => response[:ordernum],
|
|
227
|
+
:avs_result => { :code => response[:avs].to_s[2,1] },
|
|
228
|
+
:cvv_result => response[:avs].to_s[3,1]
|
|
242
229
|
)
|
|
243
230
|
end
|
|
244
231
|
|
|
232
|
+
def successful?(response)
|
|
233
|
+
response[:approved] == "APPROVED"
|
|
234
|
+
end
|
|
235
|
+
|
|
245
236
|
# Build the XML file
|
|
246
|
-
def post_data(
|
|
237
|
+
def post_data(money, creditcard, options)
|
|
238
|
+
params = parameters(money, creditcard, options)
|
|
239
|
+
|
|
247
240
|
xml = REXML::Document.new
|
|
248
241
|
order = xml.add_element("order")
|
|
249
242
|
|
|
@@ -251,11 +244,11 @@ module ActiveMerchant #:nodoc:
|
|
|
251
244
|
merchantinfo = order.add_element("merchantinfo")
|
|
252
245
|
merchantinfo.add_element("configfile").text = @options[:login]
|
|
253
246
|
|
|
254
|
-
# Loop over the
|
|
255
|
-
for key, value in
|
|
247
|
+
# Loop over the params hash to construct the XML string
|
|
248
|
+
for key, value in params
|
|
256
249
|
elem = order.add_element(key.to_s)
|
|
257
|
-
for k, v in
|
|
258
|
-
elem.add_element(k.to_s).text =
|
|
250
|
+
for k, v in params[key]
|
|
251
|
+
elem.add_element(k.to_s).text = params[key][k].to_s if params[key][k]
|
|
259
252
|
end
|
|
260
253
|
# Linkpoint doesn't understand empty elements:
|
|
261
254
|
order.delete(elem) if elem.size == 0
|
|
@@ -343,7 +336,7 @@ module ActiveMerchant #:nodoc:
|
|
|
343
336
|
params[:billing][:email] = options[:email] unless options[:email].blank?
|
|
344
337
|
end
|
|
345
338
|
|
|
346
|
-
if shipping_address = options[:shipping_address]
|
|
339
|
+
if shipping_address = options[:shipping_address]
|
|
347
340
|
|
|
348
341
|
params[:shipping] = {}
|
|
349
342
|
params[:shipping][:name] = shipping_address[:name] || creditcard ? creditcard.name : nil
|