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,219 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class ClearhausGateway < Gateway
|
4
|
+
self.test_url = 'https://gateway.test.clearhaus.com'
|
5
|
+
self.live_url = 'https://gateway.clearhaus.com'
|
6
|
+
|
7
|
+
self.supported_countries = %w[DK NO SE FI DE CH NL AD AT BE BG HR CY CZ FO GL EE FR GR
|
8
|
+
HU IS IE IT LV LI LT LU MT PL PT RO SK SI ES GB]
|
9
|
+
|
10
|
+
self.default_currency = 'EUR'
|
11
|
+
self.currencies_without_fractions = %w(BIF CLP DJF GNF JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
|
12
|
+
self.supported_cardtypes = %i[visa master]
|
13
|
+
|
14
|
+
self.homepage_url = 'https://www.clearhaus.com'
|
15
|
+
self.display_name = 'Clearhaus'
|
16
|
+
self.money_format = :cents
|
17
|
+
|
18
|
+
ACTION_CODE_MESSAGES = {
|
19
|
+
20000 => 'Approved',
|
20
|
+
40000 => 'General input error',
|
21
|
+
40110 => 'Invalid card number',
|
22
|
+
40120 => 'Invalid CSC',
|
23
|
+
40130 => 'Invalid expire date',
|
24
|
+
40135 => 'Card expired',
|
25
|
+
40140 => 'Invalid currency',
|
26
|
+
40200 => 'Clearhaus rule violation',
|
27
|
+
40300 => '3-D Secure problem',
|
28
|
+
40310 => '3-D Secure authentication failure',
|
29
|
+
40400 => 'Backend problem',
|
30
|
+
40410 => 'Declined by issuer or card scheme',
|
31
|
+
40411 => 'Card restricted',
|
32
|
+
40412 => 'Card lost or stolen',
|
33
|
+
40413 => 'Insufficient funds',
|
34
|
+
40414 => 'Suspected fraud',
|
35
|
+
40415 => 'Amount limit exceeded',
|
36
|
+
50000 => 'Clearhaus error'
|
37
|
+
}
|
38
|
+
|
39
|
+
def initialize(options = {})
|
40
|
+
requires!(options, :api_key)
|
41
|
+
options[:private_key] = options[:private_key].strip if options[:private_key]
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def purchase(amount, payment, options = {})
|
46
|
+
MultiResponse.run(:use_first_response) do |r|
|
47
|
+
r.process { authorize(amount, payment, options) }
|
48
|
+
r.process { capture(amount, r.authorization, options) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def authorize(amount, payment, options = {})
|
53
|
+
post = {}
|
54
|
+
add_invoice(post, amount, options)
|
55
|
+
|
56
|
+
action =
|
57
|
+
if payment.respond_to?(:number)
|
58
|
+
add_payment(post, payment)
|
59
|
+
'/authorizations'
|
60
|
+
elsif payment.kind_of?(String)
|
61
|
+
"/cards/#{payment}/authorizations"
|
62
|
+
else
|
63
|
+
raise ArgumentError.new("Unknown payment type #{payment.inspect}")
|
64
|
+
end
|
65
|
+
|
66
|
+
post[:recurring] = options[:recurring] if options[:recurring]
|
67
|
+
post[:card][:pares] = options[:pares] if options[:pares]
|
68
|
+
|
69
|
+
commit(action, post)
|
70
|
+
end
|
71
|
+
|
72
|
+
def capture(amount, authorization, options = {})
|
73
|
+
post = {}
|
74
|
+
add_invoice(post, amount, options)
|
75
|
+
|
76
|
+
commit("/authorizations/#{authorization}/captures", post)
|
77
|
+
end
|
78
|
+
|
79
|
+
def refund(amount, authorization, options = {})
|
80
|
+
post = {}
|
81
|
+
add_amount(post, amount, options)
|
82
|
+
|
83
|
+
commit("/authorizations/#{authorization}/refunds", post)
|
84
|
+
end
|
85
|
+
|
86
|
+
def void(authorization, options = {})
|
87
|
+
commit("/authorizations/#{authorization}/voids", options)
|
88
|
+
end
|
89
|
+
|
90
|
+
def verify(credit_card, options = {})
|
91
|
+
MultiResponse.run(:use_first_response) do |r|
|
92
|
+
r.process { authorize(0, credit_card, options) }
|
93
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def store(credit_card, options = {})
|
98
|
+
post = {}
|
99
|
+
add_payment(post, credit_card)
|
100
|
+
|
101
|
+
commit('/cards', post)
|
102
|
+
end
|
103
|
+
|
104
|
+
def supports_scrubbing?
|
105
|
+
true
|
106
|
+
end
|
107
|
+
|
108
|
+
def scrub(transcript)
|
109
|
+
transcript.
|
110
|
+
gsub(%r((Authorization: Basic )[\w=]+), '\1[FILTERED]').
|
111
|
+
gsub(%r((&?card(?:\[|%5B)csc(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]').
|
112
|
+
gsub(%r((&?card(?:\[|%5B)pan(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]')
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
def add_invoice(post, money, options)
|
118
|
+
add_amount(post, money, options)
|
119
|
+
post[:reference] = options[:order_id] if options[:order_id]
|
120
|
+
post[:text_on_statement] = options[:text_on_statement] if options[:text_on_statement]
|
121
|
+
end
|
122
|
+
|
123
|
+
def add_amount(post, amount, options)
|
124
|
+
post[:amount] = localized_amount(amount, options[:currency] || default_currency)
|
125
|
+
post[:currency] = (options[:currency] || default_currency)
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_payment(post, payment)
|
129
|
+
card = {}
|
130
|
+
card[:pan] = payment.number
|
131
|
+
card[:expire_month] = '%02d' % payment.month
|
132
|
+
card[:expire_year] = payment.year
|
133
|
+
|
134
|
+
card[:csc] = payment.verification_value if payment.verification_value?
|
135
|
+
|
136
|
+
post[:card] = card if card.any?
|
137
|
+
end
|
138
|
+
|
139
|
+
def headers(api_key)
|
140
|
+
{
|
141
|
+
'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"),
|
142
|
+
'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
def parse(body)
|
147
|
+
JSON.parse(body) rescue body
|
148
|
+
end
|
149
|
+
|
150
|
+
def commit(action, parameters)
|
151
|
+
url = (test? ? test_url : live_url) + action
|
152
|
+
headers = headers(@options[:api_key])
|
153
|
+
body = parameters.to_query
|
154
|
+
|
155
|
+
if @options[:signing_key] && @options[:private_key]
|
156
|
+
begin
|
157
|
+
headers['Signature'] = generate_signature(body)
|
158
|
+
rescue OpenSSL::PKey::RSAError => e
|
159
|
+
return Response.new(false, e.message)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
response =
|
164
|
+
begin
|
165
|
+
parse(ssl_post(url, body, headers))
|
166
|
+
rescue ResponseError => e
|
167
|
+
raise unless e.response.code.to_s =~ /400/
|
168
|
+
|
169
|
+
parse(e.response.body)
|
170
|
+
end
|
171
|
+
|
172
|
+
Response.new(
|
173
|
+
success_from(response),
|
174
|
+
message_from(response),
|
175
|
+
response,
|
176
|
+
authorization: authorization_from(action, response),
|
177
|
+
test: test?,
|
178
|
+
error_code: error_code_from(response)
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
def success_from(response)
|
183
|
+
(response && (response['status']['code'] == 20000))
|
184
|
+
end
|
185
|
+
|
186
|
+
def message_from(response)
|
187
|
+
default_message = ACTION_CODE_MESSAGES[response['status']['code']]
|
188
|
+
|
189
|
+
if success_from(response)
|
190
|
+
default_message
|
191
|
+
else
|
192
|
+
(response['status']['message'] || default_message)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def authorization_from(action, response)
|
197
|
+
id_of_auth_for_capture(action) || response['id']
|
198
|
+
end
|
199
|
+
|
200
|
+
def id_of_auth_for_capture(action)
|
201
|
+
match = action.match(/authorizations\/(.+)\/captures/)
|
202
|
+
return nil unless match
|
203
|
+
|
204
|
+
match.captures.first
|
205
|
+
end
|
206
|
+
|
207
|
+
def generate_signature(body)
|
208
|
+
key = OpenSSL::PKey::RSA.new(@options[:private_key])
|
209
|
+
hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack1('H*')
|
210
|
+
|
211
|
+
"#{@options[:signing_key]} RS256-hex #{hex}"
|
212
|
+
end
|
213
|
+
|
214
|
+
def error_code_from(response)
|
215
|
+
response['status']['code'] unless success_from(response)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -0,0 +1,366 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CommerceHubGateway < Gateway
|
4
|
+
self.test_url = 'https://cert.api.fiservapps.com/ch'
|
5
|
+
self.live_url = 'https://prod.api.fiservapps.com/ch'
|
6
|
+
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.default_currency = 'USD'
|
9
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
10
|
+
|
11
|
+
self.homepage_url = 'https://developer.fiserv.com/product/CommerceHub'
|
12
|
+
self.display_name = 'CommerceHub'
|
13
|
+
|
14
|
+
STANDARD_ERROR_CODE_MAPPING = {}
|
15
|
+
|
16
|
+
SCHEDULED_REASON_TYPES = %w(recurring installment)
|
17
|
+
ENDPOINTS = {
|
18
|
+
'sale' => '/payments/v1/charges',
|
19
|
+
'void' => '/payments/v1/cancels',
|
20
|
+
'refund' => '/payments/v1/refunds',
|
21
|
+
'vault' => '/payments-vas/v1/tokens',
|
22
|
+
'verify' => '/payments-vas/v1/accounts/verification'
|
23
|
+
}
|
24
|
+
|
25
|
+
def initialize(options = {})
|
26
|
+
requires!(options, :api_key, :api_secret, :merchant_id, :terminal_id)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def purchase(money, payment, options = {})
|
31
|
+
post = {}
|
32
|
+
options[:capture_flag] = true
|
33
|
+
options[:create_token] = false
|
34
|
+
|
35
|
+
add_transaction_details(post, options, 'sale')
|
36
|
+
build_purchase_and_auth_request(post, money, payment, options)
|
37
|
+
|
38
|
+
commit('sale', post, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
def authorize(money, payment, options = {})
|
42
|
+
post = {}
|
43
|
+
options[:capture_flag] = false
|
44
|
+
options[:create_token] = false
|
45
|
+
|
46
|
+
add_transaction_details(post, options, 'sale')
|
47
|
+
build_purchase_and_auth_request(post, money, payment, options)
|
48
|
+
|
49
|
+
commit('sale', post, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def capture(money, authorization, options = {})
|
53
|
+
post = {}
|
54
|
+
options[:capture_flag] = true
|
55
|
+
add_invoice(post, money, options)
|
56
|
+
add_transaction_details(post, options, 'capture')
|
57
|
+
add_reference_transaction_details(post, authorization, options, :capture)
|
58
|
+
|
59
|
+
commit('sale', post, options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def refund(money, authorization, options = {})
|
63
|
+
post = {}
|
64
|
+
add_invoice(post, money, options) if money
|
65
|
+
add_transaction_details(post, options)
|
66
|
+
add_reference_transaction_details(post, authorization, options, :refund)
|
67
|
+
|
68
|
+
commit('refund', post, options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def void(authorization, options = {})
|
72
|
+
post = {}
|
73
|
+
add_transaction_details(post, options)
|
74
|
+
add_reference_transaction_details(post, authorization, options, :void)
|
75
|
+
|
76
|
+
commit('void', post, options)
|
77
|
+
end
|
78
|
+
|
79
|
+
def store(credit_card, options = {})
|
80
|
+
post = {}
|
81
|
+
add_payment(post, credit_card, options)
|
82
|
+
add_billing_address(post, credit_card, options)
|
83
|
+
add_transaction_details(post, options)
|
84
|
+
add_transaction_interaction(post, options)
|
85
|
+
|
86
|
+
commit('vault', post, options)
|
87
|
+
end
|
88
|
+
|
89
|
+
def verify(credit_card, options = {})
|
90
|
+
post = {}
|
91
|
+
add_payment(post, credit_card, options)
|
92
|
+
add_billing_address(post, credit_card, options)
|
93
|
+
|
94
|
+
commit('verify', post, options)
|
95
|
+
end
|
96
|
+
|
97
|
+
def supports_scrubbing?
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
def scrub(transcript)
|
102
|
+
transcript.
|
103
|
+
gsub(%r((Authorization: )[a-zA-Z0-9+./=]+), '\1[FILTERED]').
|
104
|
+
gsub(%r((Api-Key: )\w+), '\1[FILTERED]').
|
105
|
+
gsub(%r(("cardData\\?":\\?")\d+), '\1[FILTERED]').
|
106
|
+
gsub(%r(("securityCode\\?":\\?")\d+), '\1[FILTERED]').
|
107
|
+
gsub(%r(("cavv\\?":\\?")\w+), '\1[FILTERED]')
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def add_transaction_interaction(post, options)
|
113
|
+
post[:transactionInteraction] = {}
|
114
|
+
post[:transactionInteraction][:origin] = options[:origin] || 'ECOM'
|
115
|
+
post[:transactionInteraction][:eciIndicator] = options[:eci_indicator] || 'CHANNEL_ENCRYPTED'
|
116
|
+
post[:transactionInteraction][:posConditionCode] = options[:pos_condition_code] || 'CARD_NOT_PRESENT_ECOM'
|
117
|
+
post[:transactionInteraction][:posEntryMode] = (options[:pos_entry_mode] || 'MANUAL') unless options[:encryption_data].present?
|
118
|
+
post[:transactionInteraction][:additionalPosInformation] = {}
|
119
|
+
post[:transactionInteraction][:additionalPosInformation][:dataEntrySource] = options[:data_entry_source] || 'UNSPECIFIED'
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_transaction_details(post, options, action = nil)
|
123
|
+
details = { captureFlag: options[:capture_flag], createToken: options[:create_token] }
|
124
|
+
|
125
|
+
if options[:order_id].present? && action == 'sale'
|
126
|
+
details[:merchantOrderId] = options[:order_id]
|
127
|
+
details[:merchantTransactionId] = options[:order_id]
|
128
|
+
end
|
129
|
+
|
130
|
+
if action != 'capture'
|
131
|
+
details[:merchantInvoiceNumber] = options[:merchant_invoice_number] || rand.to_s[2..13]
|
132
|
+
details[:primaryTransactionType] = options[:primary_transaction_type]
|
133
|
+
details[:accountVerification] = options[:account_verification]
|
134
|
+
end
|
135
|
+
|
136
|
+
post[:transactionDetails] = details.compact
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_billing_address(post, payment, options)
|
140
|
+
return unless billing = options[:billing_address]
|
141
|
+
|
142
|
+
billing_address = {}
|
143
|
+
if payment.is_a?(CreditCard)
|
144
|
+
billing_address[:firstName] = payment.first_name if payment.first_name
|
145
|
+
billing_address[:lastName] = payment.last_name if payment.last_name
|
146
|
+
end
|
147
|
+
address = {}
|
148
|
+
address[:street] = billing[:address1] if billing[:address1]
|
149
|
+
address[:houseNumberOrName] = billing[:address2] if billing[:address2]
|
150
|
+
address[:recipientNameOrAddress] = billing[:name] if billing[:name]
|
151
|
+
address[:city] = billing[:city] if billing[:city]
|
152
|
+
address[:stateOrProvince] = billing[:state] if billing[:state]
|
153
|
+
address[:postalCode] = billing[:zip] if billing[:zip]
|
154
|
+
address[:country] = billing[:country] if billing[:country]
|
155
|
+
|
156
|
+
billing_address[:address] = address unless address.empty?
|
157
|
+
if billing[:phone_number]
|
158
|
+
billing_address[:phone] = {}
|
159
|
+
billing_address[:phone][:phoneNumber] = billing[:phone_number]
|
160
|
+
end
|
161
|
+
post[:billingAddress] = billing_address
|
162
|
+
end
|
163
|
+
|
164
|
+
def add_shipping_address(post, options)
|
165
|
+
return unless shipping = options[:shipping_address]
|
166
|
+
|
167
|
+
shipping_address = {}
|
168
|
+
address = {}
|
169
|
+
address[:street] = shipping[:address1] if shipping[:address1]
|
170
|
+
address[:houseNumberOrName] = shipping[:address2] if shipping[:address2]
|
171
|
+
address[:recipientNameOrAddress] = shipping[:name] if shipping[:name]
|
172
|
+
address[:city] = shipping[:city] if shipping[:city]
|
173
|
+
address[:stateOrProvince] = shipping[:state] if shipping[:state]
|
174
|
+
address[:postalCode] = shipping[:zip] if shipping[:zip]
|
175
|
+
address[:country] = shipping[:country] if shipping[:country]
|
176
|
+
|
177
|
+
shipping_address[:address] = address unless address.empty?
|
178
|
+
if shipping[:phone_number]
|
179
|
+
shipping_address[:phone] = {}
|
180
|
+
shipping_address[:phone][:phoneNumber] = shipping[:phone_number]
|
181
|
+
end
|
182
|
+
post[:shippingAddress] = shipping_address
|
183
|
+
end
|
184
|
+
|
185
|
+
def build_purchase_and_auth_request(post, money, payment, options)
|
186
|
+
add_invoice(post, money, options)
|
187
|
+
add_payment(post, payment, options)
|
188
|
+
add_stored_credentials(post, options)
|
189
|
+
add_transaction_interaction(post, options)
|
190
|
+
add_billing_address(post, payment, options)
|
191
|
+
add_shipping_address(post, options)
|
192
|
+
end
|
193
|
+
|
194
|
+
def add_reference_transaction_details(post, authorization, options, action = nil)
|
195
|
+
reference_details = {}
|
196
|
+
_merchant_reference, transaction_id = authorization.include?('|') ? authorization.split('|') : [nil, authorization]
|
197
|
+
|
198
|
+
reference_details[:referenceTransactionId] = transaction_id
|
199
|
+
reference_details[:referenceTransactionType] = (options[:reference_transaction_type] || 'CHARGES') unless action == :capture
|
200
|
+
post[:referenceTransactionDetails] = reference_details.compact
|
201
|
+
end
|
202
|
+
|
203
|
+
def add_invoice(post, money, options)
|
204
|
+
post[:amount] = {
|
205
|
+
total: amount(money).to_f,
|
206
|
+
currency: options[:currency] || self.default_currency
|
207
|
+
}
|
208
|
+
end
|
209
|
+
|
210
|
+
def add_stored_credentials(post, options)
|
211
|
+
return unless stored_credential = options[:stored_credential]
|
212
|
+
|
213
|
+
post[:storedCredentials] = {}
|
214
|
+
post[:storedCredentials][:sequence] = stored_credential[:initial_transaction] ? 'FIRST' : 'SUBSEQUENT'
|
215
|
+
post[:storedCredentials][:initiator] = stored_credential[:initiator] == 'merchant' ? 'MERCHANT' : 'CARD_HOLDER'
|
216
|
+
post[:storedCredentials][:scheduled] = SCHEDULED_REASON_TYPES.include?(stored_credential[:reason_type])
|
217
|
+
post[:storedCredentials][:schemeReferenceTransactionId] = stored_credential[:network_transaction_id] if stored_credential[:network_transaction_id]
|
218
|
+
end
|
219
|
+
|
220
|
+
def add_credit_card(source, payment, options)
|
221
|
+
source[:sourceType] = 'PaymentCard'
|
222
|
+
source[:card] = {}
|
223
|
+
source[:card][:cardData] = payment.number
|
224
|
+
source[:card][:expirationMonth] = format(payment.month, :two_digits) if payment.month
|
225
|
+
source[:card][:expirationYear] = format(payment.year, :four_digits) if payment.year
|
226
|
+
if payment.verification_value
|
227
|
+
source[:card][:securityCode] = payment.verification_value
|
228
|
+
source[:card][:securityCodeIndicator] = 'PROVIDED'
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def add_payment_token(source, payment, options)
|
233
|
+
source[:sourceType] = 'PaymentToken'
|
234
|
+
source[:tokenData] = payment
|
235
|
+
source[:tokenSource] = options[:token_source] if options[:token_source]
|
236
|
+
if options[:card_expiration_month] || options[:card_expiration_year]
|
237
|
+
source[:card] = {}
|
238
|
+
source[:card][:expirationMonth] = options[:card_expiration_month] if options[:card_expiration_month]
|
239
|
+
source[:card][:expirationYear] = options[:card_expiration_year] if options[:card_expiration_year]
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def add_decrypted_wallet(source, payment, options)
|
244
|
+
source[:sourceType] = 'DecryptedWallet'
|
245
|
+
source[:card] = {}
|
246
|
+
source[:card][:cardData] = payment.number
|
247
|
+
source[:card][:expirationMonth] = format(payment.month, :two_digits)
|
248
|
+
source[:card][:expirationYear] = format(payment.year, :four_digits)
|
249
|
+
source[:cavv] = payment.payment_cryptogram
|
250
|
+
source[:walletType] = payment.source.to_s.upcase
|
251
|
+
end
|
252
|
+
|
253
|
+
def add_payment(post, payment, options = {})
|
254
|
+
source = {}
|
255
|
+
case payment
|
256
|
+
when NetworkTokenizationCreditCard
|
257
|
+
add_decrypted_wallet(source, payment, options)
|
258
|
+
when CreditCard
|
259
|
+
if options[:encryption_data].present?
|
260
|
+
source[:sourceType] = 'PaymentCard'
|
261
|
+
source[:encryptionData] = options[:encryption_data]
|
262
|
+
else
|
263
|
+
add_credit_card(source, payment, options)
|
264
|
+
end
|
265
|
+
when String
|
266
|
+
add_payment_token(source, payment, options)
|
267
|
+
end
|
268
|
+
post[:source] = source
|
269
|
+
end
|
270
|
+
|
271
|
+
def parse(body)
|
272
|
+
JSON.parse(body)
|
273
|
+
end
|
274
|
+
|
275
|
+
def headers(request, options)
|
276
|
+
time = DateTime.now.strftime('%Q').to_s
|
277
|
+
client_request_id = options[:client_request_id] || rand.to_s[2..8]
|
278
|
+
raw_signature = @options[:api_key] + client_request_id.to_s + time + request
|
279
|
+
hmac = OpenSSL::HMAC.digest('sha256', @options[:api_secret], raw_signature)
|
280
|
+
signature = Base64.strict_encode64(hmac.to_s).to_s
|
281
|
+
|
282
|
+
{
|
283
|
+
'Client-Request-Id' => client_request_id,
|
284
|
+
'Api-Key' => @options[:api_key],
|
285
|
+
'Timestamp' => time,
|
286
|
+
'Accept-Language' => 'application/json',
|
287
|
+
'Auth-Token-Type' => 'HMAC',
|
288
|
+
'Content-Type' => 'application/json',
|
289
|
+
'Accept' => 'application/json',
|
290
|
+
'Authorization' => signature
|
291
|
+
}
|
292
|
+
end
|
293
|
+
|
294
|
+
def add_merchant_details(post)
|
295
|
+
post[:merchantDetails] = {}
|
296
|
+
post[:merchantDetails][:terminalId] = @options[:terminal_id]
|
297
|
+
post[:merchantDetails][:merchantId] = @options[:merchant_id]
|
298
|
+
end
|
299
|
+
|
300
|
+
def commit(action, parameters, options)
|
301
|
+
url = (test? ? test_url : live_url) + ENDPOINTS[action]
|
302
|
+
add_merchant_details(parameters)
|
303
|
+
response = parse(ssl_post(url, parameters.to_json, headers(parameters.to_json, options)))
|
304
|
+
|
305
|
+
Response.new(
|
306
|
+
success_from(response, action),
|
307
|
+
message_from(response, action),
|
308
|
+
response,
|
309
|
+
authorization: authorization_from(action, response, options),
|
310
|
+
test: test?,
|
311
|
+
error_code: error_code_from(response, action),
|
312
|
+
avs_result: AVSResult.new(code: get_avs_cvv(response, 'avs')),
|
313
|
+
cvv_result: CVVResult.new(get_avs_cvv(response, 'cvv'))
|
314
|
+
)
|
315
|
+
end
|
316
|
+
|
317
|
+
def get_avs_cvv(response, type = 'avs')
|
318
|
+
response.dig(
|
319
|
+
'paymentReceipt',
|
320
|
+
'processorResponseDetails',
|
321
|
+
'bankAssociationDetails',
|
322
|
+
'avsSecurityCodeResponse',
|
323
|
+
'association',
|
324
|
+
type == 'avs' ? 'avsCode' : 'securityCodeResponse'
|
325
|
+
)
|
326
|
+
end
|
327
|
+
|
328
|
+
def handle_response(response)
|
329
|
+
case response.code.to_i
|
330
|
+
when 200...300, 400, 401, 429
|
331
|
+
response.body
|
332
|
+
else
|
333
|
+
raise ResponseError.new(response)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def success_from(response, action = nil)
|
338
|
+
return message_from(response, action) == 'VERIFIED' if action == 'verify'
|
339
|
+
|
340
|
+
(response.dig('paymentReceipt', 'processorResponseDetails', 'responseCode') || response.dig('paymentTokens', 0, 'tokenResponseCode')) == '000'
|
341
|
+
end
|
342
|
+
|
343
|
+
def message_from(response, action = nil)
|
344
|
+
return response.dig('error', 0, 'message') if response['error'].present?
|
345
|
+
return response.dig('gatewayResponse', 'transactionState') if action == 'verify'
|
346
|
+
|
347
|
+
response.dig('paymentReceipt', 'processorResponseDetails', 'responseMessage') || response.dig('gatewayResponse', 'transactionType')
|
348
|
+
end
|
349
|
+
|
350
|
+
def authorization_from(action, response, options)
|
351
|
+
case action
|
352
|
+
when 'vault'
|
353
|
+
response.dig('paymentTokens', 0, 'tokenData')
|
354
|
+
when 'sale'
|
355
|
+
[options[:order_id] || '', response.dig('gatewayResponse', 'transactionProcessingDetails', 'transactionId')].join('|')
|
356
|
+
else
|
357
|
+
response.dig('gatewayResponse', 'transactionProcessingDetails', 'transactionId')
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def error_code_from(response, action)
|
362
|
+
response.dig('error', 0, 'code') unless success_from(response, action)
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|