activemerchant 1.45.0 → 1.126.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +2167 -2
- data/CONTRIBUTORS +57 -0
- data/README.md +62 -41
- data/lib/active_merchant/billing/avs_result.rb +25 -28
- data/lib/active_merchant/billing/base.rb +11 -35
- data/lib/active_merchant/billing/check.rb +28 -24
- data/lib/active_merchant/billing/compatibility.rb +10 -12
- data/lib/active_merchant/billing/credit_card.rb +141 -69
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
- data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +125 -61
- data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
- data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
- data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
- data/lib/active_merchant/billing/gateways/banwire.rb +24 -13
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
- data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +143 -62
- data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
- data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
- data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
- data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
- data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
- data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
- data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
- data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
- data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
- data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
- data/lib/active_merchant/billing/gateways/element.rb +386 -0
- data/lib/active_merchant/billing/gateways/epay.rb +92 -71
- data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
- data/lib/active_merchant/billing/gateways/eway.rb +85 -73
- data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
- data/lib/active_merchant/billing/gateways/exact.rb +37 -36
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
- data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
- data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
- data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
- data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
- data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
- data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
- data/lib/active_merchant/billing/gateways/hps.rb +252 -68
- data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
- data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
- data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
- data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
- data/lib/active_merchant/billing/gateways/litle.rb +371 -94
- data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
- data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
- data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
- data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +101 -37
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +422 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
- data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
- data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
- data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
- data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
- data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
- data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
- data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
- data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
- data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
- data/lib/active_merchant/billing/gateways/payex.rb +39 -42
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
- data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
- data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
- data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
- data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
- data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
- data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
- data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
- data/lib/active_merchant/billing/gateways/payway.rb +27 -27
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +113 -37
- data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
- data/lib/active_merchant/billing/gateways/priority.rb +369 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
- data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
- data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
- data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
- data/lib/active_merchant/billing/gateways/realex.rb +154 -52
- data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +404 -133
- data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
- data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
- data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
- data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
- data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
- data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +16 -217
- data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +6 -8
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
- data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
- data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
- data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
- data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
- data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
- data/lib/active_merchant/billing/gateways.rb +8 -11
- data/lib/active_merchant/billing/model.rb +2 -2
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +1 -1
- data/lib/active_merchant/billing/rails.rb +1 -1
- data/lib/active_merchant/billing/response.rb +19 -13
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +3 -0
- data/lib/active_merchant/connection.rb +196 -0
- data/lib/active_merchant/country.rb +13 -8
- data/lib/active_merchant/errors.rb +6 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +14 -59
- data/lib/activemerchant.rb +1 -1
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +8 -10
- data/lib/support/outbound_hosts.rb +13 -10
- data/lib/support/ssl_verify.rb +9 -14
- data/lib/support/ssl_version.rb +86 -0
- metadata +136 -94
- checksums.yaml.gz.sig +0 -1
- data/lib/active_merchant/billing/gateways/app55.rb +0 -176
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
- data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
- data/lib/active_merchant/offsite_payments_shim.rb +0 -19
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,341 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class AirwallexGateway < Gateway
|
4
|
+
self.test_url = 'https://api-demo.airwallex.com/api/v1'
|
5
|
+
self.live_url = 'https://pci-api.airwallex.com/api/v1'
|
6
|
+
|
7
|
+
# per https://www.airwallex.com/docs/online-payments__overview, cards are accepted in all EU countries
|
8
|
+
self.supported_countries = %w[AT AU BE BG CY CZ DE DK EE GR ES FI FR GB HK HR HU IE IT LT LU LV MT NL PL PT RO SE SG SI SK]
|
9
|
+
self.default_currency = 'AUD'
|
10
|
+
self.supported_cardtypes = %i[visa master]
|
11
|
+
|
12
|
+
self.homepage_url = 'https://airwallex.com/'
|
13
|
+
self.display_name = 'Airwallex'
|
14
|
+
|
15
|
+
ENDPOINTS = {
|
16
|
+
login: '/authentication/login',
|
17
|
+
setup: '/pa/payment_intents/create',
|
18
|
+
sale: '/pa/payment_intents/%{id}/confirm',
|
19
|
+
capture: '/pa/payment_intents/%{id}/capture',
|
20
|
+
refund: '/pa/refunds/create',
|
21
|
+
void: '/pa/payment_intents/%{id}/cancel'
|
22
|
+
}
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
requires!(options, :client_id, :client_api_key)
|
26
|
+
@client_id = options[:client_id]
|
27
|
+
@client_api_key = options[:client_api_key]
|
28
|
+
super
|
29
|
+
@access_token = setup_access_token
|
30
|
+
end
|
31
|
+
|
32
|
+
def purchase(money, card, options = {})
|
33
|
+
requires!(options, :return_url)
|
34
|
+
|
35
|
+
payment_intent_id = create_payment_intent(money, options)
|
36
|
+
post = {
|
37
|
+
'request_id' => request_id(options),
|
38
|
+
'merchant_order_id' => merchant_order_id(options),
|
39
|
+
'return_url' => options[:return_url]
|
40
|
+
}
|
41
|
+
add_card(post, card, options)
|
42
|
+
add_descriptor(post, options)
|
43
|
+
add_stored_credential(post, options)
|
44
|
+
post['payment_method_options'] = { 'card' => { 'auto_capture' => false } } if authorization_only?(options)
|
45
|
+
|
46
|
+
add_three_ds(post, options)
|
47
|
+
commit(:sale, post, payment_intent_id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def authorize(money, payment, options = {})
|
51
|
+
# authorize is just a purchase w/o an auto capture
|
52
|
+
purchase(money, payment, options.merge({ auto_capture: false }))
|
53
|
+
end
|
54
|
+
|
55
|
+
def capture(money, authorization, options = {})
|
56
|
+
raise ArgumentError, 'An authorization value must be provided.' if authorization.blank?
|
57
|
+
|
58
|
+
post = {
|
59
|
+
'request_id' => request_id(options),
|
60
|
+
'merchant_order_id' => merchant_order_id(options),
|
61
|
+
'amount' => amount(money)
|
62
|
+
}
|
63
|
+
add_descriptor(post, options)
|
64
|
+
|
65
|
+
commit(:capture, post, authorization)
|
66
|
+
end
|
67
|
+
|
68
|
+
def refund(money, authorization, options = {})
|
69
|
+
raise ArgumentError, 'An authorization value must be provided.' if authorization.blank?
|
70
|
+
|
71
|
+
post = {}
|
72
|
+
post[:amount] = amount(money)
|
73
|
+
post[:payment_intent_id] = authorization
|
74
|
+
post[:request_id] = request_id(options)
|
75
|
+
post[:merchant_order_id] = merchant_order_id(options)
|
76
|
+
|
77
|
+
commit(:refund, post)
|
78
|
+
end
|
79
|
+
|
80
|
+
def void(authorization, options = {})
|
81
|
+
raise ArgumentError, 'An authorization value must be provided.' if authorization.blank?
|
82
|
+
|
83
|
+
post = {}
|
84
|
+
post[:request_id] = request_id(options)
|
85
|
+
post[:merchant_order_id] = merchant_order_id(options)
|
86
|
+
add_descriptor(post, options)
|
87
|
+
|
88
|
+
commit(:void, post, authorization)
|
89
|
+
end
|
90
|
+
|
91
|
+
def verify(credit_card, options = {})
|
92
|
+
MultiResponse.run(:use_first_response) do |r|
|
93
|
+
r.process { authorize(100, credit_card, options) }
|
94
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def supports_scrubbing?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
def scrub(transcript)
|
103
|
+
transcript.
|
104
|
+
gsub(/(\\\"number\\\":\\\")\d+/, '\1[REDACTED]').
|
105
|
+
gsub(/(\\\"cvc\\\":\\\")\d+/, '\1[REDACTED]')
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def request_id(options)
|
111
|
+
options[:request_id] || generate_timestamp
|
112
|
+
end
|
113
|
+
|
114
|
+
def merchant_order_id(options)
|
115
|
+
options[:merchant_order_id] || options[:order_id] || generate_timestamp
|
116
|
+
end
|
117
|
+
|
118
|
+
def generate_timestamp
|
119
|
+
(Time.now.to_f.round(2) * 100).to_i.to_s
|
120
|
+
end
|
121
|
+
|
122
|
+
def setup_access_token
|
123
|
+
token_headers = {
|
124
|
+
'Content-Type' => 'application/json',
|
125
|
+
'x-client-id' => @client_id,
|
126
|
+
'x-api-key' => @client_api_key
|
127
|
+
}
|
128
|
+
response = ssl_post(build_request_url(:login), nil, token_headers)
|
129
|
+
JSON.parse(response)['token']
|
130
|
+
end
|
131
|
+
|
132
|
+
def build_request_url(action, id = nil)
|
133
|
+
base_url = (test? ? test_url : live_url)
|
134
|
+
base_url + ENDPOINTS[action].to_s % { id: id }
|
135
|
+
end
|
136
|
+
|
137
|
+
def create_payment_intent(money, options = {})
|
138
|
+
post = {}
|
139
|
+
add_invoice(post, money, options)
|
140
|
+
add_order(post, options)
|
141
|
+
post[:request_id] = "#{request_id(options)}_setup"
|
142
|
+
post[:merchant_order_id] = "#{merchant_order_id(options)}_setup"
|
143
|
+
add_descriptor(post, options)
|
144
|
+
|
145
|
+
response = commit(:setup, post)
|
146
|
+
raise ArgumentError.new(response.message) unless response.success?
|
147
|
+
|
148
|
+
response.params['id']
|
149
|
+
end
|
150
|
+
|
151
|
+
def add_billing(post, card, options = {})
|
152
|
+
return unless has_name_info?(card)
|
153
|
+
|
154
|
+
billing = post['payment_method']['card']['billing'] || {}
|
155
|
+
billing['email'] = options[:email] if options[:email]
|
156
|
+
billing['phone'] = options[:phone] if options[:phone]
|
157
|
+
billing['first_name'] = card.first_name
|
158
|
+
billing['last_name'] = card.last_name
|
159
|
+
billing_address = options[:billing_address]
|
160
|
+
billing['address'] = build_address(billing_address) if has_required_address_info?(billing_address)
|
161
|
+
|
162
|
+
post['payment_method']['card']['billing'] = billing
|
163
|
+
end
|
164
|
+
|
165
|
+
def has_name_info?(card)
|
166
|
+
# These fields are required if billing data is sent.
|
167
|
+
card.first_name && card.last_name
|
168
|
+
end
|
169
|
+
|
170
|
+
def has_required_address_info?(address)
|
171
|
+
# These fields are required if address data is sent.
|
172
|
+
return unless address
|
173
|
+
|
174
|
+
address[:address1] && address[:country]
|
175
|
+
end
|
176
|
+
|
177
|
+
def build_address(address)
|
178
|
+
return unless address
|
179
|
+
|
180
|
+
address_data = {} # names r hard
|
181
|
+
address_data[:country_code] = address[:country]
|
182
|
+
address_data[:street] = address[:address1]
|
183
|
+
address_data[:city] = address[:city] if address[:city] # required per doc, not in practice
|
184
|
+
address_data[:postcode] = address[:zip] if address[:zip]
|
185
|
+
address_data[:state] = address[:state] if address[:state]
|
186
|
+
address_data
|
187
|
+
end
|
188
|
+
|
189
|
+
def add_invoice(post, money, options)
|
190
|
+
post[:amount] = amount(money)
|
191
|
+
post[:currency] = (options[:currency] || currency(money))
|
192
|
+
end
|
193
|
+
|
194
|
+
def add_card(post, card, options = {})
|
195
|
+
post['payment_method'] = {
|
196
|
+
'type' => 'card',
|
197
|
+
'card' => {
|
198
|
+
'expiry_month' => format(card.month, :two_digits),
|
199
|
+
'expiry_year' => card.year.to_s,
|
200
|
+
'number' => card.number.to_s,
|
201
|
+
'name' => card.name,
|
202
|
+
'cvc' => card.verification_value
|
203
|
+
}
|
204
|
+
}
|
205
|
+
add_billing(post, card, options)
|
206
|
+
end
|
207
|
+
|
208
|
+
def add_order(post, options)
|
209
|
+
return unless shipping_address = options[:shipping_address]
|
210
|
+
|
211
|
+
physical_address = build_shipping_address(shipping_address)
|
212
|
+
first_name, last_name = split_names(shipping_address[:name])
|
213
|
+
shipping = {}
|
214
|
+
shipping[:first_name] = first_name if first_name
|
215
|
+
shipping[:last_name] = last_name if last_name
|
216
|
+
shipping[:phone_number] = shipping_address[:phone_number] if shipping_address[:phone_number]
|
217
|
+
shipping[:address] = physical_address
|
218
|
+
post[:order] = { shipping: shipping }
|
219
|
+
end
|
220
|
+
|
221
|
+
def build_shipping_address(shipping_address)
|
222
|
+
address = {}
|
223
|
+
address[:city] = shipping_address[:city]
|
224
|
+
address[:country_code] = shipping_address[:country]
|
225
|
+
address[:postcode] = shipping_address[:zip]
|
226
|
+
address[:state] = shipping_address[:state]
|
227
|
+
address[:street] = shipping_address[:address1]
|
228
|
+
address
|
229
|
+
end
|
230
|
+
|
231
|
+
def add_stored_credential(post, options)
|
232
|
+
return unless stored_credential = options[:stored_credential]
|
233
|
+
|
234
|
+
external_recurring_data = post[:external_recurring_data] = {}
|
235
|
+
|
236
|
+
case stored_credential.dig(:reason_type)
|
237
|
+
when 'recurring', 'installment'
|
238
|
+
external_recurring_data[:merchant_trigger_reason] = 'scheduled'
|
239
|
+
when 'unscheduled'
|
240
|
+
external_recurring_data[:merchant_trigger_reason] = 'unscheduled'
|
241
|
+
end
|
242
|
+
|
243
|
+
external_recurring_data[:original_transaction_id] = stored_credential.dig(:network_transaction_id)
|
244
|
+
external_recurring_data[:triggered_by] = stored_credential.dig(:initiator) == 'cardholder' ? 'customer' : 'merchant'
|
245
|
+
end
|
246
|
+
|
247
|
+
def add_three_ds(post, options)
|
248
|
+
return unless three_d_secure = options[:three_d_secure]
|
249
|
+
|
250
|
+
pm_options = post.dig('payment_method_options', 'card')
|
251
|
+
|
252
|
+
external_three_ds = {
|
253
|
+
'version': format_three_ds_version(three_d_secure),
|
254
|
+
'eci': three_d_secure[:eci]
|
255
|
+
}.merge(three_ds_version_specific_fields(three_d_secure))
|
256
|
+
|
257
|
+
pm_options ? pm_options.merge!('external_three_ds': external_three_ds) : post['payment_method_options'] = { 'card': { 'external_three_ds': external_three_ds } }
|
258
|
+
end
|
259
|
+
|
260
|
+
def format_three_ds_version(three_d_secure)
|
261
|
+
version = three_d_secure[:version].split('.')
|
262
|
+
|
263
|
+
version.push('0') until version.length == 3
|
264
|
+
version.join('.')
|
265
|
+
end
|
266
|
+
|
267
|
+
def three_ds_version_specific_fields(three_d_secure)
|
268
|
+
if three_d_secure[:version].to_f >= 2
|
269
|
+
{
|
270
|
+
'authentication_value': three_d_secure[:cavv],
|
271
|
+
'ds_transaction_id': three_d_secure[:ds_transaction_id],
|
272
|
+
'three_ds_server_transaction_id': three_d_secure[:three_ds_server_trans_id]
|
273
|
+
}
|
274
|
+
else
|
275
|
+
{
|
276
|
+
'cavv': three_d_secure[:cavv],
|
277
|
+
'xid': three_d_secure[:xid]
|
278
|
+
}
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def authorization_only?(options = {})
|
283
|
+
options.include?(:auto_capture) && options[:auto_capture] == false
|
284
|
+
end
|
285
|
+
|
286
|
+
def add_descriptor(post, options)
|
287
|
+
post[:descriptor] = options[:description] if options[:description]
|
288
|
+
end
|
289
|
+
|
290
|
+
def parse(body)
|
291
|
+
JSON.parse(body)
|
292
|
+
end
|
293
|
+
|
294
|
+
def commit(action, post, id = nil)
|
295
|
+
url = build_request_url(action, id)
|
296
|
+
post_headers = { 'Authorization' => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
297
|
+
response = parse(ssl_post(url, post_data(post), post_headers))
|
298
|
+
|
299
|
+
Response.new(
|
300
|
+
success_from(response),
|
301
|
+
message_from(response),
|
302
|
+
response,
|
303
|
+
authorization: authorization_from(response),
|
304
|
+
avs_result: AVSResult.new(code: response.dig('latest_payment_attempt', 'authentication_data', 'avs_result')),
|
305
|
+
cvv_result: CVVResult.new(response.dig('latest_payment_attempt', 'authentication_data', 'cvc_code')),
|
306
|
+
test: test?,
|
307
|
+
error_code: error_code_from(response)
|
308
|
+
)
|
309
|
+
end
|
310
|
+
|
311
|
+
def handle_response(response)
|
312
|
+
case response.code.to_i
|
313
|
+
when 200...300, 400, 404
|
314
|
+
response.body
|
315
|
+
else
|
316
|
+
raise ResponseError.new(response)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
def post_data(post)
|
321
|
+
post.to_json
|
322
|
+
end
|
323
|
+
|
324
|
+
def success_from(response)
|
325
|
+
%w(REQUIRES_PAYMENT_METHOD SUCCEEDED RECEIVED REQUIRES_CAPTURE CANCELLED).include?(response['status'])
|
326
|
+
end
|
327
|
+
|
328
|
+
def message_from(response)
|
329
|
+
response.dig('latest_payment_attempt', 'status') || response['status'] || response['message']
|
330
|
+
end
|
331
|
+
|
332
|
+
def authorization_from(response)
|
333
|
+
response.dig('latest_payment_attempt', 'payment_intent_id')
|
334
|
+
end
|
335
|
+
|
336
|
+
def error_code_from(response)
|
337
|
+
response['provider_original_response_code'] || response['code'] unless success_from(response)
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class AlliedWalletGateway < Gateway
|
4
|
+
self.display_name = 'Allied Wallet'
|
5
|
+
self.homepage_url = 'https://www.alliedwallet.com'
|
6
|
+
|
7
|
+
self.live_url = 'https://api.alliedwallet.com/merchants/'
|
8
|
+
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.money_format = :dollars
|
12
|
+
self.supported_cardtypes = %i[visa master american_express discover
|
13
|
+
diners_club jcb maestro]
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
requires!(options, :site_id, :merchant_id, :token)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def purchase(amount, payment_method, options = {})
|
21
|
+
post = {}
|
22
|
+
add_invoice(post, amount, options)
|
23
|
+
add_payment_method(post, payment_method)
|
24
|
+
add_customer_data(post, options)
|
25
|
+
|
26
|
+
commit(:purchase, post)
|
27
|
+
end
|
28
|
+
|
29
|
+
def authorize(amount, payment_method, options = {})
|
30
|
+
post = {}
|
31
|
+
add_invoice(post, amount, options)
|
32
|
+
add_payment_method(post, payment_method)
|
33
|
+
add_customer_data(post, options)
|
34
|
+
|
35
|
+
commit(:authorize, post)
|
36
|
+
end
|
37
|
+
|
38
|
+
def capture(amount, authorization, options = {})
|
39
|
+
post = {}
|
40
|
+
add_invoice(post, amount, options)
|
41
|
+
add_reference(post, authorization, :capture)
|
42
|
+
add_customer_data(post, options)
|
43
|
+
|
44
|
+
commit(:capture, post)
|
45
|
+
end
|
46
|
+
|
47
|
+
def void(authorization, options = {})
|
48
|
+
post = {}
|
49
|
+
add_reference(post, authorization, :void)
|
50
|
+
|
51
|
+
commit(:void, post)
|
52
|
+
end
|
53
|
+
|
54
|
+
def refund(amount, authorization, options = {})
|
55
|
+
post = {}
|
56
|
+
add_invoice(post, amount, options)
|
57
|
+
add_reference(post, authorization, :refund)
|
58
|
+
add_amount(post, amount)
|
59
|
+
add_customer_data(post, options)
|
60
|
+
|
61
|
+
commit(:refund, post)
|
62
|
+
end
|
63
|
+
|
64
|
+
def verify(credit_card, options = {})
|
65
|
+
MultiResponse.run(:use_first_response) do |r|
|
66
|
+
r.process { authorize(100, credit_card, options) }
|
67
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def supports_scrubbing?
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def scrub(transcript)
|
76
|
+
transcript.
|
77
|
+
gsub(%r((Authorization: Bearer )[a-zA-Z0-9._-]+)i, '\1[FILTERED]').
|
78
|
+
gsub(%r(("cardNumber\\?":\\?")[^"]*)i, '\1[FILTERED]').
|
79
|
+
gsub(%r(("cVVCode\\?":\\?")\d+[^"]*)i, '\1[FILTERED]').
|
80
|
+
gsub(%r(("cVVCode\\?":)null), '\1[BLANK]').
|
81
|
+
gsub(%r(("cVVCode\\?":\\?")\\?"), '\1[BLANK]"').
|
82
|
+
gsub(%r(("cVVCode\\?":\\?")\s+), '\1[BLANK]"')
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def add_amount(post, amount)
|
88
|
+
post[:amount] = amount
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_invoice(post, money, options)
|
92
|
+
post[:siteId] = @options[:site_id]
|
93
|
+
post[:amount] = amount(money)
|
94
|
+
post[:trackingId] = options[:order_id]
|
95
|
+
post[:currency] = options[:currency] || currency(money)
|
96
|
+
end
|
97
|
+
|
98
|
+
def add_payment_method(post, payment_method)
|
99
|
+
post[:nameOnCard] = payment_method.name
|
100
|
+
post[:cardNumber] = payment_method.number
|
101
|
+
post[:cVVCode] = payment_method.verification_value
|
102
|
+
post[:expirationYear] = format(payment_method.year, :four_digits)
|
103
|
+
post[:expirationMonth] = format(payment_method.month, :two_digits)
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_customer_data(post, options)
|
107
|
+
post[:email] = options[:email] || 'unspecified@example.com'
|
108
|
+
post[:iPAddress] = options[:ip]
|
109
|
+
if (billing_address = options[:billing_address])
|
110
|
+
post[:firstName], post[:lastName] = split_names(billing_address[:name])
|
111
|
+
post[:addressLine1] = billing_address[:address1]
|
112
|
+
post[:addressLine2] = billing_address[:address2]
|
113
|
+
post[:city] = billing_address[:city]
|
114
|
+
post[:state] = billing_address[:state]
|
115
|
+
post[:countryId] = billing_address[:country]
|
116
|
+
post[:postalCode] = billing_address[:zip]
|
117
|
+
post[:phone] = billing_address[:phone]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def add_reference(post, authorization, action)
|
122
|
+
transactions = {
|
123
|
+
capture: :authorizetransactionid,
|
124
|
+
void: :authorizeTransactionid,
|
125
|
+
refund: :referencetransactionid,
|
126
|
+
recurring: :saleTransactionid
|
127
|
+
}
|
128
|
+
post[transactions[action]] = authorization
|
129
|
+
end
|
130
|
+
|
131
|
+
ACTIONS = {
|
132
|
+
purchase: 'SALE',
|
133
|
+
authorize: 'AUTHORIZE',
|
134
|
+
capture: 'CAPTURE',
|
135
|
+
void: 'VOID',
|
136
|
+
refund: 'REFUND'
|
137
|
+
}
|
138
|
+
|
139
|
+
def commit(action, post)
|
140
|
+
begin
|
141
|
+
raw_response = ssl_post(url(action), post.to_json, headers)
|
142
|
+
response = parse(raw_response)
|
143
|
+
rescue ResponseError => e
|
144
|
+
raise unless e.response.code.to_s =~ /4\d\d/
|
145
|
+
|
146
|
+
response = parse(e.response.body)
|
147
|
+
end
|
148
|
+
|
149
|
+
succeeded = success_from(response['status'])
|
150
|
+
Response.new(
|
151
|
+
succeeded,
|
152
|
+
message_from(succeeded, response),
|
153
|
+
response,
|
154
|
+
authorization: response['id'],
|
155
|
+
avs_result: AVSResult.new(code: response['avs_response']),
|
156
|
+
cvv_result: CVVResult.new(response['cvv2_response']),
|
157
|
+
test: test?
|
158
|
+
)
|
159
|
+
rescue JSON::ParserError
|
160
|
+
unparsable_response(raw_response)
|
161
|
+
end
|
162
|
+
|
163
|
+
def unparsable_response(raw_response)
|
164
|
+
message = 'Unparsable response received from Allied Wallet. Please contact Allied Wallet if you continue to receive this message.'
|
165
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
166
|
+
return Response.new(false, message)
|
167
|
+
end
|
168
|
+
|
169
|
+
def headers
|
170
|
+
{
|
171
|
+
'Content-type' => 'application/json',
|
172
|
+
'Authorization' => 'Bearer ' + @options[:token]
|
173
|
+
}
|
174
|
+
end
|
175
|
+
|
176
|
+
def url(action)
|
177
|
+
live_url + CGI.escape(@options[:merchant_id]) + '/' + ACTIONS[action] + 'transactions'
|
178
|
+
end
|
179
|
+
|
180
|
+
def parse(body)
|
181
|
+
JSON.parse(body)
|
182
|
+
end
|
183
|
+
|
184
|
+
def parse_element(response, node)
|
185
|
+
if node.has_elements?
|
186
|
+
node.elements.each { |element| parse_element(response, element) }
|
187
|
+
else
|
188
|
+
response[node.name.underscore.to_sym] = node.text
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def success_from(response)
|
193
|
+
response == 'Successful'
|
194
|
+
end
|
195
|
+
|
196
|
+
def message_from(succeeded, response)
|
197
|
+
if succeeded
|
198
|
+
'Succeeded'
|
199
|
+
else
|
200
|
+
response['message'] || 'Unable to read error message'
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|