swiss-activemerchant 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +249 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +243 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +227 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +120 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
module QuickpayCommon
|
2
|
+
MD5_CHECK_FIELDS = {
|
3
|
+
3 => {
|
4
|
+
authorize: %w(protocol msgtype merchant ordernumber amount
|
5
|
+
currency autocapture cardnumber expirationdate
|
6
|
+
cvd cardtypelock testmode),
|
7
|
+
|
8
|
+
capture: %w(protocol msgtype merchant amount finalize transaction),
|
9
|
+
|
10
|
+
cancel: %w(protocol msgtype merchant transaction),
|
11
|
+
|
12
|
+
refund: %w(protocol msgtype merchant amount transaction),
|
13
|
+
|
14
|
+
subscribe: %w(protocol msgtype merchant ordernumber cardnumber
|
15
|
+
expirationdate cvd cardtypelock description testmode),
|
16
|
+
|
17
|
+
recurring: %w(protocol msgtype merchant ordernumber amount
|
18
|
+
currency autocapture transaction),
|
19
|
+
|
20
|
+
status: %w(protocol msgtype merchant transaction),
|
21
|
+
|
22
|
+
chstatus: %w(protocol msgtype merchant)
|
23
|
+
},
|
24
|
+
|
25
|
+
4 => {
|
26
|
+
authorize: %w(protocol msgtype merchant ordernumber amount
|
27
|
+
currency autocapture cardnumber expirationdate cvd
|
28
|
+
cardtypelock testmode fraud_remote_addr
|
29
|
+
fraud_http_accept fraud_http_accept_language
|
30
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
31
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
32
|
+
|
33
|
+
capture: %w(protocol msgtype merchant amount finalize transaction apikey),
|
34
|
+
|
35
|
+
cancel: %w(protocol msgtype merchant transaction apikey),
|
36
|
+
|
37
|
+
refund: %w(protocol msgtype merchant amount transaction apikey),
|
38
|
+
|
39
|
+
subscribe: %w(protocol msgtype merchant ordernumber cardnumber
|
40
|
+
expirationdate cvd cardtypelock description testmode
|
41
|
+
fraud_remote_addr fraud_http_accept fraud_http_accept_language
|
42
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
43
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
44
|
+
|
45
|
+
recurring: %w(protocol msgtype merchant ordernumber amount currency
|
46
|
+
autocapture transaction apikey),
|
47
|
+
|
48
|
+
status: %w(protocol msgtype merchant transaction apikey),
|
49
|
+
|
50
|
+
chstatus: %w(protocol msgtype merchant apikey)
|
51
|
+
},
|
52
|
+
|
53
|
+
5 => {
|
54
|
+
authorize: %w(protocol msgtype merchant ordernumber amount
|
55
|
+
currency autocapture cardnumber expirationdate cvd
|
56
|
+
cardtypelock testmode fraud_remote_addr
|
57
|
+
fraud_http_accept fraud_http_accept_language
|
58
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
59
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
60
|
+
|
61
|
+
capture: %w(protocol msgtype merchant amount finalize transaction apikey),
|
62
|
+
|
63
|
+
cancel: %w(protocol msgtype merchant transaction apikey),
|
64
|
+
|
65
|
+
refund: %w(protocol msgtype merchant amount transaction apikey),
|
66
|
+
|
67
|
+
subscribe: %w(protocol msgtype merchant ordernumber cardnumber
|
68
|
+
expirationdate cvd cardtypelock description testmode
|
69
|
+
fraud_remote_addr fraud_http_accept fraud_http_accept_language
|
70
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
71
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
72
|
+
|
73
|
+
recurring: %w(protocol msgtype merchant ordernumber amount currency
|
74
|
+
autocapture transaction apikey),
|
75
|
+
|
76
|
+
status: %w(protocol msgtype merchant transaction apikey),
|
77
|
+
|
78
|
+
chstatus: %w(protocol msgtype merchant apikey)
|
79
|
+
},
|
80
|
+
|
81
|
+
6 => {
|
82
|
+
authorize: %w(protocol msgtype merchant ordernumber amount
|
83
|
+
currency autocapture cardnumber expirationdate cvd
|
84
|
+
cardtypelock testmode fraud_remote_addr
|
85
|
+
fraud_http_accept fraud_http_accept_language
|
86
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
87
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
88
|
+
|
89
|
+
capture: %w(protocol msgtype merchant amount finalize transaction
|
90
|
+
apikey),
|
91
|
+
|
92
|
+
cancel: %w(protocol msgtype merchant transaction apikey),
|
93
|
+
|
94
|
+
refund: %w(protocol msgtype merchant amount transaction apikey),
|
95
|
+
|
96
|
+
subscribe: %w(protocol msgtype merchant ordernumber cardnumber
|
97
|
+
expirationdate cvd cardtypelock description testmode
|
98
|
+
fraud_remote_addr fraud_http_accept fraud_http_accept_language
|
99
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
100
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
101
|
+
|
102
|
+
recurring: %w(protocol msgtype merchant ordernumber amount currency
|
103
|
+
autocapture transaction apikey),
|
104
|
+
|
105
|
+
status: %w(protocol msgtype merchant transaction apikey),
|
106
|
+
|
107
|
+
chstatus: %w(protocol msgtype merchant apikey)
|
108
|
+
},
|
109
|
+
|
110
|
+
7 => {
|
111
|
+
authorize: %w(protocol msgtype merchant ordernumber amount
|
112
|
+
currency autocapture cardnumber expirationdate cvd
|
113
|
+
acquirers cardtypelock testmode fraud_remote_addr
|
114
|
+
fraud_http_accept fraud_http_accept_language
|
115
|
+
fraud_http_accept_encoding fraud_http_accept_charset
|
116
|
+
fraud_http_referer fraud_http_user_agent apikey),
|
117
|
+
|
118
|
+
capture: %w(protocol msgtype merchant amount finalize transaction
|
119
|
+
apikey),
|
120
|
+
|
121
|
+
cancel: %w(protocol msgtype merchant transaction apikey),
|
122
|
+
|
123
|
+
refund: %w(protocol msgtype merchant amount transaction apikey),
|
124
|
+
|
125
|
+
subscribe: %w(protocol msgtype merchant ordernumber amount currency
|
126
|
+
cardnumber expirationdate cvd acquirers cardtypelock
|
127
|
+
description testmode fraud_remote_addr fraud_http_accept
|
128
|
+
fraud_http_accept_language fraud_http_accept_encoding
|
129
|
+
fraud_http_accept_charset fraud_http_referer
|
130
|
+
fraud_http_user_agent apikey),
|
131
|
+
|
132
|
+
recurring: %w(protocol msgtype merchant ordernumber amount currency
|
133
|
+
autocapture transaction apikey),
|
134
|
+
|
135
|
+
status: %w(protocol msgtype merchant transaction apikey),
|
136
|
+
|
137
|
+
chstatus: %w(protocol msgtype merchant apikey)
|
138
|
+
},
|
139
|
+
|
140
|
+
10 => {
|
141
|
+
authorize: %w(mobile_number acquirer autofee customer_id extras
|
142
|
+
zero_auth customer_ip),
|
143
|
+
capture: %w(extras),
|
144
|
+
cancel: %w(extras),
|
145
|
+
refund: %w(extras),
|
146
|
+
subscribe: %w(variables branding_id),
|
147
|
+
authorize_subscription: %w(mobile_number acquirer customer_ip),
|
148
|
+
recurring: %w(auto_capture autofee zero_auth)
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
RESPONSE_CODES = {
|
153
|
+
200 => 'OK',
|
154
|
+
201 => 'Created',
|
155
|
+
202 => 'Accepted',
|
156
|
+
400 => 'Bad Request',
|
157
|
+
401 => 'UnAuthorized',
|
158
|
+
402 => 'Payment Required',
|
159
|
+
403 => 'Forbidden',
|
160
|
+
404 => 'Not Found',
|
161
|
+
405 => 'Method Not Allowed',
|
162
|
+
406 => 'Not Acceptable',
|
163
|
+
409 => 'Conflict',
|
164
|
+
500 => 'Internal Server Error'
|
165
|
+
}
|
166
|
+
|
167
|
+
def self.included(base)
|
168
|
+
base.default_currency = 'DKK'
|
169
|
+
base.money_format = :cents
|
170
|
+
|
171
|
+
base.supported_countries = %w[DE DK ES FI FR FO GB IS NO SE]
|
172
|
+
base.supported_cardtypes = %i[dankort forbrugsforeningen visa master
|
173
|
+
american_express diners_club jcb maestro]
|
174
|
+
base.homepage_url = 'http://quickpay.net/'
|
175
|
+
base.display_name = 'QuickPay'
|
176
|
+
end
|
177
|
+
|
178
|
+
def expdate(credit_card)
|
179
|
+
year = format(credit_card.year, :two_digits)
|
180
|
+
month = format(credit_card.month, :two_digits)
|
181
|
+
|
182
|
+
"#{year}#{month}"
|
183
|
+
end
|
184
|
+
end
|
@@ -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
|