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,297 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'active_merchant/billing/gateways/quickpay/quickpay_common'
|
3
|
+
|
4
|
+
module ActiveMerchant
|
5
|
+
module Billing
|
6
|
+
class QuickpayV10Gateway < Gateway
|
7
|
+
include QuickpayCommon
|
8
|
+
API_VERSION = 10
|
9
|
+
|
10
|
+
self.live_url = self.test_url = 'https://api.quickpay.net'
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
requires!(options, :api_key)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def purchase(money, credit_card_or_reference, options = {})
|
18
|
+
MultiResponse.run do |r|
|
19
|
+
if credit_card_or_reference.is_a?(String)
|
20
|
+
r.process { create_token(credit_card_or_reference, options) }
|
21
|
+
credit_card_or_reference = r.authorization
|
22
|
+
end
|
23
|
+
r.process { create_payment(money, options) }
|
24
|
+
r.process {
|
25
|
+
post = authorization_params(money, credit_card_or_reference, options)
|
26
|
+
add_autocapture(post, false)
|
27
|
+
commit(synchronized_path("/payments/#{r.responses.last.params['id']}/authorize"), post)
|
28
|
+
}
|
29
|
+
r.process {
|
30
|
+
post = capture_params(money, credit_card_or_reference, options)
|
31
|
+
commit(synchronized_path("/payments/#{r.responses.last.params['id']}/capture"), post)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def authorize(money, credit_card_or_reference, options = {})
|
37
|
+
MultiResponse.run do |r|
|
38
|
+
if credit_card_or_reference.is_a?(String)
|
39
|
+
r.process { create_token(credit_card_or_reference, options) }
|
40
|
+
credit_card_or_reference = r.authorization
|
41
|
+
end
|
42
|
+
r.process { create_payment(money, options) }
|
43
|
+
r.process {
|
44
|
+
post = authorization_params(money, credit_card_or_reference, options)
|
45
|
+
commit(synchronized_path("/payments/#{r.responses.last.params['id']}/authorize"), post)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def void(identification, _options = {})
|
51
|
+
commit(synchronized_path "/payments/#{identification}/cancel")
|
52
|
+
end
|
53
|
+
|
54
|
+
def credit(money, identification, options = {})
|
55
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
56
|
+
refund(money, identification, options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def capture(money, identification, options = {})
|
60
|
+
post = capture_params(money, identification, options)
|
61
|
+
commit(synchronized_path("/payments/#{identification}/capture"), post)
|
62
|
+
end
|
63
|
+
|
64
|
+
def refund(money, identification, options = {})
|
65
|
+
post = {}
|
66
|
+
add_amount(post, money, options)
|
67
|
+
add_additional_params(:refund, post, options)
|
68
|
+
commit(synchronized_path("/payments/#{identification}/refund"), post)
|
69
|
+
end
|
70
|
+
|
71
|
+
def verify(credit_card, options = {})
|
72
|
+
MultiResponse.run(:use_first_response) do |r|
|
73
|
+
r.process { authorize(100, credit_card, options) }
|
74
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def store(credit_card, options = {})
|
79
|
+
MultiResponse.run do |r|
|
80
|
+
r.process { create_store(options) }
|
81
|
+
r.process { authorize_store(r.authorization, credit_card, options) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def unstore(identification)
|
86
|
+
commit(synchronized_path "/cards/#{identification}/cancel")
|
87
|
+
end
|
88
|
+
|
89
|
+
def supports_scrubbing?
|
90
|
+
true
|
91
|
+
end
|
92
|
+
|
93
|
+
def scrub(transcript)
|
94
|
+
transcript.
|
95
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
96
|
+
gsub(%r(("card\\?":{\\?"number\\?":\\?")\d+), '\1[FILTERED]').
|
97
|
+
gsub(%r(("cvd\\?":\\?")\d+), '\1[FILTERED]')
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def authorization_params(money, credit_card_or_reference, options = {})
|
103
|
+
post = {}
|
104
|
+
|
105
|
+
add_amount(post, money, options)
|
106
|
+
add_credit_card_or_reference(post, credit_card_or_reference, options)
|
107
|
+
add_additional_params(:authorize, post, options)
|
108
|
+
|
109
|
+
post
|
110
|
+
end
|
111
|
+
|
112
|
+
def capture_params(money, credit_card, options = {})
|
113
|
+
post = {}
|
114
|
+
|
115
|
+
add_amount(post, money, options)
|
116
|
+
add_additional_params(:capture, post, options)
|
117
|
+
|
118
|
+
post
|
119
|
+
end
|
120
|
+
|
121
|
+
def create_store(options = {})
|
122
|
+
post = {}
|
123
|
+
commit('/cards', post)
|
124
|
+
end
|
125
|
+
|
126
|
+
def authorize_store(identification, credit_card, options = {})
|
127
|
+
post = {}
|
128
|
+
|
129
|
+
add_credit_card_or_reference(post, credit_card, options)
|
130
|
+
commit(synchronized_path("/cards/#{identification}/authorize"), post)
|
131
|
+
end
|
132
|
+
|
133
|
+
def create_token(identification, options)
|
134
|
+
post = {}
|
135
|
+
commit(synchronized_path("/cards/#{identification}/tokens"), post)
|
136
|
+
end
|
137
|
+
|
138
|
+
def create_payment(money, options = {})
|
139
|
+
post = {}
|
140
|
+
add_currency(post, money, options)
|
141
|
+
add_invoice(post, options)
|
142
|
+
commit('/payments', post)
|
143
|
+
end
|
144
|
+
|
145
|
+
def commit(action, params = {})
|
146
|
+
success = false
|
147
|
+
begin
|
148
|
+
response = parse(ssl_post(self.live_url + action, params.to_json, headers))
|
149
|
+
success = successful?(response)
|
150
|
+
rescue ResponseError => e
|
151
|
+
response = response_error(e.response.body)
|
152
|
+
rescue JSON::ParserError
|
153
|
+
response = json_error(response)
|
154
|
+
end
|
155
|
+
|
156
|
+
Response.new(success, message_from(success, response), response,
|
157
|
+
test: test?,
|
158
|
+
authorization: authorization_from(response))
|
159
|
+
end
|
160
|
+
|
161
|
+
def authorization_from(response)
|
162
|
+
if response['token']
|
163
|
+
response['token'].to_s
|
164
|
+
else
|
165
|
+
response['id'].to_s
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def add_currency(post, money, options)
|
170
|
+
post[:currency] = options[:currency] || currency(money)
|
171
|
+
end
|
172
|
+
|
173
|
+
def add_amount(post, money, options)
|
174
|
+
post[:amount] = options[:amount] || amount(money)
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_autocapture(post, value)
|
178
|
+
post[:auto_capture] = value
|
179
|
+
end
|
180
|
+
|
181
|
+
def add_order_id(post, options)
|
182
|
+
requires!(options, :order_id)
|
183
|
+
post[:order_id] = format_order_id(options[:order_id])
|
184
|
+
end
|
185
|
+
|
186
|
+
def add_invoice(post, options)
|
187
|
+
add_order_id(post, options)
|
188
|
+
|
189
|
+
post[:invoice_address] = map_address(options[:billing_address]) if options[:billing_address]
|
190
|
+
|
191
|
+
post[:shipping_address] = map_address(options[:shipping_address]) if options[:shipping_address]
|
192
|
+
|
193
|
+
%i[metadata branding_id variables].each do |field|
|
194
|
+
post[field] = options[field] if options[field]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def add_additional_params(action, post, options = {})
|
199
|
+
MD5_CHECK_FIELDS[API_VERSION][action].each do |key|
|
200
|
+
key = key.to_sym
|
201
|
+
post[key] = options[key] if options[key]
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def add_credit_card_or_reference(post, credit_card_or_reference, options = {})
|
206
|
+
post[:card] ||= {}
|
207
|
+
if credit_card_or_reference.is_a?(String)
|
208
|
+
post[:card][:token] = credit_card_or_reference
|
209
|
+
else
|
210
|
+
post[:card][:number] = credit_card_or_reference.number
|
211
|
+
post[:card][:cvd] = credit_card_or_reference.verification_value
|
212
|
+
post[:card][:expiration] = expdate(credit_card_or_reference)
|
213
|
+
post[:card][:issued_to] = credit_card_or_reference.name
|
214
|
+
end
|
215
|
+
|
216
|
+
if options[:three_d_secure]
|
217
|
+
post[:card][:cavv] = options.dig(:three_d_secure, :cavv)
|
218
|
+
post[:card][:eci] = options.dig(:three_d_secure, :eci)
|
219
|
+
post[:card][:xav] = options.dig(:three_d_secure, :xid)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def parse(body)
|
224
|
+
JSON.parse(body)
|
225
|
+
end
|
226
|
+
|
227
|
+
def successful?(response)
|
228
|
+
has_error = response['errors']
|
229
|
+
invalid_code = invalid_operation_code?(response)
|
230
|
+
|
231
|
+
!(has_error || invalid_code)
|
232
|
+
end
|
233
|
+
|
234
|
+
def message_from(success, response)
|
235
|
+
success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay')
|
236
|
+
end
|
237
|
+
|
238
|
+
def invalid_operation_code?(response)
|
239
|
+
if response['operations']
|
240
|
+
operation = response['operations'].last
|
241
|
+
operation && operation['qp_status_code'] != '20000'
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def invalid_operation_message(response)
|
246
|
+
response['operations'] && response['operations'].last['qp_status_msg']
|
247
|
+
end
|
248
|
+
|
249
|
+
def map_address(address)
|
250
|
+
return {} if address.nil?
|
251
|
+
|
252
|
+
requires!(address, :name, :address1, :city, :zip, :country)
|
253
|
+
country = Country.find(address[:country])
|
254
|
+
mapped = {
|
255
|
+
name: address[:name],
|
256
|
+
street: address[:address1],
|
257
|
+
city: address[:city],
|
258
|
+
region: address[:address2],
|
259
|
+
zip_code: address[:zip],
|
260
|
+
country_code: country.code(:alpha3).value
|
261
|
+
}
|
262
|
+
mapped
|
263
|
+
end
|
264
|
+
|
265
|
+
def format_order_id(order_id)
|
266
|
+
truncate(order_id.to_s.delete('#'), 20)
|
267
|
+
end
|
268
|
+
|
269
|
+
def headers
|
270
|
+
auth = Base64.strict_encode64(":#{@options[:api_key]}")
|
271
|
+
{
|
272
|
+
'Authorization' => 'Basic ' + auth,
|
273
|
+
'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
274
|
+
'Accept' => 'application/json',
|
275
|
+
'Accept-Version' => "v#{API_VERSION}",
|
276
|
+
'Content-Type' => 'application/json'
|
277
|
+
}
|
278
|
+
end
|
279
|
+
|
280
|
+
def response_error(raw_response)
|
281
|
+
parse(raw_response)
|
282
|
+
rescue JSON::ParserError
|
283
|
+
json_error(raw_response)
|
284
|
+
end
|
285
|
+
|
286
|
+
def json_error(raw_response)
|
287
|
+
msg = 'Invalid response received from the Quickpay API.'
|
288
|
+
msg += " (The raw response returned by the API was #{raw_response.inspect})"
|
289
|
+
{ 'message' => msg }
|
290
|
+
end
|
291
|
+
|
292
|
+
def synchronized_path(path)
|
293
|
+
"#{path}?synchronized"
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require 'digest/md5'
|
3
|
+
require 'active_merchant/billing/gateways/quickpay/quickpay_common'
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
class QuickpayV4to7Gateway < Gateway
|
8
|
+
include QuickpayCommon
|
9
|
+
self.live_url = self.test_url = 'https://secure.quickpay.dk/api'
|
10
|
+
APPROVED = '000'
|
11
|
+
|
12
|
+
# The login is the QuickpayId
|
13
|
+
# The password is the md5checkword from the Quickpay manager
|
14
|
+
# To use the API-key from the Quickpay manager, specify :api-key
|
15
|
+
# Using the API-key, requires that you use version 4+. Specify :version => 4/5/6/7 in options.
|
16
|
+
def initialize(options = {})
|
17
|
+
requires!(options, :login, :password)
|
18
|
+
@protocol = options.delete(:version) || 7 # default to protocol version 7
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def authorize(money, credit_card_or_reference, options = {})
|
23
|
+
post = {}
|
24
|
+
|
25
|
+
action = recurring_or_authorize(credit_card_or_reference)
|
26
|
+
|
27
|
+
add_amount(post, money, options)
|
28
|
+
add_invoice(post, options)
|
29
|
+
add_creditcard_or_reference(post, credit_card_or_reference, options)
|
30
|
+
add_autocapture(post, false)
|
31
|
+
add_fraud_parameters(post, options) if action.eql?(:authorize)
|
32
|
+
add_testmode(post)
|
33
|
+
|
34
|
+
commit(action, post)
|
35
|
+
end
|
36
|
+
|
37
|
+
def purchase(money, credit_card_or_reference, options = {})
|
38
|
+
post = {}
|
39
|
+
|
40
|
+
action = recurring_or_authorize(credit_card_or_reference)
|
41
|
+
|
42
|
+
add_amount(post, money, options)
|
43
|
+
add_creditcard_or_reference(post, credit_card_or_reference, options)
|
44
|
+
add_invoice(post, options)
|
45
|
+
add_fraud_parameters(post, options) if action.eql?(:authorize)
|
46
|
+
add_autocapture(post, true)
|
47
|
+
|
48
|
+
commit(action, post)
|
49
|
+
end
|
50
|
+
|
51
|
+
def capture(money, authorization, options = {})
|
52
|
+
post = {}
|
53
|
+
|
54
|
+
add_finalize(post, options)
|
55
|
+
add_reference(post, authorization)
|
56
|
+
add_amount_without_currency(post, money)
|
57
|
+
commit(:capture, post)
|
58
|
+
end
|
59
|
+
|
60
|
+
def void(identification, options = {})
|
61
|
+
post = {}
|
62
|
+
|
63
|
+
add_reference(post, identification)
|
64
|
+
|
65
|
+
commit(:cancel, post)
|
66
|
+
end
|
67
|
+
|
68
|
+
def refund(money, identification, options = {})
|
69
|
+
post = {}
|
70
|
+
|
71
|
+
add_amount_without_currency(post, money)
|
72
|
+
add_reference(post, identification)
|
73
|
+
|
74
|
+
commit(:refund, post)
|
75
|
+
end
|
76
|
+
|
77
|
+
def credit(money, identification, options = {})
|
78
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
79
|
+
refund(money, identification, options)
|
80
|
+
end
|
81
|
+
|
82
|
+
def store(creditcard, options = {})
|
83
|
+
post = {}
|
84
|
+
|
85
|
+
add_creditcard(post, creditcard, options)
|
86
|
+
add_amount(post, 0, options) if @protocol >= 7
|
87
|
+
add_invoice(post, options)
|
88
|
+
add_description(post, options)
|
89
|
+
add_fraud_parameters(post, options)
|
90
|
+
add_testmode(post)
|
91
|
+
|
92
|
+
commit(:subscribe, post)
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def add_amount(post, money, options = {})
|
98
|
+
post[:amount] = amount(money)
|
99
|
+
post[:currency] = options[:currency] || currency(money)
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_amount_without_currency(post, money, options = {})
|
103
|
+
post[:amount] = amount(money)
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_invoice(post, options)
|
107
|
+
post[:ordernumber] = format_order_number(options[:order_id])
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_creditcard(post, credit_card, options)
|
111
|
+
post[:cardnumber] = credit_card.number
|
112
|
+
post[:cvd] = credit_card.verification_value
|
113
|
+
post[:expirationdate] = expdate(credit_card)
|
114
|
+
post[:cardtypelock] = options[:cardtypelock] unless options[:cardtypelock].blank?
|
115
|
+
post[:acquirers] = options[:acquirers] unless options[:acquirers].blank?
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_reference(post, identification)
|
119
|
+
post[:transaction] = identification
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_creditcard_or_reference(post, credit_card_or_reference, options)
|
123
|
+
if credit_card_or_reference.is_a?(String)
|
124
|
+
add_reference(post, credit_card_or_reference)
|
125
|
+
else
|
126
|
+
add_creditcard(post, credit_card_or_reference, options)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def add_autocapture(post, autocapture)
|
131
|
+
post[:autocapture] = autocapture ? 1 : 0
|
132
|
+
end
|
133
|
+
|
134
|
+
def recurring_or_authorize(credit_card_or_reference)
|
135
|
+
credit_card_or_reference.is_a?(String) ? :recurring : :authorize
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_description(post, options)
|
139
|
+
post[:description] = options[:description] || 'Description'
|
140
|
+
end
|
141
|
+
|
142
|
+
def add_testmode(post)
|
143
|
+
return if post[:transaction].present?
|
144
|
+
|
145
|
+
post[:testmode] = test? ? '1' : '0'
|
146
|
+
end
|
147
|
+
|
148
|
+
def add_fraud_parameters(post, options)
|
149
|
+
if @protocol >= 4
|
150
|
+
post[:fraud_remote_addr] = options[:ip] if options[:ip]
|
151
|
+
post[:fraud_http_accept] = options[:fraud_http_accept] if options[:fraud_http_accept]
|
152
|
+
post[:fraud_http_accept_language] = options[:fraud_http_accept_language] if options[:fraud_http_accept_language]
|
153
|
+
post[:fraud_http_accept_encoding] = options[:fraud_http_accept_encoding] if options[:fraud_http_accept_encoding]
|
154
|
+
post[:fraud_http_accept_charset] = options[:fraud_http_accept_charset] if options[:fraud_http_accept_charset]
|
155
|
+
post[:fraud_http_referer] = options[:fraud_http_referer] if options[:fraud_http_referer]
|
156
|
+
post[:fraud_http_user_agent] = options[:fraud_http_user_agent] if options[:fraud_http_user_agent]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def add_finalize(post, options)
|
161
|
+
post[:finalize] = options[:finalize] ? '1' : '0'
|
162
|
+
end
|
163
|
+
|
164
|
+
def commit(action, params)
|
165
|
+
response = parse(ssl_post(self.live_url, post_data(action, params)))
|
166
|
+
|
167
|
+
Response.new(successful?(response), message_from(response), response,
|
168
|
+
test: test?,
|
169
|
+
authorization: response[:transaction])
|
170
|
+
end
|
171
|
+
|
172
|
+
def successful?(response)
|
173
|
+
response[:qpstat] == APPROVED
|
174
|
+
end
|
175
|
+
|
176
|
+
def parse(data)
|
177
|
+
response = {}
|
178
|
+
|
179
|
+
doc = REXML::Document.new(data)
|
180
|
+
|
181
|
+
doc.root.elements.each do |element|
|
182
|
+
response[element.name.to_sym] = element.text
|
183
|
+
end
|
184
|
+
|
185
|
+
response
|
186
|
+
end
|
187
|
+
|
188
|
+
def message_from(response)
|
189
|
+
response[:qpstatmsg].to_s
|
190
|
+
end
|
191
|
+
|
192
|
+
def post_data(action, params = {})
|
193
|
+
params[:protocol] = @protocol
|
194
|
+
params[:msgtype] = action.to_s
|
195
|
+
params[:merchant] = @options[:login]
|
196
|
+
params[:apikey] = @options[:apikey] if @options[:apikey]
|
197
|
+
params[:md5check] = generate_check_hash(action, params)
|
198
|
+
|
199
|
+
params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
200
|
+
end
|
201
|
+
|
202
|
+
def generate_check_hash(action, params)
|
203
|
+
string = MD5_CHECK_FIELDS[@protocol][action].collect do |key|
|
204
|
+
params[key.to_sym]
|
205
|
+
end.join('')
|
206
|
+
|
207
|
+
# Add the md5checkword
|
208
|
+
string << @options[:password].to_s
|
209
|
+
|
210
|
+
Digest::MD5.hexdigest(string)
|
211
|
+
end
|
212
|
+
|
213
|
+
def expdate(credit_card)
|
214
|
+
year = format(credit_card.year, :two_digits)
|
215
|
+
month = format(credit_card.month, :two_digits)
|
216
|
+
|
217
|
+
"#{year}#{month}"
|
218
|
+
end
|
219
|
+
|
220
|
+
# Limited to 20 digits max
|
221
|
+
def format_order_number(number)
|
222
|
+
number.to_s.gsub(/[^\w]/, '').rjust(4, '0')[0...20]
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|