swiss-crm-activemerchant 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +252 -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 +242 -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 +228 -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 +354 -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 +121 -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,392 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PayArcGateway < Gateway
|
4
|
+
self.test_url = 'https://testapi.payarc.net/v1'
|
5
|
+
self.live_url = 'https://api.payarc.net/v1'
|
6
|
+
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.default_currency = 'usd'
|
9
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb]
|
10
|
+
|
11
|
+
self.homepage_url = 'https://www.payarc.net/'
|
12
|
+
self.display_name = 'PAYARC Gateway'
|
13
|
+
|
14
|
+
STANDARD_ERROR_CODE_MAPPING = {}
|
15
|
+
STANDARD_ACTIONS = {
|
16
|
+
token:
|
17
|
+
{ end_point: 'tokens',
|
18
|
+
allowed_fields: %i[card_source card_number exp_month exp_year cvv card_holder_name
|
19
|
+
address_line1 address_line2 city state zip country] },
|
20
|
+
capture:
|
21
|
+
{ end_point: 'charges',
|
22
|
+
allowed_fields: %i[amount statement_description card_id currency customer_id token_id card_source tip_amount
|
23
|
+
card_level sales_tax purchase_order supplier_reference_number customer_ref_id ship_to_zip
|
24
|
+
amex_descriptor customer_vat_number summary_commodity_code shipping_charges duty_charges
|
25
|
+
ship_from_zip destination_country_code vat_invoice order_date tax_category tax_type
|
26
|
+
tax_amount tax_rate address_line1 zip terminal_id surcharge description email receipt_phone statement_descriptor ] },
|
27
|
+
void:
|
28
|
+
{ end_point: 'charges/{{chargeID}}/void',
|
29
|
+
allowed_fields: %i[reason void_description] },
|
30
|
+
refund:
|
31
|
+
{ end_point: 'charges/{{charge_id}}/refunds',
|
32
|
+
allowed_fields: %i[amount reason description] },
|
33
|
+
credit:
|
34
|
+
{ end_point: 'refunds/wo_reference',
|
35
|
+
allowed_fields: %i[amount charge_description statement_description terminal_id card_source card_number
|
36
|
+
exp_month exp_year cvv card_holder_name address_line1 address_line2 city state zip
|
37
|
+
country currency reason receipt_phone receipt_email ] }
|
38
|
+
}
|
39
|
+
|
40
|
+
SUCCESS_STATUS = %w[
|
41
|
+
submitted_for_settlement authorized partially_submitted_for_settlement
|
42
|
+
credit partial_refund void refunded settled
|
43
|
+
]
|
44
|
+
|
45
|
+
FAILURE_STATUS = %w[not_processed failed_by_gateway invalid_track_data authorization_expired]
|
46
|
+
|
47
|
+
# The gateway must be configured with Bearer token.
|
48
|
+
#
|
49
|
+
# <tt>:api_key</tt> PAYARC's Bearer token must be passsed to initialise the gateway.
|
50
|
+
|
51
|
+
def initialize(options = {})
|
52
|
+
requires!(options, :api_key)
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Purchase API through PAYARC.
|
58
|
+
#
|
59
|
+
# <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
|
60
|
+
#
|
61
|
+
# <tt>:creditcard</tt> <tt>CreditCard</tt> object with card details.
|
62
|
+
#
|
63
|
+
# <tt>:options</tt> Other information like address, card source etc can be passed in options
|
64
|
+
#
|
65
|
+
# ==== Options
|
66
|
+
#
|
67
|
+
# * <tt>:card_source </tt> -- Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )
|
68
|
+
# * <tt>:currency </tt> -- Three-letter ISO currency code, in lowercase (REQUIRED)
|
69
|
+
# * <tt>:card_holder_name</tt> --Name of the Card Holder (OPTIONAL)
|
70
|
+
# * <tt>:address_line1</tt> -- Set in payment method's billing address (OPTIONAL)
|
71
|
+
# * <tt>:address_line2</tt> -- Set in payment method's billing address (OPTIONAL)
|
72
|
+
# * <tt>:state </tt> -- State (OPTIONAL)
|
73
|
+
# * <tt>:country </tt> -- Country (OPTIONAL)
|
74
|
+
# * <tt>:statement_description </tt> -- An arbitrary string to be displayed on your costomer's credit card statement. This may be up to 22 characters. (OPTIONAL)
|
75
|
+
# * <tt> :card_level </tt> -- Commercial card level - "LEVEL2" OR "LEVEL3" (OPTIONAL)
|
76
|
+
# * <tt> :sales_tax </tt> -- A positive integer in cents representing sales tax. (OPTIONAL)
|
77
|
+
# * <tt> :terminal_id </tt> -- Optional terminal id. (OPTIONAL)
|
78
|
+
# * <tt> :tip_amount </tt> -- A positive integer in cents representing tip amount. (OPTIONAL)
|
79
|
+
# * <tt> :sales_tax </tt> -- Applicable for LEVEL2 or LEVEL3 Charge. A positive integer in cents representing sales tax. (REQUIRED for LEVEL2 0r LEVEL3)
|
80
|
+
# * <tt> :purchase_order </tt> -- Applicable for Level2 or Level3 Charge. The value used by the customer to identify an order. Issued by the buyer to the seller. (REQUIRED for LEVEL2 0r LEVEL3)
|
81
|
+
# * <tt> :order_date </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The date the order was processed. Format: Alphanumeric and Special Character |Min Length=0 Max Length=10|Allowed format: MM/DD/YYYY For example: 12/01/2016
|
82
|
+
# * <tt> :customer_ref_id </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The reference identifier supplied by the Commercial Card cardholder. Format: Alphanumeric and Special Character |Min Length=0 Max Length=17| a-z A-Z 0-9 Space <>
|
83
|
+
# * <tt> :ship_to_zip </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
|
84
|
+
# * <tt> :amex_descriptor </tt> -- Applicable for Level2 Charge for AMEX card only. The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer's AMEX card statement. Format: Alphanumeric and Special Character |Min Length=0 Max Length=40|a-z A-Z 0-9 Space <>
|
85
|
+
# * <tt> :supplier_reference_number </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 charge. The value used by the customer to identify an order. Issued by the buyer to the seller.
|
86
|
+
# * <tt> :tax_amount </tt> -- Applicable for Level3 Charge. The tax amount. Format: Numeric|Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
|
87
|
+
# * <tt> :tax_category </tt> -- Applicable for Level3 Charge. The type of tax. Formerly established through TaxCategory messages. Allowed values: SERVICE, DUTY, VAT, ALTERNATE, NATIONAL, TAX_EXEMPT
|
88
|
+
# * <tt> :customer_vat_number </tt> -- Applicable for Level3 Charge. Indicates the customer's government assigned tax identification number or the identification number assigned to their purchasing company by the tax authorities. Format: Alphanumeric and Special Character|Min Length=0 Max Length=13| a-z A-Z 0-9 Space <>
|
89
|
+
# * <tt> :summary_commodity_code </tt> -- Applicable for Level3 Charge. The international description code of the overall goods or services being supplied. Format: Alphanumeric and Special Character |Min Length=0 Max Length=4|Allowed character: a-z A-Z 0-9 Space <>
|
90
|
+
# * <tt> :shipping_charges </tt> -- Applicable for Level3 Charge. The dollar amount for shipping or freight charges applied to a product or transaction. Format: Numeric |Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
|
91
|
+
# * <tt> :duty_charges </tt> -- Applicable for Level3 Charge. Indicates the total charges for any import or export duties included in the order. Format: Numeric |Max Length=12|Allowed characters: 0-9 . (dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
|
92
|
+
# * <tt> :ship_from_zip </tt> -- Applicable for Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
|
93
|
+
# * <tt> :destination_country_code </tt> -- Applicable for Level3 Charge. The destination country code indicator. Format: Alphanumeric.
|
94
|
+
# * <tt> :tax_type </tt> -- Applicable for Level3 Charge. The type of tax. For example, VAT, NATIONAL, Service Tax. Format: Alphanumeric and Special Character
|
95
|
+
# * <tt> :vat_invoice </tt> -- Applicable for Level3 Charge. The Value Added Tax (VAT) invoice number associated with the transaction. Format: Alphanumeric and Special Character |Min Length=0 Max Length=15|Allowed character: a-z A-Z 0-9 Space <>
|
96
|
+
# * <tt> :tax_rate </tt> -- Applicable for Level3 Charge. The type of tax rate. This field is used if taxCategory is not used. Default sale tax rate in percentage Must be between 0.1% - 22% ,Applicable only Level 2 AutoFill. Format: Decimal Number |Max Length=4|Allowed characters: 0-9 .(dot) Allowed range: 0.01 - 100
|
97
|
+
# * <tt> :email </tt> -- Customer's email address sent with payment method.
|
98
|
+
|
99
|
+
def purchase(money, creditcard, options = {})
|
100
|
+
options[:capture] = 1
|
101
|
+
MultiResponse.run do |r|
|
102
|
+
r.process { token(creditcard, options) }
|
103
|
+
r.process { charge(money, r.authorization, options) }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Authorize the payment API through PAYARC.
|
109
|
+
#
|
110
|
+
# <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
|
111
|
+
#
|
112
|
+
# <tt>:creditcard</tt> <tt>CreditCard</tt> object with card details.
|
113
|
+
#
|
114
|
+
# <tt>:options</tt> Other information like address, card source etc can be passed in options
|
115
|
+
#
|
116
|
+
# ==== Options
|
117
|
+
#
|
118
|
+
# * <tt>:card_source </tt> -- Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )
|
119
|
+
# * <tt>:currency </tt> -- Three-letter ISO currency code, in lowercase (REQUIRED)
|
120
|
+
# * <tt>:card_holder_name</tt> --Name of the Card Holder (OPTIONAL)
|
121
|
+
# * <tt>:address_line1</tt> -- Set in payment method's billing address (OPTIONAL)
|
122
|
+
# * <tt>:address_line2</tt> -- Set in payment method's billing address (OPTIONAL)
|
123
|
+
# * <tt>:state </tt> -- State (OPTIONAL)
|
124
|
+
# * <tt>:country </tt> -- Country (OPTIONAL)
|
125
|
+
# * <tt>:statement_description </tt> -- An arbitrary string to be displayed on your costomer's credit card statement. This may be up to 22 characters. (OPTIONAL)
|
126
|
+
# * <tt> :card_level </tt> -- Commercial card level - "LEVEL2" OR "LEVEL3" (OPTIONAL)
|
127
|
+
# * <tt> :sales_tax </tt> -- A positive integer in cents representing sales tax. (OPTIONAL)
|
128
|
+
# * <tt> :terminal_id </tt> -- Optional terminal id. (OPTIONAL)
|
129
|
+
# * <tt> :tip_amount </tt> -- A positive integer in cents representing tip amount. (OPTIONAL)
|
130
|
+
# * <tt> :sales_tax </tt> -- Applicable for LEVEL2 or LEVEL3 Charge. A positive integer in cents representing sales tax. (REQUIRED for LEVEL2 0r LEVEL3)
|
131
|
+
# * <tt> :purchase_order </tt> -- Applicable for Level2 or Level3 Charge. The value used by the customer to identify an order. Issued by the buyer to the seller. (REQUIRED for LEVEL2 0r LEVEL3)
|
132
|
+
# * <tt> :order_date </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The date the order was processed. Format: Alphanumeric and Special Character |Min Length=0 Max Length=10|Allowed format: MM/DD/YYYY For example: 12/01/2016
|
133
|
+
# * <tt> :customer_ref_id </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The reference identifier supplied by the Commercial Card cardholder. Format: Alphanumeric and Special Character |Min Length=0 Max Length=17| a-z A-Z 0-9 Space <>
|
134
|
+
# * <tt> :ship_to_zip </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
|
135
|
+
# * <tt> :amex_descriptor </tt> -- Applicable for Level2 Charge for AMEX card only. The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer's AMEX card statement. Format: Alphanumeric and Special Character |Min Length=0 Max Length=40|a-z A-Z 0-9 Space <>
|
136
|
+
# * <tt> :supplier_reference_number </tt> -- Applicable for Level2 Charge for AMEX card only or Level3 charge. The value used by the customer to identify an order. Issued by the buyer to the seller.
|
137
|
+
# * <tt> :tax_amount </tt> -- Applicable for Level3 Charge. The tax amount. Format: Numeric|Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
|
138
|
+
# * <tt> :tax_category </tt> -- Applicable for Level3 Charge. The type of tax. Formerly established through TaxCategory messages. Allowed values: SERVICE, DUTY, VAT, ALTERNATE, NATIONAL, TAX_EXEMPT
|
139
|
+
# * <tt> :customer_vat_number </tt> -- Applicable for Level3 Charge. Indicates the customer's government assigned tax identification number or the identification number assigned to their purchasing company by the tax authorities. Format: Alphanumeric and Special Character|Min Length=0 Max Length=13| a-z A-Z 0-9 Space <>
|
140
|
+
# * <tt> :summary_commodity_code </tt> -- Applicable for Level3 Charge. The international description code of the overall goods or services being supplied. Format: Alphanumeric and Special Character |Min Length=0 Max Length=4|Allowed character: a-z A-Z 0-9 Space <>
|
141
|
+
# * <tt> :shipping_charges </tt> -- Applicable for Level3 Charge. The dollar amount for shipping or freight charges applied to a product or transaction. Format: Numeric |Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
|
142
|
+
# * <tt> :duty_charges </tt> -- Applicable for Level3 Charge. Indicates the total charges for any import or export duties included in the order. Format: Numeric |Max Length=12|Allowed characters: 0-9 . (dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.
|
143
|
+
# * <tt> :ship_from_zip </tt> -- Applicable for Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10
|
144
|
+
# * <tt> :destination_country_code </tt> -- Applicable for Level3 Charge. The destination country code indicator. Format: Alphanumeric.
|
145
|
+
# * <tt> :tax_type </tt> -- Applicable for Level3 Charge. The type of tax. For example, VAT, NATIONAL, Service Tax. Format: Alphanumeric and Special Character
|
146
|
+
# * <tt> :vat_invoice </tt> -- Applicable for Level3 Charge. The Value Added Tax (VAT) invoice number associated with the transaction. Format: Alphanumeric and Special Character |Min Length=0 Max Length=15|Allowed character: a-z A-Z 0-9 Space <>
|
147
|
+
# * <tt> :tax_rate </tt> -- Applicable for Level3 Charge. The type of tax rate. This field is used if taxCategory is not used. Default sale tax rate in percentage Must be between 0.1% - 22% ,Applicable only Level 2 AutoFill. Format: Decimal Number |Max Length=4|Allowed characters: 0-9 .(dot) Allowed range: 0.01 - 100
|
148
|
+
# * <tt> :email </tt> -- Customer's email address.
|
149
|
+
|
150
|
+
def authorize(money, creditcard, options = {})
|
151
|
+
options[:capture] = '0'
|
152
|
+
MultiResponse.run do |r|
|
153
|
+
r.process { token(creditcard, options) }
|
154
|
+
r.process { charge(money, r.authorization, options) }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
#
|
159
|
+
# Capture the payment of an existing, uncaptured, charge.
|
160
|
+
# This is the second half of the two-step payment flow, where first you created / authorized a charge
|
161
|
+
# with the capture option set to false.
|
162
|
+
#
|
163
|
+
# <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
|
164
|
+
#
|
165
|
+
# <tt>:tx_reference</tt> charge_id from previously created / authorized a charge
|
166
|
+
#
|
167
|
+
# <tt>:options</tt> Other information like address, card source etc can be passed in options
|
168
|
+
|
169
|
+
def capture(money, tx_reference, options = {})
|
170
|
+
post = {}
|
171
|
+
add_money(post, money, options)
|
172
|
+
action = "#{STANDARD_ACTIONS[:capture][:end_point]}/#{tx_reference}/capture"
|
173
|
+
post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:capture][:allowed_fields])
|
174
|
+
commit(action, post)
|
175
|
+
end
|
176
|
+
|
177
|
+
#
|
178
|
+
# Voids the transaction / charge.
|
179
|
+
#
|
180
|
+
# <tt>:tx_reference</tt> charge_id from previously created charge
|
181
|
+
#
|
182
|
+
# <tt>:options</tt> Other information like address, card source etc can be passed in options
|
183
|
+
#
|
184
|
+
# ==== Options
|
185
|
+
#
|
186
|
+
# * <tt> :reason </tt> -- Reason for voiding transaction (REQUIRED) ( requested_by_customer, duplicate, fraudulent, other )
|
187
|
+
|
188
|
+
def void(tx_reference, options = {})
|
189
|
+
post = {}
|
190
|
+
post['reason'] = options[:reason]
|
191
|
+
action = STANDARD_ACTIONS[:void][:end_point].gsub(/{{chargeID}}/, tx_reference)
|
192
|
+
post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:void][:allowed_fields])
|
193
|
+
commit(action, post)
|
194
|
+
end
|
195
|
+
|
196
|
+
#
|
197
|
+
# Refund full / partial payment of an successful charge / capture / purchase.
|
198
|
+
#
|
199
|
+
# <tt>:money</tt> A positive integer in cents representing how much to charge. The minimum amount is 50c USD.
|
200
|
+
#
|
201
|
+
# <tt>:tx_reference</tt> charge_id from previously created / authorized a charge
|
202
|
+
#
|
203
|
+
# <tt>:options</tt> Other information like address, card source etc can be passed in options
|
204
|
+
|
205
|
+
def refund(money, tx_reference, options = {})
|
206
|
+
post = {}
|
207
|
+
add_money(post, money, options)
|
208
|
+
action = STANDARD_ACTIONS[:refund][:end_point].gsub(/{{charge_id}}/, tx_reference)
|
209
|
+
post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:refund][:allowed_fields])
|
210
|
+
commit(action, post)
|
211
|
+
end
|
212
|
+
|
213
|
+
def credit(money, creditcard, options = {})
|
214
|
+
post = {}
|
215
|
+
add_money(post, money, options)
|
216
|
+
add_creditcard(post, creditcard, options)
|
217
|
+
add_address(post, options)
|
218
|
+
add_phone(post, options)
|
219
|
+
post['receipt_email'] = options[:email] if options[:email]
|
220
|
+
action = STANDARD_ACTIONS[:credit][:end_point]
|
221
|
+
post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:credit][:allowed_fields])
|
222
|
+
commit(action, post)
|
223
|
+
end
|
224
|
+
|
225
|
+
#
|
226
|
+
# Verify the creditcard API through PAYARC.
|
227
|
+
#
|
228
|
+
# <tt>:creditcard</tt> <tt>CreditCard</tt> object with card details.
|
229
|
+
#
|
230
|
+
# <tt>:options</tt> Other information like address, card source etc can be passed in options
|
231
|
+
#
|
232
|
+
# ==== Options
|
233
|
+
#
|
234
|
+
# * <tt>:card_source </tt> -- Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )
|
235
|
+
# * <tt>:card_holder_name</tt> --Name of the Card Holder (OPTIONAL)
|
236
|
+
# * <tt>:address_line1</tt> -- Set in payment method's billing address (OPTIONAL)
|
237
|
+
# * <tt>:address_line2</tt> -- Set in payment method's billing address (OPTIONAL)
|
238
|
+
# * <tt>:state </tt> -- State (OPTIONAL)
|
239
|
+
# * <tt>:country </tt> -- Country (OPTIONAL)
|
240
|
+
|
241
|
+
def verify(creditcard, options = {})
|
242
|
+
token(creditcard, options)
|
243
|
+
end
|
244
|
+
|
245
|
+
#:nodoc:
|
246
|
+
def token(creditcard, options = {})
|
247
|
+
post = {}
|
248
|
+
post['authorize_card'] = 1
|
249
|
+
post['card_source'] = options[:card_source]
|
250
|
+
add_creditcard(post, creditcard, options)
|
251
|
+
add_address(post, options)
|
252
|
+
post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:token][:allowed_fields])
|
253
|
+
commit(STANDARD_ACTIONS[:token][:end_point], post)
|
254
|
+
end
|
255
|
+
|
256
|
+
def supports_scrubbing? #:nodoc:
|
257
|
+
true
|
258
|
+
end
|
259
|
+
|
260
|
+
def scrub(transcript)
|
261
|
+
#:nodoc:
|
262
|
+
transcript.
|
263
|
+
gsub(%r((Authorization: Bearer )[^\s]+\s)i, '\1[FILTERED]\2').
|
264
|
+
gsub(%r((&?card_number=)[^&]*)i, '\1[FILTERED]').
|
265
|
+
gsub(%r((&?cvv=)[^&]*)i, '\1[BLANK]')
|
266
|
+
end
|
267
|
+
|
268
|
+
private
|
269
|
+
|
270
|
+
def charge(money, authorization, options = {})
|
271
|
+
post = {}
|
272
|
+
post['token_id'] = authorization
|
273
|
+
post['capture'] = options[:capture] || 1
|
274
|
+
add_money(post, money, options)
|
275
|
+
add_phone(post, options)
|
276
|
+
post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:capture][:allowed_fields])
|
277
|
+
commit(STANDARD_ACTIONS[:capture][:end_point], post)
|
278
|
+
end
|
279
|
+
|
280
|
+
def add_creditcard(post, creditcard, options)
|
281
|
+
post['card_number'] = creditcard.number
|
282
|
+
post['exp_month'] = format(creditcard.month, :two_digits)
|
283
|
+
post['exp_year'] = creditcard.year
|
284
|
+
post['cvv'] = creditcard.verification_value unless creditcard.verification_value.nil?
|
285
|
+
post['card_holder_name'] = options[:card_holder_name] || "#{creditcard.first_name} #{creditcard.last_name}"
|
286
|
+
end
|
287
|
+
|
288
|
+
def add_address(post, options)
|
289
|
+
return unless billing_address = options[:billing_address]
|
290
|
+
|
291
|
+
post['address_line1'] = billing_address[:address1]
|
292
|
+
post['address_line2'] = billing_address[:address2]
|
293
|
+
post['city'] = billing_address[:city]
|
294
|
+
post['state'] = billing_address[:state]
|
295
|
+
post['zip'] = billing_address[:zip]
|
296
|
+
post['country'] = billing_address[:country]
|
297
|
+
end
|
298
|
+
|
299
|
+
def add_phone(post, options)
|
300
|
+
post['phone_number'] = options[:billing_address][:phone] if options.dig(:billing_address, :phone)
|
301
|
+
end
|
302
|
+
|
303
|
+
def add_money(post, money, options)
|
304
|
+
post['amount'] = money
|
305
|
+
post['currency'] = currency(money) unless options[:currency]
|
306
|
+
post['statement_description'] = options[:statement_description]
|
307
|
+
end
|
308
|
+
|
309
|
+
def headers(api_key)
|
310
|
+
{
|
311
|
+
'Authorization' => 'Bearer ' + api_key.strip,
|
312
|
+
'Accept' => 'application/json',
|
313
|
+
'User-Agent' => "PayArc ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
|
314
|
+
}
|
315
|
+
end
|
316
|
+
|
317
|
+
def parse(body)
|
318
|
+
JSON.parse(body)
|
319
|
+
rescue JSON::ParserError
|
320
|
+
body
|
321
|
+
end
|
322
|
+
|
323
|
+
def filter_gateway_fields(post, options, gateway_fields)
|
324
|
+
filtered_options = options.slice(*gateway_fields).compact
|
325
|
+
post.update(filtered_options)
|
326
|
+
post
|
327
|
+
end
|
328
|
+
|
329
|
+
def commit(action, parameters)
|
330
|
+
url = (test? ? test_url : live_url)
|
331
|
+
headers = headers(@options[:api_key])
|
332
|
+
end_point = "#{url}/#{action}"
|
333
|
+
begin
|
334
|
+
response = ssl_post(end_point, post_data(parameters), headers)
|
335
|
+
parsed_response = parse(response)
|
336
|
+
|
337
|
+
Response.new(
|
338
|
+
success_from(parsed_response, action),
|
339
|
+
message_from(parsed_response, action),
|
340
|
+
parsed_response,
|
341
|
+
test: test?,
|
342
|
+
authorization: parse_response_id(parsed_response),
|
343
|
+
error_code: error_code_from(parsed_response, action)
|
344
|
+
)
|
345
|
+
rescue ResponseError => e
|
346
|
+
parsed_response = parse(e.response.body)
|
347
|
+
Response.new(
|
348
|
+
false,
|
349
|
+
message_from(parsed_response, action),
|
350
|
+
parsed_response,
|
351
|
+
test: test?,
|
352
|
+
authorization: nil,
|
353
|
+
error_code: error_code_from(parsed_response, action)
|
354
|
+
)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def success_from(response, action)
|
359
|
+
if action == STANDARD_ACTIONS[:token][:end_point]
|
360
|
+
token = parse_response_id(response)
|
361
|
+
(!token.nil? && !token.empty?)
|
362
|
+
elsif response
|
363
|
+
return SUCCESS_STATUS.include? response['data']['status'] if response['data']
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def message_from(response, action)
|
368
|
+
if success_from(response, action)
|
369
|
+
if action == STANDARD_ACTIONS[:token][:end_point]
|
370
|
+
return response['data']['id']
|
371
|
+
else
|
372
|
+
return response['data']['status']
|
373
|
+
end
|
374
|
+
else
|
375
|
+
return response['message']
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def parse_response_id(response)
|
380
|
+
response['data']['id'] if response && response['data']
|
381
|
+
end
|
382
|
+
|
383
|
+
def post_data(params)
|
384
|
+
params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
385
|
+
end
|
386
|
+
|
387
|
+
def error_code_from(response, action)
|
388
|
+
response['status_code'] unless success_from(response, action)
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
@@ -0,0 +1,245 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PayConexGateway < Gateway
|
4
|
+
include Empty
|
5
|
+
|
6
|
+
self.test_url = 'https://cert.payconex.net/api/qsapi/3.8/'
|
7
|
+
self.live_url = 'https://secure.payconex.net/api/qsapi/3.8/'
|
8
|
+
|
9
|
+
self.supported_countries = %w(US CA)
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
|
12
|
+
|
13
|
+
self.homepage_url = 'http://www.bluefincommerce.com/'
|
14
|
+
self.display_name = 'PayConex'
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
requires!(options, :account_id, :api_accesskey)
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def purchase(money, payment_method, options = {})
|
22
|
+
post = {}
|
23
|
+
add_auth_purchase_params(post, money, payment_method, options)
|
24
|
+
commit('SALE', post)
|
25
|
+
end
|
26
|
+
|
27
|
+
def authorize(money, payment_method, options = {})
|
28
|
+
post = {}
|
29
|
+
add_auth_purchase_params(post, money, payment_method, options)
|
30
|
+
commit('AUTHORIZATION', post)
|
31
|
+
end
|
32
|
+
|
33
|
+
def capture(money, authorization, options = {})
|
34
|
+
post = {}
|
35
|
+
add_reference_params(post, authorization, options)
|
36
|
+
add_amount(post, money, options)
|
37
|
+
commit('CAPTURE', post)
|
38
|
+
end
|
39
|
+
|
40
|
+
def refund(money, authorization, options = {})
|
41
|
+
post = {}
|
42
|
+
add_reference_params(post, authorization, options)
|
43
|
+
add_amount(post, money, options)
|
44
|
+
commit('REFUND', post)
|
45
|
+
end
|
46
|
+
|
47
|
+
def void(authorization, options = {})
|
48
|
+
post = {}
|
49
|
+
add_reference_params(post, authorization, options)
|
50
|
+
commit('REVERSAL', post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def credit(money, payment_method, options = {})
|
54
|
+
raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' if payment_method.is_a?(String)
|
55
|
+
|
56
|
+
post = {}
|
57
|
+
add_auth_purchase_params(post, money, payment_method, options)
|
58
|
+
commit('CREDIT', post)
|
59
|
+
end
|
60
|
+
|
61
|
+
def verify(payment_method, options = {})
|
62
|
+
authorize(0, payment_method, options)
|
63
|
+
end
|
64
|
+
|
65
|
+
def store(payment_method, options = {})
|
66
|
+
post = {}
|
67
|
+
add_credentials(post)
|
68
|
+
add_payment_method(post, payment_method)
|
69
|
+
add_address(post, options)
|
70
|
+
add_common_options(post, options)
|
71
|
+
commit('STORE', post)
|
72
|
+
end
|
73
|
+
|
74
|
+
def supports_scrubbing?
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
def scrub(transcript)
|
79
|
+
force_utf8(transcript).
|
80
|
+
gsub(%r((api_accesskey=)\w+), '\1[FILTERED]').
|
81
|
+
gsub(%r((card_number=)\w+), '\1[FILTERED]').
|
82
|
+
gsub(%r((card_verification=)\w+), '\1[FILTERED]').
|
83
|
+
gsub(%r((bank_account_number=)\w+), '\1[FILTERED]').
|
84
|
+
gsub(%r((bank_routing_number=)\w+), '\1[FILTERED]')
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def force_utf8(string)
|
90
|
+
return nil unless string
|
91
|
+
|
92
|
+
binary = string.encode('BINARY', invalid: :replace, undef: :replace, replace: '?') # Needed for Ruby 2.0 since #encode is a no-op if the string is already UTF-8. It's not needed for Ruby 2.1 and up since it's not a no-op there.
|
93
|
+
binary.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_credentials(post)
|
97
|
+
post[:account_id] = @options[:account_id]
|
98
|
+
post[:api_accesskey] = @options[:api_accesskey]
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_auth_purchase_params(post, money, payment_method, options)
|
102
|
+
add_credentials(post)
|
103
|
+
add_payment_method(post, payment_method)
|
104
|
+
add_address(post, options)
|
105
|
+
add_common_options(post, options)
|
106
|
+
add_amount(post, money, options)
|
107
|
+
add_if_present(post, :email, options[:email])
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_reference_params(post, authorization, options)
|
111
|
+
add_credentials(post)
|
112
|
+
add_common_options(post, options)
|
113
|
+
add_token_id(post, authorization)
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_amount(post, money, options)
|
117
|
+
post[:transaction_amount] = amount(money)
|
118
|
+
currency_code = (options[:currency] || currency(money))
|
119
|
+
add_if_present(post, :currency, currency_code)
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_payment_method(post, payment_method)
|
123
|
+
case payment_method
|
124
|
+
when String
|
125
|
+
add_token_payment_method(post, payment_method)
|
126
|
+
when Check
|
127
|
+
add_check(post, payment_method)
|
128
|
+
else
|
129
|
+
if payment_method.respond_to?(:track_data) && payment_method.track_data.present?
|
130
|
+
add_card_present_payment_method(post, payment_method)
|
131
|
+
else
|
132
|
+
add_credit_card(post, payment_method)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def add_credit_card(post, payment_method)
|
138
|
+
post[:tender_type] = 'CARD'
|
139
|
+
post[:card_number] = payment_method.number
|
140
|
+
post[:card_expiration] = expdate(payment_method)
|
141
|
+
post[:card_verification] = payment_method.verification_value
|
142
|
+
post[:first_name] = payment_method.first_name
|
143
|
+
post[:last_name] = payment_method.last_name
|
144
|
+
end
|
145
|
+
|
146
|
+
def add_token_payment_method(post, payment_method)
|
147
|
+
post[:tender_type] = 'CARD'
|
148
|
+
post[:token_id] = payment_method
|
149
|
+
post[:reissue] = true
|
150
|
+
end
|
151
|
+
|
152
|
+
def add_card_present_payment_method(post, payment_method)
|
153
|
+
post[:tender_type] = 'CARD'
|
154
|
+
post[:card_tracks] = payment_method.track_data
|
155
|
+
end
|
156
|
+
|
157
|
+
def add_check(post, payment_method)
|
158
|
+
post[:tender_type] = 'ACH'
|
159
|
+
post[:first_name] = payment_method.first_name
|
160
|
+
post[:last_name] = payment_method.last_name
|
161
|
+
post[:bank_account_number] = payment_method.account_number
|
162
|
+
post[:bank_routing_number] = payment_method.routing_number
|
163
|
+
post[:check_number] = payment_method.number
|
164
|
+
add_if_present(post, :ach_account_type, payment_method.account_type)
|
165
|
+
end
|
166
|
+
|
167
|
+
def add_address(post, options)
|
168
|
+
address = options[:billing_address]
|
169
|
+
return unless address
|
170
|
+
|
171
|
+
add_if_present(post, :street_address1, address[:address1])
|
172
|
+
add_if_present(post, :street_address2, address[:address2])
|
173
|
+
add_if_present(post, :city, address[:city])
|
174
|
+
add_if_present(post, :state, address[:state])
|
175
|
+
add_if_present(post, :zip, address[:zip])
|
176
|
+
add_if_present(post, :country, address[:country])
|
177
|
+
add_if_present(post, :phone, address[:phone])
|
178
|
+
end
|
179
|
+
|
180
|
+
def add_common_options(post, options)
|
181
|
+
add_if_present(post, :transaction_description, options[:description])
|
182
|
+
add_if_present(post, :custom_id, options[:custom_id])
|
183
|
+
add_if_present(post, :custom_data, options[:custom_data])
|
184
|
+
add_if_present(post, :ip_address, options[:ip])
|
185
|
+
add_if_present(post, :payment_type, options[:payment_type])
|
186
|
+
add_if_present(post, :cashier, options[:cashier])
|
187
|
+
|
188
|
+
post[:disable_cvv] = options[:disable_cvv] unless options[:disable_cvv].nil?
|
189
|
+
post[:response_format] = 'JSON'
|
190
|
+
end
|
191
|
+
|
192
|
+
def add_if_present(post, key, value)
|
193
|
+
post[key] = value unless empty?(value)
|
194
|
+
end
|
195
|
+
|
196
|
+
def add_token_id(post, authorization)
|
197
|
+
post[:token_id] = authorization
|
198
|
+
end
|
199
|
+
|
200
|
+
def parse(body)
|
201
|
+
JSON.parse(body)
|
202
|
+
end
|
203
|
+
|
204
|
+
def commit(action, params)
|
205
|
+
raw_response = ssl_post(url, post_data(action, params))
|
206
|
+
response = parse(raw_response)
|
207
|
+
|
208
|
+
Response.new(
|
209
|
+
success_from(response),
|
210
|
+
message_from(response),
|
211
|
+
response,
|
212
|
+
authorization: response['transaction_id'],
|
213
|
+
avs_result: AVSResult.new(code: response['avs_response']),
|
214
|
+
cvv_result: CVVResult.new(response['cvv2_response']),
|
215
|
+
test: test?
|
216
|
+
)
|
217
|
+
rescue JSON::ParserError
|
218
|
+
unparsable_response(raw_response)
|
219
|
+
end
|
220
|
+
|
221
|
+
def url
|
222
|
+
test? ? test_url : live_url
|
223
|
+
end
|
224
|
+
|
225
|
+
def success_from(response)
|
226
|
+
response['transaction_approved'] || !response['error']
|
227
|
+
end
|
228
|
+
|
229
|
+
def message_from(response)
|
230
|
+
success_from(response) ? response['authorization_message'] : response['error_message']
|
231
|
+
end
|
232
|
+
|
233
|
+
def post_data(action, params)
|
234
|
+
params[:transaction_type] = action
|
235
|
+
params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
236
|
+
end
|
237
|
+
|
238
|
+
def unparsable_response(raw_response)
|
239
|
+
message = 'Invalid JSON response received from PayConex. Please contact PayConex if you continue to receive this message.'
|
240
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
241
|
+
return Response.new(false, message)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|