activemerchant-nsp 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +952 -0
- data/CONTRIBUTORS +347 -0
- data/MIT-LICENSE +20 -0
- data/README.md +204 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +56 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +274 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +143 -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 +176 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -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 +137 -0
- data/lib/active_merchant/billing/gateways/epay.rb +276 -0
- data/lib/active_merchant/billing/gateways/eway.rb +287 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -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 +252 -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 +257 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
- data/lib/active_merchant/billing/gateways/litle.rb +290 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
- data/lib/active_merchant/billing/gateways/migs.rb +263 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -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 +196 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -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_express.rb +224 -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 +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
- data/lib/active_merchant/billing/gateways/payway.rb +214 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -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 +297 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/realex.rb +313 -0
- data/lib/active_merchant/billing/gateways/sage.rb +148 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +121 -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 +284 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -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/chronopay.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/direc_pay.rb +41 -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/directebanking.rb +47 -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/dotpay.rb +22 -0
- data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
- data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
- data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
- data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
- data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/epay.rb +21 -0
- data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
- data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
- data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
- data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
- data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -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/helper.rb +117 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -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/maksuturva.rb +86 -0
- data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
- data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -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/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
- data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
- data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
- data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
- data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
- data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
- data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
- data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -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 +129 -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/two_checkout.rb +44 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -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 +97 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
- data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
- data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +27 -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/response.rb +64 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +65 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +482 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
# Gateway for netregistry.com.au.
|
4
|
+
#
|
5
|
+
# Note that NetRegistry itself uses gateway service providers. At the
|
6
|
+
# time of this writing, there are at least two (Quest and Ingenico).
|
7
|
+
# This module has only been tested with Quest.
|
8
|
+
#
|
9
|
+
# Also note that NetRegistry does not offer a test mode, nor does it
|
10
|
+
# have support for the authorize/capture/void functionality by default
|
11
|
+
# (you may arrange for this as described in "Programming for
|
12
|
+
# NetRegistry's E-commerce Gateway." [http://rubyurl.com/hNG]), and no
|
13
|
+
# #void functionality is documented. As a result, the #authorize and
|
14
|
+
# #capture have not yet been tested through a live gateway, and #void
|
15
|
+
# will raise an error.
|
16
|
+
#
|
17
|
+
# If you have this functionality enabled, please consider contributing
|
18
|
+
# to ActiveMerchant by writing tests/code for these methods, and
|
19
|
+
# submitting a patch.
|
20
|
+
#
|
21
|
+
# In addition to the standard ActiveMerchant functionality, the
|
22
|
+
# response will contain a 'receipt' parameter
|
23
|
+
# (response.params['receipt']) if a receipt was issued by the gateway.
|
24
|
+
class NetRegistryGateway < Gateway
|
25
|
+
self.live_url = self.test_url = 'https://4tknox.au.com/cgi-bin/themerchant.au.com/ecom/external2.pl'
|
26
|
+
|
27
|
+
FILTERED_PARAMS = [ 'card_no', 'card_expiry', 'receipt_array' ]
|
28
|
+
|
29
|
+
self.supported_countries = ['AU']
|
30
|
+
|
31
|
+
# Note that support for Diners, Amex, and JCB require extra
|
32
|
+
# steps in setting up your account, as detailed in
|
33
|
+
# "Programming for NetRegistry's E-commerce Gateway."
|
34
|
+
# [http://rubyurl.com/hNG]
|
35
|
+
self.supported_cardtypes = [:visa, :master, :diners_club, :american_express, :jcb]
|
36
|
+
self.display_name = 'NetRegistry'
|
37
|
+
self.homepage_url = 'http://www.netregistry.com.au'
|
38
|
+
|
39
|
+
TRANSACTIONS = {
|
40
|
+
:authorization => 'preauth',
|
41
|
+
:purchase => 'purchase',
|
42
|
+
:capture => 'completion',
|
43
|
+
:status => 'status',
|
44
|
+
:credit => 'refund'
|
45
|
+
}
|
46
|
+
|
47
|
+
# Create a new NetRegistry gateway.
|
48
|
+
#
|
49
|
+
# Options :login and :password must be given.
|
50
|
+
def initialize(options = {})
|
51
|
+
requires!(options, :login, :password)
|
52
|
+
@options = options
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
# Note that #authorize and #capture only work if your account
|
57
|
+
# vendor is St George, and if your account has been setup as
|
58
|
+
# described in "Programming for NetRegistry's E-commerce
|
59
|
+
# Gateway." [http://rubyurl.com/hNG]
|
60
|
+
def authorize(money, credit_card, options = {})
|
61
|
+
params = {
|
62
|
+
'AMOUNT' => amount(money),
|
63
|
+
'CCNUM' => credit_card.number,
|
64
|
+
'CCEXP' => expiry(credit_card)
|
65
|
+
}
|
66
|
+
add_request_details(params, options)
|
67
|
+
commit(:authorization, params)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Note that #authorize and #capture only work if your account
|
71
|
+
# vendor is St George, and if your account has been setup as
|
72
|
+
# described in "Programming for NetRegistry's E-commerce
|
73
|
+
# Gateway." [http://rubyurl.com/hNG]
|
74
|
+
def capture(money, authorization, options = {})
|
75
|
+
requires!(options, :credit_card)
|
76
|
+
credit_card = options[:credit_card]
|
77
|
+
|
78
|
+
params = {
|
79
|
+
'PREAUTHNUM' => authorization,
|
80
|
+
'AMOUNT' => amount(money),
|
81
|
+
'CCNUM' => credit_card.number,
|
82
|
+
'CCEXP' => expiry(credit_card)
|
83
|
+
}
|
84
|
+
add_request_details(params, options)
|
85
|
+
commit(:capture, params)
|
86
|
+
end
|
87
|
+
|
88
|
+
def purchase(money, credit_card, options = {})
|
89
|
+
params = {
|
90
|
+
'AMOUNT' => amount(money),
|
91
|
+
'CCNUM' => credit_card.number,
|
92
|
+
'CCEXP' => expiry(credit_card)
|
93
|
+
}
|
94
|
+
add_request_details(params, options)
|
95
|
+
commit(:purchase, params)
|
96
|
+
end
|
97
|
+
|
98
|
+
def credit(money, identification, options = {})
|
99
|
+
params = {
|
100
|
+
'AMOUNT' => amount(money),
|
101
|
+
'TXNREF' => identification
|
102
|
+
}
|
103
|
+
add_request_details(params, options)
|
104
|
+
commit(:credit, params)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Specific to NetRegistry.
|
108
|
+
#
|
109
|
+
# Run a 'status' command. This lets you view the status of a
|
110
|
+
# completed transaction.
|
111
|
+
#
|
112
|
+
def status(identification)
|
113
|
+
params = {
|
114
|
+
'TXNREF' => identification
|
115
|
+
}
|
116
|
+
|
117
|
+
commit(:status, params)
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
def add_request_details(params, options)
|
122
|
+
params['COMMENT'] = options[:description] unless options[:description].blank?
|
123
|
+
end
|
124
|
+
|
125
|
+
# Return the expiry for the given creditcard in the required
|
126
|
+
# format for a command.
|
127
|
+
def expiry(credit_card)
|
128
|
+
month = format(credit_card.month, :two_digits)
|
129
|
+
year = format(credit_card.year , :two_digits)
|
130
|
+
"#{month}/#{year}"
|
131
|
+
end
|
132
|
+
|
133
|
+
# Post the a request with the given parameters and return the
|
134
|
+
# response object.
|
135
|
+
#
|
136
|
+
# Login and password are added automatically, and the comment is
|
137
|
+
# omitted if nil.
|
138
|
+
def commit(action, params)
|
139
|
+
# get gateway response
|
140
|
+
response = parse( ssl_post(self.live_url, post_data(action, params)) )
|
141
|
+
|
142
|
+
Response.new(response['status'] == 'approved', message_from(response), response,
|
143
|
+
:authorization => authorization_from(response, action)
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
def post_data(action, params)
|
148
|
+
params['COMMAND'] = TRANSACTIONS[action]
|
149
|
+
params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}"
|
150
|
+
URI.encode(params.map{|k,v| "#{k}=#{v}"}.join('&'))
|
151
|
+
end
|
152
|
+
|
153
|
+
def parse(response)
|
154
|
+
params = {}
|
155
|
+
|
156
|
+
lines = response.split("\n")
|
157
|
+
|
158
|
+
# Just incase there is no real response returned
|
159
|
+
params['status'] = lines[0]
|
160
|
+
params['response_text'] = lines[1]
|
161
|
+
|
162
|
+
started = false
|
163
|
+
lines.each do |line|
|
164
|
+
if started
|
165
|
+
key, val = line.chomp.split(/=/, 2)
|
166
|
+
params[key] = val unless FILTERED_PARAMS.include?(key)
|
167
|
+
end
|
168
|
+
|
169
|
+
started = line.chomp =~ /^\.$/ unless started
|
170
|
+
end
|
171
|
+
|
172
|
+
params
|
173
|
+
end
|
174
|
+
|
175
|
+
def message_from(response)
|
176
|
+
response['response_text']
|
177
|
+
end
|
178
|
+
|
179
|
+
def authorization_from(response, command)
|
180
|
+
case command
|
181
|
+
when :purchase
|
182
|
+
response['txn_ref']
|
183
|
+
when :authorization
|
184
|
+
response['transaction_no']
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class NetaxeptGateway < Gateway
|
6
|
+
self.test_url = 'https://epayment-test.bbs.no/'
|
7
|
+
self.live_url = 'https://epayment.bbs.no/'
|
8
|
+
|
9
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
10
|
+
self.supported_countries = ['NO', 'DK', 'SE', 'FI']
|
11
|
+
|
12
|
+
# The card types supported by the payment gateway
|
13
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
14
|
+
|
15
|
+
# The homepage URL of the gateway
|
16
|
+
self.homepage_url = 'http://www.betalingsterminal.no/Netthandel-forside/'
|
17
|
+
|
18
|
+
# The name of the gateway
|
19
|
+
self.display_name = 'BBS Netaxept'
|
20
|
+
|
21
|
+
self.money_format = :cents
|
22
|
+
|
23
|
+
self.default_currency = 'NOK'
|
24
|
+
|
25
|
+
def initialize(options = {})
|
26
|
+
requires!(options, :login, :password)
|
27
|
+
@options = options
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def purchase(money, creditcard, options = {})
|
32
|
+
requires!(options, :order_id)
|
33
|
+
|
34
|
+
post = {}
|
35
|
+
add_credentials(post, options)
|
36
|
+
add_transaction(post, options)
|
37
|
+
add_order(post, money, options)
|
38
|
+
add_creditcard(post, creditcard)
|
39
|
+
commit('Sale', post)
|
40
|
+
end
|
41
|
+
|
42
|
+
def authorize(money, creditcard, options = {})
|
43
|
+
requires!(options, :order_id)
|
44
|
+
|
45
|
+
post = {}
|
46
|
+
add_credentials(post, options)
|
47
|
+
add_transaction(post, options)
|
48
|
+
add_order(post, money, options)
|
49
|
+
add_creditcard(post, creditcard)
|
50
|
+
commit('Auth', post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
post = {}
|
55
|
+
add_credentials(post, options)
|
56
|
+
add_authorization(post, authorization, money)
|
57
|
+
commit('Capture', post, false)
|
58
|
+
end
|
59
|
+
|
60
|
+
def refund(money, authorization, options = {})
|
61
|
+
post = {}
|
62
|
+
add_credentials(post, options)
|
63
|
+
add_authorization(post, authorization, money)
|
64
|
+
commit('Credit', post, false)
|
65
|
+
end
|
66
|
+
|
67
|
+
def credit(money, authorization, options = {})
|
68
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
69
|
+
refund(money, authorization, options)
|
70
|
+
end
|
71
|
+
|
72
|
+
def void(authorization, options = {})
|
73
|
+
post = {}
|
74
|
+
add_credentials(post, options)
|
75
|
+
add_authorization(post, authorization)
|
76
|
+
commit('Annul', post, false)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test?
|
80
|
+
@options[:test] || Base.gateway_mode == :test
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def add_credentials(post, options)
|
87
|
+
post[:merchantId] = @options[:login]
|
88
|
+
post[:token] = @options[:password]
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_authorization(post, authorization, money=nil)
|
92
|
+
post[:transactionId] = authorization
|
93
|
+
post[:transactionAmount] = amount(money) if money
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_transaction(post, options)
|
97
|
+
post[:transactionId] = generate_transaction_id(options)
|
98
|
+
post[:serviceType] = 'M'
|
99
|
+
post[:redirectUrl] = 'http://example.com'
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_order(post, money, options)
|
103
|
+
post[:orderNumber] = options[:order_id]
|
104
|
+
post[:amount] = amount(money)
|
105
|
+
post[:currencyCode] = (options[:currency] || currency(money))
|
106
|
+
end
|
107
|
+
|
108
|
+
CARD_TYPE_PREFIXES = {
|
109
|
+
'visa' => 'v',
|
110
|
+
'master' => 'm',
|
111
|
+
'american_express' => 'a',
|
112
|
+
}
|
113
|
+
def add_creditcard(post, creditcard)
|
114
|
+
brand = Gateway.card_brand(creditcard)
|
115
|
+
prefix = CARD_TYPE_PREFIXES[brand]
|
116
|
+
unless prefix
|
117
|
+
raise ArgumentError.new("Card type #{brand} not supported.")
|
118
|
+
end
|
119
|
+
|
120
|
+
post[:creditcard] = {}
|
121
|
+
post[:creditcard][:"#{prefix}a"] = creditcard.number
|
122
|
+
post[:creditcard][:"#{prefix}m"] = format(creditcard.month, :two_digits)
|
123
|
+
post[:creditcard][:"#{prefix}y"] = format(creditcard.year, :two_digits)
|
124
|
+
post[:creditcard][:"#{prefix}c"] = creditcard.verification_value
|
125
|
+
end
|
126
|
+
|
127
|
+
def commit(action, parameters, setup=true)
|
128
|
+
parameters[:action] = action
|
129
|
+
|
130
|
+
response = {:success => false}
|
131
|
+
|
132
|
+
catch(:exception) do
|
133
|
+
if setup
|
134
|
+
commit_transaction_setup(response, parameters)
|
135
|
+
commit_payment_details(response, parameters)
|
136
|
+
commit_process_setup(response, parameters)
|
137
|
+
end
|
138
|
+
commit_transaction(response, parameters)
|
139
|
+
response[:success] = true
|
140
|
+
end
|
141
|
+
|
142
|
+
Response.new(response[:success], response[:message], response, :test => test?, :authorization => response[:authorization])
|
143
|
+
end
|
144
|
+
|
145
|
+
def commit_transaction_setup(response, parameters)
|
146
|
+
response[:setup] = parse(ssl_get(build_url("REST/Setup.aspx", pick(parameters, :merchantId, :token, :serviceType, :amount, :currencyCode, :redirectUrl, :orderNumber, :transactionId))))
|
147
|
+
process(response, :setup)
|
148
|
+
end
|
149
|
+
|
150
|
+
def commit_payment_details(response, parameters)
|
151
|
+
data = encode(parameters[:creditcard].merge(:BBSePay_transaction => response[:setup]['SetupString']))
|
152
|
+
response[:paymentDetails] = parse(ssl_post(build_url("terminal/default.aspx"), data), false)
|
153
|
+
process(response, :paymentDetails)
|
154
|
+
end
|
155
|
+
|
156
|
+
def commit_process_setup(response, parameters)
|
157
|
+
result = ssl_get(build_url("REST/ProcessSetup.aspx", pick(parameters, :merchantId, :token, :transactionId).merge(:transactionString => response[:paymentDetails][:result])))
|
158
|
+
response[:processSetup] = parse(result)
|
159
|
+
process(response, :processSetup)
|
160
|
+
end
|
161
|
+
|
162
|
+
def commit_transaction(response, parameters)
|
163
|
+
result = ssl_get(build_url("REST/#{parameters[:action]}.aspx", pick(parameters, :merchantId, :token, :transactionId, :transactionAmount)))
|
164
|
+
response[:action] = parse(result)
|
165
|
+
process(response, :action)
|
166
|
+
end
|
167
|
+
|
168
|
+
def process(response, step)
|
169
|
+
if response[step][:container] =~ /Exception|Error/
|
170
|
+
response[:message] = response[step]['Message']
|
171
|
+
throw :exception
|
172
|
+
else
|
173
|
+
message = (response[step]['ResponseText'] || response[step]['ResponseCode'])
|
174
|
+
response[:message] = (message || response[:message])
|
175
|
+
|
176
|
+
response[:authorization] = response[step]['TransactionId']
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def parse(result, expects_xml=true)
|
181
|
+
if expects_xml || /^</ =~ result
|
182
|
+
doc = REXML::Document.new(result)
|
183
|
+
extract_xml(doc.root).merge(:container => doc.root.name)
|
184
|
+
else
|
185
|
+
{:result => result}
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def extract_xml(element)
|
190
|
+
if element.has_elements?
|
191
|
+
hash = {}
|
192
|
+
element.elements.each do |e|
|
193
|
+
hash[e.name] = extract_xml(e)
|
194
|
+
end
|
195
|
+
hash
|
196
|
+
else
|
197
|
+
element.text
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def url
|
202
|
+
(test? ? self.test_url : self.live_url)
|
203
|
+
end
|
204
|
+
|
205
|
+
def generate_transaction_id(options)
|
206
|
+
Digest::MD5.hexdigest("#{options.inspect}+#{Time.now}+#{rand}")
|
207
|
+
end
|
208
|
+
|
209
|
+
def pick(hash, *keys)
|
210
|
+
keys.inject({}){|h,key| h[key] = hash[key] if hash[key]; h}
|
211
|
+
end
|
212
|
+
|
213
|
+
def build_url(base, parameters=nil)
|
214
|
+
url = "#{test? ? self.test_url : self.live_url}"
|
215
|
+
url << base
|
216
|
+
if parameters
|
217
|
+
url << '?'
|
218
|
+
url << encode(parameters)
|
219
|
+
end
|
220
|
+
url
|
221
|
+
end
|
222
|
+
|
223
|
+
def encode(hash)
|
224
|
+
hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
|
225
|
+
end
|
226
|
+
|
227
|
+
class Response < Billing::Response
|
228
|
+
attr_reader :error_detail
|
229
|
+
def initialize(success, message, raw, options)
|
230
|
+
super
|
231
|
+
unless success
|
232
|
+
@error_detail = raw[:processSetup]['Result']['ResponseText'] if raw[:processSetup] && raw[:processSetup]['Result']
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class NetbillingGateway < Gateway
|
4
|
+
self.live_url = self.test_url = 'https://secure.netbilling.com:1402/gw/sas/direct3.1'
|
5
|
+
|
6
|
+
TRANSACTIONS = {
|
7
|
+
:authorization => 'A',
|
8
|
+
:purchase => 'S',
|
9
|
+
:refund => 'R',
|
10
|
+
:credit => 'C',
|
11
|
+
:capture => 'D',
|
12
|
+
:void => 'U'
|
13
|
+
}
|
14
|
+
|
15
|
+
SUCCESS_CODES = [ '1', 'T' ]
|
16
|
+
SUCCESS_MESSAGE = 'The transaction was approved'
|
17
|
+
FAILURE_MESSAGE = 'The transaction failed'
|
18
|
+
TEST_LOGIN = '104901072025'
|
19
|
+
|
20
|
+
self.display_name = 'NETbilling'
|
21
|
+
self.homepage_url = 'http://www.netbilling.com'
|
22
|
+
self.supported_countries = ['US']
|
23
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
24
|
+
|
25
|
+
def initialize(options = {})
|
26
|
+
requires!(options, :login)
|
27
|
+
@options = options
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def authorize(money, credit_card, options = {})
|
32
|
+
post = {}
|
33
|
+
add_amount(post, money)
|
34
|
+
add_invoice(post, options)
|
35
|
+
add_credit_card(post, credit_card)
|
36
|
+
add_address(post, credit_card, options)
|
37
|
+
add_customer_data(post, options)
|
38
|
+
|
39
|
+
commit(:authorization, post)
|
40
|
+
end
|
41
|
+
|
42
|
+
def purchase(money, credit_card, options = {})
|
43
|
+
post = {}
|
44
|
+
add_amount(post, money)
|
45
|
+
add_invoice(post, options)
|
46
|
+
add_credit_card(post, credit_card)
|
47
|
+
add_address(post, credit_card, options)
|
48
|
+
add_customer_data(post, options)
|
49
|
+
|
50
|
+
commit(:purchase, post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
post = {}
|
55
|
+
add_reference(post, authorization)
|
56
|
+
commit(:capture, post)
|
57
|
+
end
|
58
|
+
|
59
|
+
def refund(money, source, options = {})
|
60
|
+
post = {}
|
61
|
+
add_amount(post, money)
|
62
|
+
add_reference(post, source)
|
63
|
+
commit(:refund, post)
|
64
|
+
end
|
65
|
+
|
66
|
+
def credit(money, credit_card, options = {})
|
67
|
+
post = {}
|
68
|
+
add_amount(post, money)
|
69
|
+
add_invoice(post, options)
|
70
|
+
add_credit_card(post, credit_card)
|
71
|
+
add_address(post, credit_card, options)
|
72
|
+
add_customer_data(post, options)
|
73
|
+
|
74
|
+
commit(:credit, post)
|
75
|
+
end
|
76
|
+
|
77
|
+
def void(source, options = {})
|
78
|
+
post = {}
|
79
|
+
add_reference(post, source)
|
80
|
+
commit(:void, post)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test?
|
84
|
+
@options[:login] == TEST_LOGIN || super
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def add_amount(post, money)
|
89
|
+
post[:amount] = amount(money)
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_reference(post, reference)
|
93
|
+
post[:orig_id] = reference
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_customer_data(post, options)
|
97
|
+
post[:cust_email] = options[:email]
|
98
|
+
post[:cust_ip] = options[:ip]
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_address(post, credit_card, options)
|
102
|
+
if billing_address = options[:billing_address] || options[:address]
|
103
|
+
post[:bill_street] = billing_address[:address1]
|
104
|
+
post[:cust_phone] = billing_address[:phone]
|
105
|
+
post[:bill_zip] = billing_address[:zip]
|
106
|
+
post[:bill_city] = billing_address[:city]
|
107
|
+
post[:bill_country] = billing_address[:country]
|
108
|
+
post[:bill_state] = billing_address[:state]
|
109
|
+
end
|
110
|
+
|
111
|
+
if shipping_address = options[:shipping_address]
|
112
|
+
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
113
|
+
|
114
|
+
post[:ship_name1] = first_name
|
115
|
+
post[:ship_name2] = last_name
|
116
|
+
post[:ship_street] = shipping_address[:address1]
|
117
|
+
post[:ship_zip] = shipping_address[:zip]
|
118
|
+
post[:ship_city] = shipping_address[:city]
|
119
|
+
post[:ship_country] = shipping_address[:country]
|
120
|
+
post[:ship_state] = shipping_address[:state]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_invoice(post, options)
|
125
|
+
post[:description] = options[:description]
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_credit_card(post, credit_card)
|
129
|
+
post[:bill_name1] = credit_card.first_name
|
130
|
+
post[:bill_name2] = credit_card.last_name
|
131
|
+
post[:card_number] = credit_card.number
|
132
|
+
post[:card_expire] = expdate(credit_card)
|
133
|
+
post[:card_cvv2] = credit_card.verification_value
|
134
|
+
end
|
135
|
+
|
136
|
+
def parse(body)
|
137
|
+
results = {}
|
138
|
+
body.split(/&/).each do |pair|
|
139
|
+
key,val = pair.split(/\=/)
|
140
|
+
results[key.to_sym] = CGI.unescape(val)
|
141
|
+
end
|
142
|
+
results
|
143
|
+
end
|
144
|
+
|
145
|
+
def commit(action, parameters)
|
146
|
+
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
|
147
|
+
|
148
|
+
Response.new(success?(response), message_from(response), response,
|
149
|
+
:test => test_response?(response),
|
150
|
+
:authorization => response[:trans_id],
|
151
|
+
:avs_result => { :code => response[:avs_code]},
|
152
|
+
:cvv_result => response[:cvv2_code]
|
153
|
+
)
|
154
|
+
rescue ActiveMerchant::ResponseError => e
|
155
|
+
raise unless(e.response.code =~ /^[67]\d\d$/)
|
156
|
+
return Response.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_response?(response)
|
160
|
+
!!(test? || response[:auth_msg] =~ /TEST/)
|
161
|
+
end
|
162
|
+
|
163
|
+
def success?(response)
|
164
|
+
SUCCESS_CODES.include?(response[:status_code])
|
165
|
+
end
|
166
|
+
|
167
|
+
def message_from(response)
|
168
|
+
success?(response) ? SUCCESS_MESSAGE : (response[:auth_msg] || FAILURE_MESSAGE)
|
169
|
+
end
|
170
|
+
|
171
|
+
def expdate(credit_card)
|
172
|
+
year = sprintf("%.4i", credit_card.year)
|
173
|
+
month = sprintf("%.2i", credit_card.month)
|
174
|
+
|
175
|
+
"#{month}#{year[-2..-1]}"
|
176
|
+
end
|
177
|
+
|
178
|
+
def post_data(action, parameters = {})
|
179
|
+
parameters[:account_id] = @options[:login]
|
180
|
+
parameters[:pay_type] = 'C'
|
181
|
+
parameters[:tran_type] = TRANSACTIONS[action]
|
182
|
+
|
183
|
+
parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
184
|
+
end
|
185
|
+
|
186
|
+
def parse_first_and_last_name(value)
|
187
|
+
name = value.to_s.split(' ')
|
188
|
+
|
189
|
+
last_name = name.pop || ''
|
190
|
+
first_name = name.join(' ')
|
191
|
+
[ first_name, last_name ]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|