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,479 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class PayuLatamGateway < Gateway
|
6
|
+
self.display_name = 'PayU Latam'
|
7
|
+
self.homepage_url = 'http://www.payulatam.com'
|
8
|
+
|
9
|
+
self.test_url = 'https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi'
|
10
|
+
self.live_url = 'https://api.payulatam.com/payments-api/4.0/service.cgi'
|
11
|
+
|
12
|
+
self.supported_countries = %w[AR BR CL CO MX PA PE]
|
13
|
+
self.default_currency = 'USD'
|
14
|
+
self.money_format = :dollars
|
15
|
+
self.supported_cardtypes = %i[visa master american_express diners_club naranja cabal]
|
16
|
+
|
17
|
+
BRAND_MAP = {
|
18
|
+
'visa' => 'VISA',
|
19
|
+
'master' => 'MASTERCARD',
|
20
|
+
'maestro' => 'MASTERCARD',
|
21
|
+
'american_express' => 'AMEX',
|
22
|
+
'diners_club' => 'DINERS',
|
23
|
+
'naranja' => 'NARANJA',
|
24
|
+
'cabal' => 'CABAL'
|
25
|
+
}
|
26
|
+
|
27
|
+
MINIMUMS = {
|
28
|
+
'ARS' => 1700,
|
29
|
+
'BRL' => 600,
|
30
|
+
'MXN' => 3900,
|
31
|
+
'PEN' => 500
|
32
|
+
}
|
33
|
+
|
34
|
+
def initialize(options = {})
|
35
|
+
requires!(options, :merchant_id, :account_id, :api_login, :api_key, :payment_country)
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def purchase(amount, payment_method, options = {})
|
40
|
+
post = {}
|
41
|
+
auth_or_sale(post, 'AUTHORIZATION_AND_CAPTURE', amount, payment_method, options)
|
42
|
+
commit('purchase', post)
|
43
|
+
end
|
44
|
+
|
45
|
+
def authorize(amount, payment_method, options = {})
|
46
|
+
post = {}
|
47
|
+
auth_or_sale(post, 'AUTHORIZATION', amount, payment_method, options)
|
48
|
+
commit('auth', post)
|
49
|
+
end
|
50
|
+
|
51
|
+
def capture(amount, authorization, options = {})
|
52
|
+
post = {}
|
53
|
+
|
54
|
+
add_credentials(post, 'SUBMIT_TRANSACTION', options)
|
55
|
+
add_transaction_elements(post, 'CAPTURE', options)
|
56
|
+
add_reference(post, authorization)
|
57
|
+
|
58
|
+
if !amount.nil? && amount.to_f != 0.0
|
59
|
+
post[:transaction][:additionalValues] ||= {}
|
60
|
+
post[:transaction][:additionalValues][:TX_VALUE] = invoice_for(amount, options)[:TX_VALUE]
|
61
|
+
end
|
62
|
+
|
63
|
+
commit('capture', post)
|
64
|
+
end
|
65
|
+
|
66
|
+
def void(authorization, options = {})
|
67
|
+
post = {}
|
68
|
+
|
69
|
+
add_credentials(post, 'SUBMIT_TRANSACTION', options)
|
70
|
+
add_transaction_elements(post, 'VOID', options)
|
71
|
+
add_reference(post, authorization)
|
72
|
+
|
73
|
+
commit('void', post)
|
74
|
+
end
|
75
|
+
|
76
|
+
def refund(amount, authorization, options = {})
|
77
|
+
post = {}
|
78
|
+
|
79
|
+
add_credentials(post, 'SUBMIT_TRANSACTION', options)
|
80
|
+
|
81
|
+
if options[:partial_refund]
|
82
|
+
add_transaction_elements(post, 'PARTIAL_REFUND', options)
|
83
|
+
post[:transaction][:additionalValues] ||= {}
|
84
|
+
post[:transaction][:additionalValues][:TX_VALUE] = invoice_for(amount, options)[:TX_VALUE]
|
85
|
+
else
|
86
|
+
add_transaction_elements(post, 'REFUND', options)
|
87
|
+
end
|
88
|
+
|
89
|
+
add_reference(post, authorization)
|
90
|
+
commit('refund', post)
|
91
|
+
end
|
92
|
+
|
93
|
+
def verify(credit_card, options = {})
|
94
|
+
minimum = MINIMUMS[options[:currency].upcase] if options[:currency]
|
95
|
+
amount = options[:verify_amount] || minimum || 100
|
96
|
+
|
97
|
+
MultiResponse.run(:use_first_response) do |r|
|
98
|
+
r.process { authorize(amount, credit_card, options) }
|
99
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def store(payment_method, options = {})
|
104
|
+
post = {}
|
105
|
+
|
106
|
+
add_credentials(post, 'CREATE_TOKEN')
|
107
|
+
add_payment_method_to_be_tokenized(post, payment_method, options)
|
108
|
+
|
109
|
+
commit('store', post)
|
110
|
+
end
|
111
|
+
|
112
|
+
def verify_credentials
|
113
|
+
post = {}
|
114
|
+
add_credentials(post, 'GET_PAYMENT_METHODS')
|
115
|
+
response = commit('verify_credentials', post)
|
116
|
+
response.success?
|
117
|
+
end
|
118
|
+
|
119
|
+
def supports_scrubbing?
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
123
|
+
def scrub(transcript)
|
124
|
+
transcript.
|
125
|
+
gsub(%r((\"creditCard\\\":{\\\"number\\\":\\\")\d+), '\1[FILTERED]').
|
126
|
+
gsub(%r((\"securityCode\\\":\\\")\d+), '\1[FILTERED]').
|
127
|
+
gsub(%r((\"apiKey\\\":\\\")\w+), '\1[FILTERED]')
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
def auth_or_sale(post, transaction_type, amount, payment_method, options)
|
133
|
+
add_credentials(post, 'SUBMIT_TRANSACTION', options)
|
134
|
+
add_transaction_elements(post, transaction_type, options)
|
135
|
+
add_order(post, options)
|
136
|
+
add_buyer(post, payment_method, options)
|
137
|
+
add_invoice(post, amount, options)
|
138
|
+
add_signature(post)
|
139
|
+
add_payment_method(post, payment_method, options)
|
140
|
+
add_payer(post, payment_method, options)
|
141
|
+
add_extra_parameters(post, options)
|
142
|
+
end
|
143
|
+
|
144
|
+
def add_credentials(post, command, options = {})
|
145
|
+
post[:test] = test? unless command == 'CREATE_TOKEN'
|
146
|
+
post[:language] = options[:language] || 'en'
|
147
|
+
post[:command] = command
|
148
|
+
merchant = {}
|
149
|
+
merchant[:apiLogin] = @options[:api_login]
|
150
|
+
merchant[:apiKey] = @options[:api_key]
|
151
|
+
post[:merchant] = merchant
|
152
|
+
end
|
153
|
+
|
154
|
+
def add_transaction_elements(post, type, options)
|
155
|
+
transaction = {}
|
156
|
+
transaction[:paymentCountry] = @options[:payment_country]
|
157
|
+
transaction[:type] = type
|
158
|
+
transaction[:ipAddress] = options[:ip] || ''
|
159
|
+
transaction[:userAgent] = options[:user_agent] if options[:user_agent]
|
160
|
+
transaction[:cookie] = options[:cookie] if options[:cookie]
|
161
|
+
transaction[:deviceSessionId] = options[:device_session_id] if options[:device_session_id]
|
162
|
+
post[:transaction] = transaction
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_order(post, options)
|
166
|
+
order = {}
|
167
|
+
order[:accountId] = @options[:account_id]
|
168
|
+
order[:partnerId] = options[:partner_id] if options[:partner_id]
|
169
|
+
order[:referenceCode] = options[:order_id] || generate_unique_id
|
170
|
+
order[:description] = options[:description] || 'Compra en ' + @options[:merchant_id]
|
171
|
+
order[:language] = options[:language] || 'en'
|
172
|
+
order[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
173
|
+
post[:transaction][:order] = order
|
174
|
+
end
|
175
|
+
|
176
|
+
def add_payer(post, payment_method, options)
|
177
|
+
address = options[:billing_address]
|
178
|
+
payer = {}
|
179
|
+
payer[:fullName] = payment_method.name.strip
|
180
|
+
payer[:contactPhone] = address[:phone] if address && address[:phone]
|
181
|
+
payer[:dniNumber] = options[:dni_number] if options[:dni_number]
|
182
|
+
payer[:dniType] = options[:dni_type] if options[:dni_type]
|
183
|
+
payer[:emailAddress] = options[:email] if options[:email]
|
184
|
+
payer[:birthdate] = options[:birth_date] if options[:birth_date] && @options[:payment_country] == 'MX'
|
185
|
+
payer[:billingAddress] = billing_address_fields(options)
|
186
|
+
post[:transaction][:payer] = payer
|
187
|
+
end
|
188
|
+
|
189
|
+
def billing_address_fields(options)
|
190
|
+
return unless address = options[:billing_address]
|
191
|
+
|
192
|
+
billing_address = {}
|
193
|
+
billing_address[:street1] = address[:address1]
|
194
|
+
billing_address[:street2] = address[:address2]
|
195
|
+
billing_address[:city] = address[:city]
|
196
|
+
billing_address[:state] = address[:state]
|
197
|
+
billing_address[:country] = address[:country] unless address[:country].blank?
|
198
|
+
billing_address[:postalCode] = address[:zip] if @options[:payment_country] == 'MX'
|
199
|
+
billing_address[:phone] = address[:phone]
|
200
|
+
billing_address
|
201
|
+
end
|
202
|
+
|
203
|
+
def add_buyer(post, payment_method, options)
|
204
|
+
buyer = {}
|
205
|
+
if buyer_hash = options[:buyer]
|
206
|
+
buyer[:fullName] = buyer_hash[:name]
|
207
|
+
buyer[:dniNumber] = buyer_hash[:dni_number]
|
208
|
+
buyer[:dniType] = buyer_hash[:dni_type]
|
209
|
+
buyer[:merchantBuyerId] = buyer_hash[:merchant_buyer_id]
|
210
|
+
buyer[:cnpj] = buyer_hash[:cnpj] if @options[:payment_country] == 'BR'
|
211
|
+
buyer[:emailAddress] = buyer_hash[:email]
|
212
|
+
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone_number] if options[:shipping_address]) || ''
|
213
|
+
buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
214
|
+
else
|
215
|
+
buyer[:fullName] = payment_method.name.strip
|
216
|
+
buyer[:dniNumber] = options[:dni_number]
|
217
|
+
buyer[:dniType] = options[:dni_type]
|
218
|
+
buyer[:merchantBuyerId] = options[:merchant_buyer_id]
|
219
|
+
buyer[:cnpj] = options[:cnpj] if @options[:payment_country] == 'BR'
|
220
|
+
buyer[:emailAddress] = options[:email]
|
221
|
+
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone_number] if options[:shipping_address]) || ''
|
222
|
+
buyer[:shippingAddress] = shipping_address_fields(options) if options[:shipping_address]
|
223
|
+
end
|
224
|
+
post[:transaction][:order][:buyer] = buyer
|
225
|
+
end
|
226
|
+
|
227
|
+
def shipping_address_fields(options)
|
228
|
+
return unless address = options[:shipping_address]
|
229
|
+
|
230
|
+
shipping_address = {}
|
231
|
+
shipping_address[:street1] = address[:address1]
|
232
|
+
shipping_address[:street2] = address[:address2]
|
233
|
+
shipping_address[:city] = address[:city]
|
234
|
+
shipping_address[:state] = address[:state]
|
235
|
+
shipping_address[:country] = address[:country]
|
236
|
+
shipping_address[:postalCode] = address[:zip]
|
237
|
+
shipping_address[:phone] = address[:phone_number]
|
238
|
+
shipping_address
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_invoice(post, money, options)
|
242
|
+
post[:transaction][:order][:additionalValues] = invoice_for(money, options)
|
243
|
+
end
|
244
|
+
|
245
|
+
def invoice_for(money, options)
|
246
|
+
tx_value = {}
|
247
|
+
tx_value[:value] = amount(money)
|
248
|
+
tx_value[:currency] = options[:currency] || currency(money)
|
249
|
+
|
250
|
+
tx_tax = {}
|
251
|
+
tx_tax[:value] = options[:tax] || '0'
|
252
|
+
tx_tax[:currency] = options[:currency] || currency(money)
|
253
|
+
|
254
|
+
tx_tax_return_base = {}
|
255
|
+
tx_tax_return_base[:value] = options[:tax_return_base] || '0'
|
256
|
+
tx_tax_return_base[:currency] = options[:currency] || currency(money)
|
257
|
+
|
258
|
+
additional_values = {}
|
259
|
+
additional_values[:TX_VALUE] = tx_value
|
260
|
+
additional_values[:TX_TAX] = tx_tax if @options[:payment_country] == 'CO'
|
261
|
+
additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if @options[:payment_country] == 'CO'
|
262
|
+
|
263
|
+
additional_values
|
264
|
+
end
|
265
|
+
|
266
|
+
def add_signature(post)
|
267
|
+
post[:transaction][:order][:signature] = signature_from(post)
|
268
|
+
end
|
269
|
+
|
270
|
+
def signature_from(post)
|
271
|
+
signature_string = [
|
272
|
+
@options[:api_key],
|
273
|
+
@options[:merchant_id],
|
274
|
+
post[:transaction][:order][:referenceCode],
|
275
|
+
post[:transaction][:order][:additionalValues][:TX_VALUE][:value],
|
276
|
+
post[:transaction][:order][:additionalValues][:TX_VALUE][:currency]
|
277
|
+
].compact.join('~')
|
278
|
+
|
279
|
+
Digest::MD5.hexdigest(signature_string)
|
280
|
+
end
|
281
|
+
|
282
|
+
def codensa_bin?(number)
|
283
|
+
number.start_with?('590712')
|
284
|
+
end
|
285
|
+
|
286
|
+
def add_payment_method(post, payment_method, options)
|
287
|
+
if payment_method.is_a?(String)
|
288
|
+
brand, token = split_authorization(payment_method)
|
289
|
+
credit_card = {}
|
290
|
+
credit_card[:securityCode] = options[:cvv] if options[:cvv]
|
291
|
+
credit_card[:processWithoutCvv2] = true if options[:cvv].blank?
|
292
|
+
post[:transaction][:creditCard] = credit_card
|
293
|
+
post[:transaction][:creditCardTokenId] = token
|
294
|
+
post[:transaction][:paymentMethod] = brand.upcase
|
295
|
+
else
|
296
|
+
credit_card = {}
|
297
|
+
credit_card[:number] = payment_method.number
|
298
|
+
credit_card[:securityCode] = payment_method.verification_value || options[:cvv]
|
299
|
+
credit_card[:expirationDate] = format(payment_method.year, :four_digits).to_s + '/' + format(payment_method.month, :two_digits).to_s
|
300
|
+
credit_card[:name] = payment_method.name.strip
|
301
|
+
credit_card[:processWithoutCvv2] = true if add_process_without_cvv2(payment_method, options)
|
302
|
+
post[:transaction][:creditCard] = credit_card
|
303
|
+
post[:transaction][:paymentMethod] = codensa_bin?(payment_method.number) ? 'CODENSA' : BRAND_MAP[payment_method.brand.to_s]
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def add_process_without_cvv2(payment_method, options)
|
308
|
+
return true if payment_method.verification_value.blank? && options[:cvv].blank?
|
309
|
+
|
310
|
+
false
|
311
|
+
end
|
312
|
+
|
313
|
+
def add_extra_parameters(post, options)
|
314
|
+
extra_parameters = {}
|
315
|
+
extra_parameters[:INSTALLMENTS_NUMBER] = options[:installments_number] || 1
|
316
|
+
post[:transaction][:extraParameters] = extra_parameters
|
317
|
+
end
|
318
|
+
|
319
|
+
def add_reference(post, authorization)
|
320
|
+
order_id, transaction_id = split_authorization(authorization)
|
321
|
+
order = {}
|
322
|
+
order[:id] = order_id
|
323
|
+
post[:transaction][:order] = order
|
324
|
+
post[:transaction][:parentTransactionId] = transaction_id
|
325
|
+
post[:transaction][:reason] = 'n/a'
|
326
|
+
end
|
327
|
+
|
328
|
+
def add_payment_method_to_be_tokenized(post, payment_method, options)
|
329
|
+
credit_card_token = {}
|
330
|
+
credit_card_token[:payerId] = options[:payer_id] || generate_unique_id
|
331
|
+
credit_card_token[:name] = payment_method.name.strip
|
332
|
+
credit_card_token[:identificationNumber] = options[:dni_number]
|
333
|
+
credit_card_token[:paymentMethod] = BRAND_MAP[payment_method.brand.to_s]
|
334
|
+
credit_card_token[:number] = payment_method.number
|
335
|
+
credit_card_token[:expirationDate] = format(payment_method.year, :four_digits).to_s + '/' + format(payment_method.month, :two_digits).to_s
|
336
|
+
post[:creditCardToken] = credit_card_token
|
337
|
+
end
|
338
|
+
|
339
|
+
def commit(action, params)
|
340
|
+
raw_response = ssl_post(url, post_data(params), headers)
|
341
|
+
response = parse(raw_response)
|
342
|
+
rescue ResponseError => e
|
343
|
+
raw_response = e.response.body
|
344
|
+
response_error(raw_response)
|
345
|
+
rescue JSON::ParserError
|
346
|
+
unparsable_response(raw_response)
|
347
|
+
else
|
348
|
+
success = success_from(action, response)
|
349
|
+
Response.new(
|
350
|
+
success,
|
351
|
+
message_from(action, success, response),
|
352
|
+
response,
|
353
|
+
authorization: success ? authorization_from(action, response) : nil,
|
354
|
+
error_code: success ? nil : error_from(action, response),
|
355
|
+
test: test?
|
356
|
+
)
|
357
|
+
end
|
358
|
+
|
359
|
+
def headers
|
360
|
+
{
|
361
|
+
'Content-Type' => 'application/json',
|
362
|
+
'Accept' => 'application/json'
|
363
|
+
}
|
364
|
+
end
|
365
|
+
|
366
|
+
def post_data(params)
|
367
|
+
params.merge(test: test?)
|
368
|
+
params.to_json
|
369
|
+
end
|
370
|
+
|
371
|
+
def url
|
372
|
+
test? ? test_url : live_url
|
373
|
+
end
|
374
|
+
|
375
|
+
def parse(body)
|
376
|
+
JSON.parse(body)
|
377
|
+
end
|
378
|
+
|
379
|
+
def success_from(action, response)
|
380
|
+
case action
|
381
|
+
when 'store'
|
382
|
+
response['code'] == 'SUCCESS' && response['creditCardToken'] && response['creditCardToken']['creditCardTokenId'].present?
|
383
|
+
when 'verify_credentials'
|
384
|
+
response['code'] == 'SUCCESS'
|
385
|
+
when 'refund', 'void'
|
386
|
+
response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'PENDING' || response['transactionResponse']['state'] == 'APPROVED')
|
387
|
+
else
|
388
|
+
response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'APPROVED')
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
def message_from(action, success, response)
|
393
|
+
case action
|
394
|
+
when 'store'
|
395
|
+
message_from_store(success, response)
|
396
|
+
when 'verify_credentials'
|
397
|
+
message_from_verify_credentials(success)
|
398
|
+
else
|
399
|
+
message_from_transaction_response(success, response)
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
def message_from_store(success, response)
|
404
|
+
return response['code'] if success
|
405
|
+
|
406
|
+
error_description = response['creditCardToken']['errorDescription'] if response['creditCardToken']
|
407
|
+
response['error'] || error_description || 'FAILED'
|
408
|
+
end
|
409
|
+
|
410
|
+
def message_from_verify_credentials(success)
|
411
|
+
return 'VERIFIED' if success
|
412
|
+
|
413
|
+
'FAILED'
|
414
|
+
end
|
415
|
+
|
416
|
+
def message_from_transaction_response(success, response)
|
417
|
+
response_code = response.dig('transactionResponse', 'responseCode') || response.dig('transactionResponse', 'pendingReason')
|
418
|
+
return response_code if success
|
419
|
+
return response_code + ' | ' + response.dig('transactionResponse', 'paymentNetworkResponseErrorMessage') if response.dig('transactionResponse', 'paymentNetworkResponseErrorMessage')
|
420
|
+
return response.dig('transactionResponse', 'responseMessage') if response.dig('transactionResponse', 'responseMessage')
|
421
|
+
return response['error'] if response['error']
|
422
|
+
return response_code if response_code
|
423
|
+
|
424
|
+
'FAILED'
|
425
|
+
end
|
426
|
+
|
427
|
+
def authorization_from(action, response)
|
428
|
+
case action
|
429
|
+
when 'store'
|
430
|
+
[
|
431
|
+
response['creditCardToken']['paymentMethod'],
|
432
|
+
response['creditCardToken']['creditCardTokenId']
|
433
|
+
].compact.join('|')
|
434
|
+
when 'verify_credentials'
|
435
|
+
nil
|
436
|
+
else
|
437
|
+
[
|
438
|
+
response['transactionResponse']['orderId'],
|
439
|
+
response['transactionResponse']['transactionId']
|
440
|
+
].compact.join('|')
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
def split_authorization(authorization)
|
445
|
+
authorization.split('|')
|
446
|
+
end
|
447
|
+
|
448
|
+
def error_from(action, response)
|
449
|
+
case action
|
450
|
+
when 'store'
|
451
|
+
response['creditCardToken']['errorDescription'] if response['creditCardToken']
|
452
|
+
when 'verify_credentials'
|
453
|
+
response['error'] || 'FAILED'
|
454
|
+
else
|
455
|
+
response['transactionResponse']['errorCode'] || response['transactionResponse']['responseCode'] if response['transactionResponse']
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
def response_error(raw_response)
|
460
|
+
response = parse(raw_response)
|
461
|
+
rescue JSON::ParserError
|
462
|
+
unparsable_response(raw_response)
|
463
|
+
else
|
464
|
+
return Response.new(
|
465
|
+
false,
|
466
|
+
message_from('', false, response),
|
467
|
+
response,
|
468
|
+
test: test?
|
469
|
+
)
|
470
|
+
end
|
471
|
+
|
472
|
+
def unparsable_response(raw_response)
|
473
|
+
message = 'Invalid JSON response received from PayuLatamGateway. Please contact PayuLatamGateway if you continue to receive this message.'
|
474
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
475
|
+
return Response.new(false, message)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
@@ -3,8 +3,8 @@ module ActiveMerchant
|
|
3
3
|
class PaywayGateway < Gateway
|
4
4
|
self.live_url = self.test_url = 'https://ccapi.client.qvalent.com/payway/ccapi'
|
5
5
|
|
6
|
-
self.supported_countries = [
|
7
|
-
self.supported_cardtypes = [
|
6
|
+
self.supported_countries = ['AU']
|
7
|
+
self.supported_cardtypes = %i[visa master diners_club american_express bankcard]
|
8
8
|
self.display_name = 'Pay Way'
|
9
9
|
self.homepage_url = 'http://www.payway.com.au'
|
10
10
|
self.default_currency = 'AUD'
|
@@ -17,7 +17,7 @@ module ActiveMerchant
|
|
17
17
|
'3' => 'Rejected'
|
18
18
|
}
|
19
19
|
|
20
|
-
RESPONSE_CODES= {
|
20
|
+
RESPONSE_CODES = {
|
21
21
|
'00' => 'Completed Successfully',
|
22
22
|
'01' => 'Refer to card issuer',
|
23
23
|
'03' => 'Invalid merchant',
|
@@ -74,16 +74,16 @@ module ActiveMerchant
|
|
74
74
|
'QZ' => 'Zero value transaction'
|
75
75
|
}
|
76
76
|
|
77
|
-
TRANSACTIONS
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
77
|
+
TRANSACTIONS = {
|
78
|
+
authorize: 'preauth',
|
79
|
+
purchase: 'capture',
|
80
|
+
capture: 'captureWithoutAuth',
|
81
|
+
status: 'query',
|
82
|
+
refund: 'refund',
|
83
|
+
store: 'registerAccount'
|
84
84
|
}
|
85
85
|
|
86
|
-
def initialize(options={})
|
86
|
+
def initialize(options = {})
|
87
87
|
@options = options
|
88
88
|
|
89
89
|
@options[:merchant] ||= 'TEST' if test?
|
@@ -92,7 +92,7 @@ module ActiveMerchant
|
|
92
92
|
@options[:eci] ||= 'SSL'
|
93
93
|
end
|
94
94
|
|
95
|
-
def authorize(amount, payment_method, options={})
|
95
|
+
def authorize(amount, payment_method, options = {})
|
96
96
|
requires!(options, :order_id)
|
97
97
|
|
98
98
|
post = {}
|
@@ -101,7 +101,7 @@ module ActiveMerchant
|
|
101
101
|
commit(:authorize, post)
|
102
102
|
end
|
103
103
|
|
104
|
-
def capture(amount, authorization, options={})
|
104
|
+
def capture(amount, authorization, options = {})
|
105
105
|
requires!(options, :order_id)
|
106
106
|
|
107
107
|
post = {}
|
@@ -110,7 +110,7 @@ module ActiveMerchant
|
|
110
110
|
commit(:capture, post)
|
111
111
|
end
|
112
112
|
|
113
|
-
def purchase(amount, payment_method, options={})
|
113
|
+
def purchase(amount, payment_method, options = {})
|
114
114
|
requires!(options, :order_id)
|
115
115
|
|
116
116
|
post = {}
|
@@ -119,7 +119,7 @@ module ActiveMerchant
|
|
119
119
|
commit(:purchase, post)
|
120
120
|
end
|
121
121
|
|
122
|
-
def refund(amount, authorization, options={})
|
122
|
+
def refund(amount, authorization, options = {})
|
123
123
|
requires!(options, :order_id)
|
124
124
|
|
125
125
|
post = {}
|
@@ -128,7 +128,7 @@ module ActiveMerchant
|
|
128
128
|
commit(:refund, post)
|
129
129
|
end
|
130
130
|
|
131
|
-
def store(credit_card, options={})
|
131
|
+
def store(credit_card, options = {})
|
132
132
|
requires!(options, :billing_id)
|
133
133
|
|
134
134
|
post = {}
|
@@ -137,7 +137,7 @@ module ActiveMerchant
|
|
137
137
|
commit(:store, post)
|
138
138
|
end
|
139
139
|
|
140
|
-
def status(options={})
|
140
|
+
def status(options = {})
|
141
141
|
requires!(options, :order_id)
|
142
142
|
|
143
143
|
commit(:status, 'customer.orderNumber' => options[:order_id])
|
@@ -150,7 +150,7 @@ module ActiveMerchant
|
|
150
150
|
post['card.cardHolderName'] = "#{payment_method.first_name} #{payment_method.last_name}"
|
151
151
|
post['card.PAN'] = payment_method.number
|
152
152
|
post['card.CVN'] = payment_method.verification_value
|
153
|
-
post['card.expiryYear'] = payment_method.year.to_s[-2,2]
|
153
|
+
post['card.expiryYear'] = payment_method.year.to_s[-2, 2]
|
154
154
|
post['card.expiryMonth'] = sprintf('%02d', payment_method.month)
|
155
155
|
else
|
156
156
|
post['customer.customerReferenceNumber'] = payment_method
|
@@ -177,30 +177,30 @@ module ActiveMerchant
|
|
177
177
|
# Creates the request and returns the summarized result
|
178
178
|
def commit(action, post)
|
179
179
|
add_auth(post)
|
180
|
-
post
|
180
|
+
post['order.type'] = TRANSACTIONS[action]
|
181
181
|
|
182
|
-
request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join(
|
182
|
+
request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
183
183
|
response = ssl_post(self.live_url, request)
|
184
184
|
|
185
185
|
params = {}
|
186
186
|
CGI.parse(response).each_pair do |key, value|
|
187
|
-
actual_key = key.split(
|
187
|
+
actual_key = key.split('.').last
|
188
188
|
params[actual_key.underscore.to_sym] = value[0]
|
189
189
|
end
|
190
190
|
|
191
191
|
message = "#{SUMMARY_CODES[params[:summary_code]]} - #{RESPONSE_CODES[params[:response_code]]}"
|
192
192
|
|
193
|
-
success = (params[:summary_code] ? (params[:summary_code] ==
|
193
|
+
success = (params[:summary_code] ? (params[:summary_code] == '0') : (params[:response_code] == '00'))
|
194
194
|
|
195
195
|
Response.new(success, message, params,
|
196
|
-
:
|
197
|
-
:
|
198
|
-
)
|
196
|
+
test: (@options[:merchant].to_s == 'TEST'),
|
197
|
+
authorization: post[:order_number])
|
199
198
|
rescue ActiveMerchant::ResponseError => e
|
200
199
|
raise unless e.response.code == '403'
|
201
|
-
|
200
|
+
|
201
|
+
return Response.new(false, 'Invalid credentials', {}, test: test?)
|
202
202
|
rescue ActiveMerchant::ClientCertificateError
|
203
|
-
return Response.new(false,
|
203
|
+
return Response.new(false, 'Invalid certificate', {}, test: test?)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
end
|