activemerchant 1.100.0 → 1.133.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1057 -0
- data/README.md +11 -9
- data/lib/active_merchant/billing/avs_result.rb +9 -9
- data/lib/active_merchant/billing/base.rb +0 -13
- data/lib/active_merchant/billing/check.rb +49 -17
- data/lib/active_merchant/billing/compatibility.rb +5 -4
- data/lib/active_merchant/billing/credit_card.rb +55 -8
- data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +38 -36
- data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
- 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 +14 -14
- data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
- data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
- data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
- data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
- data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
- data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
- data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
- data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
- data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
- data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
- data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
- data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -175
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
- data/lib/active_merchant/billing/gateways/cams.rb +10 -10
- data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
- data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
- data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
- data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
- data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
- data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
- data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
- data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
- data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
- data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
- data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
- data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
- data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
- data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
- data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
- data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
- data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
- data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
- data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
- data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
- data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
- data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
- data/lib/active_merchant/billing/gateways/element.rb +71 -21
- data/lib/active_merchant/billing/gateways/epay.rb +43 -43
- data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
- data/lib/active_merchant/billing/gateways/eway.rb +9 -9
- data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
- data/lib/active_merchant/billing/gateways/exact.rb +19 -20
- data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
- data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
- data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
- data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
- data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
- data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
- data/lib/active_merchant/billing/gateways/forte.rb +38 -22
- data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
- data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
- data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
- data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
- data/lib/active_merchant/billing/gateways/hps.rb +171 -50
- data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
- data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
- data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
- data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
- data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
- data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
- data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
- data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
- data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
- data/lib/active_merchant/billing/gateways/litle.rb +181 -45
- data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
- data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
- data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
- data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
- data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +18 -21
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +236 -150
- data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
- data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
- data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
- data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
- data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
- data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
- data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
- data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
- data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
- data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
- data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
- data/lib/active_merchant/billing/gateways/omise.rb +15 -16
- data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
- data/lib/active_merchant/billing/gateways/opp.rb +39 -33
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
- data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
- data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
- data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
- data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
- data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
- data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
- data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
- data/lib/active_merchant/billing/gateways/payex.rb +24 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
- data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
- data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
- data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
- data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
- data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
- data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
- data/lib/active_merchant/billing/gateways/payway.rb +22 -22
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +60 -21
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
- data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
- data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
- data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
- data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
- data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
- data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
- data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
- 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 +42 -16
- data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
- data/lib/active_merchant/billing/gateways/s5.rb +10 -9
- data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
- data/lib/active_merchant/billing/gateways/sage.rb +19 -21
- data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
- data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
- data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
- 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 +19 -19
- data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
- data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
- data/lib/active_merchant/billing/gateways/telr.rb +17 -18
- data/lib/active_merchant/billing/gateways/tns.rb +3 -7
- data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
- data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
- data/lib/active_merchant/billing/gateways/transax.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
- data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
- data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
- data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
- data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
- data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
- data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
- data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
- data/lib/active_merchant/billing/response.rb +25 -6
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +1 -0
- data/lib/active_merchant/connection.rb +14 -15
- data/lib/active_merchant/country.rb +3 -1
- data/lib/active_merchant/errors.rb +4 -1
- data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
- data/lib/active_merchant/network_connection_retries.rb +15 -17
- data/lib/active_merchant/post_data.rb +3 -2
- data/lib/active_merchant/posts_data.rb +2 -2
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +2 -2
- data/lib/certs/cacert.pem +1587 -2361
- data/lib/support/gateway_support.rb +1 -1
- data/lib/support/ssl_verify.rb +3 -7
- data/lib/support/ssl_version.rb +2 -3
- metadata +86 -34
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -31,18 +31,18 @@ module ActiveMerchant #:nodoc:
|
|
31
31
|
|
32
32
|
self.default_currency = 'USD'
|
33
33
|
|
34
|
-
self.supported_countries = [
|
35
|
-
self.supported_cardtypes = [
|
34
|
+
self.supported_countries = %w[US CA GB]
|
35
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
36
36
|
self.homepage_url = 'http://www.authorize.net/'
|
37
37
|
self.display_name = 'Authorize.Net'
|
38
38
|
|
39
39
|
AUTHORIZE_NET_ARB_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
|
40
40
|
|
41
41
|
RECURRING_ACTIONS = {
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
42
|
+
create: 'ARBCreateSubscription',
|
43
|
+
update: 'ARBUpdateSubscription',
|
44
|
+
cancel: 'ARBCancelSubscription',
|
45
|
+
status: 'ARBGetSubscriptionStatus'
|
46
46
|
}
|
47
47
|
|
48
48
|
# Creates a new AuthorizeNetArbGateway
|
@@ -82,9 +82,9 @@ module ActiveMerchant #:nodoc:
|
|
82
82
|
# +:interval => { :unit => :months, :length => 3 }+ (REQUIRED)
|
83
83
|
# * <tt>:duration</tt> -- A hash containing keys for the <tt>:start_date</tt> the subscription begins (also the date the
|
84
84
|
# initial billing occurs) and the total number of billing <tt>:occurrences</tt> or payments for the subscription. (REQUIRED)
|
85
|
-
def recurring(money, creditcard, options={})
|
85
|
+
def recurring(money, creditcard, options = {})
|
86
86
|
requires!(options, :interval, :duration, :billing_address)
|
87
|
-
requires!(options[:interval], :length, [
|
87
|
+
requires!(options[:interval], :length, %i[unit days months])
|
88
88
|
requires!(options[:duration], :start_date, :occurrences)
|
89
89
|
requires!(options[:billing_address], :first_name, :last_name)
|
90
90
|
|
@@ -110,7 +110,7 @@ module ActiveMerchant #:nodoc:
|
|
110
110
|
#
|
111
111
|
# * <tt>:subscription_id</tt> -- A string containing the <tt>:subscription_id</tt> of the recurring payment already in place
|
112
112
|
# for a given credit card. (REQUIRED)
|
113
|
-
def update_recurring(options={})
|
113
|
+
def update_recurring(options = {})
|
114
114
|
requires!(options, :subscription_id)
|
115
115
|
request = build_recurring_request(:update, options)
|
116
116
|
recurring_commit(:update, request)
|
@@ -126,7 +126,7 @@ module ActiveMerchant #:nodoc:
|
|
126
126
|
# * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place
|
127
127
|
# for a given credit card. (REQUIRED)
|
128
128
|
def cancel_recurring(subscription_id)
|
129
|
-
request = build_recurring_request(:cancel, :
|
129
|
+
request = build_recurring_request(:cancel, subscription_id: subscription_id)
|
130
130
|
recurring_commit(:cancel, request)
|
131
131
|
end
|
132
132
|
|
@@ -139,7 +139,7 @@ module ActiveMerchant #:nodoc:
|
|
139
139
|
# * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place
|
140
140
|
# for a given credit card. (REQUIRED)
|
141
141
|
def status_recurring(subscription_id)
|
142
|
-
request = build_recurring_request(:status, :
|
142
|
+
request = build_recurring_request(:status, subscription_id: subscription_id)
|
143
143
|
recurring_commit(:status, request)
|
144
144
|
end
|
145
145
|
|
@@ -147,13 +147,11 @@ module ActiveMerchant #:nodoc:
|
|
147
147
|
|
148
148
|
# Builds recurring billing request
|
149
149
|
def build_recurring_request(action, options = {})
|
150
|
-
unless RECURRING_ACTIONS.include?(action)
|
151
|
-
raise StandardError, "Invalid Automated Recurring Billing Action: #{action}"
|
152
|
-
end
|
150
|
+
raise StandardError, "Invalid Automated Recurring Billing Action: #{action}" unless RECURRING_ACTIONS.include?(action)
|
153
151
|
|
154
|
-
xml = Builder::XmlMarkup.new(:
|
155
|
-
xml.instruct!(:xml, :
|
156
|
-
xml.tag!("#{RECURRING_ACTIONS[action]}Request", :
|
152
|
+
xml = Builder::XmlMarkup.new(indent: 2)
|
153
|
+
xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
|
154
|
+
xml.tag!("#{RECURRING_ACTIONS[action]}Request", xmlns: AUTHORIZE_NET_ARB_NAMESPACE) do
|
157
155
|
add_merchant_authentication(xml)
|
158
156
|
# Merchant-assigned reference ID for the request
|
159
157
|
xml.tag!('refId', options[:ref_id]) if options[:ref_id]
|
@@ -232,6 +230,7 @@ module ActiveMerchant #:nodoc:
|
|
232
230
|
def add_interval(xml, options)
|
233
231
|
interval = options[:interval]
|
234
232
|
return unless interval
|
233
|
+
|
235
234
|
xml.tag!('interval') do
|
236
235
|
# The measurement of time, in association with the Interval Unit,
|
237
236
|
# that is used to define the frequency of the billing occurrences
|
@@ -246,6 +245,7 @@ module ActiveMerchant #:nodoc:
|
|
246
245
|
def add_duration(xml, options)
|
247
246
|
duration = options[:duration]
|
248
247
|
return unless duration
|
248
|
+
|
249
249
|
# The date the subscription begins
|
250
250
|
# (also the date the initial billing occurs)
|
251
251
|
xml.tag!('startDate', duration[:start_date]) if duration[:start_date]
|
@@ -255,6 +255,7 @@ module ActiveMerchant #:nodoc:
|
|
255
255
|
|
256
256
|
def add_payment_schedule(xml, options)
|
257
257
|
return unless options[:interval] || options[:duration]
|
258
|
+
|
258
259
|
xml.tag!('paymentSchedule') do
|
259
260
|
# Contains information about the interval of time between payments
|
260
261
|
add_interval(xml, options)
|
@@ -269,6 +270,7 @@ module ActiveMerchant #:nodoc:
|
|
269
270
|
# Adds customer's credit card or bank account payment information
|
270
271
|
def add_payment(xml, options)
|
271
272
|
return unless options[:credit_card] || options[:bank_account]
|
273
|
+
|
272
274
|
xml.tag!('payment') do
|
273
275
|
# Contains the customer’s credit card information
|
274
276
|
add_credit_card(xml, options)
|
@@ -283,6 +285,7 @@ module ActiveMerchant #:nodoc:
|
|
283
285
|
def add_credit_card(xml, options)
|
284
286
|
credit_card = options[:credit_card]
|
285
287
|
return unless credit_card
|
288
|
+
|
286
289
|
xml.tag!('creditCard') do
|
287
290
|
# The credit card number used for payment of the subscription
|
288
291
|
xml.tag!('cardNumber', credit_card.number)
|
@@ -297,6 +300,7 @@ module ActiveMerchant #:nodoc:
|
|
297
300
|
def add_bank_account(xml, options)
|
298
301
|
bank_account = options[:bank_account]
|
299
302
|
return unless bank_account
|
303
|
+
|
300
304
|
xml.tag!('bankAccount') do
|
301
305
|
# The type of bank account used for payment of the subscription
|
302
306
|
xml.tag!('accountType', bank_account[:account_type])
|
@@ -319,6 +323,7 @@ module ActiveMerchant #:nodoc:
|
|
319
323
|
def add_order(xml, options)
|
320
324
|
order = options[:order]
|
321
325
|
return unless order
|
326
|
+
|
322
327
|
xml.tag!('order') do
|
323
328
|
# Merchant-assigned invoice number for the subscription (optional)
|
324
329
|
xml.tag!('invoiceNumber', order[:invoice_number])
|
@@ -331,6 +336,7 @@ module ActiveMerchant #:nodoc:
|
|
331
336
|
def add_customer(xml, options)
|
332
337
|
customer = options[:customer]
|
333
338
|
return unless customer
|
339
|
+
|
334
340
|
xml.tag!('customer') do
|
335
341
|
xml.tag!('type', customer[:type]) if customer[:type]
|
336
342
|
xml.tag!('id', customer[:id]) if customer[:id]
|
@@ -346,6 +352,7 @@ module ActiveMerchant #:nodoc:
|
|
346
352
|
def add_drivers_license(xml, options)
|
347
353
|
return unless customer = options[:customer]
|
348
354
|
return unless drivers_license = customer[:drivers_license]
|
355
|
+
|
349
356
|
xml.tag!('driversLicense') do
|
350
357
|
# The customer's driver's license number
|
351
358
|
xml.tag!('number', drivers_license[:number])
|
@@ -359,6 +366,7 @@ module ActiveMerchant #:nodoc:
|
|
359
366
|
# Adds address information
|
360
367
|
def add_address(xml, container_name, address)
|
361
368
|
return if address.blank?
|
369
|
+
|
362
370
|
xml.tag!(container_name) do
|
363
371
|
xml.tag!('firstName', address[:first_name])
|
364
372
|
xml.tag!('lastName', address[:last_name])
|
@@ -386,9 +394,8 @@ module ActiveMerchant #:nodoc:
|
|
386
394
|
success = response[:result_code] == 'Ok'
|
387
395
|
|
388
396
|
Response.new(success, message, response,
|
389
|
-
:
|
390
|
-
:
|
391
|
-
)
|
397
|
+
test: test_mode,
|
398
|
+
authorization: response[:subscription_id])
|
392
399
|
end
|
393
400
|
|
394
401
|
def recurring_parse(action, xml)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
|
2
3
|
module ActiveMerchant #:nodoc:
|
3
4
|
module Billing #:nodoc:
|
4
5
|
# ==== Customer Information Manager (CIM)
|
@@ -33,55 +34,55 @@ module ActiveMerchant #:nodoc:
|
|
33
34
|
AUTHORIZE_NET_CIM_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
|
34
35
|
|
35
36
|
CIM_ACTIONS = {
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
37
|
+
create_customer_profile: 'createCustomerProfile',
|
38
|
+
create_customer_payment_profile: 'createCustomerPaymentProfile',
|
39
|
+
create_customer_shipping_address: 'createCustomerShippingAddress',
|
40
|
+
get_customer_profile: 'getCustomerProfile',
|
41
|
+
get_customer_profile_ids: 'getCustomerProfileIds',
|
42
|
+
get_customer_payment_profile: 'getCustomerPaymentProfile',
|
43
|
+
get_customer_shipping_address: 'getCustomerShippingAddress',
|
44
|
+
delete_customer_profile: 'deleteCustomerProfile',
|
45
|
+
delete_customer_payment_profile: 'deleteCustomerPaymentProfile',
|
46
|
+
delete_customer_shipping_address: 'deleteCustomerShippingAddress',
|
47
|
+
update_customer_profile: 'updateCustomerProfile',
|
48
|
+
update_customer_payment_profile: 'updateCustomerPaymentProfile',
|
49
|
+
update_customer_shipping_address: 'updateCustomerShippingAddress',
|
50
|
+
create_customer_profile_transaction: 'createCustomerProfileTransaction',
|
51
|
+
validate_customer_payment_profile: 'validateCustomerPaymentProfile'
|
51
52
|
}
|
52
53
|
|
53
54
|
CIM_TRANSACTION_TYPES = {
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
55
|
+
auth_capture: 'profileTransAuthCapture',
|
56
|
+
auth_only: 'profileTransAuthOnly',
|
57
|
+
capture_only: 'profileTransCaptureOnly',
|
58
|
+
prior_auth_capture: 'profileTransPriorAuthCapture',
|
59
|
+
refund: 'profileTransRefund',
|
60
|
+
void: 'profileTransVoid'
|
60
61
|
}
|
61
62
|
|
62
63
|
CIM_VALIDATION_MODES = {
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
64
|
+
none: 'none',
|
65
|
+
test: 'testMode',
|
66
|
+
live: 'liveMode',
|
67
|
+
old: 'oldLiveMode'
|
67
68
|
}
|
68
69
|
|
69
70
|
BANK_ACCOUNT_TYPES = {
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
71
|
+
checking: 'checking',
|
72
|
+
savings: 'savings',
|
73
|
+
business_checking: 'businessChecking'
|
73
74
|
}
|
74
75
|
|
75
76
|
ECHECK_TYPES = {
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
77
|
+
ccd: 'CCD',
|
78
|
+
ppd: 'PPD',
|
79
|
+
web: 'WEB'
|
79
80
|
}
|
80
81
|
|
81
82
|
self.homepage_url = 'http://www.authorize.net/'
|
82
83
|
self.display_name = 'Authorize.Net CIM'
|
83
84
|
self.supported_countries = ['US']
|
84
|
-
self.supported_cardtypes = [
|
85
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
85
86
|
|
86
87
|
# Creates a new AuthorizeNetCimGateway
|
87
88
|
#
|
@@ -485,13 +486,11 @@ module ActiveMerchant #:nodoc:
|
|
485
486
|
end
|
486
487
|
|
487
488
|
def build_request(action, options = {})
|
488
|
-
unless CIM_ACTIONS.include?(action)
|
489
|
-
raise StandardError, "Invalid Customer Information Manager Action: #{action}"
|
490
|
-
end
|
489
|
+
raise StandardError, "Invalid Customer Information Manager Action: #{action}" unless CIM_ACTIONS.include?(action)
|
491
490
|
|
492
|
-
xml = Builder::XmlMarkup.new(:
|
493
|
-
xml.instruct!(:xml, :
|
494
|
-
xml.tag!("#{CIM_ACTIONS[action]}Request", :
|
491
|
+
xml = Builder::XmlMarkup.new(indent: 2)
|
492
|
+
xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
|
493
|
+
xml.tag!("#{CIM_ACTIONS[action]}Request", xmlns: AUTHORIZE_NET_CIM_NAMESPACE) do
|
495
494
|
add_merchant_authentication(xml)
|
496
495
|
# Merchant-assigned reference ID for the request
|
497
496
|
xml.tag!('refId', options[:ref_id]) if options[:ref_id]
|
@@ -564,6 +563,8 @@ module ActiveMerchant #:nodoc:
|
|
564
563
|
|
565
564
|
def build_get_customer_profile_request(xml, options)
|
566
565
|
xml.tag!('customerProfileId', options[:customer_profile_id])
|
566
|
+
xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
|
567
|
+
xml.tag!('includeIssuerInfo', options[:include_issuer_info]) if options[:include_issuer_info]
|
567
568
|
xml.target!
|
568
569
|
end
|
569
570
|
|
@@ -575,6 +576,7 @@ module ActiveMerchant #:nodoc:
|
|
575
576
|
xml.tag!('customerProfileId', options[:customer_profile_id])
|
576
577
|
xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
|
577
578
|
xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
|
579
|
+
xml.tag!('includeIssuerInfo', options[:include_issuer_info]) if options[:include_issuer_info]
|
578
580
|
xml.target!
|
579
581
|
end
|
580
582
|
|
@@ -657,9 +659,7 @@ module ActiveMerchant #:nodoc:
|
|
657
659
|
end
|
658
660
|
|
659
661
|
def add_transaction(xml, transaction)
|
660
|
-
unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
|
661
|
-
raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}"
|
662
|
-
end
|
662
|
+
raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}" unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
|
663
663
|
|
664
664
|
xml.tag!('transaction') do
|
665
665
|
xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
|
@@ -695,12 +695,10 @@ module ActiveMerchant #:nodoc:
|
|
695
695
|
add_order(xml, transaction[:order]) if transaction[:order].present?
|
696
696
|
|
697
697
|
end
|
698
|
-
if [
|
698
|
+
if %i[auth_capture auth_only capture_only].include?(transaction[:type])
|
699
699
|
xml.tag!('recurringBilling', transaction[:recurring_billing]) if transaction.has_key?(:recurring_billing)
|
700
700
|
end
|
701
|
-
unless [
|
702
|
-
tag_unless_blank(xml, 'cardCode', transaction[:card_code])
|
703
|
-
end
|
701
|
+
tag_unless_blank(xml, 'cardCode', transaction[:card_code]) unless %i[void refund prior_auth_capture].include?(transaction[:type])
|
704
702
|
end
|
705
703
|
end
|
706
704
|
end
|
@@ -797,6 +795,7 @@ module ActiveMerchant #:nodoc:
|
|
797
795
|
# when the payment method is credit card.
|
798
796
|
def add_credit_card(xml, credit_card)
|
799
797
|
return unless credit_card
|
798
|
+
|
800
799
|
xml.tag!('creditCard') do
|
801
800
|
# The credit card number used for payment of the subscription
|
802
801
|
xml.tag!('cardNumber', full_or_masked_card_number(credit_card.number))
|
@@ -857,7 +856,7 @@ module ActiveMerchant #:nodoc:
|
|
857
856
|
|
858
857
|
response_params = parse(action, xml)
|
859
858
|
|
860
|
-
message_element= response_params['messages']['message']
|
859
|
+
message_element = response_params['messages']['message']
|
861
860
|
first_error = message_element.is_a?(Array) ? message_element.first : message_element
|
862
861
|
message = first_error['text']
|
863
862
|
test_mode = @options[:test_requests] || message =~ /Test Mode/
|
@@ -883,7 +882,7 @@ module ActiveMerchant #:nodoc:
|
|
883
882
|
|
884
883
|
def parse_direct_response(params)
|
885
884
|
delimiter = @options[:delimiter] || ','
|
886
|
-
direct_response = {'raw' => params}
|
885
|
+
direct_response = { 'raw' => params }
|
887
886
|
direct_response_fields = params.split(delimiter)
|
888
887
|
direct_response.merge(
|
889
888
|
{
|
@@ -933,7 +932,7 @@ module ActiveMerchant #:nodoc:
|
|
933
932
|
'card_type' => direct_response_fields[51] || '',
|
934
933
|
'split_tender_id' => direct_response_fields[52] || '',
|
935
934
|
'requested_amount' => direct_response_fields[53] || '',
|
936
|
-
'balance_on_card' => direct_response_fields[54] || ''
|
935
|
+
'balance_on_card' => direct_response_fields[54] || ''
|
937
936
|
}
|
938
937
|
)
|
939
938
|
end
|
@@ -942,9 +941,7 @@ module ActiveMerchant #:nodoc:
|
|
942
941
|
xml = REXML::Document.new(xml)
|
943
942
|
root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") ||
|
944
943
|
REXML::XPath.first(xml, '//ErrorResponse')
|
945
|
-
if root
|
946
|
-
response = parse_element(root)
|
947
|
-
end
|
944
|
+
response = parse_element(root) if root
|
948
945
|
|
949
946
|
response
|
950
947
|
end
|
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
|
|
8
8
|
GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT MX NL
|
9
9
|
NO PL PT RO RU SE SI SK TR US VA)
|
10
10
|
|
11
|
-
self.supported_cardtypes = [
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb maestro]
|
12
12
|
|
13
13
|
self.homepage_url = 'http://www.axcessms.com/'
|
14
14
|
self.display_name = 'Axcess MS'
|
@@ -23,33 +23,33 @@ module ActiveMerchant #:nodoc:
|
|
23
23
|
PAYMENT_CODE_REFUND = 'CC.RF'
|
24
24
|
PAYMENT_CODE_REBILL = 'CC.RB'
|
25
25
|
|
26
|
-
def initialize(options={})
|
26
|
+
def initialize(options = {})
|
27
27
|
requires!(options, :sender, :login, :password, :channel)
|
28
28
|
super
|
29
29
|
end
|
30
30
|
|
31
|
-
def purchase(money, payment, options={})
|
31
|
+
def purchase(money, payment, options = {})
|
32
32
|
payment_code = payment.respond_to?(:number) ? PAYMENT_CODE_DEBIT : PAYMENT_CODE_REBILL
|
33
33
|
commit(payment_code, money, payment, options)
|
34
34
|
end
|
35
35
|
|
36
|
-
def authorize(money, authorization, options={})
|
36
|
+
def authorize(money, authorization, options = {})
|
37
37
|
commit(PAYMENT_CODE_PREAUTHORIZATION, money, authorization, options)
|
38
38
|
end
|
39
39
|
|
40
|
-
def capture(money, authorization, options={})
|
40
|
+
def capture(money, authorization, options = {})
|
41
41
|
commit(PAYMENT_CODE_CAPTURE, money, authorization, options)
|
42
42
|
end
|
43
43
|
|
44
|
-
def refund(money, authorization, options={})
|
44
|
+
def refund(money, authorization, options = {})
|
45
45
|
commit(PAYMENT_CODE_REFUND, money, authorization, options)
|
46
46
|
end
|
47
47
|
|
48
|
-
def void(authorization, options={})
|
48
|
+
def void(authorization, options = {})
|
49
49
|
commit(PAYMENT_CODE_REVERSAL, nil, authorization, options)
|
50
50
|
end
|
51
51
|
|
52
|
-
def verify(credit_card, options={})
|
52
|
+
def verify(credit_card, options = {})
|
53
53
|
MultiResponse.run(:use_first_response) do |r|
|
54
54
|
r.process { authorize(100, credit_card, options) }
|
55
55
|
r.process(:ignore_result) { void(r.authorization, options) }
|
@@ -72,9 +72,8 @@ module ActiveMerchant #:nodoc:
|
|
72
72
|
authorization = response[:unique_id]
|
73
73
|
|
74
74
|
Response.new(success, message, response,
|
75
|
-
:
|
76
|
-
:
|
77
|
-
)
|
75
|
+
authorization: authorization,
|
76
|
+
test: (response[:mode] != 'LIVE'))
|
78
77
|
end
|
79
78
|
|
80
79
|
def parse(body)
|
@@ -93,9 +92,7 @@ module ActiveMerchant #:nodoc:
|
|
93
92
|
end
|
94
93
|
|
95
94
|
def parse_element(response, node)
|
96
|
-
if node.has_attributes?
|
97
|
-
node.attributes.each { |name, value| response["#{node.name}_#{name}".underscore.to_sym] = value }
|
98
|
-
end
|
95
|
+
node.attributes.each { |name, value| response["#{node.name}_#{name}".underscore.to_sym] = value } if node.has_attributes?
|
99
96
|
|
100
97
|
if node.has_elements?
|
101
98
|
node.elements.each { |element| parse_element(response, element) }
|
@@ -105,7 +102,7 @@ module ActiveMerchant #:nodoc:
|
|
105
102
|
end
|
106
103
|
|
107
104
|
def build_request(payment_code, money, payment, options)
|
108
|
-
xml = Builder::XmlMarkup.new :
|
105
|
+
xml = Builder::XmlMarkup.new indent: 2
|
109
106
|
xml.instruct!
|
110
107
|
xml.tag! 'Request', 'version' => API_VERSION do
|
111
108
|
xml.tag! 'Header' do
|
@@ -168,6 +165,7 @@ module ActiveMerchant #:nodoc:
|
|
168
165
|
|
169
166
|
def add_address(xml, address)
|
170
167
|
raise ArgumentError.new('Address is required') unless address
|
168
|
+
|
171
169
|
xml.tag! 'Address' do
|
172
170
|
xml.tag! 'Street', "#{address[:address1]} #{address[:address2]}".strip
|
173
171
|
xml.tag! 'City', address[:city]
|
@@ -22,7 +22,7 @@ module ActiveMerchant #:nodoc:
|
|
22
22
|
self.live_url = 'https://api.balancedpayments.com'
|
23
23
|
|
24
24
|
self.supported_countries = ['US']
|
25
|
-
self.supported_cardtypes = [
|
25
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
26
26
|
self.homepage_url = 'https://www.balancedpayments.com/'
|
27
27
|
self.display_name = 'Balanced'
|
28
28
|
self.money_format = :cents
|
@@ -44,12 +44,13 @@ module ActiveMerchant #:nodoc:
|
|
44
44
|
add_common_params(post, options)
|
45
45
|
|
46
46
|
MultiResponse.run do |r|
|
47
|
-
identifier =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
53
54
|
r.process { commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post) }
|
54
55
|
end
|
55
56
|
end
|
@@ -61,12 +62,13 @@ module ActiveMerchant #:nodoc:
|
|
61
62
|
add_common_params(post, options)
|
62
63
|
|
63
64
|
MultiResponse.run do |r|
|
64
|
-
identifier =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
70
72
|
r.process { commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post) }
|
71
73
|
end
|
72
74
|
end
|
@@ -97,7 +99,7 @@ module ActiveMerchant #:nodoc:
|
|
97
99
|
commit('refunds', "debits/#{reference_identifier_from(identifier)}/refunds", post)
|
98
100
|
end
|
99
101
|
|
100
|
-
def store(credit_card, options={})
|
102
|
+
def store(credit_card, options = {})
|
101
103
|
post = {}
|
102
104
|
|
103
105
|
post[:number] = credit_card.number
|
@@ -137,7 +139,7 @@ module ActiveMerchant #:nodoc:
|
|
137
139
|
|
138
140
|
def add_address(post, options)
|
139
141
|
address = (options[:billing_address] || options[:address])
|
140
|
-
if
|
142
|
+
if address && address[:zip].present?
|
141
143
|
post[:address] = {}
|
142
144
|
post[:address][:line1] = address[:address1] if address[:address1]
|
143
145
|
post[:address][:line2] = address[:address2] if address[:address2]
|
@@ -154,18 +156,22 @@ module ActiveMerchant #:nodoc:
|
|
154
156
|
post[:meta] = options[:meta]
|
155
157
|
end
|
156
158
|
|
157
|
-
def commit(entity_name, path, post, method
|
158
|
-
raw_response =
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
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
|
169
175
|
|
170
176
|
Response.new(
|
171
177
|
success_from(entity_name, raw_response),
|
@@ -178,13 +184,13 @@ module ActiveMerchant #:nodoc:
|
|
178
184
|
|
179
185
|
def success_from(entity_name, raw_response)
|
180
186
|
entity = (raw_response[entity_name] || []).first
|
181
|
-
if
|
187
|
+
if !entity
|
182
188
|
false
|
183
|
-
elsif(
|
189
|
+
elsif (entity_name == 'refunds') && entity.include?('status')
|
184
190
|
%w(succeeded pending).include?(entity['status'])
|
185
|
-
elsif
|
191
|
+
elsif entity.include?('status')
|
186
192
|
(entity['status'] == 'succeeded')
|
187
|
-
elsif
|
193
|
+
elsif entity_name == 'cards'
|
188
194
|
!!entity['id']
|
189
195
|
else
|
190
196
|
false
|
@@ -192,7 +198,7 @@ module ActiveMerchant #:nodoc:
|
|
192
198
|
end
|
193
199
|
|
194
200
|
def message_from(raw_response)
|
195
|
-
if
|
201
|
+
if raw_response['errors']
|
196
202
|
error = raw_response['errors'].first
|
197
203
|
(error['additional'] || error['message'] || error['description'])
|
198
204
|
else
|
@@ -222,6 +228,7 @@ module ActiveMerchant #:nodoc:
|
|
222
228
|
|
223
229
|
params.map do |key, value|
|
224
230
|
next if value.blank?
|
231
|
+
|
225
232
|
if value.is_a?(Hash)
|
226
233
|
h = {}
|
227
234
|
value.each do |k, v|
|
@@ -245,10 +252,10 @@ module ActiveMerchant #:nodoc:
|
|
245
252
|
)
|
246
253
|
|
247
254
|
{
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
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
|
252
259
|
}
|
253
260
|
end
|
254
261
|
end
|