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
|
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
|
|
|
4
4
|
module Billing #:nodoc:
|
|
5
5
|
class VerifiGateway < Gateway
|
|
6
6
|
class VerifiPostData < PostData
|
|
7
|
-
# Fields that will be
|
|
7
|
+
# Fields that will be sent even if they are blank
|
|
8
8
|
self.required_fields = [ :amount, :type, :ccnumber, :ccexp, :firstname, :lastname,
|
|
9
9
|
:company, :address1, :address2, :city, :state, :zip, :country, :phone ]
|
|
10
10
|
end
|
|
@@ -62,23 +62,19 @@ module ActiveMerchant #:nodoc:
|
|
|
62
62
|
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
|
63
63
|
self.homepage_url = 'http://www.verifi.com/'
|
|
64
64
|
self.display_name = 'Verifi'
|
|
65
|
-
|
|
66
|
-
attr_reader :url
|
|
67
|
-
attr_reader :response
|
|
68
|
-
attr_reader :options
|
|
69
|
-
|
|
65
|
+
|
|
70
66
|
def initialize(options = {})
|
|
71
67
|
requires!(options, :login, :password)
|
|
72
68
|
@options = options
|
|
73
69
|
super
|
|
74
70
|
end
|
|
75
71
|
|
|
76
|
-
def purchase(money,
|
|
77
|
-
sale_authorization_or_credit_template(:purchase, money,
|
|
72
|
+
def purchase(money, credit_card, options = {})
|
|
73
|
+
sale_authorization_or_credit_template(:purchase, money, credit_card, options)
|
|
78
74
|
end
|
|
79
75
|
|
|
80
|
-
def authorize(money,
|
|
81
|
-
sale_authorization_or_credit_template(:authorization, money,
|
|
76
|
+
def authorize(money, credit_card, options = {})
|
|
77
|
+
sale_authorization_or_credit_template(:authorization, money, credit_card, options)
|
|
82
78
|
end
|
|
83
79
|
|
|
84
80
|
def capture(money, authorization, options = {})
|
|
@@ -89,20 +85,20 @@ module ActiveMerchant #:nodoc:
|
|
|
89
85
|
capture_void_or_refund_template(:void, 0, authorization, options)
|
|
90
86
|
end
|
|
91
87
|
|
|
92
|
-
def credit(money,
|
|
93
|
-
if
|
|
94
|
-
capture_void_or_refund_template(:refund, money,
|
|
88
|
+
def credit(money, credit_card_or_authorization, options = {})
|
|
89
|
+
if credit_card_or_authorization.is_a?(String)
|
|
90
|
+
capture_void_or_refund_template(:refund, money, credit_card_or_authorization, options)
|
|
95
91
|
else
|
|
96
|
-
sale_authorization_or_credit_template(:credit, money,
|
|
92
|
+
sale_authorization_or_credit_template(:credit, money, credit_card_or_authorization, options)
|
|
97
93
|
end
|
|
98
94
|
end
|
|
99
95
|
|
|
100
96
|
private
|
|
101
97
|
|
|
102
|
-
def sale_authorization_or_credit_template(trx_type, money,
|
|
98
|
+
def sale_authorization_or_credit_template(trx_type, money, credit_card, options = {})
|
|
103
99
|
post = VerifiPostData.new
|
|
104
100
|
add_security_key_data(post, options, money)
|
|
105
|
-
|
|
101
|
+
add_credit_card(post, credit_card)
|
|
106
102
|
add_addresses(post, options)
|
|
107
103
|
add_customer_data(post, options)
|
|
108
104
|
add_invoice_data(post, options)
|
|
@@ -117,17 +113,17 @@ module ActiveMerchant #:nodoc:
|
|
|
117
113
|
commit(trx_type, money, post)
|
|
118
114
|
end
|
|
119
115
|
|
|
120
|
-
def
|
|
121
|
-
post[:ccnumber] =
|
|
122
|
-
post[:ccexp] = expdate(
|
|
123
|
-
post[:firstname] =
|
|
124
|
-
post[:lastname] =
|
|
125
|
-
post[:cvv] =
|
|
116
|
+
def add_credit_card(post, credit_card)
|
|
117
|
+
post[:ccnumber] = credit_card.number
|
|
118
|
+
post[:ccexp] = expdate(credit_card)
|
|
119
|
+
post[:firstname] = credit_card.first_name
|
|
120
|
+
post[:lastname] = credit_card.last_name
|
|
121
|
+
post[:cvv] = credit_card.verification_value
|
|
126
122
|
end
|
|
127
123
|
|
|
128
|
-
def expdate(
|
|
129
|
-
year = sprintf("%.4i",
|
|
130
|
-
month = sprintf("%.2i",
|
|
124
|
+
def expdate(credit_card)
|
|
125
|
+
year = sprintf("%.4i", credit_card.year)
|
|
126
|
+
month = sprintf("%.2i", credit_card.month)
|
|
131
127
|
|
|
132
128
|
"#{month}#{year[-2..-1]}"
|
|
133
129
|
end
|
|
@@ -145,7 +141,7 @@ module ActiveMerchant #:nodoc:
|
|
|
145
141
|
post[:fax] = billing_address[:fax]
|
|
146
142
|
end
|
|
147
143
|
|
|
148
|
-
if shipping_address = options[:shipping_address]
|
|
144
|
+
if shipping_address = options[:shipping_address]
|
|
149
145
|
post[:shipping_firstname] = shipping_address[:first_name]
|
|
150
146
|
post[:shipping_lastname] = shipping_address[:last_name]
|
|
151
147
|
post[:shipping_company] = shipping_address[:company]
|
|
@@ -197,24 +193,21 @@ module ActiveMerchant #:nodoc:
|
|
|
197
193
|
end
|
|
198
194
|
|
|
199
195
|
def commit(trx_type, money, post)
|
|
200
|
-
|
|
201
196
|
post[:amount] = amount(money)
|
|
202
197
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
data = ssl_post(URL, post_data(trx_type, post), 'Content-type' => "application/x-www-form-urlencoded")
|
|
208
|
-
@response = parse(data)
|
|
209
|
-
|
|
210
|
-
success = @response[:response].to_i == SUCCESS
|
|
211
|
-
message = @response[:response_code_message] ? @response[:response_code_message] : ""
|
|
212
|
-
|
|
213
|
-
Response.new(success, message, @response,
|
|
198
|
+
response = parse( ssl_post(URL, post_data(trx_type, post)) )
|
|
199
|
+
|
|
200
|
+
Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
|
|
214
201
|
:test => test?,
|
|
215
|
-
:authorization =>
|
|
202
|
+
:authorization => response[:transactionid],
|
|
203
|
+
:avs_result => { :code => response[:avsresponse] },
|
|
204
|
+
:cvv_result => response[:cvvresponse]
|
|
216
205
|
)
|
|
217
206
|
end
|
|
207
|
+
|
|
208
|
+
def message_from(response)
|
|
209
|
+
response[:response_code_message] ? response[:response_code_message] : ""
|
|
210
|
+
end
|
|
218
211
|
|
|
219
212
|
def parse(body)
|
|
220
213
|
results = {}
|
|
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
|
|
|
42
42
|
# Viaklix does not support credits by reference. You must pass in the credit card
|
|
43
43
|
def credit(money, creditcard, options = {})
|
|
44
44
|
if creditcard.is_a?(String)
|
|
45
|
-
raise ArgumentError, "Reference credits are not supported.
|
|
45
|
+
raise ArgumentError, "Reference credits are not supported. Please supply the original credit card"
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
form = {}
|
|
@@ -55,39 +55,39 @@ module ActiveMerchant #:nodoc:
|
|
|
55
55
|
|
|
56
56
|
private
|
|
57
57
|
def add_customer_data(form, options)
|
|
58
|
-
form[:email] = options[:email] unless options[:email].blank?
|
|
58
|
+
form[:email] = options[:email].to_s.slice(0, 100) unless options[:email].blank?
|
|
59
59
|
form[:customer_code] = options[:customer].to_s.slice(0, 17) unless options[:customer].blank?
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def add_invoice(form,options)
|
|
63
|
-
form[:invoice_number] = options[:order_id] || options[:invoice]
|
|
63
|
+
form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
|
|
64
|
+
form[:description] = options[:description].to_s.slice(0, 255)
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
def add_address(form,options)
|
|
67
68
|
billing_address = options[:billing_address] || options[:address]
|
|
68
69
|
|
|
69
70
|
if billing_address
|
|
70
|
-
form[:avs_address] = billing_address[:address1]
|
|
71
|
-
form[:
|
|
72
|
-
form[:
|
|
73
|
-
form[:
|
|
74
|
-
form[:
|
|
75
|
-
form[:
|
|
76
|
-
form[:
|
|
71
|
+
form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
|
|
72
|
+
form[:address2] = billing_address[:address2].to_s.slice(0, 30)
|
|
73
|
+
form[:avs_zip] = billing_address[:zip].to_s.slice(0, 10)
|
|
74
|
+
form[:city] = billing_address[:city].to_s.slice(0, 30)
|
|
75
|
+
form[:state] = billing_address[:state].to_s.slice(0, 10)
|
|
76
|
+
form[:company] = billing_address[:company].to_s.slice(0, 50)
|
|
77
|
+
form[:phone] = billing_address[:phone].to_s.slice(0, 20)
|
|
78
|
+
form[:country] = billing_address[:country].to_s.slice(0, 50)
|
|
77
79
|
end
|
|
78
|
-
|
|
79
|
-
shipping_address = options[:shipping_address]
|
|
80
|
-
|
|
81
|
-
if shipping_address
|
|
80
|
+
|
|
81
|
+
if shipping_address = options[:shipping_address]
|
|
82
82
|
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
|
83
|
-
form[:ship_to_first_name] = first_name
|
|
84
|
-
form[:ship_to_last_name] = last_name
|
|
85
|
-
form[:ship_to_address] = shipping_address[:address1]
|
|
86
|
-
form[:ship_to_city] = shipping_address[:city]
|
|
87
|
-
form[:ship_to_state] = shipping_address[:state]
|
|
88
|
-
form[:ship_to_company] = shipping_address[:company]
|
|
89
|
-
form[:ship_to_country] = shipping_address[:country]
|
|
90
|
-
form[:ship_to_zip] = shipping_address[:zip]
|
|
83
|
+
form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
|
|
84
|
+
form[:ship_to_last_name] = last_name.to_s.slice(0, 30)
|
|
85
|
+
form[:ship_to_address] = shipping_address[:address1].to_s.slice(0, 30)
|
|
86
|
+
form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30)
|
|
87
|
+
form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10)
|
|
88
|
+
form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50)
|
|
89
|
+
form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50)
|
|
90
|
+
form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
@@ -108,8 +108,8 @@ module ActiveMerchant #:nodoc:
|
|
|
108
108
|
form[:cvv2] = 'present'
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
form[:first_name] = creditcard.first_name
|
|
112
|
-
form[:last_name] = creditcard.last_name
|
|
111
|
+
form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
|
|
112
|
+
form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
def preamble
|
|
@@ -126,22 +126,16 @@ module ActiveMerchant #:nodoc:
|
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
def commit(action, money, parameters)
|
|
129
|
-
if result = test_result_from_cc_number(parameters[:card_number])
|
|
130
|
-
return result
|
|
131
|
-
end
|
|
132
|
-
|
|
133
129
|
parameters[:amount] = amount(money)
|
|
134
130
|
parameters[:transaction_type] = action
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
success = @response['result'] == APPROVED
|
|
140
|
-
message = @response['result_message']
|
|
141
|
-
|
|
142
|
-
Response.new(success, message, @response,
|
|
132
|
+
response = parse( ssl_post(test? ? TEST_URL : LIVE_URL, post_data(parameters)) )
|
|
133
|
+
|
|
134
|
+
Response.new(response['result'] == APPROVED, response['result_message'], response,
|
|
143
135
|
:test => @options[:test] || test?,
|
|
144
|
-
:authorization =>
|
|
136
|
+
:authorization => response['txn_id'],
|
|
137
|
+
:avs_result => { :code => response['avs_response'] },
|
|
138
|
+
:cvv_result => response['cvv2_response']
|
|
145
139
|
)
|
|
146
140
|
end
|
|
147
141
|
|
|
@@ -159,7 +153,7 @@ module ActiveMerchant #:nodoc:
|
|
|
159
153
|
|
|
160
154
|
# Parse the response message
|
|
161
155
|
def parse(msg)
|
|
162
|
-
resp =
|
|
156
|
+
resp = {}
|
|
163
157
|
msg.split("\r\n").collect{|li|
|
|
164
158
|
key, value = li.split("=")
|
|
165
159
|
resp[key.gsub(/^ssl_/, '')] = value.to_s.strip
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
require 'active_merchant/billing/integrations/notification'
|
|
2
2
|
require 'active_merchant/billing/integrations/helper'
|
|
3
|
+
require 'active_merchant/billing/integrations/return'
|
|
3
4
|
require 'active_merchant/billing/integrations/bogus'
|
|
4
5
|
require 'active_merchant/billing/integrations/chronopay'
|
|
5
6
|
require 'active_merchant/billing/integrations/paypal'
|
|
6
7
|
require 'active_merchant/billing/integrations/nochex'
|
|
7
8
|
require 'active_merchant/billing/integrations/gestpay'
|
|
8
9
|
require 'active_merchant/billing/integrations/two_checkout'
|
|
10
|
+
require 'active_merchant/billing/integrations/hi_trust'
|
|
9
11
|
|
|
10
12
|
# make the bogus gateway be classified correctly by the inflector
|
|
11
13
|
Inflector.inflections do |inflect|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'active_merchant/billing/integrations/bogus/helper.rb'
|
|
2
2
|
require 'active_merchant/billing/integrations/bogus/notification.rb'
|
|
3
|
+
require 'active_merchant/billing/integrations/bogus/return.rb'
|
|
3
4
|
|
|
4
5
|
module ActiveMerchant #:nodoc:
|
|
5
6
|
module Billing #:nodoc:
|
|
@@ -11,6 +12,10 @@ module ActiveMerchant #:nodoc:
|
|
|
11
12
|
def self.notification(post)
|
|
12
13
|
Notification.new(post)
|
|
13
14
|
end
|
|
15
|
+
|
|
16
|
+
def self.return(query_string)
|
|
17
|
+
Return.new(query_string)
|
|
18
|
+
end
|
|
14
19
|
end
|
|
15
20
|
end
|
|
16
21
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'active_merchant/billing/integrations/chronopay/helper.rb'
|
|
2
2
|
require 'active_merchant/billing/integrations/chronopay/notification.rb'
|
|
3
|
+
require 'active_merchant/billing/integrations/chronopay/return.rb'
|
|
3
4
|
|
|
4
5
|
module ActiveMerchant #:nodoc:
|
|
5
6
|
module Billing #:nodoc:
|
|
@@ -11,6 +12,10 @@ module ActiveMerchant #:nodoc:
|
|
|
11
12
|
def self.notification(post)
|
|
12
13
|
Notification.new(post)
|
|
13
14
|
end
|
|
15
|
+
|
|
16
|
+
def self.return(query_string)
|
|
17
|
+
Return.new(query_string)
|
|
18
|
+
end
|
|
14
19
|
end
|
|
15
20
|
end
|
|
16
21
|
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require File.dirname(__FILE__) + '/gestpay/common.rb'
|
|
4
4
|
require File.dirname(__FILE__) + '/gestpay/helper.rb'
|
|
5
5
|
require File.dirname(__FILE__) + '/gestpay/notification.rb'
|
|
6
|
+
require File.dirname(__FILE__) + '/gestpay/return.rb'
|
|
6
7
|
|
|
7
8
|
module ActiveMerchant #:nodoc:
|
|
8
9
|
module Billing #:nodoc:
|
|
@@ -15,6 +16,10 @@ module ActiveMerchant #:nodoc:
|
|
|
15
16
|
def self.notification(post)
|
|
16
17
|
Notification.new(post)
|
|
17
18
|
end
|
|
19
|
+
|
|
20
|
+
def self.return(query_string)
|
|
21
|
+
Return.new(query_string)
|
|
22
|
+
end
|
|
18
23
|
end
|
|
19
24
|
end
|
|
20
25
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/hi_trust/helper.rb'
|
|
2
|
+
require File.dirname(__FILE__) + '/hi_trust/notification.rb'
|
|
3
|
+
require File.dirname(__FILE__) + '/hi_trust/return.rb'
|
|
4
|
+
|
|
5
|
+
module ActiveMerchant #:nodoc:
|
|
6
|
+
module Billing #:nodoc:
|
|
7
|
+
module Integrations #:nodoc:
|
|
8
|
+
module HiTrust
|
|
9
|
+
TEST_URL = 'https://testtrustlink.hitrust.com.tw/TrustLink/TrxReq'
|
|
10
|
+
LIVE_URL = 'https://trustlink.hitrust.com.tw/TrustLink/TrxReq'
|
|
11
|
+
|
|
12
|
+
def self.service_url
|
|
13
|
+
ActiveMerchant::Billing::Base.integration_mode == :test ? TEST_URL : LIVE_URL
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.notification(post)
|
|
17
|
+
Notification.new(post)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.return(query_string)
|
|
21
|
+
Return.new(query_string)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
module Integrations #:nodoc:
|
|
4
|
+
module HiTrust
|
|
5
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
|
6
|
+
|
|
7
|
+
# Transaction types
|
|
8
|
+
# * Auth
|
|
9
|
+
# * AuthRe
|
|
10
|
+
# * Capture
|
|
11
|
+
# * CaptureRe
|
|
12
|
+
# * Refund
|
|
13
|
+
# * RefundRe
|
|
14
|
+
# * Query
|
|
15
|
+
def initialize(order, account, options = {})
|
|
16
|
+
super
|
|
17
|
+
# Perform an authorization by default
|
|
18
|
+
add_field('Type', 'Auth')
|
|
19
|
+
|
|
20
|
+
# Capture the payment right away
|
|
21
|
+
add_field('depositflag', '1')
|
|
22
|
+
|
|
23
|
+
# Disable auto query - who knows what it does?
|
|
24
|
+
add_field('queryflag', '1')
|
|
25
|
+
|
|
26
|
+
add_field('orderdesc', 'Store purchase')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
mapping :account, 'storeid'
|
|
30
|
+
mapping :amount, 'amount'
|
|
31
|
+
|
|
32
|
+
def amount=(money)
|
|
33
|
+
cents = money.respond_to?(:cents) ? money.cents : money
|
|
34
|
+
|
|
35
|
+
if money.is_a?(String) or cents.to_i < 0
|
|
36
|
+
raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
add_field(mappings[:amount], cents)
|
|
40
|
+
end
|
|
41
|
+
# Supported currencies include:
|
|
42
|
+
# * CNY:Chinese Yuan (Renminbi)
|
|
43
|
+
# * TWD:New Taiwan Dollar
|
|
44
|
+
# * HKD:Hong Kong Dollar
|
|
45
|
+
# * USD:US Dollar
|
|
46
|
+
# * AUD:Austrian Dollar
|
|
47
|
+
mapping :currency, 'currency'
|
|
48
|
+
|
|
49
|
+
mapping :order, 'ordernumber'
|
|
50
|
+
mapping :description, 'orderdesc'
|
|
51
|
+
|
|
52
|
+
mapping :notify_url, 'merUpdateURL'
|
|
53
|
+
mapping :return_url, 'returnURL'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant #:nodoc:
|
|
4
|
+
module Billing #:nodoc:
|
|
5
|
+
module Integrations #:nodoc:
|
|
6
|
+
module HiTrust
|
|
7
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
|
8
|
+
SUCCESS = '00'
|
|
9
|
+
|
|
10
|
+
def complete?
|
|
11
|
+
status == 'Completed'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def transaction_id
|
|
15
|
+
params['authRRN']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def item_id
|
|
19
|
+
params['ordernumber']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def received_at
|
|
23
|
+
Time.parse(params['orderdate']) rescue nil
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def currency
|
|
27
|
+
params['currency']
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def gross
|
|
31
|
+
params['approveamount']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def gross_cents
|
|
35
|
+
gross.to_i
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def account
|
|
39
|
+
params['storeid']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def status
|
|
43
|
+
params['retcode'] == SUCCESS ? 'Completed' : 'Failed'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test?
|
|
47
|
+
ActiveMerchant::Billing::Base.integration_mode == :test
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def acknowledge
|
|
51
|
+
true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|