swiss-activemerchant 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +249 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +243 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +227 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +120 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class AxcessmsGateway < Gateway
|
4
|
+
include Empty
|
5
|
+
|
6
|
+
self.test_url = 'https://eu-test.oppwa.com/'
|
7
|
+
self.live_url = 'https://eu-prod.oppwa.com/'
|
8
|
+
|
9
|
+
self.supported_countries = %w(AD AT BE BG BR CA CH CY CZ DE DK EE ES FI FO FR GB
|
10
|
+
GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT MX NL
|
11
|
+
NO PL PT RO RU SE SI SK TR US VA)
|
12
|
+
|
13
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb maestro]
|
14
|
+
|
15
|
+
self.homepage_url = 'http://www.axcessms.com/'
|
16
|
+
self.display_name = 'Axcess MS'
|
17
|
+
self.money_format = :dollars
|
18
|
+
self.default_currency = 'GBP'
|
19
|
+
|
20
|
+
API_VERSION = 'v1'
|
21
|
+
PAYMENT_CODE_PREAUTHORIZATION = 'PA'
|
22
|
+
PAYMENT_CODE_DEBIT = 'DB'
|
23
|
+
PAYMENT_CODE_CAPTURE = 'CP'
|
24
|
+
PAYMENT_CODE_REVERSAL = 'RV'
|
25
|
+
PAYMENT_CODE_REFUND = 'RF'
|
26
|
+
PAYMENT_CODE_REBILL = 'RB'
|
27
|
+
|
28
|
+
SUCCESS_CODES = %w[000.000.100 000.000.100 000.100.110]
|
29
|
+
SOFT_DECLINE_CODES = %w{
|
30
|
+
800.100.201 800.100.203 800.100.204 100.150.204 000.100.204
|
31
|
+
000.100.205 800.100.205 000.100.221 000.100.223 000.100.225
|
32
|
+
000.100.226 300.100.100
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
def initialize(options = {})
|
36
|
+
requires!(options, :token, :entityId)
|
37
|
+
super
|
38
|
+
@response_http_code = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def authorize(amount, payment_method, options = {})
|
42
|
+
post = {}
|
43
|
+
add_payment_method(post, payment_method, options)
|
44
|
+
add_customer_details(post, options)
|
45
|
+
add_three_d_secure_data(post, amount, options) if options[:three_d_secure_data].present?
|
46
|
+
add_invoice_details(post, PAYMENT_CODE_PREAUTHORIZATION, amount, options)
|
47
|
+
add_recurring_details(post, options)
|
48
|
+
commit(:authorize, post)
|
49
|
+
end
|
50
|
+
|
51
|
+
def purchase(amount, payment_method, options = {})
|
52
|
+
post = {}
|
53
|
+
add_payment_method(post, payment_method, options)
|
54
|
+
add_customer_details(post, options)
|
55
|
+
add_three_d_secure_data(post, amount, options) if options[:three_d_secure_data].present?
|
56
|
+
add_invoice_details(post, PAYMENT_CODE_DEBIT, amount, options)
|
57
|
+
add_recurring_details(post, options)
|
58
|
+
commit(:purchase, post)
|
59
|
+
end
|
60
|
+
|
61
|
+
def registration_token_purchase(amount, payment_method, options)
|
62
|
+
post = {}
|
63
|
+
add_customer_details(post, options)
|
64
|
+
add_invoice_details(post, PAYMENT_CODE_DEBIT, amount, options)
|
65
|
+
add_repeated_recurring_details(post, options)
|
66
|
+
commit(:registration_token_purchase, post, :post, payment_method)
|
67
|
+
end
|
68
|
+
|
69
|
+
def rebill(amount, authorization, options = {})
|
70
|
+
post = {}
|
71
|
+
add_invoice_details(post, PAYMENT_CODE_REBILL, amount, options)
|
72
|
+
commit(:rebill, post, :post, authorization)
|
73
|
+
end
|
74
|
+
|
75
|
+
def capture(amount, authorization, options = {})
|
76
|
+
post = {}
|
77
|
+
add_invoice_details(post, PAYMENT_CODE_CAPTURE, amount, options)
|
78
|
+
commit(:capture, post, :post, authorization)
|
79
|
+
end
|
80
|
+
|
81
|
+
def refund(amount, authorization, options = {})
|
82
|
+
post = {}
|
83
|
+
add_invoice_details(post, PAYMENT_CODE_REFUND, amount, options)
|
84
|
+
commit(:refund, post, :post, authorization)
|
85
|
+
end
|
86
|
+
|
87
|
+
def void(amount, authorization, options = {})
|
88
|
+
post = {}
|
89
|
+
add_invoice_details(post, PAYMENT_CODE_REVERSAL, amount, options)
|
90
|
+
commit(:void, post, :post, authorization)
|
91
|
+
end
|
92
|
+
|
93
|
+
def confirm(authorization)
|
94
|
+
post = {}
|
95
|
+
commit(:confirm, post, :get, authorization)
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def add_payment_method(post, payment_method, options)
|
101
|
+
post["createRegistration"] = true
|
102
|
+
post["card.number"] = payment_method.number
|
103
|
+
post["card.expiryMonth"] = format(payment_method.month, :two_digits)
|
104
|
+
post["card.expiryYear"] = format(payment_method.year, :four_digits)
|
105
|
+
post["card.cvv"] = payment_method.verification_value unless empty?(payment_method.verification_value)
|
106
|
+
post["card.holder"] = options[:billing_address][:name] if options[:billing_address].present?
|
107
|
+
end
|
108
|
+
|
109
|
+
def add_customer_details(post, options)
|
110
|
+
post["customer.email"] = options[:email]
|
111
|
+
post["customer.ip"] = options[:ip]
|
112
|
+
post["customer.browser.userAgent"] = options[:browser_details][:identity] if options[:browser_details].present?
|
113
|
+
post["shopperResultUrl"] = options[:redirect_links][:success_url] if options[:redirect_links].present?
|
114
|
+
|
115
|
+
if options[:billing_address].present?
|
116
|
+
post["billing.street1"] = options[:billing_address][:address1]
|
117
|
+
post["billing.street2"] = options[:billing_address][:address2]
|
118
|
+
post["billing.city"] = options[:billing_address][:city]
|
119
|
+
post["billing.postcode"] = options[:billing_address][:zip]
|
120
|
+
post["billing.state"] = options[:billing_address][:state]
|
121
|
+
post["billing.country"] = options[:billing_address][:country]
|
122
|
+
post['customer.phone'] = options[:billing_address][:phone]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_invoice_details(post, payment_code, amount, options)
|
127
|
+
post["amount"] = localized_amount(amount, options[:currency])
|
128
|
+
post["currency"] = options[:currency]
|
129
|
+
post["paymentType"] = payment_code
|
130
|
+
end
|
131
|
+
|
132
|
+
def add_three_d_secure_data(post, amount, options)
|
133
|
+
post["threeDSecure.challengeIndicator"]= options[:three_d_secure_data][:challengeIndicator]
|
134
|
+
post["threeDSecure.exemptionFlag"]= options[:three_d_secure_data][:exemptionFlag]
|
135
|
+
post["threeDSecure.verificationId"]= options[:three_d_secure_data][:verificationId]
|
136
|
+
post["threeDSecure.eci"]= options[:three_d_secure_data][:eci]
|
137
|
+
post["threeDSecure.xid"]= options[:three_d_secure_data][:xid]
|
138
|
+
end
|
139
|
+
|
140
|
+
def add_recurring_details(post, options)
|
141
|
+
post["standingInstruction.type"] = "RECURRING"
|
142
|
+
post["standingInstruction.mode"] = "INITIAL"
|
143
|
+
post["standingInstruction.source"] = "CIT"
|
144
|
+
end
|
145
|
+
|
146
|
+
def add_repeated_recurring_details(post, options)
|
147
|
+
post["standingInstruction.type"] = "RECURRING"
|
148
|
+
post["standingInstruction.mode"] = "REPEATED"
|
149
|
+
post["standingInstruction.source"] = "MIT"
|
150
|
+
end
|
151
|
+
|
152
|
+
def commit(action, params, method = :post, authorization=nil)
|
153
|
+
params = params.merge("entityId" => @options[:entityId])
|
154
|
+
request_body = post_data(action, params)
|
155
|
+
request_endpoint = url(action, authorization)
|
156
|
+
raw_response = if method == :post
|
157
|
+
ssl_post(request_endpoint, request_body, headers)
|
158
|
+
else
|
159
|
+
request_endpoint = request_endpoint + "?#{request_body}"
|
160
|
+
ssl_get(request_endpoint, headers)
|
161
|
+
end
|
162
|
+
response = JSON.parse(raw_response)
|
163
|
+
|
164
|
+
succeeded = success_from(response)
|
165
|
+
Response.new(
|
166
|
+
succeeded,
|
167
|
+
message_from(succeeded, response),
|
168
|
+
response,
|
169
|
+
authorization: authorization_from(response, params["paymentType"]),
|
170
|
+
response_type: response_type(response.dig('result', 'code')),
|
171
|
+
test: test?,
|
172
|
+
response_http_code: @response_http_code,
|
173
|
+
request_endpoint:,
|
174
|
+
request_method: method,
|
175
|
+
request_body: params
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
def base_url
|
180
|
+
test? ? test_url : live_url
|
181
|
+
end
|
182
|
+
|
183
|
+
def url(action, authorization)
|
184
|
+
case action
|
185
|
+
when :authorize, :purchase
|
186
|
+
"#{base_url}#{API_VERSION}/payments"
|
187
|
+
when :capture, :refund, :void, :rebill, :confirm
|
188
|
+
"#{base_url}#{API_VERSION}/payments/#{split_authorization(authorization)}"
|
189
|
+
when :registration_token_purchase
|
190
|
+
"#{base_url}#{API_VERSION}/registrations/#{authorization}/payments"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def headers
|
195
|
+
headers = { 'Authorization' => 'Bearer ' + @options[:token] }
|
196
|
+
headers
|
197
|
+
end
|
198
|
+
|
199
|
+
def post_data(action, params)
|
200
|
+
params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
201
|
+
end
|
202
|
+
|
203
|
+
def authorization_from(response, payment_type)
|
204
|
+
authorization = response["id"].present? ? response["id"] : "Failed"
|
205
|
+
[authorization, payment_type].join('#')
|
206
|
+
end
|
207
|
+
|
208
|
+
def split_authorization(authorization)
|
209
|
+
transaction_id, = authorization.split('#')
|
210
|
+
transaction_id
|
211
|
+
end
|
212
|
+
|
213
|
+
def message_from(succeeded, response)
|
214
|
+
if succeeded
|
215
|
+
'Succeeded'
|
216
|
+
else
|
217
|
+
response.dig('result', 'description') == 'transaction pending' ? '3DS_REQUIRED' : response.dig('result', 'description')
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def success_from(response)
|
222
|
+
code = response.dig('result', 'code')
|
223
|
+
SUCCESS_CODES.include?(code)
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
def response_type(code)
|
228
|
+
if SUCCESS_CODES.include?(code)
|
229
|
+
0
|
230
|
+
elsif SOFT_DECLINE_CODES.include?(code)
|
231
|
+
1
|
232
|
+
else
|
233
|
+
2
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def handle_response(response)
|
238
|
+
@response_http_code = response.code.to_i
|
239
|
+
response.body
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# For more information on Balanced visit https://www.balancedpayments.com
|
6
|
+
# or visit #balanced on irc.freenode.net
|
7
|
+
#
|
8
|
+
# Instantiate a instance of BalancedGateway by passing through your
|
9
|
+
# Balanced API key secret.
|
10
|
+
#
|
11
|
+
# ==== To obtain an API key of your own
|
12
|
+
#
|
13
|
+
# 1. Visit https://www.balancedpayments.com
|
14
|
+
# 2. Click "Get started"
|
15
|
+
# 3. The next screen will give you a test API key of your own
|
16
|
+
# 4. When you're ready to generate a production API key click the "Go
|
17
|
+
# live" button on the Balanced dashboard and fill in your marketplace
|
18
|
+
# details.
|
19
|
+
class BalancedGateway < Gateway
|
20
|
+
VERSION = '2.0.0'
|
21
|
+
|
22
|
+
self.live_url = 'https://api.balancedpayments.com'
|
23
|
+
|
24
|
+
self.supported_countries = ['US']
|
25
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
26
|
+
self.homepage_url = 'https://www.balancedpayments.com/'
|
27
|
+
self.display_name = 'Balanced'
|
28
|
+
self.money_format = :cents
|
29
|
+
|
30
|
+
# Creates a new BalancedGateway
|
31
|
+
#
|
32
|
+
# ==== Options
|
33
|
+
#
|
34
|
+
# * <tt>:login</tt> -- The Balanced API Secret (REQUIRED)
|
35
|
+
def initialize(options = {})
|
36
|
+
requires!(options, :login)
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def purchase(money, payment_method, options = {})
|
41
|
+
post = {}
|
42
|
+
add_amount(post, money)
|
43
|
+
post[:description] = options[:description]
|
44
|
+
add_common_params(post, options)
|
45
|
+
|
46
|
+
MultiResponse.run do |r|
|
47
|
+
identifier =
|
48
|
+
if payment_method.respond_to?(:number)
|
49
|
+
r.process { store(payment_method, options) }
|
50
|
+
r.authorization
|
51
|
+
else
|
52
|
+
payment_method
|
53
|
+
end
|
54
|
+
r.process { commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def authorize(money, payment_method, options = {})
|
59
|
+
post = {}
|
60
|
+
add_amount(post, money)
|
61
|
+
post[:description] = options[:description]
|
62
|
+
add_common_params(post, options)
|
63
|
+
|
64
|
+
MultiResponse.run do |r|
|
65
|
+
identifier =
|
66
|
+
if payment_method.respond_to?(:number)
|
67
|
+
r.process { store(payment_method, options) }
|
68
|
+
r.authorization
|
69
|
+
else
|
70
|
+
payment_method
|
71
|
+
end
|
72
|
+
r.process { commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post) }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def capture(money, identifier, options = {})
|
77
|
+
post = {}
|
78
|
+
add_amount(post, money)
|
79
|
+
post[:description] = options[:description] if options[:description]
|
80
|
+
add_common_params(post, options)
|
81
|
+
|
82
|
+
commit('debits', "card_holds/#{reference_identifier_from(identifier)}/debits", post)
|
83
|
+
end
|
84
|
+
|
85
|
+
def void(identifier, options = {})
|
86
|
+
post = {}
|
87
|
+
post[:is_void] = true
|
88
|
+
add_common_params(post, options)
|
89
|
+
|
90
|
+
commit('card_holds', "card_holds/#{reference_identifier_from(identifier)}", post, :put)
|
91
|
+
end
|
92
|
+
|
93
|
+
def refund(money, identifier, options = {})
|
94
|
+
post = {}
|
95
|
+
add_amount(post, money)
|
96
|
+
post[:description] = options[:description]
|
97
|
+
add_common_params(post, options)
|
98
|
+
|
99
|
+
commit('refunds', "debits/#{reference_identifier_from(identifier)}/refunds", post)
|
100
|
+
end
|
101
|
+
|
102
|
+
def store(credit_card, options = {})
|
103
|
+
post = {}
|
104
|
+
|
105
|
+
post[:number] = credit_card.number
|
106
|
+
post[:expiration_month] = credit_card.month
|
107
|
+
post[:expiration_year] = credit_card.year
|
108
|
+
post[:cvv] = credit_card.verification_value if credit_card.verification_value?
|
109
|
+
post[:name] = credit_card.name if credit_card.name
|
110
|
+
|
111
|
+
add_address(post, options)
|
112
|
+
|
113
|
+
commit('cards', 'cards', post)
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def reference_identifier_from(identifier)
|
119
|
+
case identifier
|
120
|
+
when %r{\|}
|
121
|
+
uri = identifier.
|
122
|
+
split('|').
|
123
|
+
detect { |part| part.size > 0 }
|
124
|
+
uri.split('/')[2]
|
125
|
+
when %r{\/}
|
126
|
+
identifier.split('/')[5]
|
127
|
+
else
|
128
|
+
identifier
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def card_identifier_from(identifier)
|
133
|
+
identifier.split('/').last
|
134
|
+
end
|
135
|
+
|
136
|
+
def add_amount(post, money)
|
137
|
+
post[:amount] = amount(money) if money
|
138
|
+
end
|
139
|
+
|
140
|
+
def add_address(post, options)
|
141
|
+
address = (options[:billing_address] || options[:address])
|
142
|
+
if address && address[:zip].present?
|
143
|
+
post[:address] = {}
|
144
|
+
post[:address][:line1] = address[:address1] if address[:address1]
|
145
|
+
post[:address][:line2] = address[:address2] if address[:address2]
|
146
|
+
post[:address][:city] = address[:city] if address[:city]
|
147
|
+
post[:address][:state] = address[:state] if address[:state]
|
148
|
+
post[:address][:postal_code] = address[:zip] if address[:zip]
|
149
|
+
post[:address][:country_code] = address[:country] if address[:country]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def add_common_params(post, options)
|
154
|
+
post[:appears_on_statement_as] = options[:appears_on_statement_as]
|
155
|
+
post[:on_behalf_of_uri] = options[:on_behalf_of_uri]
|
156
|
+
post[:meta] = options[:meta]
|
157
|
+
end
|
158
|
+
|
159
|
+
def commit(entity_name, path, post, method = :post)
|
160
|
+
raw_response =
|
161
|
+
begin
|
162
|
+
parse(
|
163
|
+
ssl_request(
|
164
|
+
method,
|
165
|
+
live_url + "/#{path}",
|
166
|
+
post_data(post),
|
167
|
+
headers
|
168
|
+
)
|
169
|
+
)
|
170
|
+
rescue ResponseError => e
|
171
|
+
raise unless e.response.code.to_s =~ /4\d\d/
|
172
|
+
|
173
|
+
parse(e.response.body)
|
174
|
+
end
|
175
|
+
|
176
|
+
Response.new(
|
177
|
+
success_from(entity_name, raw_response),
|
178
|
+
message_from(raw_response),
|
179
|
+
raw_response,
|
180
|
+
authorization: authorization_from(entity_name, raw_response),
|
181
|
+
test: test?
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
def success_from(entity_name, raw_response)
|
186
|
+
entity = (raw_response[entity_name] || []).first
|
187
|
+
if !entity
|
188
|
+
false
|
189
|
+
elsif (entity_name == 'refunds') && entity.include?('status')
|
190
|
+
%w(succeeded pending).include?(entity['status'])
|
191
|
+
elsif entity.include?('status')
|
192
|
+
(entity['status'] == 'succeeded')
|
193
|
+
elsif entity_name == 'cards'
|
194
|
+
!!entity['id']
|
195
|
+
else
|
196
|
+
false
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def message_from(raw_response)
|
201
|
+
if raw_response['errors']
|
202
|
+
error = raw_response['errors'].first
|
203
|
+
(error['additional'] || error['message'] || error['description'])
|
204
|
+
else
|
205
|
+
'Success'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def authorization_from(entity_name, raw_response)
|
210
|
+
entity = (raw_response[entity_name] || []).first
|
211
|
+
(entity && entity['id'])
|
212
|
+
end
|
213
|
+
|
214
|
+
def parse(body)
|
215
|
+
JSON.parse(body)
|
216
|
+
rescue JSON::ParserError
|
217
|
+
message = 'Invalid response received from the Balanced API. Please contact support@balancedpayments.com if you continue to receive this message.'
|
218
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
219
|
+
{
|
220
|
+
'errors' => [{
|
221
|
+
'message' => message
|
222
|
+
}]
|
223
|
+
}
|
224
|
+
end
|
225
|
+
|
226
|
+
def post_data(params)
|
227
|
+
return nil unless params
|
228
|
+
|
229
|
+
params.map do |key, value|
|
230
|
+
next if value.blank?
|
231
|
+
|
232
|
+
if value.is_a?(Hash)
|
233
|
+
h = {}
|
234
|
+
value.each do |k, v|
|
235
|
+
h["#{key}[#{k}]"] = v unless v.blank?
|
236
|
+
end
|
237
|
+
post_data(h)
|
238
|
+
else
|
239
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
240
|
+
end
|
241
|
+
end.compact.join('&')
|
242
|
+
end
|
243
|
+
|
244
|
+
def headers
|
245
|
+
@@ua ||= JSON.dump(
|
246
|
+
bindings_version: ActiveMerchant::VERSION,
|
247
|
+
lang: 'ruby',
|
248
|
+
lang_version: "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
|
249
|
+
lib_version: BalancedGateway::VERSION,
|
250
|
+
platform: RUBY_PLATFORM,
|
251
|
+
publisher: 'active_merchant'
|
252
|
+
)
|
253
|
+
|
254
|
+
{
|
255
|
+
'Authorization' => 'Basic ' + Base64.encode64(@options[:login].to_s + ':').strip,
|
256
|
+
'User-Agent' => "Balanced/v1.1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
257
|
+
'Accept' => 'application/vnd.api+json;revision=1.1',
|
258
|
+
'X-Balanced-User-Agent' => @@ua
|
259
|
+
}
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|