activemerchant-kiddy 1.15.0.kiddy
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +688 -0
- data/CONTRIBUTORS +233 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +164 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +172 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +170 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +671 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +858 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +309 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +282 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +139 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +132 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +293 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +410 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/epay.rb +268 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +231 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +250 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +258 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +454 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +156 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +209 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +292 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +317 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +253 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +222 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +235 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +351 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +177 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +25 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +295 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +218 -0
- data/lib/active_merchant/billing/gateways/realex.rb +311 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +116 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +320 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +193 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +271 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +25 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +280 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/helper.rb +96 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +48 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +111 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +88 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +38 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/common/connection.rb +177 -0
- data/lib/active_merchant/common/country.rb +328 -0
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/common/posts_data.rb +63 -0
- data/lib/active_merchant/common/requires_parameters.rb +16 -0
- data/lib/active_merchant/common/utils.rb +22 -0
- data/lib/active_merchant/common/validateable.rb +81 -0
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +50 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/support/gateway_support.rb +58 -0
- data/lib/support/outbound_hosts.rb +25 -0
- metadata +273 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class SallieMaeGateway < Gateway
|
4
|
+
URL = 'https://trans.salliemae.com/cgi-bin/process.cgi'
|
5
|
+
|
6
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
|
9
|
+
# The card types supported by the payment gateway
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
11
|
+
|
12
|
+
# The homepage URL of the gateway
|
13
|
+
self.homepage_url = 'http://www.salliemae.com/'
|
14
|
+
|
15
|
+
# The name of the gateway
|
16
|
+
self.display_name = 'Sallie Mae'
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
requires!(options, :login)
|
20
|
+
@options = options
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def test?
|
25
|
+
@options[:login] == "TEST0"
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(money, creditcard, options = {})
|
29
|
+
post = PostData.new
|
30
|
+
add_invoice(post, options)
|
31
|
+
add_creditcard(post, creditcard)
|
32
|
+
add_address(post, creditcard, options)
|
33
|
+
add_customer_data(post, options)
|
34
|
+
|
35
|
+
commit(:authonly, money, post)
|
36
|
+
end
|
37
|
+
|
38
|
+
def purchase(money, creditcard, options = {})
|
39
|
+
post = PostData.new
|
40
|
+
add_invoice(post, options)
|
41
|
+
add_creditcard(post, creditcard)
|
42
|
+
add_address(post, creditcard, options)
|
43
|
+
add_customer_data(post, options)
|
44
|
+
|
45
|
+
commit(:sale, money, post)
|
46
|
+
end
|
47
|
+
|
48
|
+
def capture(money, authorization, options = {})
|
49
|
+
post = PostData.new
|
50
|
+
post[:postonly] = authorization
|
51
|
+
commit(:capture, money, post)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def add_customer_data(post, options)
|
57
|
+
if address = options[:billing_address] || options[:shipping_address] || options[:address]
|
58
|
+
post[:ci_phone] = address[:phone].to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
post[:ci_email] = options[:email].to_s unless options[:email].blank?
|
62
|
+
post[:ci_IP] = options[:ip].to_s unless options[:ip].blank?
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_address(post, creditcard, options)
|
66
|
+
if address = options[:billing_address] || options[:address]
|
67
|
+
post[:ci_billaddr1] = address[:address1].to_s
|
68
|
+
post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank?
|
69
|
+
post[:ci_billcity] = address[:city].to_s
|
70
|
+
post[:ci_billstate] = address[:state].to_s
|
71
|
+
post[:ci_billzip] = address[:zip].to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
if shipping_address = options[:shipping_address] || options[:address]
|
75
|
+
post[:ci_shipaddr1] = shipping_address[:address1].to_s
|
76
|
+
post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank?
|
77
|
+
post[:ci_shipcity] = shipping_address[:city].to_s
|
78
|
+
post[:ci_shipstate] = shipping_address[:state].to_s
|
79
|
+
post[:ci_shipzip] = shipping_address[:zip].to_s
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_invoice(post, options)
|
84
|
+
memo = "OrderID: #{options[:order_id]}\nDescription: #{options[:description]}"
|
85
|
+
post[:ci_memo] = memo
|
86
|
+
end
|
87
|
+
|
88
|
+
def add_creditcard(post, creditcard)
|
89
|
+
post[:ccnum] = creditcard.number.to_s
|
90
|
+
post[:ccname] = creditcard.name.to_s
|
91
|
+
post[:cvv2] = creditcard.verification_value.to_s if creditcard.verification_value?
|
92
|
+
post[:expmon] = creditcard.month.to_s
|
93
|
+
post[:expyear] = creditcard.year.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse(body)
|
97
|
+
h = {}
|
98
|
+
body.gsub!("<html><body><plaintext>", "")
|
99
|
+
body.
|
100
|
+
split("\r\n").
|
101
|
+
map do |i|
|
102
|
+
a = i.split("=")
|
103
|
+
h[a.first] = a.last unless a.first.nil?
|
104
|
+
end
|
105
|
+
h
|
106
|
+
end
|
107
|
+
|
108
|
+
def commit(action, money, parameters)
|
109
|
+
parameters[:acctid] = @options[:login].to_s
|
110
|
+
parameters[:subid] = @options[:sub_id].to_s unless @options[:sub_id].blank?
|
111
|
+
parameters[:amount] = amount(money)
|
112
|
+
|
113
|
+
case action
|
114
|
+
when :sale
|
115
|
+
parameters[:action] = "ns_quicksale_cc"
|
116
|
+
when :authonly
|
117
|
+
parameters[:action] = "ns_quicksale_cc"
|
118
|
+
parameters[:authonly] = 1
|
119
|
+
when :capture
|
120
|
+
parameters[:action] = "ns_quicksale_cc"
|
121
|
+
end
|
122
|
+
|
123
|
+
response = parse(ssl_post(URL, parameters.to_post_data) || "")
|
124
|
+
Response.new(successful?(response), message_from(response), response,
|
125
|
+
:test => test?,
|
126
|
+
:authorization => response["refcode"]
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
def successful?(response)
|
131
|
+
response["Status"] == "Accepted"
|
132
|
+
end
|
133
|
+
|
134
|
+
def message_from(response)
|
135
|
+
if successful?(response)
|
136
|
+
"Accepted"
|
137
|
+
else
|
138
|
+
response["Reason"].split(":")[2].capitalize unless response["Reason"].nil?
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
@@ -0,0 +1,330 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class SecureNetGateway < Gateway
|
4
|
+
|
5
|
+
API_VERSION = "4.0"
|
6
|
+
|
7
|
+
TRANSACTIONS = {
|
8
|
+
:auth_only => "0000", #
|
9
|
+
:partial_auth_only => "0001",
|
10
|
+
:auth_capture => "0100", #
|
11
|
+
:partial_auth_capture => "0101",
|
12
|
+
:prior_auth_capture => "0200",
|
13
|
+
:capture_only => "0300", #
|
14
|
+
:void => "0400", #
|
15
|
+
:partial_void => "0401",
|
16
|
+
:credit => "0500", #
|
17
|
+
:credit_authonly => "0501",
|
18
|
+
:credit_priorauthcapture => "0502",
|
19
|
+
:force_credit => "0600",
|
20
|
+
:force_credit_authonly => "0601",
|
21
|
+
:force_credit_priorauthcapture => "0602",
|
22
|
+
:verification => "0700",
|
23
|
+
:auth_increment => "0800",
|
24
|
+
:issue => "0900",
|
25
|
+
:activate => "0901",
|
26
|
+
:redeem => "0902",
|
27
|
+
:redeem_partial => "0903",
|
28
|
+
:deactivate => "0904",
|
29
|
+
:reactivate => "0905",
|
30
|
+
:inquiry_balance => "0906"
|
31
|
+
}
|
32
|
+
|
33
|
+
XML_ATTRIBUTES = { 'xmlns' => "http://gateway.securenet.com/API/Contracts",
|
34
|
+
'xmlns:i' => "http://www.w3.org/2001/XMLSchema-instance"
|
35
|
+
}
|
36
|
+
NIL_ATTRIBUTE = { 'i:nil' => "true" }
|
37
|
+
|
38
|
+
# SUCCESS = "true"
|
39
|
+
# SENSITIVE_FIELDS = [ :verification_str2, :expiry_date, :card_number ]
|
40
|
+
|
41
|
+
self.supported_countries = ['US']
|
42
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
43
|
+
self.homepage_url = 'http://www.securenet.com/'
|
44
|
+
self.display_name = 'SecureNet'
|
45
|
+
# self.wiredump_device = STDOUT
|
46
|
+
|
47
|
+
# TEST_URL = 'https://certify.securenet.com/api/Gateway.svc'
|
48
|
+
TEST_URL = 'https://certify.securenet.com/API/gateway.svc/webHttp/ProcessTransaction'
|
49
|
+
LIVE_URL = 'https://gateway.securenet.com/api/Gateway.svc'
|
50
|
+
|
51
|
+
APPROVED, DECLINED, ERROR = 1, 2, 3
|
52
|
+
|
53
|
+
RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT = 0, 2, 3
|
54
|
+
AVS_RESULT_CODE, CARD_CODE_RESPONSE_CODE, TRANSACTION_ID = 5, 6, 8
|
55
|
+
|
56
|
+
CARD_CODE_ERRORS = %w( N S )
|
57
|
+
AVS_ERRORS = %w( A E N R W Z )
|
58
|
+
|
59
|
+
def initialize(options = {})
|
60
|
+
requires!(options, :login, :password)
|
61
|
+
@options = options
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
def authorize(money, creditcard, options = {})
|
66
|
+
commit(build_sale_or_authorization_request(creditcard, options, :auth_only), money)
|
67
|
+
end
|
68
|
+
|
69
|
+
def purchase(money, creditcard, options = {})
|
70
|
+
commit(build_sale_or_authorization_request(creditcard, options, :auth_capture), money)
|
71
|
+
end
|
72
|
+
|
73
|
+
def capture(money, creditcard, authorization, options = {})
|
74
|
+
commit(build_capture_request(authorization, creditcard, options, :prior_auth_capture), money)
|
75
|
+
end
|
76
|
+
|
77
|
+
def void(money, creditcard, authorization, options = {})
|
78
|
+
commit(build_void_request(authorization, creditcard, options, :void), money)
|
79
|
+
end
|
80
|
+
|
81
|
+
def credit(money, creditcard, authorization, options = {})
|
82
|
+
commit(build_credit_request(authorization, creditcard, options, :credit), money)
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
def commit(request, money)
|
87
|
+
xml = build_request(request, money)
|
88
|
+
data = ssl_post(TEST_URL, xml, "Content-Type" => "text/xml")
|
89
|
+
response = parse(data)
|
90
|
+
|
91
|
+
test_mode = test?
|
92
|
+
Response.new(success?(response), message_from(response), response,
|
93
|
+
:test => test_mode,
|
94
|
+
:authorization => response[:transactionid],
|
95
|
+
:avs_result => { :code => response[:avs_result_code] },
|
96
|
+
:cvv_result => response[:card_code_response_code]
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def build_request(request, money)
|
101
|
+
xml = Builder::XmlMarkup.new
|
102
|
+
|
103
|
+
xml.instruct!
|
104
|
+
xml.tag!("TRANSACTION", XML_ATTRIBUTES) do
|
105
|
+
xml.tag! 'AMOUNT', amount(money)
|
106
|
+
xml << request
|
107
|
+
end
|
108
|
+
|
109
|
+
xml.target!
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_sale_or_authorization_request(creditcard, options, action)
|
113
|
+
xml = Builder::XmlMarkup.new
|
114
|
+
|
115
|
+
add_credit_card(xml, creditcard)
|
116
|
+
xml.tag! 'CODE', TRANSACTIONS[action]
|
117
|
+
add_customer_data(xml, options)
|
118
|
+
add_address(xml, creditcard, options)
|
119
|
+
xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID
|
120
|
+
xml.tag! 'INSTALLMENT_SEQUENCENUM', 1
|
121
|
+
add_invoice(xml, options)
|
122
|
+
add_merchant_key(xml, options)
|
123
|
+
xml.tag! 'METHOD', 'CC'
|
124
|
+
xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id]
|
125
|
+
xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it
|
126
|
+
xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!?
|
127
|
+
xml.tag! 'TEST', 'TRUE'
|
128
|
+
xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0
|
129
|
+
xml.tag! 'TRANSACTION_SERVICE', 0
|
130
|
+
|
131
|
+
xml.target!
|
132
|
+
end
|
133
|
+
|
134
|
+
def build_capture_or_credit_request(identification, options)
|
135
|
+
xml = Builder::XmlMarkup.new
|
136
|
+
|
137
|
+
add_identification(xml, identification)
|
138
|
+
add_customer_data(xml, options)
|
139
|
+
|
140
|
+
xml.target!
|
141
|
+
end
|
142
|
+
|
143
|
+
def build_capture_request(authorization, creditcard, options, action)
|
144
|
+
xml = Builder::XmlMarkup.new
|
145
|
+
|
146
|
+
add_credit_card(xml, creditcard)
|
147
|
+
xml.tag! 'CODE', TRANSACTIONS[action]
|
148
|
+
add_customer_data(xml, options)
|
149
|
+
xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID
|
150
|
+
xml.tag! 'INSTALLMENT_SEQUENCENUM', 1
|
151
|
+
add_merchant_key(xml, options)
|
152
|
+
xml.tag! 'METHOD', 'CC'
|
153
|
+
xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id]
|
154
|
+
xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it
|
155
|
+
xml.tag! 'REF_TRANSID', authorization
|
156
|
+
xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!?
|
157
|
+
xml.tag! 'TEST', 'TRUE'
|
158
|
+
xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0
|
159
|
+
xml.tag! 'TRANSACTION_SERVICE', 0
|
160
|
+
|
161
|
+
xml.target!
|
162
|
+
end
|
163
|
+
|
164
|
+
def build_credit_request(authorization, creditcard, options, action)
|
165
|
+
# requires!(options, :card_number)
|
166
|
+
xml = Builder::XmlMarkup.new
|
167
|
+
|
168
|
+
add_credit_card(xml, creditcard)
|
169
|
+
xml.tag! 'CODE', TRANSACTIONS[action]
|
170
|
+
add_customer_data(xml, options)
|
171
|
+
xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID
|
172
|
+
xml.tag! 'INSTALLMENT_SEQUENCENUM', 1
|
173
|
+
add_merchant_key(xml, options)
|
174
|
+
xml.tag! 'METHOD', 'CC'
|
175
|
+
xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id]
|
176
|
+
xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it
|
177
|
+
xml.tag! 'REF_TRANSID', authorization
|
178
|
+
xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!?
|
179
|
+
xml.tag! 'TEST', 'TRUE'
|
180
|
+
xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0
|
181
|
+
xml.tag! 'TRANSACTION_SERVICE', 0
|
182
|
+
|
183
|
+
xml.target!
|
184
|
+
end
|
185
|
+
|
186
|
+
def build_void_request(authorization, creditcard, options, action)
|
187
|
+
xml = Builder::XmlMarkup.new
|
188
|
+
|
189
|
+
add_credit_card(xml, creditcard)
|
190
|
+
xml.tag! 'CODE', TRANSACTIONS[action]
|
191
|
+
add_customer_data(xml, options)
|
192
|
+
xml.tag! 'DCI', 0 # No duplicate checking will be done, except for ORDERID
|
193
|
+
xml.tag! 'INSTALLMENT_SEQUENCENUM', 1
|
194
|
+
add_merchant_key(xml, options)
|
195
|
+
xml.tag! 'METHOD', 'CC'
|
196
|
+
xml.tag! 'ORDERID', options[:order_id]#'30'.to_i.to_s#'22'# @options[:order_id]
|
197
|
+
xml.tag! 'OVERRIDE_FROM', 0 # Docs say not required, but doesn't work without it
|
198
|
+
xml.tag! 'REF_TRANSID', authorization
|
199
|
+
xml.tag! 'RETAIL_LANENUM', '0' # Docs say string, but it's an integer!?
|
200
|
+
xml.tag! 'TEST', 'TRUE'
|
201
|
+
xml.tag! 'TOTAL_INSTALLMENTCOUNT', 0
|
202
|
+
xml.tag! 'TRANSACTION_SERVICE', 0
|
203
|
+
|
204
|
+
xml.target!
|
205
|
+
end
|
206
|
+
|
207
|
+
#########################################################################
|
208
|
+
# FUNCTIONS RELATED TO BUILDING THE XML
|
209
|
+
#########################################################################
|
210
|
+
def add_credit_card(xml, creditcard)
|
211
|
+
xml.tag!("CARD") do
|
212
|
+
xml.tag! 'CARDCODE', creditcard.verification_value if creditcard.verification_value?
|
213
|
+
xml.tag! 'CARDNUMBER', creditcard.number
|
214
|
+
xml.tag! 'EXPDATE', expdate(creditcard)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def expdate(creditcard)
|
219
|
+
year = sprintf("%.4i", creditcard.year)
|
220
|
+
month = sprintf("%.2i", creditcard.month)
|
221
|
+
|
222
|
+
"#{month}#{year[-2..-1]}"
|
223
|
+
end
|
224
|
+
|
225
|
+
def add_customer_data(xml, options)
|
226
|
+
if options.has_key? :customer
|
227
|
+
xml.tag! 'CUSTOMERID', options[:customer]
|
228
|
+
end
|
229
|
+
|
230
|
+
if options.has_key? :ip
|
231
|
+
xml.tag! 'CUSTOMERIP', options[:ip]
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def add_address(xml, creditcard, options)
|
236
|
+
|
237
|
+
if address = options[:billing_address] || options[:address]
|
238
|
+
xml.tag!("CUSTOMER_BILL") do
|
239
|
+
xml.tag! 'ADDRESS', address[:address1].to_s
|
240
|
+
xml.tag! 'CITY', address[:city].to_s
|
241
|
+
xml.tag! 'COMPANY', address[:company].to_s
|
242
|
+
xml.tag! 'COUNTRY', address[:country].to_s
|
243
|
+
if options.has_key? :email
|
244
|
+
xml.tag! 'EMAIL', options[:email]
|
245
|
+
# xml.tag! 'EMAIL', 'myemail@yahoo.com'
|
246
|
+
xml.tag! 'EMAILRECEIPT', 'FALSE'
|
247
|
+
end
|
248
|
+
xml.tag! 'FIRSTNAME', creditcard.first_name
|
249
|
+
xml.tag! 'LASTNAME', creditcard.last_name
|
250
|
+
xml.tag! 'PHONE', address[:phone].to_s
|
251
|
+
xml.tag! 'STATE', address[:state].blank? ? 'n/a' : address[:state]
|
252
|
+
xml.tag! 'ZIP', address[:zip].to_s
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
if address = options[:shipping_address]
|
257
|
+
xml.tag!("CUSTOMER_SHIP") do
|
258
|
+
xml.tag! 'ADDRESS', address[:address1].to_s
|
259
|
+
xml.tag! 'CITY', address[:city].to_s
|
260
|
+
xml.tag! 'COMPANY', address[:company].to_s
|
261
|
+
xml.tag! 'COUNTRY', address[:country].to_s
|
262
|
+
xml.tag! 'FIRSTNAME', address[:first_name].to_s
|
263
|
+
xml.tag! 'LASTNAME', address[:last_name].to_s
|
264
|
+
xml.tag! 'STATE', address[:state].blank? ? 'n/a' : address[:state]
|
265
|
+
xml.tag! 'ZIP', address[:zip].to_s
|
266
|
+
end
|
267
|
+
else
|
268
|
+
xml.tag!('CUSTOMER_SHIP', NIL_ATTRIBUTE) do
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
def add_invoice(xml, options)
|
275
|
+
xml.tag! 'INVOICEDESC', options[:description]
|
276
|
+
xml.tag! 'INVOICENUM', 'inv-8'
|
277
|
+
end
|
278
|
+
|
279
|
+
def add_merchant_key(xml, options)
|
280
|
+
xml.tag!("MERCHANT_KEY") do
|
281
|
+
xml.tag! 'GROUPID', 0
|
282
|
+
xml.tag! 'SECUREKEY', @options[:password]
|
283
|
+
xml.tag! 'SECURENETID', @options[:login]
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
#########################################################################
|
288
|
+
# FUNCTIONS RELATED TO THE RESPONSE
|
289
|
+
#########################################################################
|
290
|
+
def success?(response)
|
291
|
+
response[:response_code].to_i == APPROVED
|
292
|
+
end
|
293
|
+
|
294
|
+
def message_from(response)
|
295
|
+
if response[:response_code].to_i == DECLINED
|
296
|
+
return CVVResult.messages[ response[:card_code_response_code] ] if CARD_CODE_ERRORS.include?(response[:card_code_response_code])
|
297
|
+
return AVSResult.messages[ response[:avs_result_code] ] if AVS_ERRORS.include?(response[:avs_result_code])
|
298
|
+
end
|
299
|
+
|
300
|
+
return response[:response_reason_text].nil? ? '' : response[:response_reason_text][0..-1]
|
301
|
+
end
|
302
|
+
|
303
|
+
def parse(xml)
|
304
|
+
response = {}
|
305
|
+
xml = REXML::Document.new(xml)
|
306
|
+
root = REXML::XPath.first(xml, "//GATEWAYRESPONSE")# ||
|
307
|
+
# root = REXML::XPath.first(xml, "//ProcessTransactionResponse")# ||
|
308
|
+
# REXML::XPath.first(xml, "//ErrorResponse")
|
309
|
+
if root
|
310
|
+
root.elements.to_a.each do |node|
|
311
|
+
recurring_parse_element(response, node)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
response
|
316
|
+
end
|
317
|
+
|
318
|
+
def recurring_parse_element(response, node)
|
319
|
+
if node.has_elements?
|
320
|
+
node.elements.each{|e| recurring_parse_element(response, e) }
|
321
|
+
else
|
322
|
+
response[node.name.underscore.to_sym] = node.text
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/authorize_net'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class SecurePayGateway < AuthorizeNetGateway
|
6
|
+
self.live_url = self.test_url = 'https://www.securepay.com/AuthSpayAdapter/process.aspx'
|
7
|
+
|
8
|
+
self.homepage_url = 'http://www.securepay.com/'
|
9
|
+
self.display_name = 'SecurePay'
|
10
|
+
|
11
|
+
# Limit support to purchase() for the time being
|
12
|
+
# JRuby chokes here
|
13
|
+
# undef_method :authorize, :capture, :void, :credit
|
14
|
+
|
15
|
+
undef_method :authorize
|
16
|
+
undef_method :capture
|
17
|
+
undef_method :void
|
18
|
+
undef_method :credit
|
19
|
+
|
20
|
+
def test?
|
21
|
+
Base.gateway_mode == :test
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def split(response)
|
26
|
+
response.split(',')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class SecurePayAuGateway < Gateway
|
6
|
+
API_VERSION = 'xml-4.2'
|
7
|
+
|
8
|
+
TEST_URL = 'https://www.securepay.com.au/test/payment'
|
9
|
+
LIVE_URL = 'https://www.securepay.com.au/xmlapi/payment'
|
10
|
+
|
11
|
+
self.supported_countries = ['AU']
|
12
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
|
13
|
+
|
14
|
+
# The homepage URL of the gateway
|
15
|
+
self.homepage_url = 'http://securepay.com.au'
|
16
|
+
|
17
|
+
# The name of the gateway
|
18
|
+
self.display_name = 'SecurePay'
|
19
|
+
|
20
|
+
class_attribute :request_timeout
|
21
|
+
self.request_timeout = 60
|
22
|
+
|
23
|
+
self.money_format = :cents
|
24
|
+
self.default_currency = 'AUD'
|
25
|
+
|
26
|
+
# 0 Standard Payment
|
27
|
+
# 4 Refund
|
28
|
+
# 6 Client Reversal (Void)
|
29
|
+
# 10 Preauthorise
|
30
|
+
# 11 Preauth Complete (Advice)
|
31
|
+
TRANSACTIONS = {
|
32
|
+
:purchase => 0,
|
33
|
+
:authorization => 10,
|
34
|
+
:capture => 11,
|
35
|
+
:void => 6,
|
36
|
+
:refund => 4
|
37
|
+
}
|
38
|
+
|
39
|
+
SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]
|
40
|
+
|
41
|
+
def initialize(options = {})
|
42
|
+
requires!(options, :login, :password)
|
43
|
+
@options = options
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def test?
|
48
|
+
@options[:test] || super
|
49
|
+
end
|
50
|
+
|
51
|
+
def purchase(money, credit_card, options = {})
|
52
|
+
requires!(options, :order_id)
|
53
|
+
commit :purchase, build_purchase_request(money, credit_card, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def authorize(money, credit_card, options = {})
|
57
|
+
requires!(options, :order_id)
|
58
|
+
commit :authorization, build_purchase_request(money, credit_card, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def capture(money, reference, options = {})
|
62
|
+
commit :capture, build_reference_request(money, reference)
|
63
|
+
end
|
64
|
+
|
65
|
+
def refund(money, reference, options = {})
|
66
|
+
commit :refund, build_reference_request(money, reference)
|
67
|
+
end
|
68
|
+
|
69
|
+
def credit(money, reference, options = {})
|
70
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
71
|
+
refund(money, reference)
|
72
|
+
end
|
73
|
+
|
74
|
+
def void(reference, options = {})
|
75
|
+
commit :void, build_reference_request(nil, reference)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def build_purchase_request(money, credit_card, options)
|
81
|
+
xml = Builder::XmlMarkup.new
|
82
|
+
|
83
|
+
xml.tag! 'amount', amount(money)
|
84
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
85
|
+
xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
|
86
|
+
|
87
|
+
xml.tag! 'CreditCardInfo' do
|
88
|
+
xml.tag! 'cardNumber', credit_card.number
|
89
|
+
xml.tag! 'expiryDate', expdate(credit_card)
|
90
|
+
xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
|
91
|
+
end
|
92
|
+
|
93
|
+
xml.target!
|
94
|
+
end
|
95
|
+
|
96
|
+
def build_reference_request(money, reference)
|
97
|
+
xml = Builder::XmlMarkup.new
|
98
|
+
|
99
|
+
transaction_id, order_id, preauth_id, original_amount = reference.split("*")
|
100
|
+
xml.tag! 'amount', (money ? amount(money) : original_amount)
|
101
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
102
|
+
xml.tag! 'txnID', transaction_id
|
103
|
+
xml.tag! 'purchaseOrderNo', order_id
|
104
|
+
xml.tag! 'preauthID', preauth_id
|
105
|
+
|
106
|
+
xml.target!
|
107
|
+
end
|
108
|
+
|
109
|
+
def build_request(action, body)
|
110
|
+
xml = Builder::XmlMarkup.new
|
111
|
+
xml.instruct!
|
112
|
+
xml.tag! 'SecurePayMessage' do
|
113
|
+
xml.tag! 'MessageInfo' do
|
114
|
+
xml.tag! 'messageID', Utils.generate_unique_id.slice(0, 30)
|
115
|
+
xml.tag! 'messageTimestamp', generate_timestamp
|
116
|
+
xml.tag! 'timeoutValue', request_timeout
|
117
|
+
xml.tag! 'apiVersion', API_VERSION
|
118
|
+
end
|
119
|
+
|
120
|
+
xml.tag! 'MerchantInfo' do
|
121
|
+
xml.tag! 'merchantID', @options[:login]
|
122
|
+
xml.tag! 'password', @options[:password]
|
123
|
+
end
|
124
|
+
|
125
|
+
xml.tag! 'RequestType', 'Payment'
|
126
|
+
xml.tag! 'Payment' do
|
127
|
+
xml.tag! 'TxnList', "count" => 1 do
|
128
|
+
xml.tag! 'Txn', "ID" => 1 do
|
129
|
+
xml.tag! 'txnType', TRANSACTIONS[action]
|
130
|
+
xml.tag! 'txnSource', 23
|
131
|
+
xml << body
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
xml.target!
|
138
|
+
end
|
139
|
+
|
140
|
+
def commit(action, request)
|
141
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, build_request(action, request)))
|
142
|
+
|
143
|
+
Response.new(success?(response), message_from(response), response,
|
144
|
+
:test => test?,
|
145
|
+
:authorization => authorization_from(response)
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
def success?(response)
|
150
|
+
SUCCESS_CODES.include?(response[:response_code])
|
151
|
+
end
|
152
|
+
|
153
|
+
def authorization_from(response)
|
154
|
+
[response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*')
|
155
|
+
end
|
156
|
+
|
157
|
+
def message_from(response)
|
158
|
+
response[:response_text] || response[:status_description]
|
159
|
+
end
|
160
|
+
|
161
|
+
def expdate(credit_card)
|
162
|
+
"#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
|
163
|
+
end
|
164
|
+
|
165
|
+
def parse(body)
|
166
|
+
xml = REXML::Document.new(body)
|
167
|
+
|
168
|
+
response = {}
|
169
|
+
|
170
|
+
xml.root.elements.to_a.each do |node|
|
171
|
+
parse_element(response, node)
|
172
|
+
end
|
173
|
+
|
174
|
+
response
|
175
|
+
end
|
176
|
+
|
177
|
+
def parse_element(response, node)
|
178
|
+
if node.has_elements?
|
179
|
+
node.elements.each{|element| parse_element(response, element) }
|
180
|
+
else
|
181
|
+
response[node.name.underscore.to_sym] = node.text
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# YYYYDDMMHHNNSSKKK000sOOO
|
186
|
+
def generate_timestamp
|
187
|
+
time = Time.now.utc
|
188
|
+
time.strftime("%Y%d%m%H%M%S#{time.usec}+000")
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|