swiss-activemerchant 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +249 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +243 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +227 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +120 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,488 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# To learn more about the Moneris gateway, please contact
|
6
|
+
# eselectplus@moneris.com for a copy of their integration guide. For
|
7
|
+
# information on remote testing, please see "Test Environment Penny Value
|
8
|
+
# Response Table", and "Test Environment eFraud (AVS and CVD) Penny
|
9
|
+
# Response Values", available at Moneris' {eSelect Plus Documentation
|
10
|
+
# Centre}[https://www3.moneris.com/connect/en/documents/index.html].
|
11
|
+
class MonerisGateway < Gateway
|
12
|
+
WALLETS = %w(APP GPP)
|
13
|
+
|
14
|
+
self.test_url = 'https://esqa.moneris.com/gateway2/servlet/MpgRequest'
|
15
|
+
self.live_url = 'https://www3.moneris.com/gateway2/servlet/MpgRequest'
|
16
|
+
|
17
|
+
self.supported_countries = ['CA']
|
18
|
+
self.supported_cardtypes = %i[visa master american_express diners_club discover]
|
19
|
+
self.homepage_url = 'http://www.moneris.com/'
|
20
|
+
self.display_name = 'Moneris'
|
21
|
+
|
22
|
+
# Initialize the Gateway
|
23
|
+
#
|
24
|
+
# The gateway requires that a valid login and password be passed
|
25
|
+
# in the +options+ hash.
|
26
|
+
#
|
27
|
+
# ==== Options
|
28
|
+
#
|
29
|
+
# * <tt>:login</tt> -- Your Store ID
|
30
|
+
# * <tt>:password</tt> -- Your API Token
|
31
|
+
# * <tt>:cvv_enabled</tt> -- Specify that you would like the CVV passed to the gateway.
|
32
|
+
# Only particular account types at Moneris will allow this.
|
33
|
+
# Defaults to false. (optional)
|
34
|
+
def initialize(options = {})
|
35
|
+
requires!(options, :login, :password)
|
36
|
+
@cvv_enabled = options[:cvv_enabled]
|
37
|
+
@avs_enabled = options[:avs_enabled]
|
38
|
+
options[:crypt_type] = 7 unless options.has_key?(:crypt_type)
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
# Referred to as "PreAuth" in the Moneris integration guide, this action
|
43
|
+
# verifies and locks funds on a customer's card, which then must be
|
44
|
+
# captured at a later date.
|
45
|
+
#
|
46
|
+
# Pass in +order_id+ and optionally a +customer+ parameter.
|
47
|
+
def authorize(money, creditcard_or_datakey, options = {})
|
48
|
+
requires!(options, :order_id)
|
49
|
+
post = {}
|
50
|
+
add_payment_source(post, creditcard_or_datakey, options)
|
51
|
+
post[:amount] = amount(money)
|
52
|
+
post[:order_id] = format_order_id(post[:wallet_indicator], options[:order_id])
|
53
|
+
post[:address] = options[:billing_address] || options[:address]
|
54
|
+
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
|
55
|
+
add_external_mpi_fields(post, options)
|
56
|
+
add_stored_credential(post, options)
|
57
|
+
action = if post[:cavv] || options[:three_d_secure]
|
58
|
+
'cavv_preauth'
|
59
|
+
elsif post[:data_key].blank?
|
60
|
+
'preauth'
|
61
|
+
else
|
62
|
+
'res_preauth_cc'
|
63
|
+
end
|
64
|
+
commit(action, post, options)
|
65
|
+
end
|
66
|
+
|
67
|
+
# This action verifies funding on a customer's card and readies them for
|
68
|
+
# deposit in a merchant's account.
|
69
|
+
#
|
70
|
+
# Pass in <tt>order_id</tt> and optionally a <tt>customer</tt> parameter
|
71
|
+
def purchase(money, creditcard_or_datakey, options = {})
|
72
|
+
requires!(options, :order_id)
|
73
|
+
post = {}
|
74
|
+
add_payment_source(post, creditcard_or_datakey, options)
|
75
|
+
post[:amount] = amount(money)
|
76
|
+
post[:order_id] = format_order_id(post[:wallet_indicator], options[:order_id])
|
77
|
+
post[:address] = options[:billing_address] || options[:address]
|
78
|
+
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
|
79
|
+
add_external_mpi_fields(post, options)
|
80
|
+
add_stored_credential(post, options)
|
81
|
+
action = if post[:cavv] || options[:three_d_secure]
|
82
|
+
'cavv_purchase'
|
83
|
+
elsif post[:data_key].blank?
|
84
|
+
'purchase'
|
85
|
+
else
|
86
|
+
'res_purchase_cc'
|
87
|
+
end
|
88
|
+
commit(action, post, options)
|
89
|
+
end
|
90
|
+
|
91
|
+
# This method retrieves locked funds from a customer's account (from a
|
92
|
+
# PreAuth) and prepares them for deposit in a merchant's account.
|
93
|
+
#
|
94
|
+
# Note: Moneris requires both the order_id and the transaction number of
|
95
|
+
# the original authorization. To maintain the same interface as the other
|
96
|
+
# gateways the two numbers are concatenated together with a ; separator as
|
97
|
+
# the authorization number returned by authorization
|
98
|
+
def capture(money, authorization, options = {})
|
99
|
+
commit 'completion', crediting_params(authorization, comp_amount: amount(money))
|
100
|
+
end
|
101
|
+
|
102
|
+
# Voiding requires the original transaction ID and order ID of some open
|
103
|
+
# transaction. Closed transactions must be refunded.
|
104
|
+
#
|
105
|
+
# Moneris supports the voiding of an unsettled capture or purchase via
|
106
|
+
# its <tt>purchasecorrection</tt> command. This action can only occur
|
107
|
+
# on the same day as the capture/purchase prior to 22:00-23:00 EST. If
|
108
|
+
# you want to do this, pass <tt>:purchasecorrection => true</tt> as
|
109
|
+
# an option.
|
110
|
+
#
|
111
|
+
# Fun, Historical Trivia:
|
112
|
+
# Voiding an authorization in Moneris is a relatively new feature
|
113
|
+
# (September, 2011). It is actually done by doing a $0 capture.
|
114
|
+
#
|
115
|
+
# Concatenate your transaction number and order_id by using a semicolon
|
116
|
+
# (';'). This is to keep the Moneris interface consistent with other
|
117
|
+
# gateways. (See +capture+ for details.)
|
118
|
+
def void(authorization, options = {})
|
119
|
+
if options[:purchasecorrection]
|
120
|
+
commit 'purchasecorrection', crediting_params(authorization)
|
121
|
+
else
|
122
|
+
capture(0, authorization, options)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Performs a refund. This method requires that the original transaction
|
127
|
+
# number and order number be included. Concatenate your transaction
|
128
|
+
# number and order_id by using a semicolon (';'). This is to keep the
|
129
|
+
# Moneris interface consistent with other gateways. (See +capture+ for
|
130
|
+
# details.)
|
131
|
+
def credit(money, authorization, options = {})
|
132
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
133
|
+
refund(money, authorization, options)
|
134
|
+
end
|
135
|
+
|
136
|
+
def refund(money, authorization, options = {})
|
137
|
+
commit 'refund', crediting_params(authorization, amount: amount(money))
|
138
|
+
end
|
139
|
+
|
140
|
+
def verify(credit_card, options = {})
|
141
|
+
requires!(options, :order_id)
|
142
|
+
post = {}
|
143
|
+
add_payment_source(post, credit_card, options)
|
144
|
+
post[:order_id] = options[:order_id]
|
145
|
+
post[:address] = options[:billing_address] || options[:address]
|
146
|
+
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
|
147
|
+
add_stored_credential(post, options)
|
148
|
+
action = if post[:data_key].blank?
|
149
|
+
'card_verification'
|
150
|
+
else
|
151
|
+
'res_card_verification_cc'
|
152
|
+
end
|
153
|
+
commit(action, post)
|
154
|
+
end
|
155
|
+
|
156
|
+
# When passing a :duration option (time in seconds) you can create a
|
157
|
+
# temporary vault record to avoid incurring Moneris vault storage fees
|
158
|
+
#
|
159
|
+
# https://developer.moneris.com/Documentation/NA/E-Commerce%20Solutions/API/Vault#vaulttokenadd
|
160
|
+
def store(credit_card, options = {})
|
161
|
+
post = {}
|
162
|
+
post[:pan] = credit_card.number
|
163
|
+
post[:expdate] = expdate(credit_card)
|
164
|
+
post[:address] = options[:billing_address] || options[:address]
|
165
|
+
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
|
166
|
+
add_stored_credential(post, options)
|
167
|
+
|
168
|
+
if options[:duration]
|
169
|
+
post[:duration] = options[:duration]
|
170
|
+
commit('res_temp_add', post)
|
171
|
+
else
|
172
|
+
commit('res_add_cc', post)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def unstore(data_key, options = {})
|
177
|
+
post = {}
|
178
|
+
post[:data_key] = data_key
|
179
|
+
commit('res_delete', post)
|
180
|
+
end
|
181
|
+
|
182
|
+
def update(data_key, credit_card, options = {})
|
183
|
+
post = {}
|
184
|
+
post[:pan] = credit_card.number
|
185
|
+
post[:expdate] = expdate(credit_card)
|
186
|
+
post[:data_key] = data_key
|
187
|
+
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
|
188
|
+
commit('res_update_cc', post)
|
189
|
+
end
|
190
|
+
|
191
|
+
def supports_scrubbing?
|
192
|
+
true
|
193
|
+
end
|
194
|
+
|
195
|
+
def scrub(transcript)
|
196
|
+
transcript.
|
197
|
+
gsub(%r((<store_id>).+(</store_id>)), '\1[FILTERED]\2').
|
198
|
+
gsub(%r((<api_token>).+(</api_token>)), '\1[FILTERED]\2').
|
199
|
+
gsub(%r((<pan>).+(</pan>)), '\1[FILTERED]\2').
|
200
|
+
gsub(%r((<cvd_value>).+(</cvd_value>)), '\1[FILTERED]\2').
|
201
|
+
gsub(%r((<cavv>).+(</cavv>)), '\1[FILTERED]\2')
|
202
|
+
end
|
203
|
+
|
204
|
+
private # :nodoc: all
|
205
|
+
|
206
|
+
def expdate(creditcard)
|
207
|
+
sprintf('%.4i', creditcard.year)[-2..-1] + sprintf('%.2i', creditcard.month)
|
208
|
+
end
|
209
|
+
|
210
|
+
def add_external_mpi_fields(post, options)
|
211
|
+
# See these pages:
|
212
|
+
# https://developer.moneris.com/livedemo/3ds2/cavv_purchase/tool/php
|
213
|
+
# https://developer.moneris.com/livedemo/3ds2/cavv_preauth/guide/php
|
214
|
+
return unless options[:three_d_secure]
|
215
|
+
|
216
|
+
three_d_secure_options = options[:three_d_secure]
|
217
|
+
|
218
|
+
post[:threeds_version] = three_d_secure_options[:version]
|
219
|
+
post[:crypt_type] = three_d_secure_options[:eci]
|
220
|
+
post[:cavv] = three_d_secure_options[:cavv]
|
221
|
+
post[:threeds_server_trans_id] = three_d_secure_options[:three_ds_server_trans_id]
|
222
|
+
post[:ds_trans_id] = three_d_secure_options[:ds_transaction_id]
|
223
|
+
end
|
224
|
+
|
225
|
+
def add_payment_source(post, payment_method, options)
|
226
|
+
if payment_method.is_a?(String)
|
227
|
+
post[:data_key] = payment_method
|
228
|
+
post[:cust_id] = options[:customer]
|
229
|
+
else
|
230
|
+
if payment_method.respond_to?(:track_data) && payment_method.track_data.present?
|
231
|
+
post[:pos_code] = '00'
|
232
|
+
post[:track2] = payment_method.track_data
|
233
|
+
else
|
234
|
+
post[:pan] = payment_method.number
|
235
|
+
post[:expdate] = expdate(payment_method)
|
236
|
+
post[:cvd_value] = payment_method.verification_value if payment_method.verification_value?
|
237
|
+
post[:cavv] = payment_method.payment_cryptogram if payment_method.is_a?(NetworkTokenizationCreditCard)
|
238
|
+
post[:wallet_indicator] = wallet_indicator(payment_method.source.to_s) if payment_method.is_a?(NetworkTokenizationCreditCard)
|
239
|
+
post[:crypt_type] = (payment_method.eci || 7) if payment_method.is_a?(NetworkTokenizationCreditCard)
|
240
|
+
end
|
241
|
+
post[:cust_id] = options[:customer] || payment_method.name
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def add_cof(post, options)
|
246
|
+
post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
|
247
|
+
post[:payment_indicator] = options[:payment_indicator] if options[:payment_indicator]
|
248
|
+
post[:payment_information] = options[:payment_information] if options[:payment_information]
|
249
|
+
end
|
250
|
+
|
251
|
+
def add_stored_credential(post, options)
|
252
|
+
add_cof(post, options)
|
253
|
+
# if any of :issuer_id, :payment_information, or :payment_indicator is not passed,
|
254
|
+
# then check for :stored credential options
|
255
|
+
return unless (stored_credential = options[:stored_credential]) && !cof_details_present?(options)
|
256
|
+
|
257
|
+
if stored_credential[:initial_transaction]
|
258
|
+
add_stored_credential_initial(post, options)
|
259
|
+
else
|
260
|
+
add_stored_credential_used(post, options)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def add_stored_credential_initial(post, options)
|
265
|
+
post[:payment_information] ||= '0'
|
266
|
+
post[:issuer_id] ||= ''
|
267
|
+
if options[:stored_credential][:initiator] == 'merchant'
|
268
|
+
case options[:stored_credential][:reason_type]
|
269
|
+
when 'recurring', 'installment'
|
270
|
+
post[:payment_indicator] ||= 'R'
|
271
|
+
when 'unscheduled'
|
272
|
+
post[:payment_indicator] ||= 'C'
|
273
|
+
end
|
274
|
+
else
|
275
|
+
post[:payment_indicator] ||= 'C'
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def add_stored_credential_used(post, options)
|
280
|
+
post[:payment_information] ||= '2'
|
281
|
+
post[:issuer_id] = options[:stored_credential][:network_transaction_id] if options[:issuer_id].blank?
|
282
|
+
if options[:stored_credential][:initiator] == 'merchant'
|
283
|
+
case options[:stored_credential][:reason_type]
|
284
|
+
when 'recurring', 'installment'
|
285
|
+
post[:payment_indicator] ||= 'R'
|
286
|
+
when '', 'unscheduled'
|
287
|
+
post[:payment_indicator] ||= 'U'
|
288
|
+
end
|
289
|
+
else
|
290
|
+
post[:payment_indicator] ||= 'Z'
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# Common params used amongst the +credit+, +void+ and +capture+ methods
|
295
|
+
def crediting_params(authorization, options = {})
|
296
|
+
{
|
297
|
+
txn_number: split_authorization(authorization).first,
|
298
|
+
order_id: split_authorization(authorization).last,
|
299
|
+
crypt_type: options[:crypt_type] || @options[:crypt_type]
|
300
|
+
}.merge(options)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Splits an +authorization+ param and retrieves the order id and
|
304
|
+
# transaction number in that order.
|
305
|
+
def split_authorization(authorization)
|
306
|
+
if authorization.nil? || authorization.empty? || authorization !~ /;/
|
307
|
+
raise ArgumentError, 'You must include a valid authorization code (e.g. "1234;567")'
|
308
|
+
else
|
309
|
+
authorization.split(';')
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def commit(action, parameters = {}, options = {})
|
314
|
+
threed_ds_transaction = options[:three_d_secure].present?
|
315
|
+
|
316
|
+
data = post_data(action, parameters)
|
317
|
+
url = test? ? self.test_url : self.live_url
|
318
|
+
raw = ssl_post(url, data)
|
319
|
+
response = parse(raw)
|
320
|
+
|
321
|
+
Response.new(
|
322
|
+
successful?(action, response, threed_ds_transaction),
|
323
|
+
message_from(response[:message]),
|
324
|
+
response,
|
325
|
+
test: test?,
|
326
|
+
avs_result: { code: response[:avs_result_code] },
|
327
|
+
cvv_result: response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
|
328
|
+
authorization: authorization_from(response)
|
329
|
+
)
|
330
|
+
end
|
331
|
+
|
332
|
+
# Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
|
333
|
+
def authorization_from(response = {})
|
334
|
+
"#{response[:trans_id]};#{response[:receipt_id]}" if response[:trans_id] && response[:receipt_id]
|
335
|
+
end
|
336
|
+
|
337
|
+
# Tests for a successful response from Moneris' servers
|
338
|
+
def successful?(action, response, threed_ds_transaction = false)
|
339
|
+
# See 9.4 CAVV Result Codes in https://developer.moneris.com/livedemo/3ds2/reference/guide/php
|
340
|
+
cavv_accepted = if threed_ds_transaction
|
341
|
+
response[:cavv_result_code] && response[:cavv_result_code] == '2'
|
342
|
+
else
|
343
|
+
true
|
344
|
+
end
|
345
|
+
|
346
|
+
cavv_accepted &&
|
347
|
+
response[:response_code] &&
|
348
|
+
response[:complete] &&
|
349
|
+
(0..49).cover?(response[:response_code].to_i)
|
350
|
+
end
|
351
|
+
|
352
|
+
def parse(xml)
|
353
|
+
response = { message: 'Global Error Receipt', complete: false }
|
354
|
+
hashify_xml!(xml, response)
|
355
|
+
response
|
356
|
+
end
|
357
|
+
|
358
|
+
def hashify_xml!(xml, response)
|
359
|
+
xml = REXML::Document.new(xml)
|
360
|
+
return if xml.root.nil?
|
361
|
+
|
362
|
+
xml.elements.each('//receipt/*') do |node|
|
363
|
+
response[node.name.underscore.to_sym] = normalize(node.text)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def post_data(action, parameters = {})
|
368
|
+
xml = REXML::Document.new
|
369
|
+
root = xml.add_element('request')
|
370
|
+
root.add_element('store_id').text = options[:login]
|
371
|
+
root.add_element('api_token').text = options[:password]
|
372
|
+
root.add_element(transaction_element(action, parameters))
|
373
|
+
|
374
|
+
xml.to_s
|
375
|
+
end
|
376
|
+
|
377
|
+
def transaction_element(action, parameters)
|
378
|
+
transaction = REXML::Element.new(action)
|
379
|
+
|
380
|
+
# Must add the elements in the correct order
|
381
|
+
actions[action].each do |key|
|
382
|
+
case key
|
383
|
+
when :avs_info
|
384
|
+
transaction.add_element(avs_element(parameters[:address])) if @avs_enabled && parameters[:address]
|
385
|
+
when :cvd_info
|
386
|
+
transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled
|
387
|
+
when :cof_info
|
388
|
+
transaction.add_element(credential_on_file(parameters)) if cof_details_present?(parameters)
|
389
|
+
else
|
390
|
+
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
transaction
|
395
|
+
end
|
396
|
+
|
397
|
+
def avs_element(address)
|
398
|
+
full_address = "#{address[:address1]} #{address[:address2]}"
|
399
|
+
tokens = full_address.split(/\s+/)
|
400
|
+
|
401
|
+
element = REXML::Element.new('avs_info')
|
402
|
+
element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ')
|
403
|
+
element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ')
|
404
|
+
element.add_element('avs_zipcode').text = address[:zip]
|
405
|
+
element
|
406
|
+
end
|
407
|
+
|
408
|
+
def cvd_element(cvd_value)
|
409
|
+
element = REXML::Element.new('cvd_info')
|
410
|
+
if cvd_value
|
411
|
+
element.add_element('cvd_indicator').text = '1'
|
412
|
+
element.add_element('cvd_value').text = cvd_value
|
413
|
+
else
|
414
|
+
element.add_element('cvd_indicator').text = '0'
|
415
|
+
end
|
416
|
+
element
|
417
|
+
end
|
418
|
+
|
419
|
+
def cof_details_present?(parameters)
|
420
|
+
parameters[:issuer_id] && parameters[:payment_indicator] && parameters[:payment_information]
|
421
|
+
end
|
422
|
+
|
423
|
+
def credential_on_file(parameters)
|
424
|
+
issuer_id = parameters[:issuer_id]
|
425
|
+
payment_indicator = parameters[:payment_indicator]
|
426
|
+
payment_information = parameters[:payment_information]
|
427
|
+
|
428
|
+
cof_info = REXML::Element.new('cof_info')
|
429
|
+
cof_info.add_element('issuer_id').text = issuer_id
|
430
|
+
cof_info.add_element('payment_indicator').text = payment_indicator
|
431
|
+
cof_info.add_element('payment_information').text = payment_information
|
432
|
+
cof_info
|
433
|
+
end
|
434
|
+
|
435
|
+
def wallet_indicator(token_source)
|
436
|
+
return {
|
437
|
+
'apple_pay' => 'APP',
|
438
|
+
'google_pay' => 'GPP',
|
439
|
+
'android_pay' => 'ANP'
|
440
|
+
}[token_source]
|
441
|
+
end
|
442
|
+
|
443
|
+
def format_order_id(wallet_indicator_code, order_id = nil)
|
444
|
+
# Truncate (max 100 characters) order id for
|
445
|
+
# google pay and apple pay (specific wallets / token sources)
|
446
|
+
return truncate_order_id(order_id) if WALLETS.include?(wallet_indicator_code)
|
447
|
+
|
448
|
+
order_id
|
449
|
+
end
|
450
|
+
|
451
|
+
def truncate_order_id(order_id = nil)
|
452
|
+
order_id.present? ? order_id[0, 100] : SecureRandom.alphanumeric(100)
|
453
|
+
end
|
454
|
+
|
455
|
+
def message_from(message)
|
456
|
+
return 'Unspecified error' if message.blank?
|
457
|
+
|
458
|
+
message.gsub(/[^\w]/, ' ').split.join(' ').capitalize
|
459
|
+
end
|
460
|
+
|
461
|
+
def actions
|
462
|
+
{
|
463
|
+
'purchase' => %i[order_id cust_id amount pan expdate crypt_type avs_info cvd_info track2 pos_code cof_info],
|
464
|
+
'preauth' => %i[order_id cust_id amount pan expdate crypt_type avs_info cvd_info track2 pos_code cof_info],
|
465
|
+
'command' => [:order_id],
|
466
|
+
'refund' => %i[order_id amount txn_number crypt_type],
|
467
|
+
'indrefund' => %i[order_id cust_id amount pan expdate crypt_type],
|
468
|
+
'completion' => %i[order_id comp_amount txn_number crypt_type],
|
469
|
+
'purchasecorrection' => %i[order_id txn_number crypt_type],
|
470
|
+
'cavv_preauth' => %i[order_id cust_id amount pan expdate cavv crypt_type wallet_indicator],
|
471
|
+
'cavv_purchase' => %i[order_id cust_id amount pan expdate cavv crypt_type wallet_indicator],
|
472
|
+
'card_verification' => %i[order_id cust_id pan expdate crypt_type avs_info cvd_info cof_info],
|
473
|
+
'transact' => %i[order_id cust_id amount pan expdate crypt_type],
|
474
|
+
'Batchcloseall' => [],
|
475
|
+
'opentotals' => [:ecr_number],
|
476
|
+
'batchclose' => [:ecr_number],
|
477
|
+
'res_add_cc' => %i[pan expdate crypt_type avs_info cof_info],
|
478
|
+
'res_temp_add' => %i[pan expdate crypt_type duration],
|
479
|
+
'res_delete' => [:data_key],
|
480
|
+
'res_update_cc' => %i[data_key pan expdate crypt_type avs_info cof_info],
|
481
|
+
'res_purchase_cc' => %i[data_key order_id cust_id amount crypt_type cof_info],
|
482
|
+
'res_preauth_cc' => %i[data_key order_id cust_id amount crypt_type cof_info],
|
483
|
+
'res_card_verification_cc' => %i[order_id data_key expdate crypt_type cof_info]
|
484
|
+
}
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class MoneyMoversGateway < Gateway
|
4
|
+
self.live_url = self.test_url = 'https://secure.mmoagateway.com/api/transact.php'
|
5
|
+
|
6
|
+
APPROVED, DECLINED, ERROR = 1, 2, 3
|
7
|
+
|
8
|
+
self.homepage_url = 'http://mmoa.us/'
|
9
|
+
self.display_name = 'MoneyMovers'
|
10
|
+
self.supported_countries = ['US']
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
requires!(options, :login, :password)
|
15
|
+
@options = options
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def purchase(money, creditcard, options = {})
|
20
|
+
post = {}
|
21
|
+
add_invoice(post, options)
|
22
|
+
add_creditcard(post, creditcard)
|
23
|
+
add_address(post, options)
|
24
|
+
add_customer_data(post, options)
|
25
|
+
commit('sale', money, post)
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(money, creditcard, options = {})
|
29
|
+
post = {}
|
30
|
+
add_invoice(post, options)
|
31
|
+
add_creditcard(post, creditcard)
|
32
|
+
add_address(post, options)
|
33
|
+
add_customer_data(post, options)
|
34
|
+
commit('auth', money, post)
|
35
|
+
end
|
36
|
+
|
37
|
+
def capture(money, authorization, options = {})
|
38
|
+
options[:transactionid] = authorization
|
39
|
+
commit('capture', money, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def void(authorization, options = {})
|
43
|
+
options[:transactionid] = authorization
|
44
|
+
commit('void', nil, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def refund(money, authorization, options = {})
|
48
|
+
commit('refund', money, options.merge(transactionid: authorization))
|
49
|
+
end
|
50
|
+
|
51
|
+
def credit(money, authorization, options = {})
|
52
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
53
|
+
refund(money, authorization, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def add_customer_data(post, options)
|
59
|
+
post[:firstname] = options[:first_name]
|
60
|
+
post[:lastname] = options[:last_name]
|
61
|
+
|
62
|
+
post[:email] = options[:email]
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_address(post, options)
|
66
|
+
if address = (options[:billing_address] || options[:address])
|
67
|
+
post[:company] = address[:company]
|
68
|
+
post[:address1] = address[:address1]
|
69
|
+
post[:address2] = address[:address2]
|
70
|
+
post[:city] = address[:city]
|
71
|
+
post[:state] = address[:state]
|
72
|
+
post[:zip] = address[:zip]
|
73
|
+
post[:country] = address[:country]
|
74
|
+
post[:phone] = address[:phone]
|
75
|
+
end
|
76
|
+
if address = options[:shipping_address]
|
77
|
+
post[:shipping_firstname] = address[:first_name]
|
78
|
+
post[:shipping_lastname] = address[:last_name]
|
79
|
+
post[:shipping_company] = address[:company]
|
80
|
+
post[:shipping_address1] = address[:address1]
|
81
|
+
post[:shipping_address2] = address[:address2]
|
82
|
+
post[:shipping_city] = address[:city]
|
83
|
+
post[:shipping_state] = address[:state]
|
84
|
+
post[:shipping_zip] = address[:zip]
|
85
|
+
post[:shipping_country] = address[:country]
|
86
|
+
post[:shipping_email] = address[:email]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_invoice(post, options)
|
91
|
+
post[:orderid] = options[:order_id]
|
92
|
+
post[:orderdescription] = options[:description]
|
93
|
+
end
|
94
|
+
|
95
|
+
def add_creditcard(post, creditcard)
|
96
|
+
post[:ccnumber] = creditcard.number
|
97
|
+
post[:ccexp] = expdate(creditcard)
|
98
|
+
post[:cvv] = creditcard.verification_value
|
99
|
+
end
|
100
|
+
|
101
|
+
def parse(body)
|
102
|
+
body.split('&').inject({}) do |memo, x|
|
103
|
+
k, v = x.split('=')
|
104
|
+
memo[k] = v
|
105
|
+
memo
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def commit(action, money, parameters)
|
110
|
+
parameters[:amount] = amount(money)
|
111
|
+
|
112
|
+
data = ssl_post(self.live_url, post_data(action, parameters))
|
113
|
+
response = parse(data)
|
114
|
+
message = message_from(response)
|
115
|
+
|
116
|
+
Response.new(success?(response), message, response,
|
117
|
+
test: test?,
|
118
|
+
authorization: response['transactionid'],
|
119
|
+
avs_result: { code: response['avsresponse'] },
|
120
|
+
cvv_result: response['cvvresponse'])
|
121
|
+
end
|
122
|
+
|
123
|
+
def success?(response)
|
124
|
+
response['response'] == '1'
|
125
|
+
end
|
126
|
+
|
127
|
+
def test?
|
128
|
+
@options[:login].eql?('demo') && @options[:password].eql?('password')
|
129
|
+
end
|
130
|
+
|
131
|
+
def message_from(response)
|
132
|
+
case response['response'].to_i
|
133
|
+
when APPROVED
|
134
|
+
'Transaction Approved'
|
135
|
+
when DECLINED
|
136
|
+
'Transaction Declined'
|
137
|
+
else
|
138
|
+
'Error in transaction data or system error'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def post_data(action, parameters = {})
|
143
|
+
parameters[:type] = action
|
144
|
+
parameters[:username] = @options[:login]
|
145
|
+
parameters[:password] = @options[:password]
|
146
|
+
parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|