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,211 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
|
6
|
+
# To learn more about the Moneris (US) gateway, please contact
|
7
|
+
# ussales@moneris.com for a copy of their integration guide. For
|
8
|
+
# information on remote testing, please see "Test Environment Penny Value
|
9
|
+
# Response Table", and "Test Environment eFraud (AVS and CVD) Penny
|
10
|
+
# Response Values", available at Moneris' {eSelect Plus Documentation
|
11
|
+
# Centre}[https://www3.moneris.com/connect/en/documents/index.html].
|
12
|
+
class MonerisUsGateway < Gateway
|
13
|
+
self.test_url = 'https://esplusqa.moneris.com/gateway_us/servlet/MpgRequest'
|
14
|
+
self.live_url = 'https://esplus.moneris.com/gateway_us/servlet/MpgRequest'
|
15
|
+
|
16
|
+
self.supported_countries = ['US']
|
17
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover]
|
18
|
+
self.homepage_url = 'http://www.monerisusa.com/'
|
19
|
+
self.display_name = 'Moneris (US)'
|
20
|
+
|
21
|
+
# login is your Store ID
|
22
|
+
# password is your API Token
|
23
|
+
def initialize(options = {})
|
24
|
+
requires!(options, :login, :password)
|
25
|
+
@options = { :crypt_type => 7 }.update(options)
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
# Referred to as "PreAuth" in the Moneris integration guide, this action
|
30
|
+
# verifies and locks funds on a customer's card, which then must be
|
31
|
+
# captured at a later date.
|
32
|
+
#
|
33
|
+
# Pass in +order_id+ and optionally a +customer+ parameter.
|
34
|
+
def authorize(money, creditcard, options = {})
|
35
|
+
debit_commit 'us_preauth', money, creditcard, options
|
36
|
+
end
|
37
|
+
|
38
|
+
# This action verifies funding on a customer's card, and readies them for
|
39
|
+
# deposit in a merchant's account.
|
40
|
+
#
|
41
|
+
# Pass in <tt>order_id</tt> and optionally a <tt>customer</tt> parameter
|
42
|
+
def purchase(money, creditcard, options = {})
|
43
|
+
debit_commit 'us_purchase', money, creditcard, options
|
44
|
+
end
|
45
|
+
|
46
|
+
# This method retrieves locked funds from a customer's account (from a
|
47
|
+
# PreAuth) and prepares them for deposit in a merchant's account.
|
48
|
+
#
|
49
|
+
# Note: Moneris requires both the order_id and the transaction number of
|
50
|
+
# the original authorization. To maintain the same interface as the other
|
51
|
+
# gateways the two numbers are concatenated together with a ; separator as
|
52
|
+
# the authorization number returned by authorization
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
commit 'us_completion', crediting_params(authorization, :comp_amount => amount(money))
|
55
|
+
end
|
56
|
+
|
57
|
+
# Voiding requires the original transaction ID and order ID of some open
|
58
|
+
# transaction. Closed transactions must be refunded. Note that the only
|
59
|
+
# methods which may be voided are +capture+ and +purchase+.
|
60
|
+
#
|
61
|
+
# Concatenate your transaction number and order_id by using a semicolon
|
62
|
+
# (';'). This is to keep the Moneris interface consistent with other
|
63
|
+
# gateways. (See +capture+ for details.)
|
64
|
+
def void(authorization, options = {})
|
65
|
+
commit 'us_purchasecorrection', crediting_params(authorization)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Performs a refund. This method requires that the original transaction
|
69
|
+
# number and order number be included. Concatenate your transaction
|
70
|
+
# number and order_id by using a semicolon (';'). This is to keep the
|
71
|
+
# Moneris interface consistent with other gateways. (See +capture+ for
|
72
|
+
# details.)
|
73
|
+
def credit(money, authorization, options = {})
|
74
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
75
|
+
refund(money, authorization, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
def refund(money, authorization, options = {})
|
79
|
+
commit 'us_refund', crediting_params(authorization, :amount => amount(money))
|
80
|
+
end
|
81
|
+
|
82
|
+
def test?
|
83
|
+
@options[:test] || super
|
84
|
+
end
|
85
|
+
private # :nodoc: all
|
86
|
+
|
87
|
+
def expdate(creditcard)
|
88
|
+
sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month)
|
89
|
+
end
|
90
|
+
|
91
|
+
def debit_commit(commit_type, money, creditcard, options)
|
92
|
+
requires!(options, :order_id)
|
93
|
+
commit(commit_type, debit_params(money, creditcard, options))
|
94
|
+
end
|
95
|
+
|
96
|
+
# Common params used amongst the +purchase+ and +authorization+ methods
|
97
|
+
def debit_params(money, creditcard, options = {})
|
98
|
+
{
|
99
|
+
:order_id => options[:order_id],
|
100
|
+
:cust_id => options[:customer],
|
101
|
+
:amount => amount(money),
|
102
|
+
:pan => creditcard.number,
|
103
|
+
:expdate => expdate(creditcard),
|
104
|
+
:crypt_type => options[:crypt_type] || @options[:crypt_type]
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
# Common params used amongst the +credit+, +void+ and +capture+ methods
|
109
|
+
def crediting_params(authorization, options = {})
|
110
|
+
{
|
111
|
+
:txn_number => split_authorization(authorization).first,
|
112
|
+
:order_id => split_authorization(authorization).last,
|
113
|
+
:crypt_type => options[:crypt_type] || @options[:crypt_type]
|
114
|
+
}.merge(options)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Splits an +authorization+ param and retrives the order id and
|
118
|
+
# transaction number in that order.
|
119
|
+
def split_authorization(authorization)
|
120
|
+
if authorization.nil? || authorization.empty? || authorization !~ /;/
|
121
|
+
raise ArgumentError, 'You must include a valid authorization code (e.g. "1234;567")'
|
122
|
+
else
|
123
|
+
authorization.split(';')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def commit(action, parameters = {})
|
128
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters)))
|
129
|
+
|
130
|
+
Response.new(successful?(response), message_from(response[:message]), response,
|
131
|
+
:test => test?,
|
132
|
+
:authorization => authorization_from(response)
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
|
137
|
+
def authorization_from(response = {})
|
138
|
+
if response[:trans_id] && response[:receipt_id]
|
139
|
+
"#{response[:trans_id]};#{response[:receipt_id]}"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Tests for a successful response from Moneris' servers
|
144
|
+
def successful?(response)
|
145
|
+
response[:response_code] &&
|
146
|
+
response[:complete] &&
|
147
|
+
(0..49).include?(response[:response_code].to_i)
|
148
|
+
end
|
149
|
+
|
150
|
+
def parse(xml)
|
151
|
+
response = { :message => "Global Error Receipt", :complete => false }
|
152
|
+
hashify_xml!(xml, response)
|
153
|
+
response
|
154
|
+
end
|
155
|
+
|
156
|
+
def hashify_xml!(xml, response)
|
157
|
+
xml = REXML::Document.new(xml)
|
158
|
+
return if xml.root.nil?
|
159
|
+
xml.elements.each('//receipt/*') do |node|
|
160
|
+
response[node.name.underscore.to_sym] = normalize(node.text)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def post_data(action, parameters = {})
|
165
|
+
xml = REXML::Document.new
|
166
|
+
root = xml.add_element("request")
|
167
|
+
root.add_element("store_id").text = options[:login]
|
168
|
+
root.add_element("api_token").text = options[:password]
|
169
|
+
transaction = root.add_element(action)
|
170
|
+
|
171
|
+
# Must add the elements in the correct order
|
172
|
+
actions[action].each do |key|
|
173
|
+
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
|
174
|
+
end
|
175
|
+
|
176
|
+
xml.to_s
|
177
|
+
end
|
178
|
+
|
179
|
+
def message_from(message)
|
180
|
+
return 'Unspecified error' if message.blank?
|
181
|
+
message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
|
182
|
+
end
|
183
|
+
|
184
|
+
# Make a Ruby type out of the response string
|
185
|
+
def normalize(field)
|
186
|
+
case field
|
187
|
+
when "true" then true
|
188
|
+
when "false" then false
|
189
|
+
when '', "null" then nil
|
190
|
+
else field
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def actions
|
195
|
+
{
|
196
|
+
"us_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
|
197
|
+
"us_preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
|
198
|
+
"us_refund" => [:order_id, :amount, :txn_number, :crypt_type],
|
199
|
+
"us_ind_refund" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
|
200
|
+
"us_completion" => [:order_id, :comp_amount, :txn_number, :crypt_type],
|
201
|
+
"us_purchasecorrection" => [:order_id, :txn_number, :crypt_type],
|
202
|
+
"us_cavv_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv],
|
203
|
+
"us_cavv_preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv],
|
204
|
+
"us_batchcloseall" => [],
|
205
|
+
"us_opentotals" => [:ecr_number],
|
206
|
+
"us_batchclose" => [:ecr_number]
|
207
|
+
}
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# The National Australia Bank provide a payment gateway that seems to
|
6
|
+
# be a rebadged Securepay Australia service, though some differences exist.
|
7
|
+
class NabTransactGateway < Gateway
|
8
|
+
API_VERSION = 'xml-4.2'
|
9
|
+
PERIODIC_API_VERSION = "spxml-4.2"
|
10
|
+
|
11
|
+
class_attribute :test_periodic_url, :live_periodic_url
|
12
|
+
|
13
|
+
self.test_url = 'https://transact.nab.com.au/test/xmlapi/payment'
|
14
|
+
self.live_url = 'https://transact.nab.com.au/live/xmlapi/payment'
|
15
|
+
self.test_periodic_url = 'https://transact.nab.com.au/xmlapidemo/periodic'
|
16
|
+
self.live_periodic_url = 'https://transact.nab.com.au/xmlapi/periodic'
|
17
|
+
|
18
|
+
self.supported_countries = ['AU']
|
19
|
+
|
20
|
+
# The card types supported by the payment gateway
|
21
|
+
# Note that support for Diners, Amex, and JCB require extra
|
22
|
+
# steps in setting up your account, as detailed in the NAB Transact API
|
23
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
|
24
|
+
|
25
|
+
self.homepage_url = 'http://transact.nab.com.au'
|
26
|
+
self.display_name = 'NAB Transact'
|
27
|
+
|
28
|
+
cattr_accessor :request_timeout
|
29
|
+
self.request_timeout = 60
|
30
|
+
|
31
|
+
self.money_format = :cents
|
32
|
+
self.default_currency = 'AUD'
|
33
|
+
|
34
|
+
#Transactions currently accepted by NAB Transact XML API
|
35
|
+
TRANSACTIONS = {
|
36
|
+
:purchase => 0, #Standard Payment
|
37
|
+
:credit => 4, #Refund
|
38
|
+
:void => 6, #Client Reversal (Void)
|
39
|
+
:authorization => 10, #Preauthorise
|
40
|
+
:capture => 11 #Preauthorise Complete (Advice)
|
41
|
+
}
|
42
|
+
|
43
|
+
PERIODIC_TYPES = {
|
44
|
+
:addcrn => 5,
|
45
|
+
:editcrn => 5,
|
46
|
+
:deletecrn => 5,
|
47
|
+
:trigger => 8
|
48
|
+
}
|
49
|
+
|
50
|
+
SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]
|
51
|
+
|
52
|
+
|
53
|
+
def initialize(options = {})
|
54
|
+
requires!(options, :login, :password)
|
55
|
+
@options = options
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def test?
|
60
|
+
@options[:test] || super
|
61
|
+
end
|
62
|
+
|
63
|
+
def purchase(money, credit_card_or_stored_id, options = {})
|
64
|
+
if credit_card_or_stored_id.respond_to?(:number)
|
65
|
+
#Credit card for instant payment
|
66
|
+
commit :purchase, build_purchase_request(money, credit_card_or_stored_id, options)
|
67
|
+
else
|
68
|
+
#Triggered payment for an existing stored credit card
|
69
|
+
options[:billing_id] = credit_card_or_stored_id.to_s
|
70
|
+
commit_periodic build_periodic_item(:trigger, money, nil, options)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def store(creditcard, options = {})
|
75
|
+
requires!(options, :billing_id, :amount)
|
76
|
+
commit_periodic(build_periodic_item(:addcrn, options[:amount], creditcard, options))
|
77
|
+
end
|
78
|
+
|
79
|
+
def unstore(identification, options = {})
|
80
|
+
options[:billing_id] = identification
|
81
|
+
commit_periodic(build_periodic_item(:deletecrn, options[:amount], nil, options))
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def add_metadata(xml, options)
|
87
|
+
if options[:merchant_name] || options[:merchant_location]
|
88
|
+
xml.tag! 'metadata' do
|
89
|
+
xml.tag! 'meta', :name => 'ca_name', :value => options[:merchant_name] if options[:merchant_name]
|
90
|
+
xml.tag! 'meta', :name => 'ca_location', :value => options[:merchant_location] if options[:merchant_location]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def build_purchase_request(money, credit_card, options)
|
96
|
+
xml = Builder::XmlMarkup.new
|
97
|
+
xml.tag! 'amount', amount(money)
|
98
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
99
|
+
xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
|
100
|
+
|
101
|
+
xml.tag! 'CreditCardInfo' do
|
102
|
+
xml.tag! 'cardNumber', credit_card.number
|
103
|
+
xml.tag! 'expiryDate', expdate(credit_card)
|
104
|
+
xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
|
105
|
+
end
|
106
|
+
|
107
|
+
add_metadata(xml, options)
|
108
|
+
|
109
|
+
xml.target!
|
110
|
+
end
|
111
|
+
|
112
|
+
#Generate payment request XML
|
113
|
+
# - API is set to allow multiple Txn's but currentlu only allows one
|
114
|
+
# - txnSource = 23 - (XML)
|
115
|
+
|
116
|
+
def build_request(action, body)
|
117
|
+
xml = Builder::XmlMarkup.new
|
118
|
+
xml.instruct!
|
119
|
+
xml.tag! 'NABTransactMessage' do
|
120
|
+
xml.tag! 'MessageInfo' do
|
121
|
+
xml.tag! 'messageID', Utils.generate_unique_id.slice(0, 30)
|
122
|
+
xml.tag! 'messageTimestamp', generate_timestamp
|
123
|
+
xml.tag! 'timeoutValue', request_timeout
|
124
|
+
xml.tag! 'apiVersion', API_VERSION
|
125
|
+
end
|
126
|
+
|
127
|
+
xml.tag! 'MerchantInfo' do
|
128
|
+
xml.tag! 'merchantID', @options[:login]
|
129
|
+
xml.tag! 'password', @options[:password]
|
130
|
+
end
|
131
|
+
|
132
|
+
xml.tag! 'RequestType', 'Payment'
|
133
|
+
xml.tag! 'Payment' do
|
134
|
+
xml.tag! 'TxnList', "count" => 1 do
|
135
|
+
xml.tag! 'Txn', "ID" => 1 do
|
136
|
+
xml.tag! 'txnType', TRANSACTIONS[action]
|
137
|
+
xml.tag! 'txnSource', 23
|
138
|
+
xml << body
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
xml.target!
|
145
|
+
end
|
146
|
+
|
147
|
+
def build_periodic_item(action, money, credit_card, options)
|
148
|
+
xml = Builder::XmlMarkup.new
|
149
|
+
|
150
|
+
xml.tag! 'actionType', action.to_s
|
151
|
+
xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action]
|
152
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
153
|
+
xml.tag! 'crn', options[:billing_id]
|
154
|
+
|
155
|
+
if credit_card
|
156
|
+
xml.tag! 'CreditCardInfo' do
|
157
|
+
xml.tag! 'cardNumber', credit_card.number
|
158
|
+
xml.tag! 'expiryDate', expdate(credit_card)
|
159
|
+
xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
|
160
|
+
end
|
161
|
+
end
|
162
|
+
xml.tag! 'amount', amount(money)
|
163
|
+
|
164
|
+
xml.target!
|
165
|
+
end
|
166
|
+
|
167
|
+
def build_periodic_request(body)
|
168
|
+
xml = Builder::XmlMarkup.new
|
169
|
+
xml.instruct!
|
170
|
+
xml.tag! 'NABTransactMessage' do
|
171
|
+
xml.tag! 'MessageInfo' do
|
172
|
+
xml.tag! 'messageID', ActiveMerchant::Utils.generate_unique_id.slice(0, 30)
|
173
|
+
xml.tag! 'messageTimestamp', generate_timestamp
|
174
|
+
xml.tag! 'timeoutValue', request_timeout
|
175
|
+
xml.tag! 'apiVersion', PERIODIC_API_VERSION
|
176
|
+
end
|
177
|
+
|
178
|
+
xml.tag! 'MerchantInfo' do
|
179
|
+
xml.tag! 'merchantID', @options[:login]
|
180
|
+
xml.tag! 'password', @options[:password]
|
181
|
+
end
|
182
|
+
|
183
|
+
xml.tag! 'RequestType', 'Periodic'
|
184
|
+
xml.tag! 'Periodic' do
|
185
|
+
xml.tag! 'PeriodicList', "count" => 1 do
|
186
|
+
xml.tag! 'PeriodicItem', "ID" => 1 do
|
187
|
+
xml << body
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
xml.target!
|
194
|
+
end
|
195
|
+
|
196
|
+
def commit(action, request)
|
197
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(action, request)))
|
198
|
+
|
199
|
+
Response.new(success?(response), message_from(response), response,
|
200
|
+
:test => test?,
|
201
|
+
:authorization => authorization_from(response)
|
202
|
+
)
|
203
|
+
end
|
204
|
+
|
205
|
+
def commit_periodic(request)
|
206
|
+
response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, build_periodic_request(request)))
|
207
|
+
Response.new(success?(response), message_from(response), response,
|
208
|
+
:test => test?,
|
209
|
+
:authorization => authorization_from(response)
|
210
|
+
)
|
211
|
+
end
|
212
|
+
|
213
|
+
def success?(response)
|
214
|
+
SUCCESS_CODES.include?(response[:response_code])
|
215
|
+
end
|
216
|
+
|
217
|
+
def authorization_from(response)
|
218
|
+
response[:txn_id]
|
219
|
+
end
|
220
|
+
|
221
|
+
def message_from(response)
|
222
|
+
response[:response_text] || response[:status_description]
|
223
|
+
end
|
224
|
+
|
225
|
+
def expdate(credit_card)
|
226
|
+
"#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
|
227
|
+
end
|
228
|
+
|
229
|
+
def parse(body)
|
230
|
+
xml = REXML::Document.new(body)
|
231
|
+
|
232
|
+
response = {}
|
233
|
+
|
234
|
+
xml.root.elements.to_a.each do |node|
|
235
|
+
parse_element(response, node)
|
236
|
+
end
|
237
|
+
|
238
|
+
response
|
239
|
+
end
|
240
|
+
|
241
|
+
def parse_element(response, node)
|
242
|
+
if node.has_elements?
|
243
|
+
node.elements.each{|element| parse_element(response, element) }
|
244
|
+
else
|
245
|
+
response[node.name.underscore.to_sym] = node.text
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# YYYYDDMMHHNNSSKKK000sOOO
|
250
|
+
def generate_timestamp
|
251
|
+
time = Time.now.utc
|
252
|
+
time.strftime("%Y%d%m%H%M%S#{time.usec}+000")
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|