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,208 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class WorldpayOnlinePaymentsGateway < Gateway
|
4
|
+
self.live_url = 'https://api.worldpay.com/v1/'
|
5
|
+
|
6
|
+
self.default_currency = 'GBP'
|
7
|
+
|
8
|
+
self.money_format = :cents
|
9
|
+
|
10
|
+
self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR)
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb maestro]
|
12
|
+
|
13
|
+
self.homepage_url = 'http://online.worldpay.com'
|
14
|
+
self.display_name = 'Worldpay Online Payments'
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
requires!(options, :client_key, :service_key)
|
18
|
+
@client_key = options[:client_key]
|
19
|
+
@service_key = options[:service_key]
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def authorize(money, credit_card, options = {})
|
24
|
+
response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
25
|
+
if response.success?
|
26
|
+
options[:authorizeOnly] = true
|
27
|
+
post = create_post_for_auth_or_purchase(response.authorization, money, options)
|
28
|
+
response = commit(:post, 'orders', post, {}, 'authorize')
|
29
|
+
end
|
30
|
+
response
|
31
|
+
end
|
32
|
+
|
33
|
+
def capture(money, authorization, options = {})
|
34
|
+
if authorization
|
35
|
+
commit(:post, "orders/#{CGI.escape(authorization)}/capture", { 'captureAmount' => money }, options, 'capture')
|
36
|
+
else
|
37
|
+
Response.new(false,
|
38
|
+
'FAILED',
|
39
|
+
'FAILED',
|
40
|
+
test: test?,
|
41
|
+
authorization: false,
|
42
|
+
avs_result: {},
|
43
|
+
cvv_result: {},
|
44
|
+
error_code: false)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def purchase(money, credit_card, options = {})
|
49
|
+
response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
50
|
+
if response.success?
|
51
|
+
post = create_post_for_auth_or_purchase(response.authorization, money, options)
|
52
|
+
response = commit(:post, 'orders', post, options, 'purchase')
|
53
|
+
end
|
54
|
+
response
|
55
|
+
end
|
56
|
+
|
57
|
+
def refund(money, orderCode, options = {})
|
58
|
+
obj = money ? { 'refundAmount' => money } : {}
|
59
|
+
commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund')
|
60
|
+
end
|
61
|
+
|
62
|
+
def void(orderCode, options = {})
|
63
|
+
response = commit(:delete, "orders/#{CGI.escape(orderCode)}", nil, options, 'void')
|
64
|
+
response = refund(nil, orderCode) if !response.success? && (response.params && response.params['customCode'] != 'ORDER_NOT_FOUND')
|
65
|
+
response
|
66
|
+
end
|
67
|
+
|
68
|
+
def verify(credit_card, options = {})
|
69
|
+
authorize(0, credit_card, options)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def create_token(reusable, name, exp_month, exp_year, number, cvc)
|
75
|
+
obj = {
|
76
|
+
'reusable' => reusable,
|
77
|
+
'paymentMethod' => {
|
78
|
+
'type' => 'Card',
|
79
|
+
'name' => name,
|
80
|
+
'expiryMonth' => exp_month,
|
81
|
+
'expiryYear' => exp_year,
|
82
|
+
'cardNumber' => number,
|
83
|
+
'cvc' => cvc
|
84
|
+
},
|
85
|
+
'clientKey' => @client_key
|
86
|
+
}
|
87
|
+
token_response = commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
|
88
|
+
token_response
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_post_for_auth_or_purchase(token, money, options)
|
92
|
+
{
|
93
|
+
'token' => token,
|
94
|
+
'orderDescription' => options[:description] || 'Worldpay Order',
|
95
|
+
'amount' => money,
|
96
|
+
'currencyCode' => options[:currency] || default_currency,
|
97
|
+
'name' => options[:billing_address] && options[:billing_address][:name] ? options[:billing_address][:name] : '',
|
98
|
+
'billingAddress' => {
|
99
|
+
'address1' => options[:billing_address] && options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
|
100
|
+
'address2' => options[:billing_address] && options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
|
101
|
+
'address3' => '',
|
102
|
+
'postalCode' => options[:billing_address] && options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
|
103
|
+
'city' => options[:billing_address] && options[:billing_address][:city] ? options[:billing_address][:city] : '',
|
104
|
+
'state' => options[:billing_address] && options[:billing_address][:state] ? options[:billing_address][:state] : '',
|
105
|
+
'countryCode' => options[:billing_address] && options[:billing_address][:country] ? options[:billing_address][:country] : ''
|
106
|
+
},
|
107
|
+
'customerOrderCode' => options[:order_id],
|
108
|
+
'orderType' => 'ECOM',
|
109
|
+
'authorizeOnly' => options[:authorizeOnly] ? true : false
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
def parse(body)
|
114
|
+
body ? JSON.parse(body) : {}
|
115
|
+
end
|
116
|
+
|
117
|
+
def headers(options = {})
|
118
|
+
headers = {
|
119
|
+
'Authorization' => @service_key,
|
120
|
+
'Content-Type' => 'application/json',
|
121
|
+
'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
122
|
+
'X-Worldpay-Client-User-Agent' => user_agent,
|
123
|
+
'X-Worldpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
|
124
|
+
}
|
125
|
+
headers['Authorization'] = options['Authorization'] if options['Authorization']
|
126
|
+
headers
|
127
|
+
end
|
128
|
+
|
129
|
+
def commit(method, url, parameters = nil, options = {}, type = false)
|
130
|
+
raw_response = response = nil
|
131
|
+
success = false
|
132
|
+
begin
|
133
|
+
json = parameters ? parameters.to_json : nil
|
134
|
+
|
135
|
+
raw_response = ssl_request(method, self.live_url + url, json, headers(options))
|
136
|
+
|
137
|
+
if raw_response != ''
|
138
|
+
response = parse(raw_response)
|
139
|
+
if type == 'token'
|
140
|
+
success = response.key?('token')
|
141
|
+
else
|
142
|
+
if response.key?('httpStatusCode')
|
143
|
+
success = false
|
144
|
+
else
|
145
|
+
if type == 'authorize' && response['paymentStatus'] == 'AUTHORIZED'
|
146
|
+
success = true
|
147
|
+
elsif type == 'purchase' && response['paymentStatus'] == 'SUCCESS'
|
148
|
+
success = true
|
149
|
+
elsif type == 'capture' || type == 'refund' || type == 'void'
|
150
|
+
success = true
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
else
|
155
|
+
success = true
|
156
|
+
response = {}
|
157
|
+
end
|
158
|
+
rescue ResponseError => e
|
159
|
+
raw_response = e.response.body
|
160
|
+
response = response_error(raw_response)
|
161
|
+
rescue JSON::ParserError
|
162
|
+
response = json_error(raw_response)
|
163
|
+
end
|
164
|
+
|
165
|
+
if response['orderCode']
|
166
|
+
authorization = response['orderCode']
|
167
|
+
elsif response['token']
|
168
|
+
authorization = response['token']
|
169
|
+
else
|
170
|
+
authorization = response['message']
|
171
|
+
end
|
172
|
+
|
173
|
+
Response.new(success,
|
174
|
+
success ? 'SUCCESS' : response['message'],
|
175
|
+
response,
|
176
|
+
test: test?,
|
177
|
+
authorization: authorization,
|
178
|
+
avs_result: {},
|
179
|
+
cvv_result: {},
|
180
|
+
error_code: success ? nil : response['customCode'])
|
181
|
+
end
|
182
|
+
|
183
|
+
def test?
|
184
|
+
@service_key[0] == 'T'
|
185
|
+
end
|
186
|
+
|
187
|
+
def response_error(raw_response)
|
188
|
+
parse(raw_response)
|
189
|
+
rescue JSON::ParserError
|
190
|
+
json_error(raw_response)
|
191
|
+
end
|
192
|
+
|
193
|
+
def json_error(raw_response)
|
194
|
+
msg = 'Invalid response received from the Worldpay Online Payments API. Please contact techsupport.online@worldpay.com if you continue to receive this message.'
|
195
|
+
msg += " (The raw response returned by the API was #{raw_response.inspect})"
|
196
|
+
{
|
197
|
+
'error' => {
|
198
|
+
'message' => msg
|
199
|
+
}
|
200
|
+
}
|
201
|
+
end
|
202
|
+
|
203
|
+
def handle_response(response)
|
204
|
+
response.body
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class WorldpayUsGateway < Gateway
|
6
|
+
class_attribute :backup_url
|
7
|
+
|
8
|
+
self.display_name = 'Worldpay US'
|
9
|
+
self.homepage_url = 'http://www.worldpay.com/us'
|
10
|
+
|
11
|
+
# No sandbox, just use test cards.
|
12
|
+
self.live_url = 'https://trans.worldpay.us/cgi-bin/process.cgi'
|
13
|
+
self.backup_url = 'https://trans.gwtx01.com/cgi-bin/process.cgi'
|
14
|
+
|
15
|
+
self.supported_countries = ['US']
|
16
|
+
self.default_currency = 'USD'
|
17
|
+
self.money_format = :dollars
|
18
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb]
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
requires!(options, :acctid, :subid, :merchantpin)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def purchase(money, payment_method, options = {})
|
26
|
+
post = {}
|
27
|
+
add_invoice(post, money, options)
|
28
|
+
add_payment_method(post, payment_method)
|
29
|
+
add_customer_data(post, options)
|
30
|
+
|
31
|
+
commit('purchase', options, post)
|
32
|
+
end
|
33
|
+
|
34
|
+
def authorize(money, payment, options = {})
|
35
|
+
post = {}
|
36
|
+
add_invoice(post, money, options)
|
37
|
+
add_credit_card(post, payment)
|
38
|
+
add_customer_data(post, options)
|
39
|
+
|
40
|
+
commit('authorize', options, post)
|
41
|
+
end
|
42
|
+
|
43
|
+
def capture(amount, authorization, options = {})
|
44
|
+
post = {}
|
45
|
+
add_invoice(post, amount, options)
|
46
|
+
add_reference(post, authorization)
|
47
|
+
add_customer_data(post, options)
|
48
|
+
|
49
|
+
commit('capture', options, post)
|
50
|
+
end
|
51
|
+
|
52
|
+
def refund(amount, authorization, options = {})
|
53
|
+
post = {}
|
54
|
+
add_invoice(post, amount, options)
|
55
|
+
add_reference(post, authorization)
|
56
|
+
add_customer_data(post, options)
|
57
|
+
|
58
|
+
commit('refund', options, post)
|
59
|
+
end
|
60
|
+
|
61
|
+
def void(authorization, options = {})
|
62
|
+
post = {}
|
63
|
+
add_reference(post, authorization)
|
64
|
+
|
65
|
+
commit('void', options, post)
|
66
|
+
end
|
67
|
+
|
68
|
+
def verify(credit_card, options = {})
|
69
|
+
MultiResponse.run(:use_first_response) do |r|
|
70
|
+
r.process { authorize(100, credit_card, options) }
|
71
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def supports_scrubbing?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
def scrub(transcript)
|
80
|
+
transcript.
|
81
|
+
gsub(%r((&?merchantpin=)[^&]*)i, '\1[FILTERED]').
|
82
|
+
gsub(%r((&?ccnum=)[^&]*)i, '\1[FILTERED]').
|
83
|
+
gsub(%r((&?ckacct=)[^&]*)i, '\1[FILTERED]').
|
84
|
+
gsub(%r((&?cvv2=)[^&]*)i, '\1[FILTERED]')
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def url(options)
|
90
|
+
options[:use_backup_url].to_s == 'true' ? self.backup_url : self.live_url
|
91
|
+
end
|
92
|
+
|
93
|
+
def add_customer_data(post, options)
|
94
|
+
if (billing_address = (options[:billing_address] || options[:address]))
|
95
|
+
post[:ci_companyname] = billing_address[:company]
|
96
|
+
post[:ci_billaddr1] = billing_address[:address1]
|
97
|
+
post[:ci_billaddr2] = billing_address[:address2]
|
98
|
+
post[:ci_billcity] = billing_address[:city]
|
99
|
+
post[:ci_billstate] = billing_address[:state]
|
100
|
+
post[:ci_billzip] = billing_address[:zip]
|
101
|
+
post[:ci_billcountry] = billing_address[:country]
|
102
|
+
|
103
|
+
post[:ci_phone] = billing_address[:phone]
|
104
|
+
post[:ci_email] = billing_address[:email]
|
105
|
+
post[:ci_ipaddress] = billing_address[:ip]
|
106
|
+
end
|
107
|
+
|
108
|
+
if (shipping_address = options[:shipping_address])
|
109
|
+
post[:ci_shipaddr1] = shipping_address[:address1]
|
110
|
+
post[:ci_shipaddr2] = shipping_address[:address2]
|
111
|
+
post[:ci_shipcity] = shipping_address[:city]
|
112
|
+
post[:ci_shipstate] = shipping_address[:state]
|
113
|
+
post[:ci_shipzip] = shipping_address[:zip]
|
114
|
+
post[:ci_shipcountry] = shipping_address[:country]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_invoice(post, money, options)
|
119
|
+
post[:amount] = amount(money)
|
120
|
+
post[:currencycode] = (options[:currency] || currency(money))
|
121
|
+
post[:merchantordernumber] = options[:order_id] if options[:order_id]
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_payment_method(post, payment_method)
|
125
|
+
if card_brand(payment_method) == 'check'
|
126
|
+
add_check(post, payment_method)
|
127
|
+
else
|
128
|
+
add_credit_card(post, payment_method)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def add_credit_card(post, payment_method)
|
133
|
+
post[:ccname] = payment_method.name
|
134
|
+
post[:ccnum] = payment_method.number
|
135
|
+
post[:cvv2] = payment_method.verification_value
|
136
|
+
post[:expyear] = format(payment_method.year, :four_digits)
|
137
|
+
post[:expmon] = format(payment_method.month, :two_digits)
|
138
|
+
end
|
139
|
+
|
140
|
+
ACCOUNT_TYPES = {
|
141
|
+
'checking' => '1',
|
142
|
+
'savings' => '2'
|
143
|
+
}
|
144
|
+
|
145
|
+
def add_check(post, payment_method)
|
146
|
+
post[:action] = 'ns_quicksale_check'
|
147
|
+
post[:ckacct] = payment_method.account_number
|
148
|
+
post[:ckaba] = payment_method.routing_number
|
149
|
+
post[:ckno] = payment_method.number
|
150
|
+
post[:ckaccttype] = ACCOUNT_TYPES[payment_method.account_type] if ACCOUNT_TYPES[payment_method.account_type]
|
151
|
+
end
|
152
|
+
|
153
|
+
def split_authorization(authorization)
|
154
|
+
historyid, orderid = authorization.split('|')
|
155
|
+
[historyid, orderid]
|
156
|
+
end
|
157
|
+
|
158
|
+
def add_reference(post, authorization)
|
159
|
+
historyid, orderid = split_authorization(authorization)
|
160
|
+
post[:postonly] = historyid
|
161
|
+
post[:historykeyid] = historyid
|
162
|
+
post[:orderkeyid] = orderid
|
163
|
+
end
|
164
|
+
|
165
|
+
def parse(xml)
|
166
|
+
response = {}
|
167
|
+
doc = Nokogiri::XML(xml)
|
168
|
+
message = doc.xpath('//plaintext')
|
169
|
+
message.text.split(/\r?\n/).each do |line|
|
170
|
+
key, value = line.split(%r{=})
|
171
|
+
response[key] = value if key
|
172
|
+
end
|
173
|
+
response
|
174
|
+
end
|
175
|
+
|
176
|
+
ACTIONS = {
|
177
|
+
'purchase' => 'ns_quicksale_cc',
|
178
|
+
'refund' => 'ns_credit',
|
179
|
+
'authorize' => 'ns_quicksale_cc',
|
180
|
+
'capture' => 'ns_quicksale_cc',
|
181
|
+
'void' => 'ns_void'
|
182
|
+
}
|
183
|
+
|
184
|
+
def commit(action, options, post)
|
185
|
+
post[:action] = ACTIONS[action] unless post[:action]
|
186
|
+
post[:acctid] = @options[:acctid]
|
187
|
+
post[:subid] = @options[:subid]
|
188
|
+
post[:merchantpin] = @options[:merchantpin]
|
189
|
+
|
190
|
+
post[:authonly] = '1' if action == 'authorize'
|
191
|
+
|
192
|
+
raw = parse(ssl_post(url(options), post.to_query))
|
193
|
+
|
194
|
+
succeeded = success_from(raw['result'])
|
195
|
+
Response.new(
|
196
|
+
succeeded,
|
197
|
+
message_from(succeeded, raw),
|
198
|
+
raw,
|
199
|
+
authorization: authorization_from(raw),
|
200
|
+
test: test?
|
201
|
+
)
|
202
|
+
end
|
203
|
+
|
204
|
+
def success_from(result)
|
205
|
+
result == '1'
|
206
|
+
end
|
207
|
+
|
208
|
+
def message_from(succeeded, response)
|
209
|
+
if succeeded
|
210
|
+
'Succeeded'
|
211
|
+
else
|
212
|
+
(response['transresult'] || response['Reason'] || 'Unable to read error message')
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def authorization_from(response)
|
217
|
+
[response['historyid'], response['orderid']].join('|')
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module Billing
|
5
|
+
load_path = Pathname.new(__FILE__ + '/../../..')
|
6
|
+
Dir[File.dirname(__FILE__) + '/gateways/**/*.rb'].each do |filename|
|
7
|
+
gateway_name = File.basename(filename, '.rb')
|
8
|
+
gateway_classname = "#{gateway_name}_gateway".camelize
|
9
|
+
gateway_filename = Pathname.new(filename).relative_path_from(load_path).sub_ext('')
|
10
|
+
|
11
|
+
autoload(gateway_classname, gateway_filename)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'active_merchant/billing/compatibility'
|
2
|
+
require 'active_merchant/empty'
|
3
|
+
|
4
|
+
module ActiveMerchant
|
5
|
+
module Billing
|
6
|
+
class Model
|
7
|
+
include Compatibility::Model
|
8
|
+
include Empty
|
9
|
+
|
10
|
+
def initialize(attributes = {})
|
11
|
+
attributes.each do |key, value|
|
12
|
+
send("#{key}=", value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def errors_hash(array)
|
23
|
+
array.inject({}) do |hash, (attribute, error)|
|
24
|
+
(hash[attribute] ||= []) << error
|
25
|
+
hash
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class NetworkTokenizationCreditCard < CreditCard
|
4
|
+
# A +NetworkTokenizationCreditCard+ object represents a tokenized credit card
|
5
|
+
# using the EMV Network Tokenization specification, http://www.emvco.com/specifications.aspx?id=263.
|
6
|
+
#
|
7
|
+
# It includes all fields of the +CreditCard+ class with additional fields for
|
8
|
+
# verification data that must be given to gateways through existing fields (3DS / EMV).
|
9
|
+
#
|
10
|
+
# The only tested usage of this at the moment is with an Apple Pay decrypted PKPaymentToken,
|
11
|
+
# https://developer.apple.com/library/ios/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
|
12
|
+
|
13
|
+
# These are not relevant (verification) or optional (name) for Apple Pay
|
14
|
+
self.require_verification_value = false
|
15
|
+
self.require_name = false
|
16
|
+
|
17
|
+
attr_accessor :payment_cryptogram, :eci, :transaction_id, :metadata
|
18
|
+
attr_writer :source
|
19
|
+
|
20
|
+
SOURCES = %i(apple_pay android_pay google_pay network_token)
|
21
|
+
|
22
|
+
def source
|
23
|
+
if defined?(@source) && SOURCES.include?(@source)
|
24
|
+
@source
|
25
|
+
else
|
26
|
+
:apple_pay
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def credit_card?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def type
|
35
|
+
'network_tokenization'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# Base class representation of cryptographic payment data tokens that may be used for EMV-style transactions
|
4
|
+
# like Apple Pay. Payment data may be transmitted via any data type, and may also be padded
|
5
|
+
# with metadata specific to the cryptographer. This metadata should be parsed and interpreted in concrete
|
6
|
+
# implementations of your given cryptographer. Like credit cards, you must also return a string representing
|
7
|
+
# the token's type, like 'apple_pay' or 'stripe' should your target payment gateway process these tokens.
|
8
|
+
class PaymentToken
|
9
|
+
attr_reader :payment_data
|
10
|
+
|
11
|
+
def initialize(payment_data, options = {})
|
12
|
+
@payment_data = payment_data
|
13
|
+
@metadata = options.with_indifferent_access
|
14
|
+
end
|
15
|
+
|
16
|
+
def type
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class Error < ActiveMerchantError #:nodoc:
|
4
|
+
end
|
5
|
+
|
6
|
+
class Response
|
7
|
+
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result,
|
8
|
+
:error_code, :emv_authorization, :network_transaction_id, :response_type,
|
9
|
+
:request_body, :response_http_code, :request_endpoint, :request_method,
|
10
|
+
:request_id, :auth_code
|
11
|
+
|
12
|
+
def success?
|
13
|
+
@success
|
14
|
+
end
|
15
|
+
|
16
|
+
def failure?
|
17
|
+
!success?
|
18
|
+
end
|
19
|
+
|
20
|
+
def test?
|
21
|
+
@test
|
22
|
+
end
|
23
|
+
|
24
|
+
def fraud_review?
|
25
|
+
@fraud_review
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(success, message, params = {}, options = {})
|
29
|
+
@success, @message, @params = success, message, params.stringify_keys
|
30
|
+
@test = options[:test] || false
|
31
|
+
@authorization = options[:authorization]
|
32
|
+
@fraud_review = options[:fraud_review]
|
33
|
+
@error_code = options[:error_code]
|
34
|
+
@emv_authorization = options[:emv_authorization]
|
35
|
+
@network_transaction_id = options[:network_transaction_id]
|
36
|
+
|
37
|
+
@avs_result = if options[:avs_result].kind_of?(AVSResult)
|
38
|
+
options[:avs_result].to_hash
|
39
|
+
else
|
40
|
+
AVSResult.new(options[:avs_result]).to_hash
|
41
|
+
end
|
42
|
+
|
43
|
+
@cvv_result = if options[:cvv_result].kind_of?(CVVResult)
|
44
|
+
options[:cvv_result].to_hash
|
45
|
+
else
|
46
|
+
CVVResult.new(options[:cvv_result]).to_hash
|
47
|
+
end
|
48
|
+
@response_type = options[:response_type]
|
49
|
+
@response_http_code = options[:response_http_code]
|
50
|
+
@request_endpoint = options[:request_endpoint]
|
51
|
+
@request_method = options[:request_method]
|
52
|
+
@request_body = options[:request_body]
|
53
|
+
@request_id = options[:request_id]
|
54
|
+
@auth_code = options[:auth_code]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class MultiResponse < Response
|
59
|
+
def self.run(use_first_response = false, &block)
|
60
|
+
new(use_first_response).tap(&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_reader :responses, :primary_response
|
64
|
+
|
65
|
+
def initialize(use_first_response = false)
|
66
|
+
@responses = []
|
67
|
+
@use_first_response = use_first_response
|
68
|
+
@primary_response = nil
|
69
|
+
end
|
70
|
+
|
71
|
+
def process(ignore_result = false)
|
72
|
+
return unless success?
|
73
|
+
|
74
|
+
response = yield
|
75
|
+
self << response
|
76
|
+
|
77
|
+
unless ignore_result
|
78
|
+
if @use_first_response && response.success?
|
79
|
+
@primary_response ||= response
|
80
|
+
else
|
81
|
+
@primary_response = response
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def <<(response)
|
87
|
+
if response.is_a?(MultiResponse)
|
88
|
+
response.responses.each { |r| @responses << r }
|
89
|
+
else
|
90
|
+
@responses << response
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def success?
|
95
|
+
(primary_response ? primary_response.success? : true)
|
96
|
+
end
|
97
|
+
|
98
|
+
def avs_result
|
99
|
+
return @primary_response.try(:avs_result) if @use_first_response
|
100
|
+
|
101
|
+
result = responses.reverse.find { |r| r.avs_result['code'].present? }
|
102
|
+
result.try(:avs_result) || responses.last.try(:avs_result)
|
103
|
+
end
|
104
|
+
|
105
|
+
def cvv_result
|
106
|
+
return @primary_response.try(:cvv_result) if @use_first_response
|
107
|
+
|
108
|
+
result = responses.reverse.find { |r| r.cvv_result['code'].present? }
|
109
|
+
result.try(:cvv_result) || responses.last.try(:cvv_result)
|
110
|
+
end
|
111
|
+
|
112
|
+
%w(params message test authorization error_code emv_authorization test? fraud_review?).each do |m|
|
113
|
+
class_eval %(
|
114
|
+
def #{m}
|
115
|
+
(@responses.empty? ? nil : primary_response.#{m})
|
116
|
+
end
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
module ThreeDSecureEciMapper
|
4
|
+
NON_THREE_D_SECURE_TRANSACTION = :non_three_d_secure_transaction
|
5
|
+
ATTEMPTED_AUTHENTICATION_TRANSACTION = :attempted_authentication_transaction
|
6
|
+
FULLY_AUTHENTICATED_TRANSACTION = :fully_authenticated_transaction
|
7
|
+
|
8
|
+
ECI_00_01_02_MAP = { '00' => NON_THREE_D_SECURE_TRANSACTION, '01' => ATTEMPTED_AUTHENTICATION_TRANSACTION, '02' => FULLY_AUTHENTICATED_TRANSACTION }.freeze
|
9
|
+
ECI_05_06_07_MAP = { '05' => FULLY_AUTHENTICATED_TRANSACTION, '06' => ATTEMPTED_AUTHENTICATION_TRANSACTION, '07' => NON_THREE_D_SECURE_TRANSACTION }.freeze
|
10
|
+
BRAND_TO_ECI_MAP = {
|
11
|
+
american_express: ECI_05_06_07_MAP,
|
12
|
+
dankort: ECI_05_06_07_MAP,
|
13
|
+
diners_club: ECI_05_06_07_MAP,
|
14
|
+
discover: ECI_05_06_07_MAP,
|
15
|
+
elo: ECI_05_06_07_MAP,
|
16
|
+
jcb: ECI_05_06_07_MAP,
|
17
|
+
maestro: ECI_00_01_02_MAP,
|
18
|
+
master: ECI_00_01_02_MAP,
|
19
|
+
visa: ECI_05_06_07_MAP
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def self.map(brand, eci)
|
23
|
+
BRAND_TO_ECI_MAP.dig(brand, eci)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|