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,323 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# For more information on the Metrics Global Payment Gateway, visit the {Metrics Global website}[www.metricsglobal.com].
|
4
|
+
# Further documentation on AVS and CVV response codes are available under the support section of the Metrics Global
|
5
|
+
# control panel.
|
6
|
+
#
|
7
|
+
# === Metrics Global Payment Gateway Authentication
|
8
|
+
#
|
9
|
+
# The login and password for the gateway are the same as the username and password used to log in to the Metrics Global
|
10
|
+
# control panel. Contact Metrics Global support to receive credentials for the control panel.
|
11
|
+
#
|
12
|
+
# === Demo Account
|
13
|
+
#
|
14
|
+
# There is a public demo account available with the following credentials:
|
15
|
+
#
|
16
|
+
# Login: demo
|
17
|
+
# Password: password
|
18
|
+
class MetricsGlobalGateway < Gateway
|
19
|
+
API_VERSION = '3.1'
|
20
|
+
|
21
|
+
class_attribute :test_url, :live_url
|
22
|
+
|
23
|
+
self.test_url = "https://secure.metricsglobalgateway.com/gateway/transact.dll?testing=true"
|
24
|
+
self.live_url = "https://secure.metricsglobalgateway.com/gateway/transact.dll"
|
25
|
+
|
26
|
+
class_attribute :duplicate_window
|
27
|
+
|
28
|
+
APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4
|
29
|
+
|
30
|
+
RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT = 0, 2, 3
|
31
|
+
AVS_RESULT_CODE, TRANSACTION_ID, CARD_CODE_RESPONSE_CODE = 5, 6, 38
|
32
|
+
|
33
|
+
self.supported_countries = ['US']
|
34
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
|
35
|
+
self.homepage_url = 'http://www.metricsglobal.com'
|
36
|
+
self.display_name = 'Metrics Global'
|
37
|
+
|
38
|
+
CARD_CODE_ERRORS = %w( N S )
|
39
|
+
AVS_ERRORS = %w( A E N R W Z )
|
40
|
+
AVS_REASON_CODES = %w(27 45)
|
41
|
+
|
42
|
+
# Creates a new MetricsGlobalGateway
|
43
|
+
#
|
44
|
+
# The gateway requires that a valid login and password be passed
|
45
|
+
# in the +options+ hash.
|
46
|
+
#
|
47
|
+
# ==== Options
|
48
|
+
#
|
49
|
+
# * <tt>:login</tt> -- The username required to access the Metrics Global control panel. (REQUIRED)
|
50
|
+
# * <tt>:password</tt> -- The password required to access the Metrics Global control panel. (REQUIRED)
|
51
|
+
# * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
|
52
|
+
# Otherwise, perform transactions against the production server.
|
53
|
+
def initialize(options = {})
|
54
|
+
requires!(options, :login, :password)
|
55
|
+
@options = options
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
# Performs an authorization, which reserves the funds on the customer's credit card, but does not
|
60
|
+
# charge the card.
|
61
|
+
#
|
62
|
+
# ==== Parameters
|
63
|
+
#
|
64
|
+
# * <tt>money</tt> -- The amount to be authorized as an Integer value in cents.
|
65
|
+
# * <tt>creditcard</tt> -- The CreditCard details for the transaction.
|
66
|
+
# * <tt>options</tt> -- A hash of optional parameters.
|
67
|
+
def authorize(money, creditcard, options = {})
|
68
|
+
post = {}
|
69
|
+
add_invoice(post, options)
|
70
|
+
add_creditcard(post, creditcard)
|
71
|
+
add_address(post, options)
|
72
|
+
add_customer_data(post, options)
|
73
|
+
add_duplicate_window(post)
|
74
|
+
|
75
|
+
commit('AUTH_ONLY', money, post)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
79
|
+
#
|
80
|
+
# ==== Parameters
|
81
|
+
#
|
82
|
+
# * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
|
83
|
+
# * <tt>creditcard</tt> -- The CreditCard details for the transaction.
|
84
|
+
# * <tt>options</tt> -- A hash of optional parameters.
|
85
|
+
def purchase(money, creditcard, options = {})
|
86
|
+
post = {}
|
87
|
+
add_invoice(post, options)
|
88
|
+
add_creditcard(post, creditcard)
|
89
|
+
add_address(post, options)
|
90
|
+
add_customer_data(post, options)
|
91
|
+
add_duplicate_window(post)
|
92
|
+
|
93
|
+
commit('AUTH_CAPTURE', money, post)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Captures the funds from an authorized transaction.
|
97
|
+
#
|
98
|
+
# ==== Parameters
|
99
|
+
#
|
100
|
+
# * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
|
101
|
+
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
|
102
|
+
def capture(money, authorization, options = {})
|
103
|
+
post = {:trans_id => authorization}
|
104
|
+
add_customer_data(post, options)
|
105
|
+
commit('PRIOR_AUTH_CAPTURE', money, post)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Void a previous transaction
|
109
|
+
#
|
110
|
+
# ==== Parameters
|
111
|
+
#
|
112
|
+
# * <tt>authorization</tt> - The authorization returned from the previous authorize request.
|
113
|
+
def void(authorization, options = {})
|
114
|
+
post = {:trans_id => authorization}
|
115
|
+
add_duplicate_window(post)
|
116
|
+
commit('VOID', nil, post)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Refund a transaction.
|
120
|
+
#
|
121
|
+
# This transaction indicates to the gateway that
|
122
|
+
# money should flow from the merchant to the customer.
|
123
|
+
#
|
124
|
+
# ==== Parameters
|
125
|
+
#
|
126
|
+
# * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
|
127
|
+
# * <tt>identification</tt> -- The ID of the original transaction against which the refund is being issued.
|
128
|
+
# * <tt>options</tt> -- A hash of parameters.
|
129
|
+
#
|
130
|
+
# ==== Options
|
131
|
+
#
|
132
|
+
# * <tt>:card_number</tt> -- The credit card number the refund is being issued to. (REQUIRED)
|
133
|
+
# * <tt>:first_name</tt> -- The first name of the account being refunded.
|
134
|
+
# * <tt>:last_name</tt> -- The last name of the account being refunded.
|
135
|
+
# * <tt>:zip</tt> -- The postal code of the account being refunded.
|
136
|
+
def refund(money, identification, options = {})
|
137
|
+
requires!(options, :card_number)
|
138
|
+
|
139
|
+
post = { :trans_id => identification,
|
140
|
+
:card_num => options[:card_number]
|
141
|
+
}
|
142
|
+
|
143
|
+
post[:first_name] = options[:first_name] if options[:first_name]
|
144
|
+
post[:last_name] = options[:last_name] if options[:last_name]
|
145
|
+
post[:zip] = options[:zip] if options[:zip]
|
146
|
+
|
147
|
+
add_invoice(post, options)
|
148
|
+
add_duplicate_window(post)
|
149
|
+
|
150
|
+
commit('CREDIT', money, post)
|
151
|
+
end
|
152
|
+
|
153
|
+
def credit(money, identification, options = {})
|
154
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
155
|
+
refund(money, identification, options)
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def commit(action, money, parameters)
|
161
|
+
parameters[:amount] = amount(money) unless action == 'VOID'
|
162
|
+
|
163
|
+
# Only activate the test_request when the :test option is passed in
|
164
|
+
parameters[:test_request] = @options[:test] ? 'TRUE' : 'FALSE'
|
165
|
+
|
166
|
+
url = test? ? self.test_url : self.live_url
|
167
|
+
data = ssl_post url, post_data(action, parameters)
|
168
|
+
|
169
|
+
response = parse(data)
|
170
|
+
|
171
|
+
message = message_from(response)
|
172
|
+
|
173
|
+
# Return the response. The authorization can be taken out of the transaction_id
|
174
|
+
# Test Mode on/off is something we have to parse from the response text.
|
175
|
+
# It usually looks something like this
|
176
|
+
#
|
177
|
+
# (TESTMODE) Successful Sale
|
178
|
+
test_mode = test? || message =~ /TESTMODE/
|
179
|
+
|
180
|
+
Response.new(success?(response), message, response,
|
181
|
+
:test => test_mode,
|
182
|
+
:authorization => response[:transaction_id],
|
183
|
+
:fraud_review => fraud_review?(response),
|
184
|
+
:avs_result => { :code => response[:avs_result_code] },
|
185
|
+
:cvv_result => response[:card_code]
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
def success?(response)
|
190
|
+
response[:response_code] == APPROVED
|
191
|
+
end
|
192
|
+
|
193
|
+
def fraud_review?(response)
|
194
|
+
response[:response_code] == FRAUD_REVIEW
|
195
|
+
end
|
196
|
+
|
197
|
+
def parse(body)
|
198
|
+
fields = split(body)
|
199
|
+
|
200
|
+
results = {
|
201
|
+
:response_code => fields[RESPONSE_CODE].to_i,
|
202
|
+
:response_reason_code => fields[RESPONSE_REASON_CODE],
|
203
|
+
:response_reason_text => fields[RESPONSE_REASON_TEXT],
|
204
|
+
:avs_result_code => fields[AVS_RESULT_CODE],
|
205
|
+
:transaction_id => fields[TRANSACTION_ID],
|
206
|
+
:card_code => fields[CARD_CODE_RESPONSE_CODE]
|
207
|
+
}
|
208
|
+
results
|
209
|
+
end
|
210
|
+
|
211
|
+
def post_data(action, parameters = {})
|
212
|
+
post = {}
|
213
|
+
|
214
|
+
post[:version] = API_VERSION
|
215
|
+
post[:login] = @options[:login]
|
216
|
+
post[:tran_key] = @options[:password]
|
217
|
+
post[:relay_response] = "FALSE"
|
218
|
+
post[:type] = action
|
219
|
+
post[:delim_data] = "TRUE"
|
220
|
+
post[:delim_char] = ","
|
221
|
+
post[:encap_char] = "$"
|
222
|
+
post[:solution_ID] = application_id if application_id.present? && application_id != "ActiveMerchant"
|
223
|
+
|
224
|
+
request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
225
|
+
request
|
226
|
+
end
|
227
|
+
|
228
|
+
def add_invoice(post, options)
|
229
|
+
post[:invoice_num] = options[:order_id]
|
230
|
+
post[:description] = options[:description]
|
231
|
+
end
|
232
|
+
|
233
|
+
def add_creditcard(post, creditcard)
|
234
|
+
post[:card_num] = creditcard.number
|
235
|
+
post[:card_code] = creditcard.verification_value if creditcard.verification_value?
|
236
|
+
post[:exp_date] = expdate(creditcard)
|
237
|
+
post[:first_name] = creditcard.first_name
|
238
|
+
post[:last_name] = creditcard.last_name
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_customer_data(post, options)
|
242
|
+
if options.has_key? :email
|
243
|
+
post[:email] = options[:email]
|
244
|
+
post[:email_customer] = false
|
245
|
+
end
|
246
|
+
|
247
|
+
if options.has_key? :customer
|
248
|
+
post[:cust_id] = options[:customer]
|
249
|
+
end
|
250
|
+
|
251
|
+
if options.has_key? :ip
|
252
|
+
post[:customer_ip] = options[:ip]
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# x_duplicate_window won't be sent by default, because sending it changes the response.
|
257
|
+
# "If this field is present in the request with or without a value, an enhanced duplicate transaction response will be sent."
|
258
|
+
def add_duplicate_window(post)
|
259
|
+
unless duplicate_window.nil?
|
260
|
+
post[:duplicate_window] = duplicate_window
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def add_address(post, options)
|
265
|
+
if address = options[:billing_address] || options[:address]
|
266
|
+
post[:address] = address[:address1].to_s
|
267
|
+
post[:company] = address[:company].to_s
|
268
|
+
post[:phone] = address[:phone].to_s
|
269
|
+
post[:zip] = address[:zip].to_s
|
270
|
+
post[:city] = address[:city].to_s
|
271
|
+
post[:country] = address[:country].to_s
|
272
|
+
post[:state] = address[:state].blank? ? 'n/a' : address[:state]
|
273
|
+
end
|
274
|
+
|
275
|
+
if address = options[:shipping_address]
|
276
|
+
post[:ship_to_first_name] = address[:first_name].to_s
|
277
|
+
post[:ship_to_last_name] = address[:last_name].to_s
|
278
|
+
post[:ship_to_address] = address[:address1].to_s
|
279
|
+
post[:ship_to_company] = address[:company].to_s
|
280
|
+
post[:ship_to_phone] = address[:phone].to_s
|
281
|
+
post[:ship_to_zip] = address[:zip].to_s
|
282
|
+
post[:ship_to_city] = address[:city].to_s
|
283
|
+
post[:ship_to_country] = address[:country].to_s
|
284
|
+
post[:ship_to_state] = address[:state].blank? ? 'n/a' : address[:state]
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
# Make a ruby type out of the response string
|
289
|
+
def normalize(field)
|
290
|
+
case field
|
291
|
+
when "true" then true
|
292
|
+
when "false" then false
|
293
|
+
when "" then nil
|
294
|
+
when "null" then nil
|
295
|
+
else field
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def message_from(results)
|
300
|
+
if results[:response_code] == DECLINED
|
301
|
+
return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
|
302
|
+
if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
|
303
|
+
return AVSResult.messages[ results[:avs_result_code] ]
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
(results[:response_reason_text] ? results[:response_reason_text].chomp('.') : '')
|
308
|
+
end
|
309
|
+
|
310
|
+
def expdate(creditcard)
|
311
|
+
year = sprintf("%.4i", creditcard.year)
|
312
|
+
month = sprintf("%.2i", creditcard.month)
|
313
|
+
|
314
|
+
"#{month}#{year[-2..-1]}"
|
315
|
+
end
|
316
|
+
|
317
|
+
def split(response)
|
318
|
+
response[1..-2].split(/\$,\$/)
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/migs/migs_codes'
|
2
|
+
|
3
|
+
require 'digest/md5' # Used in add_secure_hash
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
class MigsGateway < Gateway
|
8
|
+
include MigsCodes
|
9
|
+
|
10
|
+
API_VERSION = 1
|
11
|
+
|
12
|
+
class_attribute :server_hosted_url, :merchant_hosted_url
|
13
|
+
|
14
|
+
self.server_hosted_url = 'https://migs.mastercard.com.au/vpcpay'
|
15
|
+
self.merchant_hosted_url = 'https://migs.mastercard.com.au/vpcdps'
|
16
|
+
|
17
|
+
self.live_url = self.server_hosted_url
|
18
|
+
|
19
|
+
# MiGS is supported throughout Asia Pacific, Middle East and Africa
|
20
|
+
# MiGS is used in Australia (AU) by ANZ (eGate), CBA (CommWeb) and more
|
21
|
+
# Source of Country List: http://www.scribd.com/doc/17811923
|
22
|
+
self.supported_countries = %w(AU AE BD BN EG HK ID IN JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN)
|
23
|
+
|
24
|
+
# The card types supported by the payment gateway
|
25
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
|
26
|
+
|
27
|
+
self.money_format = :cents
|
28
|
+
|
29
|
+
# The homepage URL of the gateway
|
30
|
+
self.homepage_url = 'http://mastercard.com/mastercardsps'
|
31
|
+
|
32
|
+
# The name of the gateway
|
33
|
+
self.display_name = 'MasterCard Internet Gateway Service (MiGS)'
|
34
|
+
|
35
|
+
# Creates a new MigsGateway
|
36
|
+
# The advanced_login/advanced_password fields are needed for
|
37
|
+
# advanced methods such as the capture, refund and status methods
|
38
|
+
#
|
39
|
+
# ==== Options
|
40
|
+
#
|
41
|
+
# * <tt>:login</tt> -- The MiGS Merchant ID (REQUIRED)
|
42
|
+
# * <tt>:password</tt> -- The MiGS Access Code (REQUIRED)
|
43
|
+
# * <tt>:secure_hash</tt> -- The MiGS Secure Hash
|
44
|
+
# (Required for Server Hosted payments)
|
45
|
+
# * <tt>:advanced_login</tt> -- The MiGS AMA User
|
46
|
+
# * <tt>:advanced_password</tt> -- The MiGS AMA User's password
|
47
|
+
def initialize(options = {})
|
48
|
+
requires!(options, :login, :password)
|
49
|
+
@test = options[:login].start_with?('TEST')
|
50
|
+
@options = options
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
# ==== Options
|
55
|
+
#
|
56
|
+
# * <tt>:order_id</tt> -- A reference for tracking the order (REQUIRED)
|
57
|
+
# * <tt>:unique_id</tt> -- A unique id for this request (Max 40 chars).
|
58
|
+
# If not supplied one will be generated.
|
59
|
+
def purchase(money, creditcard, options = {})
|
60
|
+
requires!(options, :order_id)
|
61
|
+
|
62
|
+
post = {}
|
63
|
+
post[:Amount] = amount(money)
|
64
|
+
add_invoice(post, options)
|
65
|
+
add_creditcard(post, creditcard)
|
66
|
+
add_standard_parameters('pay', post, options[:unique_id])
|
67
|
+
|
68
|
+
commit(post)
|
69
|
+
end
|
70
|
+
|
71
|
+
# MiGS works by merchants being either purchase only or authorize/capture
|
72
|
+
# So authorize is the same as purchase when in authorize mode
|
73
|
+
alias_method :authorize, :purchase
|
74
|
+
|
75
|
+
# ==== Options
|
76
|
+
#
|
77
|
+
# * <tt>:unique_id</tt> -- A unique id for this request (Max 40 chars).
|
78
|
+
# If not supplied one will be generated.
|
79
|
+
def capture(money, authorization, options = {})
|
80
|
+
requires!(@options, :advanced_login, :advanced_password)
|
81
|
+
|
82
|
+
post = options.merge(:TransNo => authorization)
|
83
|
+
post[:Amount] = amount(money)
|
84
|
+
add_advanced_user(post)
|
85
|
+
add_standard_parameters('capture', post, options[:unique_id])
|
86
|
+
|
87
|
+
commit(post)
|
88
|
+
end
|
89
|
+
|
90
|
+
# ==== Options
|
91
|
+
#
|
92
|
+
# * <tt>:unique_id</tt> -- A unique id for this request (Max 40 chars).
|
93
|
+
# If not supplied one will be generated.
|
94
|
+
def refund(money, authorization, options = {})
|
95
|
+
requires!(@options, :advanced_login, :advanced_password)
|
96
|
+
|
97
|
+
post = options.merge(:TransNo => authorization)
|
98
|
+
post[:Amount] = amount(money)
|
99
|
+
add_advanced_user(post)
|
100
|
+
add_standard_parameters('refund', post, options[:unique_id])
|
101
|
+
|
102
|
+
commit(post)
|
103
|
+
end
|
104
|
+
|
105
|
+
def credit(money, authorization, options = {})
|
106
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
107
|
+
refund(money, authorization, options)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Checks the status of a previous transaction
|
111
|
+
# This can be useful when a response is not received due to network issues
|
112
|
+
#
|
113
|
+
# ==== Parameters
|
114
|
+
#
|
115
|
+
# * <tt>unique_id</tt> -- Unique id of transaction to find.
|
116
|
+
# This is the value of the option supplied in other methods or
|
117
|
+
# if not supplied is returned with key :MerchTxnRef
|
118
|
+
def status(unique_id)
|
119
|
+
requires!(@options, :advanced_login, :advanced_password)
|
120
|
+
|
121
|
+
post = {}
|
122
|
+
add_advanced_user(post)
|
123
|
+
add_standard_parameters('queryDR', post, unique_id)
|
124
|
+
|
125
|
+
commit(post)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Generates a URL to redirect user to MiGS to process payment
|
129
|
+
# Once user is finished MiGS will redirect back to specified URL
|
130
|
+
# With a response hash which can be turned into a Response object
|
131
|
+
# with purchase_offsite_response
|
132
|
+
#
|
133
|
+
# ==== Options
|
134
|
+
#
|
135
|
+
# * <tt>:order_id</tt> -- A reference for tracking the order (REQUIRED)
|
136
|
+
# * <tt>:locale</tt> -- Change the language of the redirected page
|
137
|
+
# Values are 2 digit locale, e.g. en, es
|
138
|
+
# * <tt>:return_url</tt> -- the URL to return to once the payment is complete
|
139
|
+
# * <tt>:card_type</tt> -- Providing this skips the card type step.
|
140
|
+
# Values are ActiveMerchant formats: e.g. master, visa, american_express, diners_club
|
141
|
+
# * <tt>:unique_id</tt> -- Unique id of transaction to find.
|
142
|
+
# If not supplied one will be generated.
|
143
|
+
def purchase_offsite_url(money, options = {})
|
144
|
+
requires!(options, :order_id, :return_url)
|
145
|
+
requires!(@options, :secure_hash)
|
146
|
+
|
147
|
+
post = {}
|
148
|
+
post[:Amount] = amount(money)
|
149
|
+
add_invoice(post, options)
|
150
|
+
add_creditcard_type(post, options[:card_type]) if options[:card_type]
|
151
|
+
|
152
|
+
post.merge!(
|
153
|
+
:Locale => options[:locale] || 'en',
|
154
|
+
:ReturnURL => options[:return_url]
|
155
|
+
)
|
156
|
+
|
157
|
+
add_standard_parameters('pay', post, options[:unique_id])
|
158
|
+
|
159
|
+
add_secure_hash(post)
|
160
|
+
|
161
|
+
self.server_hosted_url + '?' + post_data(post)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Parses a response from purchase_offsite_url once user is redirected back
|
165
|
+
#
|
166
|
+
# ==== Parameters
|
167
|
+
#
|
168
|
+
# * <tt>data</tt> -- All params when offsite payment returns
|
169
|
+
# e.g. returns to http://company.com/return?a=1&b=2, then input "a=1&b=2"
|
170
|
+
def purchase_offsite_response(data)
|
171
|
+
requires!(@options, :secure_hash)
|
172
|
+
|
173
|
+
response_hash = parse(data)
|
174
|
+
|
175
|
+
expected_secure_hash = calculate_secure_hash(response_hash.reject{|k, v| k == :SecureHash}, @options[:secure_hash])
|
176
|
+
unless response_hash[:SecureHash] == expected_secure_hash
|
177
|
+
raise SecurityError, "Secure Hash mismatch, response may be tampered with"
|
178
|
+
end
|
179
|
+
|
180
|
+
response_object(response_hash)
|
181
|
+
end
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
def add_advanced_user(post)
|
186
|
+
post[:User] = @options[:advanced_login]
|
187
|
+
post[:Password] = @options[:advanced_password]
|
188
|
+
end
|
189
|
+
|
190
|
+
def add_invoice(post, options)
|
191
|
+
post[:OrderInfo] = options[:order_id]
|
192
|
+
end
|
193
|
+
|
194
|
+
def add_creditcard(post, creditcard)
|
195
|
+
post[:CardNum] = creditcard.number
|
196
|
+
post[:CardSecurityCode] = creditcard.verification_value if creditcard.verification_value?
|
197
|
+
post[:CardExp] = format(creditcard.year, :two_digits) + format(creditcard.month, :two_digits)
|
198
|
+
end
|
199
|
+
|
200
|
+
def add_creditcard_type(post, card_type)
|
201
|
+
post[:Gateway] = 'ssl'
|
202
|
+
post[:card] = CARD_TYPES.detect{|ct| ct.am_code == card_type}.migs_long_code
|
203
|
+
end
|
204
|
+
|
205
|
+
def parse(body)
|
206
|
+
params = CGI::parse(body)
|
207
|
+
hash = {}
|
208
|
+
params.each do |key, value|
|
209
|
+
hash[key.gsub('vpc_', '').to_sym] = value[0]
|
210
|
+
end
|
211
|
+
hash
|
212
|
+
end
|
213
|
+
|
214
|
+
def commit(post)
|
215
|
+
data = ssl_post self.merchant_hosted_url, post_data(post)
|
216
|
+
response_hash = parse(data)
|
217
|
+
response_object(response_hash)
|
218
|
+
end
|
219
|
+
|
220
|
+
def response_object(response)
|
221
|
+
Response.new(success?(response), response[:Message], response,
|
222
|
+
:test => @test,
|
223
|
+
:authorization => response[:TransactionNo],
|
224
|
+
:fraud_review => fraud_review?(response),
|
225
|
+
:avs_result => { :code => response[:AVSResultCode] },
|
226
|
+
:cvv_result => response[:CSCResultCode]
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
def success?(response)
|
231
|
+
response[:TxnResponseCode] == '0'
|
232
|
+
end
|
233
|
+
|
234
|
+
def fraud_review?(response)
|
235
|
+
ISSUER_RESPONSE_CODES[response[:AcqResponseCode]] == 'Suspected Fraud'
|
236
|
+
end
|
237
|
+
|
238
|
+
def add_standard_parameters(action, post, unique_id = nil)
|
239
|
+
post.merge!(
|
240
|
+
:Version => API_VERSION,
|
241
|
+
:Merchant => @options[:login],
|
242
|
+
:AccessCode => @options[:password],
|
243
|
+
:Command => action,
|
244
|
+
:MerchTxnRef => unique_id || generate_unique_id.slice(0, 40)
|
245
|
+
)
|
246
|
+
end
|
247
|
+
|
248
|
+
def post_data(post)
|
249
|
+
post.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
250
|
+
end
|
251
|
+
|
252
|
+
def add_secure_hash(post)
|
253
|
+
post[:SecureHash] = calculate_secure_hash(post, @options[:secure_hash])
|
254
|
+
end
|
255
|
+
|
256
|
+
def calculate_secure_hash(post, secure_hash)
|
257
|
+
sorted_values = post.sort_by(&:to_s).map(&:last)
|
258
|
+
input = secure_hash + sorted_values.join
|
259
|
+
Digest::MD5.hexdigest(input).upcase
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|