active_accountability_merchant 1.97.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +2948 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +246 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +15 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +96 -0
- data/lib/active_merchant/billing/base.rb +61 -0
- data/lib/active_merchant/billing/check.rb +80 -0
- data/lib/active_merchant/billing/compatibility.rb +117 -0
- data/lib/active_merchant/billing/credit_card.rb +406 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +330 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -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 +384 -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.rb +217 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -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 +316 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +219 -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 +327 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
- data/lib/active_merchant/billing/gateways/element.rb +356 -0
- data/lib/active_merchant/billing/gateways/epay.rb +285 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
- data/lib/active_merchant/billing/gateways/exact.rb +224 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -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 +270 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
- data/lib/active_merchant/billing/gateways/hps.rb +350 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
- data/lib/active_merchant/billing/gateways/litle.rb +507 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
- data/lib/active_merchant/billing/gateways/migs.rb +332 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
- data/lib/active_merchant/billing/gateways/monei.rb +338 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
- data/lib/active_merchant/billing/gateways/omise.rb +324 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
- data/lib/active_merchant/billing/gateways/opp.rb +388 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -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 +188 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
- data/lib/active_merchant/billing/gateways/payex.rb +410 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +383 -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 +43 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -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 +369 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -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 +269 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +234 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
- data/lib/active_merchant/billing/gateways/realex.rb +374 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
- data/lib/active_merchant/billing/gateways/s5.rb +246 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
- data/lib/active_merchant/billing/gateways/sage.rb +448 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
- data/lib/active_merchant/billing/gateways/telr.rb +274 -0
- data/lib/active_merchant/billing/gateways/tns.rb +22 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
- data/lib/active_merchant/billing/gateways/transax.rb +22 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -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 +92 -0
- data/lib/active_merchant/connection.rb +195 -0
- data/lib/active_merchant/country.rb +336 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
- data/lib/active_merchant/network_connection_retries.rb +80 -0
- data/lib/active_merchant/post_data.rb +25 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3988 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +92 -0
- data/lib/support/ssl_version.rb +87 -0
- metadata +435 -0
@@ -0,0 +1,410 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PayeezyGateway < Gateway
|
4
|
+
class_attribute :integration_url
|
5
|
+
|
6
|
+
self.test_url = 'https://api-cert.payeezy.com/v1'
|
7
|
+
self.integration_url = 'https://api-cat.payeezy.com/v1'
|
8
|
+
self.live_url = 'https://api.payeezy.com/v1'
|
9
|
+
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.money_format = :cents
|
12
|
+
self.supported_countries = %w(US CA)
|
13
|
+
|
14
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
15
|
+
|
16
|
+
self.homepage_url = 'https://developer.payeezy.com/'
|
17
|
+
self.display_name = 'Payeezy'
|
18
|
+
|
19
|
+
CREDIT_CARD_BRAND = {
|
20
|
+
'visa' => 'Visa',
|
21
|
+
'master' => 'Mastercard',
|
22
|
+
'american_express' => 'American Express',
|
23
|
+
'discover' => 'Discover',
|
24
|
+
'jcb' => 'JCB',
|
25
|
+
'diners_club' => 'Diners Club'
|
26
|
+
}
|
27
|
+
|
28
|
+
def initialize(options = {})
|
29
|
+
requires!(options, :apikey, :apisecret, :token)
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def purchase(amount, payment_method, options = {})
|
34
|
+
params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' }
|
35
|
+
|
36
|
+
add_invoice(params, options)
|
37
|
+
add_reversal_id(params, options)
|
38
|
+
add_payment_method(params, payment_method, options)
|
39
|
+
add_address(params, options)
|
40
|
+
add_amount(params, amount, options)
|
41
|
+
add_soft_descriptors(params, options)
|
42
|
+
add_stored_credentials(params, options)
|
43
|
+
|
44
|
+
commit(params, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorize(amount, payment_method, options = {})
|
48
|
+
params = {transaction_type: 'authorize'}
|
49
|
+
|
50
|
+
add_invoice(params, options)
|
51
|
+
add_reversal_id(params, options)
|
52
|
+
add_payment_method(params, payment_method, options)
|
53
|
+
add_address(params, options)
|
54
|
+
add_amount(params, amount, options)
|
55
|
+
add_soft_descriptors(params, options)
|
56
|
+
add_stored_credentials(params, options)
|
57
|
+
|
58
|
+
commit(params, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def capture(amount, authorization, options = {})
|
62
|
+
params = {transaction_type: 'capture'}
|
63
|
+
|
64
|
+
add_authorization_info(params, authorization)
|
65
|
+
add_amount(params, amount, options)
|
66
|
+
add_soft_descriptors(params, options)
|
67
|
+
|
68
|
+
commit(params, options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def refund(amount, authorization, options = {})
|
72
|
+
params = {transaction_type: 'refund'}
|
73
|
+
|
74
|
+
add_authorization_info(params, authorization)
|
75
|
+
add_amount(params, (amount || amount_from_authorization(authorization)), options)
|
76
|
+
|
77
|
+
commit(params, options)
|
78
|
+
end
|
79
|
+
|
80
|
+
def store(payment_method, options = {})
|
81
|
+
params = {transaction_type: 'store'}
|
82
|
+
|
83
|
+
add_creditcard_for_tokenization(params, payment_method, options)
|
84
|
+
|
85
|
+
commit(params, options)
|
86
|
+
end
|
87
|
+
|
88
|
+
def void(authorization, options = {})
|
89
|
+
params = {transaction_type: 'void'}
|
90
|
+
|
91
|
+
add_authorization_info(params, authorization, options)
|
92
|
+
add_amount(params, amount_from_authorization(authorization), options)
|
93
|
+
|
94
|
+
commit(params, options)
|
95
|
+
end
|
96
|
+
|
97
|
+
def verify(credit_card, options={})
|
98
|
+
MultiResponse.run(:use_first_response) do |r|
|
99
|
+
r.process { authorize(0, credit_card, options) }
|
100
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def supports_scrubbing?
|
105
|
+
true
|
106
|
+
end
|
107
|
+
|
108
|
+
def scrub(transcript)
|
109
|
+
transcript.
|
110
|
+
gsub(%r((Token: )(\w|-)+), '\1[FILTERED]').
|
111
|
+
gsub(%r((Apikey: )(\w|-)+), '\1[FILTERED]').
|
112
|
+
gsub(%r((\\?"card_number\\?":\\?")\d+), '\1[FILTERED]').
|
113
|
+
gsub(%r((\\?"cvv\\?":\\?")\d+), '\1[FILTERED]').
|
114
|
+
gsub(%r((\\?"account_number\\?":\\?")\d+), '\1[FILTERED]').
|
115
|
+
gsub(%r((\\?"routing_number\\?":\\?")\d+), '\1[FILTERED]').
|
116
|
+
gsub(%r((\\?card_number=)\d+(&?)), '\1[FILTERED]').
|
117
|
+
gsub(%r((\\?cvv=)\d+(&?)), '\1[FILTERED]').
|
118
|
+
gsub(%r((\\?apikey=)\w+(&?)), '\1[FILTERED]').
|
119
|
+
gsub(%r{(\\?"credit_card\.card_number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
|
120
|
+
gsub(%r{(\\?"credit_card\.cvv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
|
121
|
+
gsub(%r{(\\?"apikey\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def add_invoice(params, options)
|
127
|
+
params[:merchant_ref] = options[:order_id]
|
128
|
+
end
|
129
|
+
|
130
|
+
def add_reversal_id(params, options)
|
131
|
+
params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
|
132
|
+
end
|
133
|
+
|
134
|
+
def amount_from_authorization(authorization)
|
135
|
+
authorization.split('|').last.to_i
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_authorization_info(params, authorization, options = {})
|
139
|
+
transaction_id, transaction_tag, method, _ = authorization.split('|')
|
140
|
+
params[:method] = method == 'token' ? 'credit_card' : method
|
141
|
+
|
142
|
+
if options[:reversal_id]
|
143
|
+
params[:reversal_id] = options[:reversal_id]
|
144
|
+
else
|
145
|
+
params[:transaction_id] = transaction_id
|
146
|
+
params[:transaction_tag] = transaction_tag
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def add_creditcard_for_tokenization(params, payment_method, options)
|
151
|
+
params[:apikey] = @options[:apikey]
|
152
|
+
params[:ta_token] = options[:ta_token]
|
153
|
+
params[:type] = 'FDToken'
|
154
|
+
params[:credit_card] = add_card_data(payment_method)
|
155
|
+
params[:auth] = 'false'
|
156
|
+
end
|
157
|
+
|
158
|
+
def is_store_action?(params)
|
159
|
+
params[:transaction_type] == 'store'
|
160
|
+
end
|
161
|
+
|
162
|
+
def add_payment_method(params, payment_method, options)
|
163
|
+
if payment_method.is_a? Check
|
164
|
+
add_echeck(params, payment_method, options)
|
165
|
+
elsif payment_method.is_a? String
|
166
|
+
add_token(params, payment_method, options)
|
167
|
+
else
|
168
|
+
add_creditcard(params, payment_method)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def add_echeck(params, echeck, options)
|
173
|
+
tele_check = {}
|
174
|
+
|
175
|
+
tele_check[:check_number] = echeck.number || '001'
|
176
|
+
tele_check[:check_type] = 'P'
|
177
|
+
tele_check[:routing_number] = echeck.routing_number
|
178
|
+
tele_check[:account_number] = echeck.account_number
|
179
|
+
tele_check[:accountholder_name] = "#{echeck.first_name} #{echeck.last_name}"
|
180
|
+
tele_check[:customer_id_type] = options[:customer_id_type] if options[:customer_id_type]
|
181
|
+
tele_check[:customer_id_number] = options[:customer_id_number] if options[:customer_id_number]
|
182
|
+
tele_check[:client_email] = options[:client_email] if options[:client_email]
|
183
|
+
|
184
|
+
params[:method] = 'tele_check'
|
185
|
+
params[:tele_check] = tele_check
|
186
|
+
end
|
187
|
+
|
188
|
+
def add_token(params, payment_method, options)
|
189
|
+
token = {}
|
190
|
+
token[:token_type] = 'FDToken'
|
191
|
+
|
192
|
+
type, cardholder_name, exp_date, card_number = payment_method.split('|')
|
193
|
+
|
194
|
+
token[:token_data] = {}
|
195
|
+
token[:token_data][:type] = type
|
196
|
+
token[:token_data][:cardholder_name] = cardholder_name
|
197
|
+
token[:token_data][:value] = card_number
|
198
|
+
token[:token_data][:exp_date] = exp_date
|
199
|
+
token[:token_data][:cvv] = options[:cvv] if options[:cvv]
|
200
|
+
|
201
|
+
params[:method] = 'token'
|
202
|
+
params[:token] = token
|
203
|
+
end
|
204
|
+
|
205
|
+
def add_creditcard(params, creditcard)
|
206
|
+
credit_card = add_card_data(creditcard)
|
207
|
+
|
208
|
+
params[:method] = 'credit_card'
|
209
|
+
params[:credit_card] = credit_card
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_card_data(payment_method)
|
213
|
+
card = {}
|
214
|
+
card[:type] = CREDIT_CARD_BRAND[payment_method.brand]
|
215
|
+
card[:cardholder_name] = payment_method.name
|
216
|
+
card[:card_number] = payment_method.number
|
217
|
+
card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
|
218
|
+
card[:cvv] = payment_method.verification_value if payment_method.verification_value?
|
219
|
+
card
|
220
|
+
end
|
221
|
+
|
222
|
+
def format_exp_date(month, year)
|
223
|
+
"#{format(month, :two_digits)}#{format(year, :two_digits)}"
|
224
|
+
end
|
225
|
+
|
226
|
+
def add_address(params, options)
|
227
|
+
address = options[:billing_address]
|
228
|
+
return unless address
|
229
|
+
|
230
|
+
billing_address = {}
|
231
|
+
billing_address[:street] = address[:address1] if address[:address1]
|
232
|
+
billing_address[:city] = address[:city] if address[:city]
|
233
|
+
billing_address[:state_province] = address[:state] if address[:state]
|
234
|
+
billing_address[:zip_postal_code] = address[:zip] if address[:zip]
|
235
|
+
billing_address[:country] = address[:country] if address[:country]
|
236
|
+
|
237
|
+
params[:billing_address] = billing_address
|
238
|
+
end
|
239
|
+
|
240
|
+
def add_amount(params, money, options)
|
241
|
+
params[:currency_code] = (options[:currency] || default_currency).upcase
|
242
|
+
params[:amount] = amount(money)
|
243
|
+
end
|
244
|
+
|
245
|
+
def add_soft_descriptors(params, options)
|
246
|
+
params[:soft_descriptors] = options[:soft_descriptors] if options[:soft_descriptors]
|
247
|
+
end
|
248
|
+
|
249
|
+
def add_stored_credentials(params, options)
|
250
|
+
if options[:sequence]
|
251
|
+
params[:stored_credentials] = {}
|
252
|
+
params[:stored_credentials][:cardbrand_original_transaction_id] = options[:cardbrand_original_transaction_id] if options[:cardbrand_original_transaction_id]
|
253
|
+
params[:stored_credentials][:sequence] = options[:sequence]
|
254
|
+
params[:stored_credentials][:initiator] = options[:initiator] if options[:initiator]
|
255
|
+
params[:stored_credentials][:is_scheduled] = options[:is_scheduled]
|
256
|
+
params[:stored_credentials][:auth_type_override] = options[:auth_type_override] if options[:auth_type_override]
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def commit(params, options)
|
261
|
+
url = base_url(options) + endpoint(params)
|
262
|
+
|
263
|
+
if transaction_id = params.delete(:transaction_id)
|
264
|
+
url = "#{url}/#{transaction_id}"
|
265
|
+
end
|
266
|
+
|
267
|
+
begin
|
268
|
+
response = api_request(url, params)
|
269
|
+
rescue ResponseError => e
|
270
|
+
response = response_error(e.response.body)
|
271
|
+
rescue JSON::ParserError
|
272
|
+
response = json_error(e.response.body)
|
273
|
+
end
|
274
|
+
|
275
|
+
Response.new(
|
276
|
+
success_from(response),
|
277
|
+
handle_message(response, success_from(response)),
|
278
|
+
response,
|
279
|
+
test: test?,
|
280
|
+
authorization: authorization_from(params, response),
|
281
|
+
avs_result: {code: response['avs']},
|
282
|
+
cvv_result: response['cvv2'],
|
283
|
+
error_code: error_code(response, success_from(response))
|
284
|
+
)
|
285
|
+
end
|
286
|
+
|
287
|
+
def base_url(options)
|
288
|
+
if options[:integration]
|
289
|
+
integration_url
|
290
|
+
elsif test?
|
291
|
+
test_url
|
292
|
+
else
|
293
|
+
live_url
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def endpoint(params)
|
298
|
+
is_store_action?(params) ? '/transactions/tokens' : '/transactions'
|
299
|
+
end
|
300
|
+
|
301
|
+
def api_request(url, params)
|
302
|
+
body = params.to_json
|
303
|
+
parse(ssl_post(url, body, headers(body)))
|
304
|
+
end
|
305
|
+
|
306
|
+
def post_data(params)
|
307
|
+
return nil unless params
|
308
|
+
params.reject { |k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
309
|
+
end
|
310
|
+
|
311
|
+
def generate_hmac(nonce, current_timestamp, payload)
|
312
|
+
message = [
|
313
|
+
@options[:apikey],
|
314
|
+
nonce.to_s,
|
315
|
+
current_timestamp.to_s,
|
316
|
+
@options[:token],
|
317
|
+
payload
|
318
|
+
].join('')
|
319
|
+
hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
|
320
|
+
hash
|
321
|
+
end
|
322
|
+
|
323
|
+
def headers(payload)
|
324
|
+
nonce = (SecureRandom.random_number * 10_000_000_000)
|
325
|
+
current_timestamp = (Time.now.to_f * 1000).to_i
|
326
|
+
{
|
327
|
+
'Content-Type' => 'application/json',
|
328
|
+
'apikey' => options[:apikey],
|
329
|
+
'token' => options[:token],
|
330
|
+
'nonce' => nonce.to_s,
|
331
|
+
'timestamp' => current_timestamp.to_s,
|
332
|
+
'Authorization' => generate_hmac(nonce, current_timestamp, payload)
|
333
|
+
}
|
334
|
+
end
|
335
|
+
|
336
|
+
def error_code(response, success)
|
337
|
+
return if success
|
338
|
+
response['Error'].to_h['messages'].to_a.map { |e| e['code'] }.join(', ')
|
339
|
+
end
|
340
|
+
|
341
|
+
def success_from(response)
|
342
|
+
if response['transaction_status']
|
343
|
+
response['transaction_status'] == 'approved'
|
344
|
+
elsif response['results']
|
345
|
+
response['results']['status'] == 'success'
|
346
|
+
elsif response['status']
|
347
|
+
response['status'] == 'success'
|
348
|
+
else
|
349
|
+
false
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
def handle_message(response, success)
|
354
|
+
if success && response['status'].present?
|
355
|
+
'Token successfully created.'
|
356
|
+
elsif success
|
357
|
+
"#{response['gateway_message']} - #{response['bank_message']}"
|
358
|
+
elsif %w(401 403).include?(response['code'])
|
359
|
+
response['message']
|
360
|
+
elsif response.key?('Error')
|
361
|
+
response['Error']['messages'].first['description']
|
362
|
+
elsif response.key?('results')
|
363
|
+
response['results']['Error']['messages'].first['description']
|
364
|
+
elsif response.key?('error')
|
365
|
+
response['error']
|
366
|
+
elsif response.key?('fault')
|
367
|
+
response['fault'].to_h['faultstring']
|
368
|
+
else
|
369
|
+
response['bank_message'] || response['gateway_message'] || 'Failure to successfully create token.'
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def authorization_from(params, response)
|
374
|
+
if is_store_action?(params)
|
375
|
+
if success_from(response)
|
376
|
+
[
|
377
|
+
response['token']['type'],
|
378
|
+
response['token']['cardholder_name'],
|
379
|
+
response['token']['exp_date'],
|
380
|
+
response['token']['value']
|
381
|
+
].join('|')
|
382
|
+
else
|
383
|
+
nil
|
384
|
+
end
|
385
|
+
else
|
386
|
+
[
|
387
|
+
response['transaction_id'],
|
388
|
+
response['transaction_tag'],
|
389
|
+
params[:method],
|
390
|
+
response['amount']&.to_i
|
391
|
+
].join('|')
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
def parse(body)
|
396
|
+
JSON.parse(body)
|
397
|
+
end
|
398
|
+
|
399
|
+
def response_error(raw_response)
|
400
|
+
parse(raw_response)
|
401
|
+
rescue JSON::ParserError
|
402
|
+
json_error(raw_response)
|
403
|
+
end
|
404
|
+
|
405
|
+
def json_error(raw_response)
|
406
|
+
{'error' => "Unable to parse response: #{raw_response.inspect}"}
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
@@ -0,0 +1,410 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class PayexGateway < Gateway
|
6
|
+
class_attribute :live_external_url, :test_external_url, :live_confined_url, :test_confined_url
|
7
|
+
|
8
|
+
self.live_external_url = 'https://external.payex.com/'
|
9
|
+
self.test_external_url = 'https://test-external.payex.com/'
|
10
|
+
|
11
|
+
self.live_confined_url = 'https://confined.payex.com/'
|
12
|
+
self.test_confined_url = 'https://test-confined.payex.com/'
|
13
|
+
|
14
|
+
self.money_format = :cents
|
15
|
+
self.supported_countries = ['DK', 'FI', 'NO', 'SE']
|
16
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
17
|
+
self.homepage_url = 'http://payex.com/'
|
18
|
+
self.display_name = 'Payex'
|
19
|
+
self.default_currency = 'EUR'
|
20
|
+
|
21
|
+
TRANSACTION_STATUS = {
|
22
|
+
sale: '0',
|
23
|
+
initialize: '1',
|
24
|
+
credit: '2',
|
25
|
+
authorize: '3',
|
26
|
+
cancel: '4',
|
27
|
+
failure: '5',
|
28
|
+
capture: '6',
|
29
|
+
}
|
30
|
+
|
31
|
+
SOAP_ACTIONS = {
|
32
|
+
initialize: { name: 'Initialize8', url: 'pxorder/pxorder.asmx', xmlns: 'http://external.payex.com/PxOrder/' },
|
33
|
+
purchasecc: { name: 'PurchaseCC', url: 'pxconfined/pxorder.asmx', xmlns: 'http://confined.payex.com/PxOrder/', confined: true},
|
34
|
+
cancel: { name: 'Cancel2', url: 'pxorder/pxorder.asmx', xmlns: 'http://external.payex.com/PxOrder/' },
|
35
|
+
capture: { name: 'Capture5', url: 'pxorder/pxorder.asmx', xmlns: 'http://external.payex.com/PxOrder/' },
|
36
|
+
credit: { name: 'Credit5', url: 'pxorder/pxorder.asmx', xmlns: 'http://external.payex.com/PxOrder/' },
|
37
|
+
create_agreement: { name: 'CreateAgreement3', url: 'pxagreement/pxagreement.asmx', xmlns: 'http://external.payex.com/PxAgreement/' },
|
38
|
+
delete_agreement: { name: 'DeleteAgreement', url: 'pxagreement/pxagreement.asmx', xmlns: 'http://external.payex.com/PxAgreement/' },
|
39
|
+
autopay: { name: 'AutoPay3', url: 'pxagreement/pxagreement.asmx', xmlns: 'http://external.payex.com/PxAgreement/' },
|
40
|
+
}
|
41
|
+
|
42
|
+
def initialize(options = {})
|
43
|
+
requires!(options, :account, :encryption_key)
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
# Public: Send an authorize Payex request
|
48
|
+
#
|
49
|
+
# amount - The monetary amount of the transaction in cents.
|
50
|
+
# payment_method - The Active Merchant payment method or the +store+ authorization for stored transactions.
|
51
|
+
# options - A standard ActiveMerchant options hash:
|
52
|
+
# :currency - Three letter currency code for the transaction (default: "EUR")
|
53
|
+
# :order_id - The unique order ID for this transaction (required).
|
54
|
+
# :product_number - The merchant product number (default: '1').
|
55
|
+
# :description - The merchant description for this product (default: The :order_id).
|
56
|
+
# :ip - The client IP address (default: '127.0.0.1').
|
57
|
+
# :vat - The vat amount (optional).
|
58
|
+
#
|
59
|
+
# Returns an ActiveMerchant::Billing::Response object
|
60
|
+
def authorize(amount, payment_method, options = {})
|
61
|
+
requires!(options, :order_id)
|
62
|
+
amount = amount(amount)
|
63
|
+
if payment_method.respond_to?(:number)
|
64
|
+
# credit card authorization
|
65
|
+
MultiResponse.new.tap do |r|
|
66
|
+
r.process { send_initialize(amount, true, options) }
|
67
|
+
r.process { send_purchasecc(payment_method, r.params['orderref']) }
|
68
|
+
end
|
69
|
+
else
|
70
|
+
# stored authorization
|
71
|
+
send_autopay(amount, payment_method, true, options)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Public: Send a purchase Payex request
|
76
|
+
#
|
77
|
+
# amount - The monetary amount of the transaction in cents.
|
78
|
+
# payment_method - The Active Merchant payment method or the +store+ authorization for stored transactions.
|
79
|
+
# options - A standard ActiveMerchant options hash:
|
80
|
+
# :currency - Three letter currency code for the transaction (default: "EUR")
|
81
|
+
# :order_id - The unique order ID for this transaction (required).
|
82
|
+
# :product_number - The merchant product number (default: '1').
|
83
|
+
# :description - The merchant description for this product (default: The :order_id).
|
84
|
+
# :ip - The client IP address (default: '127.0.0.1').
|
85
|
+
# :vat - The vat amount (optional).
|
86
|
+
#
|
87
|
+
# Returns an ActiveMerchant::Billing::Response object
|
88
|
+
def purchase(amount, payment_method, options = {})
|
89
|
+
requires!(options, :order_id)
|
90
|
+
amount = amount(amount)
|
91
|
+
if payment_method.respond_to?(:number)
|
92
|
+
# credit card purchase
|
93
|
+
MultiResponse.new.tap do |r|
|
94
|
+
r.process { send_initialize(amount, false, options) }
|
95
|
+
r.process { send_purchasecc(payment_method, r.params['orderref']) }
|
96
|
+
end
|
97
|
+
else
|
98
|
+
# stored purchase
|
99
|
+
send_autopay(amount, payment_method, false, options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Public: Capture money from a previously authorized transaction
|
104
|
+
#
|
105
|
+
# money - The amount to capture
|
106
|
+
# authorization - The authorization token from the authorization request
|
107
|
+
#
|
108
|
+
# Returns an ActiveMerchant::Billing::Response object
|
109
|
+
def capture(money, authorization, options = {})
|
110
|
+
amount = amount(money)
|
111
|
+
send_capture(amount, authorization)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Public: Voids an authorize transaction
|
115
|
+
#
|
116
|
+
# authorization - The authorization returned from the successful authorize transaction.
|
117
|
+
# options - A standard ActiveMerchant options hash
|
118
|
+
#
|
119
|
+
# Returns an ActiveMerchant::Billing::Response object
|
120
|
+
def void(authorization, options={})
|
121
|
+
send_cancel(authorization)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Public: Refunds a purchase transaction
|
125
|
+
#
|
126
|
+
# money - The amount to refund
|
127
|
+
# authorization - The authorization token from the purchase request.
|
128
|
+
# options - A standard ActiveMerchant options hash:
|
129
|
+
# :order_id - The unique order ID for this transaction (required).
|
130
|
+
# :vat_amount - The vat amount (optional).
|
131
|
+
#
|
132
|
+
# Returns an ActiveMerchant::Billing::Response object
|
133
|
+
def refund(money, authorization, options = {})
|
134
|
+
requires!(options, :order_id)
|
135
|
+
amount = amount(money)
|
136
|
+
send_credit(authorization, amount, options)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Public: Stores a credit card and creates a Payex agreement with a customer
|
140
|
+
#
|
141
|
+
# creditcard - The credit card to store.
|
142
|
+
# options - A standard ActiveMerchant options hash:
|
143
|
+
# :order_id - The unique order ID for this transaction (required).
|
144
|
+
# :merchant_ref - A reference that links this agreement to something the merchant takes money for (default: '1')
|
145
|
+
# :currency - Three letter currency code for the transaction (default: "EUR")
|
146
|
+
# :product_number - The merchant product number (default: '1').
|
147
|
+
# :description - The merchant description for this product (default: The :order_id).
|
148
|
+
# :ip - The client IP address (default: '127.0.0.1').
|
149
|
+
# :max_amount - The maximum amount to allow to be charged (default: 100000).
|
150
|
+
# :vat - The vat amount (optional).
|
151
|
+
#
|
152
|
+
# Returns an ActiveMerchant::Billing::Response object where the authorization is set to the agreement_ref which is used for stored payments.
|
153
|
+
def store(creditcard, options = {})
|
154
|
+
requires!(options, :order_id)
|
155
|
+
amount = amount(1) # 1 cent for authorization
|
156
|
+
MultiResponse.run(:first) do |r|
|
157
|
+
r.process { send_create_agreement(options) }
|
158
|
+
r.process { send_initialize(amount, true, options.merge({agreement_ref: r.authorization})) }
|
159
|
+
order_ref = r.params['orderref']
|
160
|
+
r.process { send_purchasecc(creditcard, order_ref) }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Public: Unstores a customer's credit card and deletes their Payex agreement.
|
165
|
+
#
|
166
|
+
# authorization - The authorization token from the store request.
|
167
|
+
#
|
168
|
+
# Returns an ActiveMerchant::Billing::Response object
|
169
|
+
def unstore(authorization, options = {})
|
170
|
+
send_delete_agreement(authorization)
|
171
|
+
end
|
172
|
+
|
173
|
+
private
|
174
|
+
|
175
|
+
def send_initialize(amount, is_auth, options = {})
|
176
|
+
properties = {
|
177
|
+
accountNumber: @options[:account],
|
178
|
+
purchaseOperation: is_auth ? 'AUTHORIZATION' : 'SALE',
|
179
|
+
price: amount,
|
180
|
+
priceArgList: nil,
|
181
|
+
currency: (options[:currency] || default_currency),
|
182
|
+
vat: options[:vat] || 0,
|
183
|
+
orderID: options[:order_id],
|
184
|
+
productNumber: options[:product_number] || '1',
|
185
|
+
description: options[:description] || options[:order_id],
|
186
|
+
clientIPAddress: options[:client_ip_address] || '127.0.0.1',
|
187
|
+
clientIdentifier: nil,
|
188
|
+
additionalValues: nil,
|
189
|
+
externalID: nil,
|
190
|
+
returnUrl: 'http://example.net', # set to dummy value since this is not used but is required
|
191
|
+
view: 'CREDITCARD',
|
192
|
+
agreementRef: options[:agreement_ref], # this is used to attach a stored agreement to a transaction as part of the store card
|
193
|
+
cancelUrl: nil,
|
194
|
+
clientLanguage: nil
|
195
|
+
}
|
196
|
+
hash_fields = [:accountNumber, :purchaseOperation, :price, :priceArgList, :currency, :vat, :orderID,
|
197
|
+
:productNumber, :description, :clientIPAddress, :clientIdentifier, :additionalValues,
|
198
|
+
:externalID, :returnUrl, :view, :agreementRef, :cancelUrl, :clientLanguage]
|
199
|
+
add_request_hash(properties, hash_fields)
|
200
|
+
soap_action = SOAP_ACTIONS[:initialize]
|
201
|
+
request = build_xml_request(soap_action, properties)
|
202
|
+
commit(soap_action, request)
|
203
|
+
end
|
204
|
+
|
205
|
+
def send_purchasecc(payment_method, order_ref)
|
206
|
+
properties = {
|
207
|
+
accountNumber: @options[:account],
|
208
|
+
orderRef: order_ref,
|
209
|
+
transactionType: 1, # online payment
|
210
|
+
cardNumber: payment_method.number,
|
211
|
+
cardNumberExpireMonth: format(payment_method.month, :two_digits),
|
212
|
+
cardNumberExpireYear: format(payment_method.year, :two_digits),
|
213
|
+
cardHolderName: payment_method.name,
|
214
|
+
cardNumberCVC: payment_method.verification_value
|
215
|
+
}
|
216
|
+
hash_fields = [:accountNumber, :orderRef, :transactionType, :cardNumber, :cardNumberExpireMonth,
|
217
|
+
:cardNumberExpireYear, :cardNumberCVC, :cardHolderName]
|
218
|
+
add_request_hash(properties, hash_fields)
|
219
|
+
|
220
|
+
soap_action = SOAP_ACTIONS[:purchasecc]
|
221
|
+
request = build_xml_request(soap_action, properties)
|
222
|
+
commit(soap_action, request)
|
223
|
+
end
|
224
|
+
|
225
|
+
def send_autopay(amount, authorization, is_auth, options = {})
|
226
|
+
properties = {
|
227
|
+
accountNumber: @options[:account],
|
228
|
+
agreementRef: authorization,
|
229
|
+
price: amount,
|
230
|
+
productNumber: options[:product_number] || '1',
|
231
|
+
description: options[:description] || options[:order_id],
|
232
|
+
orderId: options[:order_id],
|
233
|
+
purchaseOperation: is_auth ? 'AUTHORIZATION' : 'SALE',
|
234
|
+
currency: (options[:currency] || default_currency),
|
235
|
+
}
|
236
|
+
hash_fields = [:accountNumber, :agreementRef, :price, :productNumber, :description, :orderId, :purchaseOperation, :currency]
|
237
|
+
add_request_hash(properties, hash_fields)
|
238
|
+
|
239
|
+
soap_action = SOAP_ACTIONS[:autopay]
|
240
|
+
request = build_xml_request(soap_action, properties)
|
241
|
+
commit(soap_action, request)
|
242
|
+
end
|
243
|
+
|
244
|
+
def send_capture(amount, transaction_number, options = {})
|
245
|
+
properties = {
|
246
|
+
accountNumber: @options[:account],
|
247
|
+
transactionNumber: transaction_number,
|
248
|
+
amount: amount,
|
249
|
+
orderId: options[:order_id] || '',
|
250
|
+
vatAmount: options[:vat_amount] || 0,
|
251
|
+
additionalValues: ''
|
252
|
+
}
|
253
|
+
hash_fields = [:accountNumber, :transactionNumber, :amount, :orderId, :vatAmount, :additionalValues]
|
254
|
+
add_request_hash(properties, hash_fields)
|
255
|
+
|
256
|
+
soap_action = SOAP_ACTIONS[:capture]
|
257
|
+
request = build_xml_request(soap_action, properties)
|
258
|
+
commit(soap_action, request)
|
259
|
+
end
|
260
|
+
|
261
|
+
def send_credit(transaction_number, amount, options = {})
|
262
|
+
properties = {
|
263
|
+
accountNumber: @options[:account],
|
264
|
+
transactionNumber: transaction_number,
|
265
|
+
amount: amount,
|
266
|
+
orderId: options[:order_id],
|
267
|
+
vatAmount: options[:vat_amount] || 0,
|
268
|
+
additionalValues: ''
|
269
|
+
}
|
270
|
+
hash_fields = [:accountNumber, :transactionNumber, :amount, :orderId, :vatAmount, :additionalValues]
|
271
|
+
add_request_hash(properties, hash_fields)
|
272
|
+
|
273
|
+
soap_action = SOAP_ACTIONS[:credit]
|
274
|
+
request = build_xml_request(soap_action, properties)
|
275
|
+
commit(soap_action, request)
|
276
|
+
end
|
277
|
+
|
278
|
+
def send_cancel(transaction_number)
|
279
|
+
properties = {
|
280
|
+
accountNumber: @options[:account],
|
281
|
+
transactionNumber: transaction_number,
|
282
|
+
}
|
283
|
+
hash_fields = [:accountNumber, :transactionNumber]
|
284
|
+
add_request_hash(properties, hash_fields)
|
285
|
+
|
286
|
+
soap_action = SOAP_ACTIONS[:cancel]
|
287
|
+
request = build_xml_request(soap_action, properties)
|
288
|
+
commit(soap_action, request)
|
289
|
+
end
|
290
|
+
|
291
|
+
def send_create_agreement(options)
|
292
|
+
properties = {
|
293
|
+
accountNumber: @options[:account],
|
294
|
+
merchantRef: options[:merchant_ref] || '1',
|
295
|
+
description: options[:description] || options[:order_id],
|
296
|
+
purchaseOperation: 'SALE',
|
297
|
+
maxAmount: options[:max_amount] || 100000, # default to 1,000
|
298
|
+
notifyUrl: '',
|
299
|
+
startDate: options[:startDate] || '',
|
300
|
+
stopDate: options[:stopDate] || ''
|
301
|
+
}
|
302
|
+
hash_fields = [:accountNumber, :merchantRef, :description, :purchaseOperation, :maxAmount, :notifyUrl, :startDate, :stopDate]
|
303
|
+
add_request_hash(properties, hash_fields)
|
304
|
+
|
305
|
+
soap_action = SOAP_ACTIONS[:create_agreement]
|
306
|
+
request = build_xml_request(soap_action, properties)
|
307
|
+
commit(soap_action, request)
|
308
|
+
end
|
309
|
+
|
310
|
+
def send_delete_agreement(authorization)
|
311
|
+
properties = {
|
312
|
+
accountNumber: @options[:account],
|
313
|
+
agreementRef: authorization,
|
314
|
+
}
|
315
|
+
hash_fields = [:accountNumber, :agreementRef]
|
316
|
+
add_request_hash(properties, hash_fields)
|
317
|
+
|
318
|
+
soap_action = SOAP_ACTIONS[:delete_agreement]
|
319
|
+
request = build_xml_request(soap_action, properties)
|
320
|
+
commit(soap_action, request)
|
321
|
+
end
|
322
|
+
|
323
|
+
def url_for(soap_action)
|
324
|
+
File.join(base_url(soap_action), soap_action[:url])
|
325
|
+
end
|
326
|
+
|
327
|
+
def base_url(soap_action)
|
328
|
+
if soap_action[:confined]
|
329
|
+
test? ? test_confined_url : live_confined_url
|
330
|
+
else
|
331
|
+
test? ? test_external_url : live_external_url
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
# this will add a hash to the passed in properties as required by Payex requests
|
336
|
+
def add_request_hash(properties, fields)
|
337
|
+
data = fields.map { |e| properties[e] }
|
338
|
+
data << @options[:encryption_key]
|
339
|
+
properties['hash_'] = Digest::MD5.hexdigest(data.join(''))
|
340
|
+
end
|
341
|
+
|
342
|
+
def build_xml_request(soap_action, properties)
|
343
|
+
builder = Nokogiri::XML::Builder.new
|
344
|
+
builder.__send__('soap12:Envelope', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
345
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
346
|
+
'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'}) do |root|
|
347
|
+
root.__send__('soap12:Body') do |body|
|
348
|
+
body.__send__(soap_action[:name], xmlns: soap_action[:xmlns]) do |doc|
|
349
|
+
properties.each do |key, val|
|
350
|
+
doc.send(key, val)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
builder.to_xml
|
356
|
+
end
|
357
|
+
|
358
|
+
def parse(xml)
|
359
|
+
response = {}
|
360
|
+
|
361
|
+
xmldoc = Nokogiri::XML(xml)
|
362
|
+
body = xmldoc.xpath('//soap:Body/*[1]')[0].inner_text
|
363
|
+
|
364
|
+
doc = Nokogiri::XML(body)
|
365
|
+
|
366
|
+
doc.root&.xpath('*')&.each do |node|
|
367
|
+
if node.elements.size == 0
|
368
|
+
response[node.name.downcase.to_sym] = node.text
|
369
|
+
else
|
370
|
+
node.elements.each do |childnode|
|
371
|
+
name = "#{node.name.downcase}_#{childnode.name.downcase}"
|
372
|
+
response[name.to_sym] = childnode.text
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
response
|
378
|
+
end
|
379
|
+
|
380
|
+
# Commits all requests to the Payex soap endpoint
|
381
|
+
def commit(soap_action, request)
|
382
|
+
url = url_for(soap_action)
|
383
|
+
headers = {
|
384
|
+
'Content-Type' => 'application/soap+xml; charset=utf-8',
|
385
|
+
'Content-Length' => request.size.to_s
|
386
|
+
}
|
387
|
+
response = parse(ssl_post(url, request, headers))
|
388
|
+
Response.new(success?(response),
|
389
|
+
message_from(response),
|
390
|
+
response,
|
391
|
+
test: test?,
|
392
|
+
authorization: build_authorization(response)
|
393
|
+
)
|
394
|
+
end
|
395
|
+
|
396
|
+
def build_authorization(response)
|
397
|
+
# agreementref is for the store transaction, everything else gets transactionnumber
|
398
|
+
response[:transactionnumber] || response[:agreementref]
|
399
|
+
end
|
400
|
+
|
401
|
+
def success?(response)
|
402
|
+
response[:status_errorcode] == 'OK' && response[:transactionstatus] != TRANSACTION_STATUS[:failure]
|
403
|
+
end
|
404
|
+
|
405
|
+
def message_from(response)
|
406
|
+
response[:status_description]
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|