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,472 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class HpsGateway < Gateway
|
6
|
+
self.live_url = 'https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl'
|
7
|
+
self.test_url = 'https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl'
|
8
|
+
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover jbc diners_club]
|
12
|
+
|
13
|
+
self.homepage_url = 'http://developer.heartlandpaymentsystems.com/SecureSubmit/'
|
14
|
+
self.display_name = 'Heartland Payment Systems'
|
15
|
+
|
16
|
+
self.money_format = :dollars
|
17
|
+
|
18
|
+
PAYMENT_DATA_SOURCE_MAPPING = {
|
19
|
+
apple_pay: 'ApplePay',
|
20
|
+
master: 'MasterCard 3DSecure',
|
21
|
+
visa: 'Visa 3DSecure',
|
22
|
+
american_express: 'AMEX 3DSecure',
|
23
|
+
discover: 'Discover 3DSecure',
|
24
|
+
android_pay: 'GooglePayApp',
|
25
|
+
google_pay: 'GooglePayApp'
|
26
|
+
}
|
27
|
+
|
28
|
+
def initialize(options = {})
|
29
|
+
requires!(options, :secret_api_key)
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def authorize(money, card_or_token, options = {})
|
34
|
+
commit('CreditAuth') do |xml|
|
35
|
+
add_amount(xml, money)
|
36
|
+
add_allow_dup(xml)
|
37
|
+
add_card_or_token_customer_data(xml, card_or_token, options)
|
38
|
+
add_details(xml, options)
|
39
|
+
add_descriptor_name(xml, options)
|
40
|
+
add_card_or_token_payment(xml, card_or_token, options)
|
41
|
+
add_three_d_secure(xml, card_or_token, options)
|
42
|
+
add_stored_credentials(xml, options)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def capture(money, transaction_id, options = {})
|
47
|
+
commit('CreditAddToBatch', transaction_id) do |xml|
|
48
|
+
add_amount(xml, money)
|
49
|
+
add_reference(xml, transaction_id)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def purchase(money, payment_method, options = {})
|
54
|
+
if payment_method.is_a?(Check)
|
55
|
+
commit_check_sale(money, payment_method, options)
|
56
|
+
elsif options.dig(:stored_credential, :reason_type) == 'recurring'
|
57
|
+
commit_recurring_billing_sale(money, payment_method, options)
|
58
|
+
else
|
59
|
+
commit_credit_sale(money, payment_method, options)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def refund(money, transaction_id, options = {})
|
64
|
+
commit('CreditReturn') do |xml|
|
65
|
+
add_amount(xml, money)
|
66
|
+
add_allow_dup(xml)
|
67
|
+
add_reference(xml, transaction_id)
|
68
|
+
add_card_or_token_customer_data(xml, transaction_id, options)
|
69
|
+
add_details(xml, options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def credit(money, payment_method, options = {})
|
74
|
+
commit('CreditReturn') do |xml|
|
75
|
+
add_amount(xml, money)
|
76
|
+
add_allow_dup(xml)
|
77
|
+
add_card_or_token_payment(xml, payment_method, options)
|
78
|
+
add_details(xml, options)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def verify(card_or_token, options = {})
|
83
|
+
commit('CreditAccountVerify') do |xml|
|
84
|
+
add_card_or_token_customer_data(xml, card_or_token, options)
|
85
|
+
add_descriptor_name(xml, options)
|
86
|
+
add_card_or_token_payment(xml, card_or_token, options)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def void(transaction_id, options = {})
|
91
|
+
if options[:check_void]
|
92
|
+
commit('CheckVoid') do |xml|
|
93
|
+
add_reference(xml, transaction_id)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
commit('CreditVoid') do |xml|
|
97
|
+
add_reference(xml, transaction_id)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def supports_scrubbing?
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
def scrub(transcript)
|
107
|
+
transcript.
|
108
|
+
gsub(%r((<hps:CardNbr>)[^<]*(<\/hps:CardNbr>))i, '\1[FILTERED]\2').
|
109
|
+
gsub(%r((<hps:CVV2>)[^<]*(<\/hps:CVV2>))i, '\1[FILTERED]\2').
|
110
|
+
gsub(%r((<hps:SecretAPIKey>)[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2').
|
111
|
+
gsub(%r((<hps:PaymentData>)[^<]*(<\/hps:PaymentData>))i, '\1[FILTERED]\2').
|
112
|
+
gsub(%r((<hps:RoutingNumber>)[^<]*(<\/hps:RoutingNumber>))i, '\1[FILTERED]\2').
|
113
|
+
gsub(%r((<hps:AccountNumber>)[^<]*(<\/hps:AccountNumber>))i, '\1[FILTERED]\2')
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def commit_check_sale(money, check, options)
|
119
|
+
commit('CheckSale') do |xml|
|
120
|
+
add_check_payment(xml, check, options)
|
121
|
+
add_amount(xml, money)
|
122
|
+
add_sec_code(xml, options)
|
123
|
+
add_check_customer_data(xml, check, options)
|
124
|
+
add_details(xml, options)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def commit_credit_sale(money, card_or_token, options)
|
129
|
+
commit('CreditSale') do |xml|
|
130
|
+
add_amount(xml, money)
|
131
|
+
add_allow_dup(xml)
|
132
|
+
add_card_or_token_customer_data(xml, card_or_token, options)
|
133
|
+
add_details(xml, options)
|
134
|
+
add_descriptor_name(xml, options)
|
135
|
+
add_card_or_token_payment(xml, card_or_token, options)
|
136
|
+
add_three_d_secure(xml, card_or_token, options)
|
137
|
+
add_stored_credentials(xml, options)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def commit_recurring_billing_sale(money, card_or_token, options)
|
142
|
+
commit('RecurringBilling') do |xml|
|
143
|
+
add_amount(xml, money)
|
144
|
+
add_allow_dup(xml)
|
145
|
+
add_card_or_token_customer_data(xml, card_or_token, options)
|
146
|
+
add_details(xml, options)
|
147
|
+
add_descriptor_name(xml, options)
|
148
|
+
add_card_or_token_payment(xml, card_or_token, options)
|
149
|
+
add_three_d_secure(xml, card_or_token, options)
|
150
|
+
add_stored_credentials(xml, options)
|
151
|
+
add_stored_credentials_for_recurring_billing(xml, options)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def add_reference(xml, transaction_id)
|
156
|
+
reference = transaction_id.to_s.include?('|') ? transaction_id.split('|').first : transaction_id
|
157
|
+
xml.hps :GatewayTxnId, reference
|
158
|
+
end
|
159
|
+
|
160
|
+
def add_amount(xml, money)
|
161
|
+
xml.hps :Amt, amount(money) if money
|
162
|
+
end
|
163
|
+
|
164
|
+
def add_card_or_token_customer_data(xml, credit_card, options)
|
165
|
+
xml.hps :CardHolderData do
|
166
|
+
if credit_card.respond_to?(:number)
|
167
|
+
xml.hps :CardHolderFirstName, credit_card.first_name if credit_card.first_name
|
168
|
+
xml.hps :CardHolderLastName, credit_card.last_name if credit_card.last_name
|
169
|
+
end
|
170
|
+
|
171
|
+
xml.hps :CardHolderEmail, options[:email] if options[:email]
|
172
|
+
xml.hps :CardHolderPhone, options[:phone] if options[:phone]
|
173
|
+
|
174
|
+
if (billing_address = (options[:billing_address] || options[:address]))
|
175
|
+
xml.hps :CardHolderAddr, billing_address[:address1] if billing_address[:address1]
|
176
|
+
xml.hps :CardHolderCity, billing_address[:city] if billing_address[:city]
|
177
|
+
xml.hps :CardHolderState, billing_address[:state] if billing_address[:state]
|
178
|
+
xml.hps :CardHolderZip, alphanumeric_zip(billing_address[:zip]) if billing_address[:zip]
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_check_customer_data(xml, check, options)
|
184
|
+
xml.hps :ConsumerInfo do
|
185
|
+
xml.hps :FirstName, check.first_name
|
186
|
+
xml.hps :LastName, check.last_name
|
187
|
+
xml.hps :CheckName, options[:company_name] if options[:company_name]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def add_card_or_token_payment(xml, card_or_token, options)
|
192
|
+
xml.hps :CardData do
|
193
|
+
if card_or_token.respond_to?(:number)
|
194
|
+
if card_or_token.track_data
|
195
|
+
xml.tag!('hps:TrackData', 'method' => 'swipe') do
|
196
|
+
xml.text! card_or_token.track_data
|
197
|
+
end
|
198
|
+
if options[:encryption_type]
|
199
|
+
xml.hps :EncryptionData do
|
200
|
+
xml.hps :Version, options[:encryption_type]
|
201
|
+
if options[:encryption_type] == '02'
|
202
|
+
xml.hps :EncryptedTrackNumber, options[:encrypted_track_number]
|
203
|
+
xml.hps :KTB, options[:ktb]
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else
|
208
|
+
xml.hps :ManualEntry do
|
209
|
+
xml.hps :CardNbr, card_or_token.number
|
210
|
+
xml.hps :ExpMonth, card_or_token.month
|
211
|
+
xml.hps :ExpYear, card_or_token.year
|
212
|
+
xml.hps :CVV2, card_or_token.verification_value if card_or_token.verification_value
|
213
|
+
xml.hps :CardPresent, 'N'
|
214
|
+
xml.hps :ReaderPresent, 'N'
|
215
|
+
end
|
216
|
+
end
|
217
|
+
else
|
218
|
+
xml.hps :TokenData do
|
219
|
+
xml.hps :TokenValue, card_or_token
|
220
|
+
end
|
221
|
+
end
|
222
|
+
xml.hps :TokenRequest, (options[:store] ? 'Y' : 'N')
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def add_check_payment(xml, check, options)
|
227
|
+
xml.hps :CheckAction, 'SALE'
|
228
|
+
xml.hps :AccountInfo do
|
229
|
+
xml.hps :RoutingNumber, check.routing_number
|
230
|
+
xml.hps :AccountNumber, check.account_number
|
231
|
+
xml.hps :CheckNumber, check.number
|
232
|
+
xml.hps :AccountType, check.account_type&.upcase
|
233
|
+
end
|
234
|
+
xml.hps :CheckType, check.account_holder_type&.upcase
|
235
|
+
end
|
236
|
+
|
237
|
+
def add_details(xml, options)
|
238
|
+
xml.hps :AdditionalTxnFields do
|
239
|
+
xml.hps :Description, options[:description] if options[:description]
|
240
|
+
xml.hps :InvoiceNbr, options[:order_id][0..59] if options[:order_id]
|
241
|
+
xml.hps :CustomerID, options[:customer_id] if options[:customer_id]
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def add_sec_code(xml, options)
|
246
|
+
xml.hps :SECCode, options[:sec_code] || 'WEB'
|
247
|
+
end
|
248
|
+
|
249
|
+
def add_allow_dup(xml)
|
250
|
+
xml.hps :AllowDup, 'Y'
|
251
|
+
end
|
252
|
+
|
253
|
+
def add_descriptor_name(xml, options)
|
254
|
+
xml.hps :TxnDescriptor, options[:descriptor_name] if options[:descriptor_name]
|
255
|
+
end
|
256
|
+
|
257
|
+
def add_three_d_secure(xml, card_or_token, options)
|
258
|
+
if card_or_token.is_a?(NetworkTokenizationCreditCard)
|
259
|
+
build_three_d_secure(xml, {
|
260
|
+
source: card_or_token.source,
|
261
|
+
cavv: card_or_token.payment_cryptogram,
|
262
|
+
eci: card_or_token.eci,
|
263
|
+
xid: card_or_token.transaction_id
|
264
|
+
})
|
265
|
+
elsif options[:three_d_secure]
|
266
|
+
options[:three_d_secure][:source] ||= card_brand(card_or_token)
|
267
|
+
build_three_d_secure(xml, options[:three_d_secure])
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def build_three_d_secure(xml, three_d_secure)
|
272
|
+
# PaymentDataSource is required when supplying the SecureECommerce data group,
|
273
|
+
# and the gateway currently only allows the values within the mapping
|
274
|
+
return unless PAYMENT_DATA_SOURCE_MAPPING[three_d_secure[:source].to_sym]
|
275
|
+
|
276
|
+
xml.hps :SecureECommerce do
|
277
|
+
xml.hps :PaymentDataSource, PAYMENT_DATA_SOURCE_MAPPING[three_d_secure[:source].to_sym]
|
278
|
+
xml.hps :TypeOfPaymentData, '3DSecure' # Only type currently supported
|
279
|
+
xml.hps :PaymentData, three_d_secure[:cavv] if three_d_secure[:cavv]
|
280
|
+
# the gateway only allows a single character for the ECI
|
281
|
+
xml.hps :ECommerceIndicator, strip_leading_zero(three_d_secure[:eci]) if three_d_secure[:eci]
|
282
|
+
xml.hps :XID, three_d_secure[:xid] if three_d_secure[:xid]
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
# We do not currently support installments on this gateway.
|
287
|
+
# The HPS gateway treats recurring transactions as a seperate transaction type
|
288
|
+
def add_stored_credentials(xml, options)
|
289
|
+
return unless options[:stored_credential]
|
290
|
+
|
291
|
+
xml.hps :CardOnFileData do
|
292
|
+
if options[:stored_credential][:initiator] == 'customer'
|
293
|
+
xml.hps :CardOnFile, 'C'
|
294
|
+
elsif options[:stored_credential][:initiator] == 'merchant'
|
295
|
+
xml.hps :CardOnFile, 'M'
|
296
|
+
else
|
297
|
+
return
|
298
|
+
end
|
299
|
+
|
300
|
+
if options[:stored_credential][:network_transaction_id]
|
301
|
+
xml.hps :CardBrandTxnId, options[:stored_credential][:network_transaction_id]
|
302
|
+
else
|
303
|
+
return
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
def add_stored_credentials_for_recurring_billing(xml, options)
|
309
|
+
xml.hps :RecurringData do
|
310
|
+
if options[:stored_credential][:reason_type] = 'recurring'
|
311
|
+
xml.hps :OneTime, 'N'
|
312
|
+
else
|
313
|
+
xml.hps :OneTime, 'Y'
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def strip_leading_zero(value)
|
319
|
+
return value unless value[0] == '0'
|
320
|
+
|
321
|
+
value[1, 1]
|
322
|
+
end
|
323
|
+
|
324
|
+
def build_request(action)
|
325
|
+
xml = Builder::XmlMarkup.new(encoding: 'UTF-8')
|
326
|
+
xml.instruct!(:xml, encoding: 'UTF-8')
|
327
|
+
xml.SOAP :Envelope, {
|
328
|
+
'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
|
329
|
+
'xmlns:hps' => 'http://Hps.Exchange.PosGateway'
|
330
|
+
} do
|
331
|
+
xml.SOAP :Body do
|
332
|
+
xml.hps :PosRequest do
|
333
|
+
xml.hps 'Ver1.0'.to_sym do
|
334
|
+
xml.hps :Header do
|
335
|
+
xml.hps :SecretAPIKey, @options[:secret_api_key]
|
336
|
+
xml.hps :DeveloperID, @options[:developer_id] if @options[:developer_id]
|
337
|
+
xml.hps :VersionNbr, @options[:version_number] if @options[:version_number]
|
338
|
+
xml.hps :SiteTrace, @options[:site_trace] if @options[:site_trace]
|
339
|
+
end
|
340
|
+
xml.hps :Transaction do
|
341
|
+
xml.hps action.to_sym do
|
342
|
+
if %w(CreditVoid CreditAddToBatch).include?(action)
|
343
|
+
yield(xml)
|
344
|
+
else
|
345
|
+
xml.hps :Block1 do
|
346
|
+
yield(xml)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
xml.target!
|
356
|
+
end
|
357
|
+
|
358
|
+
def parse(raw)
|
359
|
+
response = {}
|
360
|
+
|
361
|
+
doc = Nokogiri::XML(raw)
|
362
|
+
doc.remove_namespaces!
|
363
|
+
if (header = doc.xpath('//Header').first)
|
364
|
+
header.elements.each do |node|
|
365
|
+
if node.elements.size == 0
|
366
|
+
response[node.name] = node.text
|
367
|
+
else
|
368
|
+
node.elements.each do |childnode|
|
369
|
+
response[childnode.name] = childnode.text
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
if (transaction = doc.xpath('//Transaction/*[1]').first)
|
375
|
+
transaction.elements.each do |node|
|
376
|
+
response[node.name] = node.text
|
377
|
+
end
|
378
|
+
end
|
379
|
+
if (fault = doc.xpath('//Fault/Reason/Text').first)
|
380
|
+
response['Fault'] = fault.text
|
381
|
+
end
|
382
|
+
|
383
|
+
response
|
384
|
+
end
|
385
|
+
|
386
|
+
def commit(action, reference = nil, &request)
|
387
|
+
data = build_request(action, &request)
|
388
|
+
|
389
|
+
response =
|
390
|
+
begin
|
391
|
+
parse(ssl_post((test? ? test_url : live_url), data, 'Content-Type' => 'text/xml'))
|
392
|
+
rescue ResponseError => e
|
393
|
+
parse(e.response.body)
|
394
|
+
end
|
395
|
+
|
396
|
+
ActiveMerchant::Billing::Response.new(
|
397
|
+
successful?(response),
|
398
|
+
message_from(response),
|
399
|
+
response,
|
400
|
+
test: test?,
|
401
|
+
authorization: authorization_from(response, reference),
|
402
|
+
avs_result: {
|
403
|
+
code: response['AVSRsltCode'],
|
404
|
+
message: response['AVSRsltText']
|
405
|
+
},
|
406
|
+
cvv_result: response['CVVRsltCode']
|
407
|
+
)
|
408
|
+
end
|
409
|
+
|
410
|
+
SUCCESSFUL_RESPONSE_CODES = %w(0 00 85)
|
411
|
+
def successful?(response)
|
412
|
+
(
|
413
|
+
(response['GatewayRspCode'] == '0') &&
|
414
|
+
((SUCCESSFUL_RESPONSE_CODES.include? response['RspCode']) || !response['RspCode'])
|
415
|
+
)
|
416
|
+
end
|
417
|
+
|
418
|
+
def message_from(response)
|
419
|
+
if response['Fault']
|
420
|
+
response['Fault']
|
421
|
+
elsif response['GatewayRspCode'] == '0'
|
422
|
+
if SUCCESSFUL_RESPONSE_CODES.include? response['RspCode']
|
423
|
+
response['GatewayRspMsg']
|
424
|
+
else
|
425
|
+
issuer_message(response['RspCode'])
|
426
|
+
end
|
427
|
+
else
|
428
|
+
(GATEWAY_MESSAGES[response['GatewayRspCode']] || response['GatewayRspMsg'])
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
def authorization_from(response, reference)
|
433
|
+
return [reference, response['GatewayTxnId']].join('|') if reference
|
434
|
+
|
435
|
+
response['GatewayTxnId']
|
436
|
+
end
|
437
|
+
|
438
|
+
def test?
|
439
|
+
@options[:secret_api_key]&.include?('_cert_')
|
440
|
+
end
|
441
|
+
|
442
|
+
def alphanumeric_zip(zip)
|
443
|
+
zip.gsub(/[^0-9a-z]/i, '')
|
444
|
+
end
|
445
|
+
|
446
|
+
ISSUER_MESSAGES = {
|
447
|
+
'13' => 'Must be greater than or equal 0.',
|
448
|
+
'14' => 'The card number is incorrect.',
|
449
|
+
'54' => 'The card has expired.',
|
450
|
+
'55' => 'The 4-digit pin is invalid.',
|
451
|
+
'75' => 'Maximum number of pin retries exceeded.',
|
452
|
+
'80' => 'Card expiration date is invalid.',
|
453
|
+
'86' => "Can't verify card pin number."
|
454
|
+
}
|
455
|
+
def issuer_message(code)
|
456
|
+
return 'The card was declined.' if %w(02 03 04 05 41 43 44 51 56 61 62 63 65 78).include?(code)
|
457
|
+
return 'An error occurred while processing the card.' if %w(06 07 12 15 19 12 52 53 57 58 76 77 91 96 EC).include?(code)
|
458
|
+
return "The card's security code is incorrect." if %w(EB N7).include?(code)
|
459
|
+
|
460
|
+
ISSUER_MESSAGES[code]
|
461
|
+
end
|
462
|
+
|
463
|
+
GATEWAY_MESSAGES = {
|
464
|
+
'-2' => 'Authentication error. Please double check your service configuration.',
|
465
|
+
'12' => 'Invalid CPC data.',
|
466
|
+
'13' => 'Invalid card data.',
|
467
|
+
'14' => 'The card number is not a valid credit card number.',
|
468
|
+
'30' => 'Gateway timed out.'
|
469
|
+
}
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|