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,345 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class Shift4Gateway < Gateway
|
4
|
+
self.test_url = 'https://utgapi.shift4test.com/api/rest/v1/'
|
5
|
+
self.live_url = 'https://utg.shift4api.net/api/rest/v1/'
|
6
|
+
|
7
|
+
self.supported_countries = %w(US CA CU HT DO PR JM TT GP MQ BS BB LC CW AW VC VI GD AG DM KY KN SX TC MF VG BQ AI BL MS)
|
8
|
+
self.default_currency = 'USD'
|
9
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
10
|
+
|
11
|
+
self.homepage_url = 'https://shift4.com'
|
12
|
+
self.display_name = 'Shift4'
|
13
|
+
|
14
|
+
RECURRING_TYPE_TRANSACTIONS = %w(recurring installment)
|
15
|
+
TRANSACTIONS_WITHOUT_RESPONSE_CODE = %w(accesstoken add)
|
16
|
+
SUCCESS_TRANSACTION_STATUS = %w(A)
|
17
|
+
DISALLOWED_ENTRY_MODE_ACTIONS = %w(capture refund add verify)
|
18
|
+
URL_POSTFIX_MAPPING = {
|
19
|
+
'accesstoken' => 'credentials',
|
20
|
+
'add' => 'tokens',
|
21
|
+
'verify' => 'cards'
|
22
|
+
}
|
23
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
24
|
+
'incorrect_number' => STANDARD_ERROR_CODE[:incorrect_number],
|
25
|
+
'invalid_number' => STANDARD_ERROR_CODE[:invalid_number],
|
26
|
+
'invalid_expiry_month' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
27
|
+
'invalid_expiry_year' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
28
|
+
'invalid_cvc' => STANDARD_ERROR_CODE[:invalid_cvc],
|
29
|
+
'expired_card' => STANDARD_ERROR_CODE[:expired_card],
|
30
|
+
'insufficient_funds' => STANDARD_ERROR_CODE[:card_declined],
|
31
|
+
'incorrect_cvc' => STANDARD_ERROR_CODE[:incorrect_cvc],
|
32
|
+
'incorrect_zip' => STANDARD_ERROR_CODE[:incorrect_zip],
|
33
|
+
'card_declined' => STANDARD_ERROR_CODE[:card_declined],
|
34
|
+
'processing_error' => STANDARD_ERROR_CODE[:processing_error],
|
35
|
+
'lost_or_stolen' => STANDARD_ERROR_CODE[:card_declined],
|
36
|
+
'suspected_fraud' => STANDARD_ERROR_CODE[:card_declined],
|
37
|
+
'expired_token' => STANDARD_ERROR_CODE[:card_declined]
|
38
|
+
}
|
39
|
+
|
40
|
+
def initialize(options = {})
|
41
|
+
requires!(options, :client_guid, :auth_token)
|
42
|
+
@client_guid = options[:client_guid]
|
43
|
+
@auth_token = options[:auth_token]
|
44
|
+
@access_token = options[:access_token]
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def purchase(money, payment_method, options = {})
|
49
|
+
post = {}
|
50
|
+
action = 'sale'
|
51
|
+
|
52
|
+
payment_method = get_card_token(payment_method) if payment_method.is_a?(String)
|
53
|
+
add_datetime(post, options)
|
54
|
+
add_invoice(post, money, options)
|
55
|
+
add_clerk(post, options)
|
56
|
+
add_transaction(post, options)
|
57
|
+
add_card(action, post, payment_method, options)
|
58
|
+
add_card_present(post, options)
|
59
|
+
add_customer(post, payment_method, options)
|
60
|
+
|
61
|
+
commit(action, post, options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def authorize(money, payment_method, options = {})
|
65
|
+
post = {}
|
66
|
+
action = 'authorization'
|
67
|
+
|
68
|
+
payment_method = get_card_token(payment_method) if payment_method.is_a?(String)
|
69
|
+
add_datetime(post, options)
|
70
|
+
add_invoice(post, money, options)
|
71
|
+
add_clerk(post, options)
|
72
|
+
add_transaction(post, options)
|
73
|
+
add_card(action, post, payment_method, options)
|
74
|
+
add_card_present(post, options)
|
75
|
+
add_customer(post, payment_method, options)
|
76
|
+
|
77
|
+
commit(action, post, options)
|
78
|
+
end
|
79
|
+
|
80
|
+
def capture(money, authorization, options = {})
|
81
|
+
post = {}
|
82
|
+
action = 'capture'
|
83
|
+
options[:invoice] = get_invoice(authorization)
|
84
|
+
|
85
|
+
add_datetime(post, options)
|
86
|
+
add_invoice(post, money, options)
|
87
|
+
add_clerk(post, options)
|
88
|
+
add_transaction(post, options)
|
89
|
+
add_card(action, post, get_card_token(authorization), options)
|
90
|
+
|
91
|
+
commit(action, post, options)
|
92
|
+
end
|
93
|
+
|
94
|
+
def refund(money, payment_method, options = {})
|
95
|
+
post = {}
|
96
|
+
action = 'refund'
|
97
|
+
|
98
|
+
add_datetime(post, options)
|
99
|
+
add_invoice(post, money, options)
|
100
|
+
add_clerk(post, options)
|
101
|
+
add_transaction(post, options)
|
102
|
+
card_token = payment_method.is_a?(CreditCard) ? get_card_token(payment_method) : payment_method
|
103
|
+
add_card(action, post, card_token, options)
|
104
|
+
add_card_present(post, options)
|
105
|
+
|
106
|
+
commit(action, post, options)
|
107
|
+
end
|
108
|
+
|
109
|
+
alias credit refund
|
110
|
+
|
111
|
+
def void(authorization, options = {})
|
112
|
+
options[:invoice] = get_invoice(authorization)
|
113
|
+
commit('invoice', {}, options)
|
114
|
+
end
|
115
|
+
|
116
|
+
def verify(credit_card, options = {})
|
117
|
+
post = {}
|
118
|
+
action = 'verify'
|
119
|
+
post[:transaction] = {}
|
120
|
+
|
121
|
+
add_datetime(post, options)
|
122
|
+
add_card(action, post, credit_card, options)
|
123
|
+
add_customer(post, credit_card, options)
|
124
|
+
add_card_on_file(post[:transaction], options)
|
125
|
+
|
126
|
+
commit(action, post, options)
|
127
|
+
end
|
128
|
+
|
129
|
+
def store(credit_card, options = {})
|
130
|
+
post = {}
|
131
|
+
action = 'add'
|
132
|
+
|
133
|
+
add_datetime(post, options)
|
134
|
+
add_card(action, post, credit_card, options)
|
135
|
+
add_customer(post, credit_card, options)
|
136
|
+
|
137
|
+
commit(action, post, options)
|
138
|
+
end
|
139
|
+
|
140
|
+
def supports_scrubbing?
|
141
|
+
true
|
142
|
+
end
|
143
|
+
|
144
|
+
def scrub(transcript)
|
145
|
+
transcript.
|
146
|
+
gsub(%r(("Number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
147
|
+
gsub(%r(("expirationDate\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
148
|
+
gsub(%r(("FirstName\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
149
|
+
gsub(%r(("LastName\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
150
|
+
gsub(%r(("securityCode\\?":{\\?"[\w]+\\?":[\d]+,\\?"value\\?":\\?")[\d]*)i, '\1[FILTERED]')
|
151
|
+
end
|
152
|
+
|
153
|
+
def setup_access_token
|
154
|
+
post = {}
|
155
|
+
add_credentials(post, options)
|
156
|
+
add_datetime(post, options)
|
157
|
+
|
158
|
+
response = commit('accesstoken', post, request_headers('accesstoken', options))
|
159
|
+
raise OAuthResponseError.new(response, response.params.fetch('result', [{}]).first.dig('error', 'longText')) unless response.success?
|
160
|
+
|
161
|
+
response.params['result'].first['credential']['accessToken']
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
def add_credentials(post, options)
|
167
|
+
post[:credential] = {}
|
168
|
+
post[:credential][:clientGuid] = @client_guid
|
169
|
+
post[:credential][:authToken] = @auth_token
|
170
|
+
end
|
171
|
+
|
172
|
+
def add_clerk(post, options)
|
173
|
+
post[:clerk] = {}
|
174
|
+
post[:clerk][:numericId] = options[:clerk_id] || '1'
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_invoice(post, money, options)
|
178
|
+
post[:amount] = {}
|
179
|
+
post[:amount][:total] = amount(money.to_f)
|
180
|
+
post[:amount][:tax] = options[:tax].to_f || 0.0
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_datetime(post, options)
|
184
|
+
post[:dateTime] = options[:date_time] || current_date_time(options)
|
185
|
+
end
|
186
|
+
|
187
|
+
def add_transaction(post, options)
|
188
|
+
post[:transaction] = {}
|
189
|
+
post[:transaction][:invoice] = options[:invoice] || Time.new.to_i.to_s[1..3] + rand.to_s[2..7]
|
190
|
+
post[:transaction][:notes] = options[:notes] if options[:notes].present?
|
191
|
+
post[:transaction][:vendorReference] = options[:order_id]
|
192
|
+
|
193
|
+
add_purchase_card(post[:transaction], options)
|
194
|
+
add_card_on_file(post[:transaction], options)
|
195
|
+
end
|
196
|
+
|
197
|
+
def add_card(action, post, payment_method, options)
|
198
|
+
post[:card] = {}
|
199
|
+
post[:card][:entryMode] = options[:entry_mode] || 'M' unless DISALLOWED_ENTRY_MODE_ACTIONS.include?(action)
|
200
|
+
if payment_method.is_a?(CreditCard)
|
201
|
+
post[:card][:expirationDate] = "#{format(payment_method.month, :two_digits)}#{format(payment_method.year, :two_digits)}"
|
202
|
+
post[:card][:number] = payment_method.number
|
203
|
+
post[:card][:securityCode] = {}
|
204
|
+
post[:card][:securityCode][:indicator] = 1
|
205
|
+
post[:card][:securityCode][:value] = payment_method.verification_value
|
206
|
+
else
|
207
|
+
post[:card] = {} if post[:card].nil?
|
208
|
+
post[:card][:token] = {}
|
209
|
+
post[:card][:token][:value] = payment_method
|
210
|
+
post[:card][:expirationDate] = options[:expiration_date] if options[:expiration_date]
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def add_card_present(post, options)
|
215
|
+
post[:card] = {} unless post[:card].present?
|
216
|
+
|
217
|
+
post[:card][:present] = options[:card_present] || 'N'
|
218
|
+
end
|
219
|
+
|
220
|
+
def add_customer(post, card, options)
|
221
|
+
address = options[:billing_address] || {}
|
222
|
+
|
223
|
+
post[:customer] = {}
|
224
|
+
post[:customer][:addressLine1] = address[:address1] if address[:address1]
|
225
|
+
post[:customer][:postalCode] = address[:zip] if address[:zip] && !address[:zip]&.to_s&.empty?
|
226
|
+
post[:customer][:firstName] = card.first_name if card.is_a?(CreditCard) && card.first_name
|
227
|
+
post[:customer][:lastName] = card.last_name if card.is_a?(CreditCard) && card.last_name
|
228
|
+
post[:customer][:emailAddress] = options[:email] if options[:email]
|
229
|
+
post[:customer][:ipAddress] = options[:ip] if options[:ip]
|
230
|
+
end
|
231
|
+
|
232
|
+
def add_purchase_card(post, options)
|
233
|
+
return unless options[:customer_reference] || options[:destination_postal_code] || options[:product_descriptors]
|
234
|
+
|
235
|
+
post[:purchaseCard] = {}
|
236
|
+
post[:purchaseCard][:customerReference] = options[:customer_reference] if options[:customer_reference]
|
237
|
+
post[:purchaseCard][:destinationPostalCode] = options[:destination_postal_code] if options[:destination_postal_code]
|
238
|
+
post[:purchaseCard][:productDescriptors] = options[:product_descriptors] if options[:product_descriptors]
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_card_on_file(post, options)
|
242
|
+
return unless options[:stored_credential] || options[:usage_indicator] || options[:indicator] || options[:scheduled_indicator] || options[:transaction_id]
|
243
|
+
|
244
|
+
stored_credential = options[:stored_credential] || {}
|
245
|
+
post[:cardOnFile] = {}
|
246
|
+
post[:cardOnFile][:usageIndicator] = options[:usage_indicator] || (stored_credential[:initial_transaction] ? '01' : '02')
|
247
|
+
post[:cardOnFile][:indicator] = options[:indicator] || '01'
|
248
|
+
post[:cardOnFile][:scheduledIndicator] = options[:scheduled_indicator] || (RECURRING_TYPE_TRANSACTIONS.include?(stored_credential[:reason_type]) ? '01' : '02')
|
249
|
+
post[:cardOnFile][:transactionId] = options[:transaction_id] || stored_credential[:network_transaction_id] if options[:transaction_id] || stored_credential[:network_transaction_id]
|
250
|
+
end
|
251
|
+
|
252
|
+
def commit(action, parameters, option)
|
253
|
+
url_postfix = URL_POSTFIX_MAPPING[action] || 'transactions'
|
254
|
+
url = (test? ? "#{test_url}#{url_postfix}/#{action}" : "#{live_url}#{url_postfix}/#{action}")
|
255
|
+
if action == 'invoice'
|
256
|
+
response = parse(ssl_request(:delete, url, parameters.to_json, request_headers(action, option)))
|
257
|
+
else
|
258
|
+
response = parse(ssl_post(url, parameters.to_json, request_headers(action, option)))
|
259
|
+
end
|
260
|
+
|
261
|
+
Response.new(
|
262
|
+
success_from(action, response),
|
263
|
+
message_from(action, response),
|
264
|
+
response,
|
265
|
+
authorization: authorization_from(action, response),
|
266
|
+
test: test?,
|
267
|
+
error_code: error_code_from(action, response)
|
268
|
+
)
|
269
|
+
end
|
270
|
+
|
271
|
+
def handle_response(response)
|
272
|
+
case response.code.to_i
|
273
|
+
when 200...300, 400, 401, 500
|
274
|
+
response.body
|
275
|
+
else
|
276
|
+
raise ResponseError.new(response)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def parse(body)
|
281
|
+
return {} if body == ''
|
282
|
+
|
283
|
+
JSON.parse(body)
|
284
|
+
end
|
285
|
+
|
286
|
+
def message_from(action, response)
|
287
|
+
success_from(action, response) ? 'Transaction successful' : (error(response)&.dig('longText') || 'Transaction declined')
|
288
|
+
end
|
289
|
+
|
290
|
+
def error_code_from(action, response)
|
291
|
+
return unless success_from(action, response)
|
292
|
+
|
293
|
+
STANDARD_ERROR_CODE_MAPPING[response['primaryCode']]
|
294
|
+
end
|
295
|
+
|
296
|
+
def authorization_from(action, response)
|
297
|
+
return unless success_from(action, response)
|
298
|
+
|
299
|
+
authorization = response.dig('result', 0, 'card', 'token', 'value').to_s
|
300
|
+
invoice = response.dig('result', 0, 'transaction', 'invoice')
|
301
|
+
authorization += "|#{invoice}" if invoice
|
302
|
+
authorization
|
303
|
+
end
|
304
|
+
|
305
|
+
def get_card_token(authorization)
|
306
|
+
authorization.is_a?(CreditCard) ? authorization : authorization.split('|')[0]
|
307
|
+
end
|
308
|
+
|
309
|
+
def get_invoice(authorization)
|
310
|
+
authorization.is_a?(CreditCard) ? authorization : authorization.split('|')[1]
|
311
|
+
end
|
312
|
+
|
313
|
+
def request_headers(action, options)
|
314
|
+
headers = {
|
315
|
+
'Content-Type' => 'application/json'
|
316
|
+
}
|
317
|
+
headers['AccessToken'] = @access_token
|
318
|
+
headers['Invoice'] = options[:invoice] if action != 'capture' && options[:invoice].present?
|
319
|
+
headers['InterfaceVersion'] = '1'
|
320
|
+
headers['InterfaceName'] = 'Spreedly'
|
321
|
+
headers['CompanyName'] = 'Spreedly'
|
322
|
+
headers
|
323
|
+
end
|
324
|
+
|
325
|
+
def success_from(action, response)
|
326
|
+
success = error(response).nil?
|
327
|
+
success &&= SUCCESS_TRANSACTION_STATUS.include?(response['result'].first['transaction']['responseCode']) unless TRANSACTIONS_WITHOUT_RESPONSE_CODE.include?(action)
|
328
|
+
success
|
329
|
+
end
|
330
|
+
|
331
|
+
def error(response)
|
332
|
+
server_error = { 'longText' => response['error'] } if response['error']
|
333
|
+
server_error || response['result'].first['error']
|
334
|
+
end
|
335
|
+
|
336
|
+
def current_date_time(options = {})
|
337
|
+
time_zone = options[:merchant_time_zone] || 'Pacific Time (US & Canada)'
|
338
|
+
time = Time.now.in_time_zone(time_zone)
|
339
|
+
offset = Time.now.in_time_zone(time_zone).formatted_offset
|
340
|
+
|
341
|
+
time.strftime('%Y-%m-%dT%H:%M:%S.%3N') + offset
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|