swiss-crm-activemerchant 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +252 -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 +242 -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 +228 -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 +354 -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 +121 -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,245 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class MerchantPartnersGateway < Gateway
|
6
|
+
self.display_name = 'Merchant Partners'
|
7
|
+
self.homepage_url = 'http://www.merchantpartners.com/'
|
8
|
+
|
9
|
+
self.live_url = 'https://trans.merchantpartners.com/cgi-bin/ProcessXML.cgi'
|
10
|
+
|
11
|
+
self.supported_countries = ['US']
|
12
|
+
self.default_currency = 'USD'
|
13
|
+
self.money_format = :dollars
|
14
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
requires!(options, :account_id, :merchant_pin)
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def purchase(amount, payment_method, options = {})
|
22
|
+
post = {}
|
23
|
+
add_invoice(post, amount, options)
|
24
|
+
add_payment_method(post, payment_method)
|
25
|
+
add_customer_data(post, options)
|
26
|
+
|
27
|
+
commit(payment_method.is_a?(String) ? :stored_purchase : :purchase, post)
|
28
|
+
end
|
29
|
+
|
30
|
+
def authorize(amount, payment_method, options = {})
|
31
|
+
post = {}
|
32
|
+
add_invoice(post, amount, options)
|
33
|
+
add_payment_method(post, payment_method)
|
34
|
+
add_customer_data(post, options)
|
35
|
+
|
36
|
+
commit(:authorize, post)
|
37
|
+
end
|
38
|
+
|
39
|
+
def capture(amount, authorization, options = {})
|
40
|
+
post = {}
|
41
|
+
add_invoice(post, amount, options)
|
42
|
+
add_reference(post, authorization)
|
43
|
+
add_customer_data(post, options)
|
44
|
+
|
45
|
+
commit(:capture, post)
|
46
|
+
end
|
47
|
+
|
48
|
+
def void(authorization, options = {})
|
49
|
+
post = {}
|
50
|
+
add_reference(post, authorization)
|
51
|
+
|
52
|
+
commit(:void, post)
|
53
|
+
end
|
54
|
+
|
55
|
+
def refund(amount, authorization, options = {})
|
56
|
+
post = {}
|
57
|
+
add_invoice(post, amount, options)
|
58
|
+
add_reference(post, authorization)
|
59
|
+
add_customer_data(post, options)
|
60
|
+
|
61
|
+
commit(:refund, post)
|
62
|
+
end
|
63
|
+
|
64
|
+
def credit(amount, payment_method, options = {})
|
65
|
+
post = {}
|
66
|
+
add_invoice(post, amount, options)
|
67
|
+
add_payment_method(post, payment_method)
|
68
|
+
|
69
|
+
commit(payment_method.is_a?(String) ? :stored_credit : :credit, post)
|
70
|
+
end
|
71
|
+
|
72
|
+
def verify(credit_card, options = {})
|
73
|
+
MultiResponse.run(:use_first_response) do |r|
|
74
|
+
r.process { authorize(100, credit_card, options) }
|
75
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def store(payment_method, options = {})
|
80
|
+
post = {}
|
81
|
+
add_payment_method(post, payment_method)
|
82
|
+
add_customer_data(post, options)
|
83
|
+
|
84
|
+
post[:profileactiontype] = options[:profileactiontype] || STORE_TX_TYPES[:store_only]
|
85
|
+
|
86
|
+
commit(:store, post)
|
87
|
+
end
|
88
|
+
|
89
|
+
def supports_scrubbing?
|
90
|
+
true
|
91
|
+
end
|
92
|
+
|
93
|
+
def scrub(transcript)
|
94
|
+
transcript.
|
95
|
+
gsub(%r((<ccnum>)[^<]+(<))i, '\1[FILTERED]\2').
|
96
|
+
gsub(%r((<cvv2>)[^<]+(<))i, '\1[FILTERED]\2').
|
97
|
+
gsub(%r((<merchantpin>)[^<]+(<))i, '\1[FILTERED]\2')
|
98
|
+
end
|
99
|
+
|
100
|
+
def test?
|
101
|
+
@options[:account_id].eql?('TEST0')
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def add_invoice(post, money, options)
|
107
|
+
post[:amount] = amount(money)
|
108
|
+
post[:merchantordernumber] = options[:order_id]
|
109
|
+
post[:currency] = options[:currency] || currency(money)
|
110
|
+
end
|
111
|
+
|
112
|
+
def add_payment_method(post, payment_method)
|
113
|
+
if payment_method.is_a?(String)
|
114
|
+
user_profile_id, last4 = split_authorization(payment_method)
|
115
|
+
post[:userprofileid] = user_profile_id
|
116
|
+
post[:last4digits] = last4
|
117
|
+
else
|
118
|
+
post[:ccname] = payment_method.name
|
119
|
+
post[:ccnum] = payment_method.number
|
120
|
+
post[:cvv2] = payment_method.verification_value
|
121
|
+
post[:expmon] = format(payment_method.month, :two_digits)
|
122
|
+
post[:expyear] = format(payment_method.year, :four_digits)
|
123
|
+
post[:swipedata] = payment_method.track_data if payment_method.track_data
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def add_customer_data(post, options)
|
128
|
+
post[:email] = options[:email] if options[:email]
|
129
|
+
post[:ipaddress] = options[:ip] if options[:ip]
|
130
|
+
if (billing_address = options[:billing_address])
|
131
|
+
post[:billaddr1] = billing_address[:address1]
|
132
|
+
post[:billaddr2] = billing_address[:address2]
|
133
|
+
post[:billcity] = billing_address[:city]
|
134
|
+
post[:billstate] = billing_address[:state]
|
135
|
+
post[:billcountry] = billing_address[:country]
|
136
|
+
post[:bilzip] = billing_address[:zip]
|
137
|
+
post[:phone] = billing_address[:phone]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def add_reference(post, authorization)
|
142
|
+
post[:historykeyid] = authorization
|
143
|
+
end
|
144
|
+
|
145
|
+
ACTIONS = {
|
146
|
+
purchase: '2',
|
147
|
+
authorize: '1',
|
148
|
+
capture: '3',
|
149
|
+
void: '5',
|
150
|
+
refund: '4',
|
151
|
+
credit: '6',
|
152
|
+
store: '7',
|
153
|
+
stored_purchase: '8',
|
154
|
+
stored_credit: '13'
|
155
|
+
}
|
156
|
+
|
157
|
+
STORE_TX_TYPES = {
|
158
|
+
store_only: '3'
|
159
|
+
}
|
160
|
+
|
161
|
+
def commit(action, post)
|
162
|
+
post[:acctid] = @options[:account_id]
|
163
|
+
post[:merchantpin] = @options[:merchant_pin]
|
164
|
+
post[:service] = ACTIONS[action] if ACTIONS[action]
|
165
|
+
|
166
|
+
data = build_request(post)
|
167
|
+
response_data = parse(ssl_post(live_url, data, headers))
|
168
|
+
succeeded = success_from(response_data)
|
169
|
+
|
170
|
+
Response.new(
|
171
|
+
succeeded,
|
172
|
+
message_from(succeeded, response_data),
|
173
|
+
response_data,
|
174
|
+
authorization: authorization_from(post, response_data),
|
175
|
+
avs_result: AVSResult.new(code: response_data['avs_response']),
|
176
|
+
cvv_result: CVVResult.new(response_data['cvv2_response']),
|
177
|
+
test: test?
|
178
|
+
)
|
179
|
+
end
|
180
|
+
|
181
|
+
def headers
|
182
|
+
{
|
183
|
+
'Content-Type' => 'application/xml'
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
def build_request(post)
|
188
|
+
Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
|
189
|
+
xml.interface_driver {
|
190
|
+
xml.trans_catalog {
|
191
|
+
xml.transaction(name: 'creditcard') {
|
192
|
+
xml.inputs {
|
193
|
+
post.each do |field, value|
|
194
|
+
xml.send(field, value)
|
195
|
+
end
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
end.to_xml
|
201
|
+
end
|
202
|
+
|
203
|
+
def parse(body)
|
204
|
+
response = {}
|
205
|
+
Nokogiri::XML(CGI.unescapeHTML(body)).xpath('//trans_catalog/transaction/outputs').children.each do |node|
|
206
|
+
parse_element(response, node)
|
207
|
+
end
|
208
|
+
response
|
209
|
+
end
|
210
|
+
|
211
|
+
def parse_element(response, node)
|
212
|
+
if node.elements.size == 0
|
213
|
+
response[node.name.downcase.underscore.to_sym] = node.text
|
214
|
+
else
|
215
|
+
node.elements.each { |element| parse_element(response, element) }
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def success_from(response)
|
220
|
+
response[:status] == 'Approved'
|
221
|
+
end
|
222
|
+
|
223
|
+
def message_from(succeeded, response)
|
224
|
+
succeeded ? 'Succeeded' : error_message_from(response)
|
225
|
+
end
|
226
|
+
|
227
|
+
def authorization_from(request, response)
|
228
|
+
request[:service] == ACTIONS[:store] ?
|
229
|
+
"#{response[:userprofileid]}|#{response[:last4digits]}" :
|
230
|
+
response[:historyid]
|
231
|
+
end
|
232
|
+
|
233
|
+
def split_authorization(authorization)
|
234
|
+
authorization.split('|')
|
235
|
+
end
|
236
|
+
|
237
|
+
def error_message_from(response)
|
238
|
+
if response[:status] == 'Declined'
|
239
|
+
match = response[:result].match(/DECLINED:\d{10}:(.+):/)
|
240
|
+
match[1] if match
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,313 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class MerchantWareGateway < Gateway
|
4
|
+
class_attribute :v4_live_url
|
5
|
+
|
6
|
+
self.live_url = self.test_url = 'https://ps1.merchantware.net/MerchantWARE/ws/RetailTransaction/TXRetail.asmx'
|
7
|
+
self.v4_live_url = 'https://ps1.merchantware.net/Merchantware/ws/RetailTransaction/v4/Credit.asmx'
|
8
|
+
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
11
|
+
self.homepage_url = 'http://merchantwarehouse.com/merchantware'
|
12
|
+
self.display_name = 'MerchantWARE'
|
13
|
+
|
14
|
+
ENV_NAMESPACES = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
15
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
16
|
+
'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/' }
|
17
|
+
ENV_NAMESPACES_V4 = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
18
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
19
|
+
'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' }
|
20
|
+
|
21
|
+
TX_NAMESPACE = 'http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail'
|
22
|
+
TX_NAMESPACE_V4 = 'http://schemas.merchantwarehouse.com/merchantware/40/Credit/'
|
23
|
+
|
24
|
+
ACTIONS = {
|
25
|
+
purchase: 'IssueKeyedSale',
|
26
|
+
authorize: 'IssueKeyedPreAuth',
|
27
|
+
capture: 'IssuePostAuth',
|
28
|
+
void: 'VoidPreAuthorization',
|
29
|
+
credit: 'IssueKeyedRefund',
|
30
|
+
reference_credit: 'IssueRefundByReference'
|
31
|
+
}
|
32
|
+
|
33
|
+
# Creates a new MerchantWareGateway
|
34
|
+
#
|
35
|
+
# The gateway requires that a valid login, password, and name be passed
|
36
|
+
# in the +options+ hash.
|
37
|
+
#
|
38
|
+
# ==== Options
|
39
|
+
#
|
40
|
+
# * <tt>:login</tt> - The MerchantWARE SiteID.
|
41
|
+
# * <tt>:password</tt> - The MerchantWARE Key.
|
42
|
+
# * <tt>:name</tt> - The MerchantWARE Name.
|
43
|
+
def initialize(options = {})
|
44
|
+
requires!(options, :login, :password, :name)
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
# Authorize a credit card for a given amount.
|
49
|
+
#
|
50
|
+
# ==== Parameters
|
51
|
+
# * <tt>money</tt> - The amount to be authorized as an Integer value in cents.
|
52
|
+
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
|
53
|
+
# * <tt>options</tt>
|
54
|
+
# * <tt>:order_id</tt> - A unique reference for this order (required).
|
55
|
+
# * <tt>:billing_address</tt> - The billing address for the cardholder.
|
56
|
+
def authorize(money, credit_card, options = {})
|
57
|
+
request = build_purchase_request(:authorize, money, credit_card, options)
|
58
|
+
commit(:authorize, request)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Authorize and immediately capture funds from a credit card.
|
62
|
+
#
|
63
|
+
# ==== Parameters
|
64
|
+
# * <tt>money</tt> - The amount to be authorized as anInteger value in cents.
|
65
|
+
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
|
66
|
+
# * <tt>options</tt>
|
67
|
+
# * <tt>:order_id</tt> - A unique reference for this order (required).
|
68
|
+
# * <tt>:billing_address</tt> - The billing address for the cardholder.
|
69
|
+
def purchase(money, credit_card, options = {})
|
70
|
+
request = build_purchase_request(:purchase, money, credit_card, options)
|
71
|
+
commit(:purchase, request)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Capture authorized funds from a credit card.
|
75
|
+
#
|
76
|
+
# ==== Parameters
|
77
|
+
# * <tt>money</tt> - The amount to be captured as anInteger value in cents.
|
78
|
+
# * <tt>authorization</tt> - The authorization string returned from the initial authorization.
|
79
|
+
def capture(money, authorization, options = {})
|
80
|
+
request = build_capture_request(:capture, money, authorization, options)
|
81
|
+
commit(:capture, request)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Void a transaction.
|
85
|
+
#
|
86
|
+
# ==== Parameters
|
87
|
+
# * <tt>authorization</tt> - The authorization string returned from the initial authorization or purchase.
|
88
|
+
def void(authorization, options = {})
|
89
|
+
reference, options[:order_id] = split_reference(authorization)
|
90
|
+
request = v4_soap_request(:void) do |xml|
|
91
|
+
add_reference_token(xml, reference)
|
92
|
+
end
|
93
|
+
commit(:void, request, true)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Refund an amount back a cardholder
|
97
|
+
#
|
98
|
+
# ==== Parameters
|
99
|
+
#
|
100
|
+
# * <tt>money</tt> - The amount to be refunded as an Integer value in cents.
|
101
|
+
# * <tt>identification</tt> - The credit card you want to refund or the authorization for the existing transaction you are refunding.
|
102
|
+
# * <tt>options</tt>
|
103
|
+
# * <tt>:order_id</tt> - A unique reference for this order (required when performing a non-referenced credit)
|
104
|
+
def credit(money, identification, options = {})
|
105
|
+
if identification.is_a?(String)
|
106
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
107
|
+
refund(money, identification, options)
|
108
|
+
else
|
109
|
+
perform_credit(money, identification, options)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def refund(money, reference, options = {})
|
114
|
+
perform_reference_credit(money, reference, options)
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def soap_request(action)
|
120
|
+
xml = Builder::XmlMarkup.new indent: 2
|
121
|
+
xml.instruct!
|
122
|
+
xml.tag! 'env:Envelope', ENV_NAMESPACES do
|
123
|
+
xml.tag! 'env:Body' do
|
124
|
+
xml.tag! ACTIONS[action], 'xmlns' => TX_NAMESPACE do
|
125
|
+
add_credentials(xml)
|
126
|
+
yield xml
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
xml.target!
|
131
|
+
end
|
132
|
+
|
133
|
+
def v4_soap_request(action)
|
134
|
+
xml = Builder::XmlMarkup.new indent: 2
|
135
|
+
xml.instruct!
|
136
|
+
xml.tag! 'soap:Envelope', ENV_NAMESPACES_V4 do
|
137
|
+
xml.tag! 'soap:Body' do
|
138
|
+
xml.tag! ACTIONS[:void], 'xmlns' => TX_NAMESPACE_V4 do
|
139
|
+
xml.tag! 'merchantName', @options[:name]
|
140
|
+
xml.tag! 'merchantSiteId', @options[:login]
|
141
|
+
xml.tag! 'merchantKey', @options[:password]
|
142
|
+
yield xml
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
xml.target!
|
147
|
+
end
|
148
|
+
|
149
|
+
def build_purchase_request(action, money, credit_card, options)
|
150
|
+
requires!(options, :order_id)
|
151
|
+
|
152
|
+
soap_request(action) do |xml|
|
153
|
+
add_invoice(xml, options)
|
154
|
+
add_amount(xml, money)
|
155
|
+
add_credit_card(xml, credit_card)
|
156
|
+
add_address(xml, options)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def build_capture_request(action, money, identification, options)
|
161
|
+
reference, options[:order_id] = split_reference(identification)
|
162
|
+
|
163
|
+
soap_request(action) do |xml|
|
164
|
+
add_reference(xml, reference)
|
165
|
+
add_invoice(xml, options)
|
166
|
+
add_amount(xml, money)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def perform_reference_credit(money, identification, options)
|
171
|
+
reference, options[:order_id] = split_reference(identification)
|
172
|
+
|
173
|
+
request = soap_request(:reference_credit) do |xml|
|
174
|
+
add_reference(xml, reference)
|
175
|
+
add_invoice(xml, options)
|
176
|
+
add_amount(xml, money, 'strOverrideAmount')
|
177
|
+
end
|
178
|
+
|
179
|
+
commit(:reference_credit, request)
|
180
|
+
end
|
181
|
+
|
182
|
+
def perform_credit(money, credit_card, options)
|
183
|
+
requires!(options, :order_id)
|
184
|
+
|
185
|
+
request = soap_request(:credit) do |xml|
|
186
|
+
add_invoice(xml, options)
|
187
|
+
add_amount(xml, money)
|
188
|
+
add_credit_card(xml, credit_card)
|
189
|
+
end
|
190
|
+
|
191
|
+
commit(:credit, request)
|
192
|
+
end
|
193
|
+
|
194
|
+
def add_credentials(xml)
|
195
|
+
xml.tag! 'strSiteId', @options[:login]
|
196
|
+
xml.tag! 'strKey', @options[:password]
|
197
|
+
xml.tag! 'strName', @options[:name]
|
198
|
+
end
|
199
|
+
|
200
|
+
def add_invoice(xml, options)
|
201
|
+
xml.tag! 'strOrderNumber', options[:order_id].to_s.gsub(/[^\w]/, '').slice(0, 25)
|
202
|
+
end
|
203
|
+
|
204
|
+
def add_amount(xml, money, tag = 'strAmount')
|
205
|
+
xml.tag! tag, amount(money)
|
206
|
+
end
|
207
|
+
|
208
|
+
def add_reference(xml, reference)
|
209
|
+
xml.tag! 'strReferenceCode', reference
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_reference_token(xml, reference)
|
213
|
+
xml.tag! 'token', reference
|
214
|
+
end
|
215
|
+
|
216
|
+
def add_address(xml, options)
|
217
|
+
if address = options[:billing_address] || options[:address]
|
218
|
+
xml.tag! 'strAVSStreetAddress', address[:address1]
|
219
|
+
xml.tag! 'strAVSZipCode', address[:zip]
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_credit_card(xml, credit_card)
|
224
|
+
if credit_card.respond_to?(:track_data) && credit_card.track_data.present?
|
225
|
+
xml.tag! 'trackData', credit_card.track_data
|
226
|
+
else
|
227
|
+
xml.tag! 'strPAN', credit_card.number
|
228
|
+
xml.tag! 'strExpDate', expdate(credit_card)
|
229
|
+
xml.tag! 'strCardHolder', credit_card.name
|
230
|
+
xml.tag! 'strCVCode', credit_card.verification_value if credit_card.verification_value?
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def split_reference(reference)
|
235
|
+
reference.to_s.split(';')
|
236
|
+
end
|
237
|
+
|
238
|
+
def parse(action, data)
|
239
|
+
response = {}
|
240
|
+
xml = REXML::Document.new(data)
|
241
|
+
|
242
|
+
root = REXML::XPath.first(xml, "//#{ACTIONS[action]}Response/#{ACTIONS[action]}Result")
|
243
|
+
|
244
|
+
root.elements.each do |element|
|
245
|
+
response[element.name] = element.text
|
246
|
+
end
|
247
|
+
|
248
|
+
status, code, message = response['ApprovalStatus'].split(';')
|
249
|
+
response[:status] = status
|
250
|
+
|
251
|
+
if response[:success] = status == 'APPROVED'
|
252
|
+
response[:message] = status
|
253
|
+
else
|
254
|
+
response[:message] = message
|
255
|
+
response[:failure_code] = code
|
256
|
+
end
|
257
|
+
|
258
|
+
response
|
259
|
+
end
|
260
|
+
|
261
|
+
def parse_error(http_response)
|
262
|
+
response = {}
|
263
|
+
response[:http_code] = http_response.code
|
264
|
+
response[:http_message] = http_response.message
|
265
|
+
response[:success] = false
|
266
|
+
|
267
|
+
document = REXML::Document.new(http_response.body)
|
268
|
+
|
269
|
+
node = REXML::XPath.first(document, '//soap:Fault')
|
270
|
+
|
271
|
+
node.elements.each do |element|
|
272
|
+
response[element.name] = element.text
|
273
|
+
end
|
274
|
+
|
275
|
+
response[:message] = response['faultstring'].to_s.tr("\n", ' ')
|
276
|
+
response
|
277
|
+
rescue REXML::ParseException
|
278
|
+
response[:http_body] = http_response.body
|
279
|
+
response[:message] = 'Failed to parse the failed response'
|
280
|
+
response
|
281
|
+
end
|
282
|
+
|
283
|
+
def soap_action(action, v4 = false)
|
284
|
+
v4 ? "#{TX_NAMESPACE_V4}#{ACTIONS[action]}" : "#{TX_NAMESPACE}/#{ACTIONS[action]}"
|
285
|
+
end
|
286
|
+
|
287
|
+
def url(v4 = false)
|
288
|
+
v4 ? v4_live_url : live_url
|
289
|
+
end
|
290
|
+
|
291
|
+
def commit(action, request, v4 = false)
|
292
|
+
begin
|
293
|
+
data = ssl_post(url(v4), request,
|
294
|
+
'Content-Type' => 'text/xml; charset=utf-8',
|
295
|
+
'SOAPAction' => soap_action(action, v4))
|
296
|
+
response = parse(action, data)
|
297
|
+
rescue ActiveMerchant::ResponseError => e
|
298
|
+
response = parse_error(e.response)
|
299
|
+
end
|
300
|
+
|
301
|
+
Response.new(response[:success], response[:message], response,
|
302
|
+
test: test?,
|
303
|
+
authorization: authorization_from(response),
|
304
|
+
avs_result: { code: response['AVSResponse'] },
|
305
|
+
cvv_result: response['CVResponse'])
|
306
|
+
end
|
307
|
+
|
308
|
+
def authorization_from(response)
|
309
|
+
[response['ReferenceID'], response['OrderNumber']].join(';') if response[:success]
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|