activemerchant 1.45.0 → 1.126.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +2167 -2
- data/CONTRIBUTORS +57 -0
- data/README.md +62 -41
- data/lib/active_merchant/billing/avs_result.rb +25 -28
- data/lib/active_merchant/billing/base.rb +11 -35
- data/lib/active_merchant/billing/check.rb +28 -24
- data/lib/active_merchant/billing/compatibility.rb +10 -12
- data/lib/active_merchant/billing/credit_card.rb +141 -69
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
- data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +125 -61
- data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
- data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
- data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
- data/lib/active_merchant/billing/gateways/banwire.rb +24 -13
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
- data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +143 -62
- data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
- data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
- data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
- data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
- 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 +70 -26
- data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
- data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -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/commercegate.rb +11 -12
- data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +506 -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.rb +637 -221
- data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
- data/lib/active_merchant/billing/gateways/decidir.rb +347 -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 +334 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
- data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
- data/lib/active_merchant/billing/gateways/element.rb +386 -0
- data/lib/active_merchant/billing/gateways/epay.rb +92 -71
- data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
- data/lib/active_merchant/billing/gateways/eway.rb +85 -73
- data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
- data/lib/active_merchant/billing/gateways/exact.rb +37 -36
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
- data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
- data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
- data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
- data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
- 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/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
- data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
- data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
- data/lib/active_merchant/billing/gateways/hps.rb +252 -68
- data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
- data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
- data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
- data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
- data/lib/active_merchant/billing/gateways/litle.rb +371 -94
- data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
- data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
- data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
- data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +101 -37
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +422 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
- data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
- data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
- data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
- data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
- data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
- data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
- data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
- 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 +84 -68
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
- data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
- data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
- data/lib/active_merchant/billing/gateways/payex.rb +39 -42
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
- data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
- data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
- data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
- data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
- data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
- data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
- data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
- data/lib/active_merchant/billing/gateways/payway.rb +27 -27
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +113 -37
- data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
- data/lib/active_merchant/billing/gateways/priority.rb +369 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
- data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
- data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
- data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
- 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 +10 -353
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
- data/lib/active_merchant/billing/gateways/realex.rb +154 -52
- data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
- 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 +404 -133
- data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
- data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
- data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
- data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
- data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
- data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +16 -217
- data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
- 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 +6 -8
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
- data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
- data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
- data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
- data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
- data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
- data/lib/active_merchant/billing/gateways.rb +8 -11
- data/lib/active_merchant/billing/model.rb +2 -2
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +1 -1
- data/lib/active_merchant/billing/rails.rb +1 -1
- data/lib/active_merchant/billing/response.rb +19 -13
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +3 -0
- data/lib/active_merchant/connection.rb +196 -0
- data/lib/active_merchant/country.rb +13 -8
- data/lib/active_merchant/errors.rb +6 -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 +1 -1
- data/lib/active_merchant.rb +14 -59
- data/lib/activemerchant.rb +1 -1
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +8 -10
- data/lib/support/outbound_hosts.rb +13 -10
- data/lib/support/ssl_verify.rb +9 -14
- data/lib/support/ssl_version.rb +86 -0
- metadata +136 -94
- checksums.yaml.gz.sig +0 -1
- data/lib/active_merchant/billing/gateways/app55.rb +0 -176
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
- data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
- data/lib/active_merchant/offsite_payments_shim.rb +0 -19
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,507 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class GlobalCollectGateway < Gateway
|
4
|
+
class_attribute :preproduction_url
|
5
|
+
|
6
|
+
self.display_name = 'GlobalCollect'
|
7
|
+
self.homepage_url = 'http://www.globalcollect.com/'
|
8
|
+
|
9
|
+
self.test_url = 'https://eu.sandbox.api-ingenico.com'
|
10
|
+
self.preproduction_url = 'https://world.preprod.api-ingenico.com'
|
11
|
+
self.live_url = 'https://world.api-ingenico.com'
|
12
|
+
|
13
|
+
self.supported_countries = %w[AD AE AG AI AL AM AO AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BW BY BZ CA CC CD CF CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HN HR HT HU ID IE IL IM IN IS IT JM JO JP KE KG KH KI KM KN KR KW KY KZ LA LB LC LI LK LR LS LT LU LV MA MC MD ME MF MG MH MK MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PL PN PS PT PW QA RE RO RS RU RW SA SB SC SE SG SH SI SJ SK SL SM SN SR ST SV SZ TC TD TG TH TJ TL TM TN TO TR TT TV TW TZ UA UG US UY UZ VC VE VG VI VN WF WS ZA ZM ZW]
|
14
|
+
self.default_currency = 'USD'
|
15
|
+
self.money_format = :cents
|
16
|
+
self.supported_cardtypes = %i[visa master american_express discover naranja cabal]
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
requires!(options, :merchant_id, :api_key_id, :secret_api_key)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def purchase(money, payment, options = {})
|
24
|
+
MultiResponse.run do |r|
|
25
|
+
r.process { authorize(money, payment, options) }
|
26
|
+
r.process { capture(money, r.authorization, options) } if should_request_capture?(r, options[:requires_approval])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def authorize(money, payment, options = {})
|
31
|
+
post = nestable_hash
|
32
|
+
add_order(post, money, options)
|
33
|
+
add_payment(post, payment, options)
|
34
|
+
add_customer_data(post, options, payment)
|
35
|
+
add_address(post, payment, options)
|
36
|
+
add_creator_info(post, options)
|
37
|
+
add_fraud_fields(post, options)
|
38
|
+
add_external_cardholder_authentication_data(post, options)
|
39
|
+
commit(:authorize, post, options: options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def capture(money, authorization, options = {})
|
43
|
+
post = nestable_hash
|
44
|
+
add_order(post, money, options, capture: true)
|
45
|
+
add_customer_data(post, options)
|
46
|
+
add_creator_info(post, options)
|
47
|
+
commit(:capture, post, authorization: authorization)
|
48
|
+
end
|
49
|
+
|
50
|
+
def refund(money, authorization, options = {})
|
51
|
+
post = nestable_hash
|
52
|
+
add_amount(post, money, options)
|
53
|
+
add_refund_customer_data(post, options)
|
54
|
+
add_creator_info(post, options)
|
55
|
+
commit(:refund, post, authorization: authorization)
|
56
|
+
end
|
57
|
+
|
58
|
+
def void(authorization, options = {})
|
59
|
+
post = nestable_hash
|
60
|
+
add_creator_info(post, options)
|
61
|
+
commit(:void, post, authorization: authorization)
|
62
|
+
end
|
63
|
+
|
64
|
+
def verify(payment, options = {})
|
65
|
+
MultiResponse.run(:use_first_response) do |r|
|
66
|
+
r.process { authorize(100, payment, options) }
|
67
|
+
r.process { void(r.authorization, options) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def supports_scrubbing?
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def scrub(transcript)
|
76
|
+
transcript.
|
77
|
+
gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]').
|
78
|
+
gsub(%r(("cardNumber\\+":\\+")\d+), '\1[FILTERED]').
|
79
|
+
gsub(%r(("cvv\\+":\\+")\d+), '\1[FILTERED]')
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
BRAND_MAP = {
|
85
|
+
'visa' => '1',
|
86
|
+
'american_express' => '2',
|
87
|
+
'master' => '3',
|
88
|
+
'discover' => '128',
|
89
|
+
'jcb' => '125',
|
90
|
+
'diners_club' => '132',
|
91
|
+
'cabal' => '135',
|
92
|
+
'naranja' => '136'
|
93
|
+
}
|
94
|
+
|
95
|
+
def add_order(post, money, options, capture: false)
|
96
|
+
if capture
|
97
|
+
post['amount'] = amount(money)
|
98
|
+
else
|
99
|
+
add_amount(post['order'], money, options)
|
100
|
+
end
|
101
|
+
post['order']['references'] = {
|
102
|
+
'merchantReference' => options[:order_id],
|
103
|
+
'descriptor' => options[:description] # Max 256 chars
|
104
|
+
}
|
105
|
+
post['order']['references']['invoiceData'] = {
|
106
|
+
'invoiceNumber' => options[:invoice]
|
107
|
+
}
|
108
|
+
add_airline_data(post, options)
|
109
|
+
add_lodging_data(post, options)
|
110
|
+
add_number_of_installments(post, options) if options[:number_of_installments]
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_airline_data(post, options)
|
114
|
+
return unless airline_options = options[:airline_data]
|
115
|
+
|
116
|
+
airline_data = {}
|
117
|
+
|
118
|
+
airline_data['flightDate'] = airline_options[:flight_date] if airline_options[:flight_date]
|
119
|
+
airline_data['passengerName'] = airline_options[:passenger_name] if airline_options[:passenger_name]
|
120
|
+
airline_data['code'] = airline_options[:code] if airline_options[:code]
|
121
|
+
airline_data['name'] = airline_options[:name] if airline_options[:name]
|
122
|
+
airline_data['invoiceNumber'] = options[:airline_data][:invoice_number] if options[:airline_data][:invoice_number]
|
123
|
+
airline_data['isETicket'] = options[:airline_data][:is_eticket] if options[:airline_data][:is_eticket]
|
124
|
+
airline_data['isRestrictedTicket'] = options[:airline_data][:is_restricted_ticket] if options[:airline_data][:is_restricted_ticket]
|
125
|
+
airline_data['isThirdParty'] = options[:airline_data][:is_third_party] if options[:airline_data][:is_third_party]
|
126
|
+
airline_data['issueDate'] = options[:airline_data][:issue_date] if options[:airline_data][:issue_date]
|
127
|
+
airline_data['merchantCustomerId'] = options[:airline_data][:merchant_customer_id] if options[:airline_data][:merchant_customer_id]
|
128
|
+
airline_data['flightLegs'] = add_flight_legs(airline_options)
|
129
|
+
airline_data['passengers'] = add_passengers(airline_options)
|
130
|
+
|
131
|
+
post['order']['additionalInput']['airlineData'] = airline_data
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_flight_legs(airline_options)
|
135
|
+
flight_legs = []
|
136
|
+
airline_options[:flight_legs]&.each do |fl|
|
137
|
+
leg = {}
|
138
|
+
leg['airlineClass'] = fl[:airline_class] if fl[:airline_class]
|
139
|
+
leg['arrivalAirport'] = fl[:arrival_airport] if fl[:arrival_airport]
|
140
|
+
leg['arrivalTime'] = fl[:arrival_time] if fl[:arrival_time]
|
141
|
+
leg['carrierCode'] = fl[:carrier_code] if fl[:carrier_code]
|
142
|
+
leg['conjunctionTicket'] = fl[:conjunction_ticket] if fl[:conjunction_ticket]
|
143
|
+
leg['couponNumber'] = fl[:coupon_number] if fl[:coupon_number]
|
144
|
+
leg['date'] = fl[:date] if fl[:date]
|
145
|
+
leg['departureTime'] = fl[:departure_time] if fl[:departure_time]
|
146
|
+
leg['endorsementOrRestriction'] = fl[:endorsement_or_restriction] if fl[:endorsement_or_restriction]
|
147
|
+
leg['exchangeTicket'] = fl[:exchange_ticket] if fl[:exchange_ticket]
|
148
|
+
leg['fare'] = fl[:fare] if fl[:fare]
|
149
|
+
leg['fareBasis'] = fl[:fare_basis] if fl[:fare_basis]
|
150
|
+
leg['fee'] = fl[:fee] if fl[:fee]
|
151
|
+
leg['flightNumber'] = fl[:flight_number] if fl[:flight_number]
|
152
|
+
leg['number'] = fl[:number] if fl[:number]
|
153
|
+
leg['originAirport'] = fl[:origin_airport] if fl[:origin_airport]
|
154
|
+
leg['passengerClass'] = fl[:passenger_class] if fl[:passenger_class]
|
155
|
+
leg['stopoverCode'] = fl[:stopover_code] if fl[:stopover_code]
|
156
|
+
leg['taxes'] = fl[:taxes] if fl[:taxes]
|
157
|
+
flight_legs << leg
|
158
|
+
end
|
159
|
+
flight_legs
|
160
|
+
end
|
161
|
+
|
162
|
+
def add_passengers(airline_options)
|
163
|
+
passengers = []
|
164
|
+
airline_options[:passengers]&.each do |flyer|
|
165
|
+
passenger = {}
|
166
|
+
passenger['firstName'] = flyer[:first_name] if flyer[:first_name]
|
167
|
+
passenger['surname'] = flyer[:surname] if flyer[:surname]
|
168
|
+
passenger['surnamePrefix'] = flyer[:surname_prefix] if flyer[:surname_prefix]
|
169
|
+
passenger['title'] = flyer[:title] if flyer[:title]
|
170
|
+
passengers << passenger
|
171
|
+
end
|
172
|
+
passengers
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_lodging_data(post, options)
|
176
|
+
return unless lodging_options = options[:lodging_data]
|
177
|
+
|
178
|
+
lodging_data = {}
|
179
|
+
|
180
|
+
lodging_data['charges'] = add_charges(lodging_options)
|
181
|
+
lodging_data['checkInDate'] = lodging_options[:check_in_date] if lodging_options[:check_in_date]
|
182
|
+
lodging_data['checkOutDate'] = lodging_options[:check_out_date] if lodging_options[:check_out_date]
|
183
|
+
lodging_data['folioNumber'] = lodging_options[:folio_number] if lodging_options[:folio_number]
|
184
|
+
lodging_data['isConfirmedReservation'] = lodging_options[:is_confirmed_reservation] if lodging_options[:is_confirmed_reservation]
|
185
|
+
lodging_data['isFacilityFireSafetyConform'] = lodging_options[:is_facility_fire_safety_conform] if lodging_options[:is_facility_fire_safety_conform]
|
186
|
+
lodging_data['isNoShow'] = lodging_options[:is_no_show] if lodging_options[:is_no_show]
|
187
|
+
lodging_data['isPreferenceSmokingRoom'] = lodging_options[:is_preference_smoking_room] if lodging_options[:is_preference_smoking_room]
|
188
|
+
lodging_data['numberOfAdults'] = lodging_options[:number_of_adults] if lodging_options[:number_of_adults]
|
189
|
+
lodging_data['numberOfNights'] = lodging_options[:number_of_nights] if lodging_options[:number_of_nights]
|
190
|
+
lodging_data['numberOfRooms'] = lodging_options[:number_of_rooms] if lodging_options[:number_of_rooms]
|
191
|
+
lodging_data['programCode'] = lodging_options[:program_code] if lodging_options[:program_code]
|
192
|
+
lodging_data['propertyCustomerServicePhoneNumber'] = lodging_options[:property_customer_service_phone_number] if lodging_options[:property_customer_service_phone_number]
|
193
|
+
lodging_data['propertyPhoneNumber'] = lodging_options[:property_phone_number] if lodging_options[:property_phone_number]
|
194
|
+
lodging_data['renterName'] = lodging_options[:renter_name] if lodging_options[:renter_name]
|
195
|
+
lodging_data['rooms'] = add_rooms(lodging_options)
|
196
|
+
|
197
|
+
post['order']['additionalInput']['lodgingData'] = lodging_data
|
198
|
+
end
|
199
|
+
|
200
|
+
def add_charges(lodging_options)
|
201
|
+
charges = []
|
202
|
+
lodging_options[:charges]&.each do |item|
|
203
|
+
charge = {}
|
204
|
+
charge['chargeAmount'] = item[:charge_amount] if item[:charge_amount]
|
205
|
+
charge['chargeAmountCurrencyCode'] = item[:charge_amount_currency_code] if item[:charge_amount_currency_code]
|
206
|
+
charge['chargeType'] = item[:charge_type] if item[:charge_type]
|
207
|
+
charges << charge
|
208
|
+
end
|
209
|
+
charges
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_rooms(lodging_options)
|
213
|
+
rooms = []
|
214
|
+
lodging_options[:rooms]&.each do |item|
|
215
|
+
room = {}
|
216
|
+
room['dailyRoomRate'] = item[:daily_room_rate] if item[:daily_room_rate]
|
217
|
+
room['dailyRoomRateCurrencyCode'] = item[:daily_room_rate_currency_code] if item[:daily_room_rate_currency_code]
|
218
|
+
room['dailyRoomTaxAmount'] = item[:daily_room_tax_amount] if item[:daily_room_tax_amount]
|
219
|
+
room['dailyRoomTaxAmountCurrencyCode'] = item[:daily_room_tax_amount_currency_code] if item[:daily_room_tax_amount_currency_code]
|
220
|
+
room['numberOfNightsAtRoomRate'] = item[:number_of_nights_at_room_rate] if item[:number_of_nights_at_room_rate]
|
221
|
+
room['roomLocation'] = item[:room_location] if item[:room_location]
|
222
|
+
room['roomNumber'] = item[:room_number] if item[:room_number]
|
223
|
+
room['typeOfBed'] = item[:type_of_bed] if item[:type_of_bed]
|
224
|
+
room['typeOfRoom'] = item[:type_of_room] if item[:type_of_room]
|
225
|
+
rooms << room
|
226
|
+
end
|
227
|
+
rooms
|
228
|
+
end
|
229
|
+
|
230
|
+
def add_creator_info(post, options)
|
231
|
+
post['sdkIdentifier'] = options[:sdk_identifier] if options[:sdk_identifier]
|
232
|
+
post['sdkCreator'] = options[:sdk_creator] if options[:sdk_creator]
|
233
|
+
post['integrator'] = options[:integrator] if options[:integrator]
|
234
|
+
post['shoppingCartExtension'] = {}
|
235
|
+
post['shoppingCartExtension']['creator'] = options[:creator] if options[:creator]
|
236
|
+
post['shoppingCartExtension']['name'] = options[:name] if options[:name]
|
237
|
+
post['shoppingCartExtension']['version'] = options[:version] if options[:version]
|
238
|
+
post['shoppingCartExtension']['extensionID'] = options[:extension_ID] if options[:extension_ID]
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_amount(post, money, options = {})
|
242
|
+
post['amountOfMoney'] = {
|
243
|
+
'amount' => amount(money),
|
244
|
+
'currencyCode' => options[:currency] || currency(money)
|
245
|
+
}
|
246
|
+
end
|
247
|
+
|
248
|
+
def add_payment(post, payment, options)
|
249
|
+
year = format(payment.year, :two_digits)
|
250
|
+
month = format(payment.month, :two_digits)
|
251
|
+
expirydate = "#{month}#{year}"
|
252
|
+
pre_authorization = options[:pre_authorization] ? 'PRE_AUTHORIZATION' : 'FINAL_AUTHORIZATION'
|
253
|
+
post['cardPaymentMethodSpecificInput'] = {
|
254
|
+
'paymentProductId' => BRAND_MAP[payment.brand],
|
255
|
+
'skipAuthentication' => 'true', # refers to 3DSecure
|
256
|
+
'skipFraudService' => 'true',
|
257
|
+
'authorizationMode' => pre_authorization
|
258
|
+
}
|
259
|
+
post['cardPaymentMethodSpecificInput']['requiresApproval'] = options[:requires_approval] unless options[:requires_approval].nil?
|
260
|
+
|
261
|
+
post['cardPaymentMethodSpecificInput']['card'] = {
|
262
|
+
'cvv' => payment.verification_value,
|
263
|
+
'cardNumber' => payment.number,
|
264
|
+
'expiryDate' => expirydate,
|
265
|
+
'cardholderName' => payment.name
|
266
|
+
}
|
267
|
+
end
|
268
|
+
|
269
|
+
def add_customer_data(post, options, payment = nil)
|
270
|
+
if payment
|
271
|
+
post['order']['customer']['personalInformation']['name']['firstName'] = payment.first_name[0..14] if payment.first_name
|
272
|
+
post['order']['customer']['personalInformation']['name']['surname'] = payment.last_name[0..69] if payment.last_name
|
273
|
+
end
|
274
|
+
post['order']['customer']['merchantCustomerId'] = options[:customer] if options[:customer]
|
275
|
+
post['order']['customer']['companyInformation']['name'] = options[:company] if options[:company]
|
276
|
+
post['order']['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email]
|
277
|
+
if address = options[:billing_address] || options[:address]
|
278
|
+
post['order']['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def add_refund_customer_data(post, options)
|
283
|
+
if address = options[:billing_address] || options[:address]
|
284
|
+
post['customer']['address'] = {
|
285
|
+
'countryCode' => address[:country]
|
286
|
+
}
|
287
|
+
post['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email]
|
288
|
+
if address = options[:billing_address] || options[:address]
|
289
|
+
post['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def add_address(post, creditcard, options)
|
295
|
+
shipping_address = options[:shipping_address]
|
296
|
+
if billing_address = options[:billing_address] || options[:address]
|
297
|
+
post['order']['customer']['billingAddress'] = {
|
298
|
+
'street' => truncate(billing_address[:address1], 50),
|
299
|
+
'additionalInfo' => truncate(billing_address[:address2], 50),
|
300
|
+
'zip' => billing_address[:zip],
|
301
|
+
'city' => billing_address[:city],
|
302
|
+
'state' => truncate(billing_address[:state], 35),
|
303
|
+
'countryCode' => billing_address[:country]
|
304
|
+
}
|
305
|
+
end
|
306
|
+
if shipping_address
|
307
|
+
post['order']['customer']['shippingAddress'] = {
|
308
|
+
'street' => truncate(shipping_address[:address1], 50),
|
309
|
+
'additionalInfo' => truncate(shipping_address[:address2], 50),
|
310
|
+
'zip' => shipping_address[:zip],
|
311
|
+
'city' => shipping_address[:city],
|
312
|
+
'state' => truncate(shipping_address[:state], 35),
|
313
|
+
'countryCode' => shipping_address[:country]
|
314
|
+
}
|
315
|
+
post['order']['customer']['shippingAddress']['name'] = {
|
316
|
+
'firstName' => shipping_address[:firstname],
|
317
|
+
'surname' => shipping_address[:lastname]
|
318
|
+
}
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
def add_fraud_fields(post, options)
|
323
|
+
fraud_fields = {}
|
324
|
+
fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields]
|
325
|
+
fraud_fields[:customerIpAddress] = options[:ip] if options[:ip]
|
326
|
+
|
327
|
+
post['fraudFields'] = fraud_fields unless fraud_fields.empty?
|
328
|
+
end
|
329
|
+
|
330
|
+
def add_external_cardholder_authentication_data(post, options)
|
331
|
+
return unless threeds_2_options = options[:three_d_secure]
|
332
|
+
|
333
|
+
authentication_data = {}
|
334
|
+
authentication_data[:acsTransactionId] = threeds_2_options[:acs_transaction_id] if threeds_2_options[:acs_transaction_id]
|
335
|
+
authentication_data[:cavv] = threeds_2_options[:cavv] if threeds_2_options[:cavv]
|
336
|
+
authentication_data[:cavvAlgorithm] = threeds_2_options[:cavv_algorithm] if threeds_2_options[:cavv_algorithm]
|
337
|
+
authentication_data[:directoryServerTransactionId] = threeds_2_options[:ds_transaction_id] if threeds_2_options[:ds_transaction_id]
|
338
|
+
authentication_data[:eci] = threeds_2_options[:eci] if threeds_2_options[:eci]
|
339
|
+
authentication_data[:threeDSecureVersion] = threeds_2_options[:version] if threeds_2_options[:version]
|
340
|
+
authentication_data[:validationResult] = threeds_2_options[:authentication_response_status] if threeds_2_options[:authentication_response_status]
|
341
|
+
authentication_data[:xid] = threeds_2_options[:xid] if threeds_2_options[:xid]
|
342
|
+
|
343
|
+
post['cardPaymentMethodSpecificInput'] ||= {}
|
344
|
+
post['cardPaymentMethodSpecificInput']['threeDSecure'] ||= {}
|
345
|
+
post['cardPaymentMethodSpecificInput']['threeDSecure']['externalCardholderAuthenticationData'] = authentication_data unless authentication_data.empty?
|
346
|
+
end
|
347
|
+
|
348
|
+
def add_number_of_installments(post, options)
|
349
|
+
post['order']['additionalInput']['numberOfInstallments'] = options[:number_of_installments] if options[:number_of_installments]
|
350
|
+
end
|
351
|
+
|
352
|
+
def parse(body)
|
353
|
+
JSON.parse(body)
|
354
|
+
end
|
355
|
+
|
356
|
+
def url(action, authorization)
|
357
|
+
return preproduction_url + uri(action, authorization) if @options[:url_override].to_s == 'preproduction'
|
358
|
+
|
359
|
+
(test? ? test_url : live_url) + uri(action, authorization)
|
360
|
+
end
|
361
|
+
|
362
|
+
def uri(action, authorization)
|
363
|
+
uri = "/v1/#{@options[:merchant_id]}/"
|
364
|
+
case action
|
365
|
+
when :authorize
|
366
|
+
uri + 'payments'
|
367
|
+
when :capture
|
368
|
+
uri + "payments/#{authorization}/approve"
|
369
|
+
when :refund
|
370
|
+
uri + "payments/#{authorization}/refund"
|
371
|
+
when :void
|
372
|
+
uri + "payments/#{authorization}/cancel"
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
def idempotency_key_for_signature(options)
|
377
|
+
"x-gcs-idempotence-key:#{options[:idempotency_key]}" if options[:idempotency_key]
|
378
|
+
end
|
379
|
+
|
380
|
+
def commit(action, post, authorization: nil, options: {})
|
381
|
+
begin
|
382
|
+
raw_response = ssl_post(url(action, authorization), post.to_json, headers(action, post, authorization, options))
|
383
|
+
response = parse(raw_response)
|
384
|
+
rescue ResponseError => e
|
385
|
+
response = parse(e.response.body) if e.response.code.to_i >= 400
|
386
|
+
rescue JSON::ParserError
|
387
|
+
response = json_error(raw_response)
|
388
|
+
end
|
389
|
+
|
390
|
+
succeeded = success_from(action, response)
|
391
|
+
Response.new(
|
392
|
+
succeeded,
|
393
|
+
message_from(succeeded, response),
|
394
|
+
response,
|
395
|
+
authorization: authorization_from(response),
|
396
|
+
error_code: error_code_from(succeeded, response),
|
397
|
+
test: test?
|
398
|
+
)
|
399
|
+
end
|
400
|
+
|
401
|
+
def json_error(raw_response)
|
402
|
+
{
|
403
|
+
'error_message' => 'Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message.' \
|
404
|
+
" (The raw response returned by the API was #{raw_response.inspect})"
|
405
|
+
}
|
406
|
+
end
|
407
|
+
|
408
|
+
def headers(action, post, authorization = nil, options = {})
|
409
|
+
headers = {
|
410
|
+
'Content-Type' => content_type,
|
411
|
+
'Authorization' => auth_digest(action, post, authorization, options),
|
412
|
+
'Date' => date
|
413
|
+
}
|
414
|
+
|
415
|
+
headers['X-GCS-Idempotence-Key'] = options[:idempotency_key] if options[:idempotency_key]
|
416
|
+
headers
|
417
|
+
end
|
418
|
+
|
419
|
+
def auth_digest(action, post, authorization = nil, options = {})
|
420
|
+
data = <<~REQUEST
|
421
|
+
POST
|
422
|
+
#{content_type}
|
423
|
+
#{date}
|
424
|
+
#{idempotency_key_for_signature(options)}
|
425
|
+
#{uri(action, authorization)}
|
426
|
+
REQUEST
|
427
|
+
data = data.each_line.reject { |line| line.strip == '' }.join
|
428
|
+
digest = OpenSSL::Digest.new('sha256')
|
429
|
+
key = @options[:secret_api_key]
|
430
|
+
"GCS v1HMAC:#{@options[:api_key_id]}:#{Base64.strict_encode64(OpenSSL::HMAC.digest(digest, key, data))}"
|
431
|
+
end
|
432
|
+
|
433
|
+
def date
|
434
|
+
@date ||= Time.now.strftime('%a, %d %b %Y %H:%M:%S %Z') # Must be same in digest and HTTP header
|
435
|
+
end
|
436
|
+
|
437
|
+
def content_type
|
438
|
+
'application/json'
|
439
|
+
end
|
440
|
+
|
441
|
+
def success_from(action, response)
|
442
|
+
return false if response['errorId'] || response['error_message']
|
443
|
+
|
444
|
+
case action
|
445
|
+
when :authorize
|
446
|
+
response.dig('payment', 'statusOutput', 'isAuthorized')
|
447
|
+
when :capture
|
448
|
+
capture_status = response.dig('status') || response.dig('payment', 'status')
|
449
|
+
%w(CAPTURED CAPTURE_REQUESTED).include?(capture_status)
|
450
|
+
when :void
|
451
|
+
void_response_id = response.dig('cardPaymentMethodSpecificOutput', 'voidResponseId') || response.dig('mobilePaymentMethodSpecificOutput', 'voidResponseId')
|
452
|
+
%w(00 0 8 11).include?(void_response_id) || response.dig('payment', 'status') == 'CANCELLED'
|
453
|
+
when :refund
|
454
|
+
refund_status = response.dig('status') || response.dig('payment', 'status')
|
455
|
+
%w(REFUNDED REFUND_REQUESTED).include?(refund_status)
|
456
|
+
else
|
457
|
+
response['status'] != 'REJECTED'
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
def message_from(succeeded, response)
|
462
|
+
return 'Succeeded' if succeeded
|
463
|
+
|
464
|
+
if errors = response['errors']
|
465
|
+
errors.first.try(:[], 'message')
|
466
|
+
elsif response['error_message']
|
467
|
+
response['error_message']
|
468
|
+
elsif response['status']
|
469
|
+
'Status: ' + response['status']
|
470
|
+
else
|
471
|
+
'No message available'
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
def authorization_from(response)
|
476
|
+
response.dig('id') || response.dig('payment', 'id') || response.dig('paymentResult', 'payment', 'id')
|
477
|
+
end
|
478
|
+
|
479
|
+
def error_code_from(succeeded, response)
|
480
|
+
return if succeeded
|
481
|
+
|
482
|
+
if errors = response['errors']
|
483
|
+
errors.first.try(:[], 'code')
|
484
|
+
elsif status = response.try(:[], 'statusOutput').try(:[], 'statusCode')
|
485
|
+
status.to_s
|
486
|
+
else
|
487
|
+
'No error code available'
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
def nestable_hash
|
492
|
+
Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
493
|
+
end
|
494
|
+
|
495
|
+
# Capture hasn't already been requested,
|
496
|
+
# and
|
497
|
+
# `requires_approval` is not false
|
498
|
+
def should_request_capture?(response, requires_approval)
|
499
|
+
!capture_requested?(response) && requires_approval != false
|
500
|
+
end
|
501
|
+
|
502
|
+
def capture_requested?(response)
|
503
|
+
response.params.try(:[], 'payment').try(:[], 'status') == 'CAPTURE_REQUESTED'
|
504
|
+
end
|
505
|
+
end
|
506
|
+
end
|
507
|
+
end
|
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
|
|
8
8
|
|
9
9
|
self.supported_countries = %w(CA PR US)
|
10
10
|
self.default_currency = 'USD'
|
11
|
-
self.supported_cardtypes = [
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
12
12
|
|
13
13
|
self.homepage_url = 'https://www.globalpaymentsinc.com'
|
14
14
|
self.display_name = 'Global Transport'
|
@@ -20,12 +20,12 @@ module ActiveMerchant #:nodoc:
|
|
20
20
|
# :global_password - Your Global password
|
21
21
|
# :term_type - 3 character field assigned by Global Transport after
|
22
22
|
# - your application is certified.
|
23
|
-
def initialize(options={})
|
23
|
+
def initialize(options = {})
|
24
24
|
requires!(options, :global_user_name, :global_password, :term_type)
|
25
25
|
super
|
26
26
|
end
|
27
27
|
|
28
|
-
def purchase(money, payment_method, options={})
|
28
|
+
def purchase(money, payment_method, options = {})
|
29
29
|
post = {}
|
30
30
|
add_invoice(post, money, options)
|
31
31
|
add_payment_method(post, payment_method)
|
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
|
|
34
34
|
commit('Sale', post, options)
|
35
35
|
end
|
36
36
|
|
37
|
-
def authorize(money, payment_method, options={})
|
37
|
+
def authorize(money, payment_method, options = {})
|
38
38
|
post = {}
|
39
39
|
add_invoice(post, money, options)
|
40
40
|
add_payment_method(post, payment_method)
|
@@ -43,7 +43,7 @@ module ActiveMerchant #:nodoc:
|
|
43
43
|
commit('Auth', post, options)
|
44
44
|
end
|
45
45
|
|
46
|
-
def capture(money, authorization, options={})
|
46
|
+
def capture(money, authorization, options = {})
|
47
47
|
post = {}
|
48
48
|
add_invoice(post, money, options)
|
49
49
|
add_auth(post, authorization)
|
@@ -51,7 +51,7 @@ module ActiveMerchant #:nodoc:
|
|
51
51
|
commit('Force', post, options)
|
52
52
|
end
|
53
53
|
|
54
|
-
def refund(money, authorization, options={})
|
54
|
+
def refund(money, authorization, options = {})
|
55
55
|
post = {}
|
56
56
|
add_invoice(post, money, options)
|
57
57
|
add_auth(post, authorization)
|
@@ -59,14 +59,14 @@ module ActiveMerchant #:nodoc:
|
|
59
59
|
commit('Return', post, options)
|
60
60
|
end
|
61
61
|
|
62
|
-
def void(authorization, options={})
|
62
|
+
def void(authorization, options = {})
|
63
63
|
post = {}
|
64
64
|
add_auth(post, authorization)
|
65
65
|
|
66
66
|
commit('Void', post, options)
|
67
67
|
end
|
68
68
|
|
69
|
-
def verify(payment_method, options={})
|
69
|
+
def verify(payment_method, options = {})
|
70
70
|
post = {}
|
71
71
|
add_payment_method(post, payment_method)
|
72
72
|
add_address(post, options)
|
@@ -74,6 +74,17 @@ module ActiveMerchant #:nodoc:
|
|
74
74
|
commit('CardVerify', post, options)
|
75
75
|
end
|
76
76
|
|
77
|
+
def supports_scrubbing?
|
78
|
+
true
|
79
|
+
end
|
80
|
+
|
81
|
+
def scrub(transcript)
|
82
|
+
transcript.
|
83
|
+
gsub(%r((&?CardNum=)[^&]*)i, '\1[FILTERED]').
|
84
|
+
gsub(%r((&?CVNum=)[^&]*)i, '\1[FILTERED]').
|
85
|
+
gsub(%r((&?GlobalPassword=)[^&]*)i, '\1[FILTERED]')
|
86
|
+
end
|
87
|
+
|
77
88
|
private
|
78
89
|
|
79
90
|
def add_address(post, options)
|
@@ -108,6 +119,10 @@ module ActiveMerchant #:nodoc:
|
|
108
119
|
response[node.name.downcase.to_sym] = node.text
|
109
120
|
end
|
110
121
|
|
122
|
+
ext_data = Nokogiri::HTML.parse(response[:extdata])
|
123
|
+
response[:approved_amount] = ext_data.xpath('//approvedamount').text
|
124
|
+
response[:balance_due] = ext_data.xpath('//balancedue').text
|
125
|
+
|
111
126
|
response
|
112
127
|
end
|
113
128
|
|
@@ -131,7 +146,7 @@ module ActiveMerchant #:nodoc:
|
|
131
146
|
post[:TransType] = action
|
132
147
|
post[:ExtData] = "<TermType>#{@options[:term_type]}</TermType>"
|
133
148
|
|
134
|
-
post.merge(params).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join(
|
149
|
+
post.merge(params).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
135
150
|
end
|
136
151
|
|
137
152
|
def url
|
@@ -139,7 +154,7 @@ module ActiveMerchant #:nodoc:
|
|
139
154
|
end
|
140
155
|
|
141
156
|
def success_from(response)
|
142
|
-
|
157
|
+
response[:result] == '0' || response[:result] == '200'
|
143
158
|
end
|
144
159
|
|
145
160
|
def message_from(response)
|
@@ -173,11 +188,6 @@ module ActiveMerchant #:nodoc:
|
|
173
188
|
ExtData: ''
|
174
189
|
}
|
175
190
|
end
|
176
|
-
|
177
|
-
def truncate(value, max_size)
|
178
|
-
return nil unless value
|
179
|
-
value.to_s[0, max_size]
|
180
|
-
end
|
181
191
|
end
|
182
192
|
end
|
183
193
|
end
|