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,513 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PayeezyGateway < Gateway
|
4
|
+
class_attribute :integration_url
|
5
|
+
|
6
|
+
self.test_url = 'https://api-cert.payeezy.com/v1'
|
7
|
+
self.integration_url = 'https://api-cat.payeezy.com/v1'
|
8
|
+
self.live_url = 'https://api.payeezy.com/v1'
|
9
|
+
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.money_format = :cents
|
12
|
+
self.supported_countries = %w(US CA)
|
13
|
+
|
14
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
|
15
|
+
|
16
|
+
self.homepage_url = 'https://developer.payeezy.com/'
|
17
|
+
self.display_name = 'Payeezy'
|
18
|
+
|
19
|
+
CREDIT_CARD_BRAND = {
|
20
|
+
'visa' => 'Visa',
|
21
|
+
'master' => 'Mastercard',
|
22
|
+
'american_express' => 'American Express',
|
23
|
+
'discover' => 'Discover',
|
24
|
+
'jcb' => 'JCB',
|
25
|
+
'diners_club' => 'Diners Club'
|
26
|
+
}
|
27
|
+
|
28
|
+
def initialize(options = {})
|
29
|
+
requires!(options, :apikey, :apisecret, :token)
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def purchase(amount, payment_method, options = {})
|
34
|
+
params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' }
|
35
|
+
|
36
|
+
add_invoice(params, options)
|
37
|
+
add_reversal_id(params, options)
|
38
|
+
add_payment_method(params, payment_method, options)
|
39
|
+
add_address(params, options)
|
40
|
+
add_amount(params, amount, options)
|
41
|
+
add_soft_descriptors(params, options)
|
42
|
+
add_level2_data(params, options)
|
43
|
+
add_stored_credentials(params, options)
|
44
|
+
add_external_three_ds(params, payment_method, options)
|
45
|
+
|
46
|
+
commit(params, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def authorize(amount, payment_method, options = {})
|
50
|
+
params = { transaction_type: 'authorize' }
|
51
|
+
|
52
|
+
add_invoice(params, options)
|
53
|
+
add_reversal_id(params, options)
|
54
|
+
add_payment_method(params, payment_method, options)
|
55
|
+
add_address(params, options)
|
56
|
+
add_amount(params, amount, options)
|
57
|
+
add_soft_descriptors(params, options)
|
58
|
+
add_level2_data(params, options)
|
59
|
+
add_stored_credentials(params, options)
|
60
|
+
add_external_three_ds(params, payment_method, options)
|
61
|
+
|
62
|
+
commit(params, options)
|
63
|
+
end
|
64
|
+
|
65
|
+
def capture(amount, authorization, options = {})
|
66
|
+
params = { transaction_type: 'capture' }
|
67
|
+
|
68
|
+
add_authorization_info(params, authorization)
|
69
|
+
add_amount(params, amount, options)
|
70
|
+
add_soft_descriptors(params, options)
|
71
|
+
|
72
|
+
commit(params, options)
|
73
|
+
end
|
74
|
+
|
75
|
+
def refund(amount, authorization, options = {})
|
76
|
+
params = { transaction_type: 'refund' }
|
77
|
+
|
78
|
+
add_authorization_info(params, authorization)
|
79
|
+
add_amount(params, (amount || amount_from_authorization(authorization)), options)
|
80
|
+
add_soft_descriptors(params, options)
|
81
|
+
add_invoice(params, options)
|
82
|
+
|
83
|
+
commit(params, options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def credit(amount, payment_method, options = {})
|
87
|
+
params = { transaction_type: 'refund' }
|
88
|
+
|
89
|
+
add_amount(params, amount, options)
|
90
|
+
add_payment_method(params, payment_method, options)
|
91
|
+
add_soft_descriptors(params, options)
|
92
|
+
add_invoice(params, options)
|
93
|
+
commit(params, options)
|
94
|
+
end
|
95
|
+
|
96
|
+
def store(payment_method, options = {})
|
97
|
+
params = { transaction_type: 'store' }
|
98
|
+
|
99
|
+
add_creditcard_for_tokenization(params, payment_method, options)
|
100
|
+
|
101
|
+
commit(params, options)
|
102
|
+
end
|
103
|
+
|
104
|
+
def void(authorization, options = {})
|
105
|
+
params = { transaction_type: 'void' }
|
106
|
+
|
107
|
+
add_authorization_info(params, authorization, options)
|
108
|
+
add_amount(params, amount_from_authorization(authorization), options)
|
109
|
+
|
110
|
+
commit(params, options)
|
111
|
+
end
|
112
|
+
|
113
|
+
def verify(credit_card, options = {})
|
114
|
+
MultiResponse.run(:use_first_response) do |r|
|
115
|
+
r.process { authorize(0, credit_card, options) }
|
116
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def supports_scrubbing?
|
121
|
+
true
|
122
|
+
end
|
123
|
+
|
124
|
+
def scrub(transcript)
|
125
|
+
transcript.
|
126
|
+
gsub(%r((Token: )(\w|-)+), '\1[FILTERED]').
|
127
|
+
gsub(%r((Apikey: )(\w|-)+), '\1[FILTERED]').
|
128
|
+
gsub(%r((\\?"card_number\\?":\\?")\d+), '\1[FILTERED]').
|
129
|
+
gsub(%r((\\?"cvv\\?":\\?")\d+), '\1[FILTERED]').
|
130
|
+
gsub(%r((\\?"cvv\\?":\\?)\d+), '\1[FILTERED]').
|
131
|
+
gsub(%r((\\?"account_number\\?":\\?")\d+), '\1[FILTERED]').
|
132
|
+
gsub(%r((\\?"routing_number\\?":\\?")\d+), '\1[FILTERED]').
|
133
|
+
gsub(%r((\\?card_number=)\d+(&?)), '\1[FILTERED]').
|
134
|
+
gsub(%r((\\?cvv=)\d+(&?)), '\1[FILTERED]').
|
135
|
+
gsub(%r((\\?apikey=)\w+(&?)), '\1[FILTERED]').
|
136
|
+
gsub(%r{(\\?"credit_card\.card_number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
|
137
|
+
gsub(%r{(\\?"credit_card\.cvv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
|
138
|
+
gsub(%r{(\\?"apikey\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
|
139
|
+
gsub(%r{(\\?"cavv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
|
140
|
+
gsub(%r{(\\?"xid\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
|
141
|
+
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def add_external_three_ds(params, payment_method, options)
|
146
|
+
return unless three_ds = options[:three_d_secure]
|
147
|
+
|
148
|
+
params[:'3DS'] = {
|
149
|
+
program_protocol: three_ds[:version][0],
|
150
|
+
directory_server_transaction_id: three_ds[:ds_transaction_id],
|
151
|
+
cardholder_name: payment_method.name,
|
152
|
+
card_number: payment_method.number,
|
153
|
+
exp_date: format_exp_date(payment_method.month, payment_method.year),
|
154
|
+
cvv: payment_method.verification_value,
|
155
|
+
xid: three_ds[:acs_transaction_id],
|
156
|
+
cavv: three_ds[:cavv],
|
157
|
+
wallet_provider_id: 'NO_WALLET',
|
158
|
+
type: 'D'
|
159
|
+
}.compact
|
160
|
+
|
161
|
+
params[:eci_indicator] = options[:three_d_secure][:eci]
|
162
|
+
params[:method] = '3DS'
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_invoice(params, options)
|
166
|
+
params[:merchant_ref] = options[:order_id]
|
167
|
+
end
|
168
|
+
|
169
|
+
def add_reversal_id(params, options)
|
170
|
+
params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
|
171
|
+
end
|
172
|
+
|
173
|
+
def amount_from_authorization(authorization)
|
174
|
+
authorization.split('|').last.to_i
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_authorization_info(params, authorization, options = {})
|
178
|
+
transaction_id, transaction_tag, method, = authorization.split('|')
|
179
|
+
params[:method] = method == 'token' ? 'credit_card' : method
|
180
|
+
# If the previous transaction `method` value was 3DS, it needs to be set to `credit_card` on follow up transactions
|
181
|
+
params[:method] = 'credit_card' if method == '3DS'
|
182
|
+
|
183
|
+
if options[:reversal_id]
|
184
|
+
params[:reversal_id] = options[:reversal_id]
|
185
|
+
else
|
186
|
+
params[:transaction_id] = transaction_id
|
187
|
+
params[:transaction_tag] = transaction_tag
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def add_creditcard_for_tokenization(params, payment_method, options)
|
192
|
+
params[:apikey] = @options[:apikey]
|
193
|
+
params[:ta_token] = options[:ta_token]
|
194
|
+
params[:type] = 'FDToken'
|
195
|
+
params[:credit_card] = add_card_data(payment_method)
|
196
|
+
params[:auth] = 'false'
|
197
|
+
end
|
198
|
+
|
199
|
+
def store_action?(params)
|
200
|
+
params[:transaction_type] == 'store'
|
201
|
+
end
|
202
|
+
|
203
|
+
def add_payment_method(params, payment_method, options)
|
204
|
+
if payment_method.is_a? Check
|
205
|
+
add_echeck(params, payment_method, options)
|
206
|
+
elsif payment_method.is_a? String
|
207
|
+
add_token(params, payment_method, options)
|
208
|
+
elsif payment_method.is_a? NetworkTokenizationCreditCard
|
209
|
+
add_network_tokenization(params, payment_method, options)
|
210
|
+
else
|
211
|
+
add_creditcard(params, payment_method)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def add_echeck(params, echeck, options)
|
216
|
+
tele_check = {}
|
217
|
+
|
218
|
+
tele_check[:check_number] = echeck.number || '001'
|
219
|
+
tele_check[:check_type] = 'P'
|
220
|
+
tele_check[:routing_number] = echeck.routing_number
|
221
|
+
tele_check[:account_number] = echeck.account_number
|
222
|
+
tele_check[:accountholder_name] = name_from_payment_method(echeck)
|
223
|
+
tele_check[:customer_id_type] = options[:customer_id_type] if options[:customer_id_type]
|
224
|
+
tele_check[:customer_id_number] = options[:customer_id_number] if options[:customer_id_number]
|
225
|
+
tele_check[:client_email] = options[:client_email] if options[:client_email]
|
226
|
+
|
227
|
+
params[:method] = 'tele_check'
|
228
|
+
params[:tele_check] = tele_check
|
229
|
+
end
|
230
|
+
|
231
|
+
def add_token(params, payment_method, options)
|
232
|
+
token = {}
|
233
|
+
token[:token_type] = 'FDToken'
|
234
|
+
|
235
|
+
type, cardholder_name, exp_date, card_number = payment_method.split('|')
|
236
|
+
|
237
|
+
token[:token_data] = {}
|
238
|
+
token[:token_data][:type] = type
|
239
|
+
token[:token_data][:cardholder_name] = cardholder_name
|
240
|
+
token[:token_data][:value] = card_number
|
241
|
+
token[:token_data][:exp_date] = exp_date
|
242
|
+
token[:token_data][:cvv] = options[:cvv] if options[:cvv]
|
243
|
+
|
244
|
+
params[:method] = 'token'
|
245
|
+
params[:token] = token
|
246
|
+
end
|
247
|
+
|
248
|
+
def add_creditcard(params, creditcard)
|
249
|
+
credit_card = add_card_data(creditcard)
|
250
|
+
|
251
|
+
params[:method] = 'credit_card'
|
252
|
+
params[:credit_card] = credit_card
|
253
|
+
end
|
254
|
+
|
255
|
+
def add_card_data(payment_method)
|
256
|
+
card = {}
|
257
|
+
card[:type] = CREDIT_CARD_BRAND[payment_method.brand]
|
258
|
+
card[:cardholder_name] = payment_method.name
|
259
|
+
card[:card_number] = payment_method.number
|
260
|
+
card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
|
261
|
+
card[:cvv] = payment_method.verification_value if payment_method.verification_value?
|
262
|
+
card
|
263
|
+
end
|
264
|
+
|
265
|
+
def add_network_tokenization(params, payment_method, options)
|
266
|
+
nt_card = {}
|
267
|
+
nt_card[:type] = 'D'
|
268
|
+
nt_card[:cardholder_name] = name_from_payment_method(payment_method) || name_from_address(options)
|
269
|
+
nt_card[:card_number] = payment_method.number
|
270
|
+
nt_card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
|
271
|
+
nt_card[:cvv] = payment_method.verification_value
|
272
|
+
nt_card[:xid] = payment_method.payment_cryptogram unless payment_method.payment_cryptogram.empty? || payment_method.brand.include?('american_express')
|
273
|
+
nt_card[:cavv] = payment_method.payment_cryptogram unless payment_method.payment_cryptogram.empty?
|
274
|
+
nt_card[:wallet_provider_id] = 'APPLE_PAY'
|
275
|
+
|
276
|
+
params['3DS'] = nt_card
|
277
|
+
params[:method] = '3DS'
|
278
|
+
params[:eci_indicator] = payment_method.eci.nil? ? '5' : payment_method.eci
|
279
|
+
end
|
280
|
+
|
281
|
+
def format_exp_date(month, year)
|
282
|
+
"#{format(month, :two_digits)}#{format(year, :two_digits)}"
|
283
|
+
end
|
284
|
+
|
285
|
+
def name_from_address(options)
|
286
|
+
return unless address = options[:billing_address]
|
287
|
+
return address[:name] if address[:name]
|
288
|
+
end
|
289
|
+
|
290
|
+
def name_from_payment_method(payment_method)
|
291
|
+
return unless payment_method.first_name && payment_method.last_name
|
292
|
+
|
293
|
+
return "#{payment_method.first_name} #{payment_method.last_name}"
|
294
|
+
end
|
295
|
+
|
296
|
+
def add_address(params, options)
|
297
|
+
address = options[:billing_address]
|
298
|
+
return unless address
|
299
|
+
|
300
|
+
billing_address = {}
|
301
|
+
billing_address[:street] = address[:address1] if address[:address1]
|
302
|
+
billing_address[:city] = address[:city] if address[:city]
|
303
|
+
billing_address[:state_province] = address[:state] if address[:state]
|
304
|
+
billing_address[:zip_postal_code] = address[:zip] if address[:zip]
|
305
|
+
billing_address[:country] = address[:country] if address[:country]
|
306
|
+
|
307
|
+
params[:billing_address] = billing_address
|
308
|
+
end
|
309
|
+
|
310
|
+
def add_amount(params, money, options)
|
311
|
+
params[:currency_code] = (options[:currency] || default_currency).upcase
|
312
|
+
params[:amount] = amount(money)
|
313
|
+
end
|
314
|
+
|
315
|
+
def add_soft_descriptors(params, options)
|
316
|
+
params[:soft_descriptors] = options[:soft_descriptors] if options[:soft_descriptors]
|
317
|
+
end
|
318
|
+
|
319
|
+
def add_level2_data(params, options)
|
320
|
+
return unless level2_data = options[:level2]
|
321
|
+
|
322
|
+
params[:level2] = {}
|
323
|
+
params[:level2][:customer_ref] = level2_data[:customer_ref]
|
324
|
+
end
|
325
|
+
|
326
|
+
def add_stored_credentials(params, options)
|
327
|
+
if options[:sequence] || options[:stored_credential]
|
328
|
+
params[:stored_credentials] = {}
|
329
|
+
params[:stored_credentials][:cardbrand_original_transaction_id] = original_transaction_id(options) if original_transaction_id(options)
|
330
|
+
params[:stored_credentials][:initiator] = initiator(options) if initiator(options)
|
331
|
+
params[:stored_credentials][:sequence] = options[:sequence] || sequence(options[:stored_credential][:initial_transaction])
|
332
|
+
params[:stored_credentials][:is_scheduled] = options[:is_scheduled] || is_scheduled(options[:stored_credential][:reason_type])
|
333
|
+
params[:stored_credentials][:auth_type_override] = options[:auth_type_override] if options[:auth_type_override]
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def original_transaction_id(options)
|
338
|
+
return options[:cardbrand_original_transaction_id] || options.dig(:stored_credential, :network_transaction_id)
|
339
|
+
end
|
340
|
+
|
341
|
+
def initiator(options)
|
342
|
+
return options[:initiator] if options[:initiator]
|
343
|
+
return options[:stored_credential][:initiator].upcase if options.dig(:stored_credential, :initiator)
|
344
|
+
end
|
345
|
+
|
346
|
+
def sequence(initial_transaction)
|
347
|
+
initial_transaction ? 'FIRST' : 'SUBSEQUENT'
|
348
|
+
end
|
349
|
+
|
350
|
+
def is_scheduled(reason_type)
|
351
|
+
reason_type == 'recurring' ? 'true' : 'false'
|
352
|
+
end
|
353
|
+
|
354
|
+
def commit(params, options)
|
355
|
+
url = base_url(options) + endpoint(params)
|
356
|
+
|
357
|
+
if transaction_id = params.delete(:transaction_id)
|
358
|
+
url = "#{url}/#{transaction_id}"
|
359
|
+
end
|
360
|
+
|
361
|
+
begin
|
362
|
+
response = api_request(url, params)
|
363
|
+
rescue ResponseError => e
|
364
|
+
response = response_error(e.response.body)
|
365
|
+
rescue JSON::ParserError
|
366
|
+
response = json_error(e.response.body)
|
367
|
+
end
|
368
|
+
|
369
|
+
success = success_from(response)
|
370
|
+
Response.new(
|
371
|
+
success,
|
372
|
+
handle_message(response, success),
|
373
|
+
response,
|
374
|
+
test: test?,
|
375
|
+
authorization: authorization_from(params, response),
|
376
|
+
avs_result: { code: response['avs'] },
|
377
|
+
cvv_result: response['cvv2'],
|
378
|
+
error_code: success ? nil : error_code_from(response)
|
379
|
+
)
|
380
|
+
end
|
381
|
+
|
382
|
+
def base_url(options)
|
383
|
+
if options[:integration]
|
384
|
+
integration_url
|
385
|
+
elsif test?
|
386
|
+
test_url
|
387
|
+
else
|
388
|
+
live_url
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
def endpoint(params)
|
393
|
+
store_action?(params) ? '/transactions/tokens' : '/transactions'
|
394
|
+
end
|
395
|
+
|
396
|
+
def api_request(url, params)
|
397
|
+
body = params.to_json
|
398
|
+
parse(ssl_post(url, body, headers(body)))
|
399
|
+
end
|
400
|
+
|
401
|
+
def post_data(params)
|
402
|
+
return nil unless params
|
403
|
+
|
404
|
+
params.reject { |_k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
405
|
+
end
|
406
|
+
|
407
|
+
def generate_hmac(nonce, current_timestamp, payload)
|
408
|
+
message = [
|
409
|
+
@options[:apikey],
|
410
|
+
nonce.to_s,
|
411
|
+
current_timestamp.to_s,
|
412
|
+
@options[:token],
|
413
|
+
payload
|
414
|
+
].join('')
|
415
|
+
hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
|
416
|
+
hash
|
417
|
+
end
|
418
|
+
|
419
|
+
def headers(payload)
|
420
|
+
nonce = (SecureRandom.random_number * 10_000_000_000)
|
421
|
+
current_timestamp = (Time.now.to_f * 1000).to_i
|
422
|
+
{
|
423
|
+
'Content-Type' => 'application/json',
|
424
|
+
'apikey' => options[:apikey],
|
425
|
+
'token' => options[:token],
|
426
|
+
'nonce' => nonce.to_s,
|
427
|
+
'timestamp' => current_timestamp.to_s,
|
428
|
+
'Authorization' => generate_hmac(nonce, current_timestamp, payload)
|
429
|
+
}
|
430
|
+
end
|
431
|
+
|
432
|
+
def error_code_from(response)
|
433
|
+
error_code = nil
|
434
|
+
if response['bank_resp_code'] == '100'
|
435
|
+
return
|
436
|
+
elsif response['bank_resp_code']
|
437
|
+
error_code = response['bank_resp_code']
|
438
|
+
elsif error_code = response['Error'].to_h['messages'].to_a.map { |e| e['code'] }.join(', ')
|
439
|
+
end
|
440
|
+
|
441
|
+
error_code
|
442
|
+
end
|
443
|
+
|
444
|
+
def success_from(response)
|
445
|
+
if response['transaction_status']
|
446
|
+
response['transaction_status'] == 'approved'
|
447
|
+
elsif response['results']
|
448
|
+
response['results']['status'] == 'success'
|
449
|
+
elsif response['status']
|
450
|
+
response['status'] == 'success'
|
451
|
+
else
|
452
|
+
false
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
def handle_message(response, success)
|
457
|
+
if success && response['status'].present?
|
458
|
+
'Token successfully created.'
|
459
|
+
elsif success
|
460
|
+
"#{response['gateway_message']} - #{response['bank_message']}"
|
461
|
+
elsif %w(401 403).include?(response['code'])
|
462
|
+
response['message']
|
463
|
+
elsif response.key?('Error')
|
464
|
+
response['Error']['messages'].first['description']
|
465
|
+
elsif response.key?('results')
|
466
|
+
response['results']['Error']['messages'].first['description']
|
467
|
+
elsif response.key?('error')
|
468
|
+
response['error']
|
469
|
+
elsif response.key?('fault')
|
470
|
+
response['fault'].to_h['faultstring']
|
471
|
+
else
|
472
|
+
response['bank_message'] || response['gateway_message'] || 'Failure to successfully create token.'
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
def authorization_from(params, response)
|
477
|
+
if store_action?(params)
|
478
|
+
if success_from(response)
|
479
|
+
[
|
480
|
+
response['token']['type'],
|
481
|
+
response['token']['cardholder_name'],
|
482
|
+
response['token']['exp_date'],
|
483
|
+
response['token']['value']
|
484
|
+
].join('|')
|
485
|
+
else
|
486
|
+
nil
|
487
|
+
end
|
488
|
+
else
|
489
|
+
[
|
490
|
+
response['transaction_id'],
|
491
|
+
response['transaction_tag'],
|
492
|
+
params[:method],
|
493
|
+
response['amount']&.to_i
|
494
|
+
].join('|')
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
def parse(body)
|
499
|
+
JSON.parse(body)
|
500
|
+
end
|
501
|
+
|
502
|
+
def response_error(raw_response)
|
503
|
+
parse(raw_response)
|
504
|
+
rescue JSON::ParserError
|
505
|
+
json_error(raw_response)
|
506
|
+
end
|
507
|
+
|
508
|
+
def json_error(raw_response)
|
509
|
+
{ 'error' => "Unable to parse response: #{raw_response.inspect}" }
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
end
|