activemerchant 1.79.2 → 1.80.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +33 -0
- data/README.md +10 -2
- data/lib/active_merchant.rb +1 -1
- data/lib/active_merchant/billing/check.rb +4 -4
- data/lib/active_merchant/billing/compatibility.rb +1 -1
- data/lib/active_merchant/billing/credit_card.rb +21 -21
- data/lib/active_merchant/billing/credit_card_formatting.rb +2 -2
- data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
- data/lib/active_merchant/billing/gateway.rb +13 -13
- data/lib/active_merchant/billing/gateways/adyen.rb +31 -15
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +22 -22
- data/lib/active_merchant/billing/gateways/authorize_net.rb +72 -72
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -3
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -3
- data/lib/active_merchant/billing/gateways/axcessms.rb +51 -51
- data/lib/active_merchant/billing/gateways/balanced.rb +29 -29
- data/lib/active_merchant/billing/gateways/bank_frick.rb +3 -3
- data/lib/active_merchant/billing/gateways/banwire.rb +8 -8
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +6 -6
- data/lib/active_merchant/billing/gateways/be2bill.rb +2 -2
- data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +69 -69
- data/lib/active_merchant/billing/gateways/blue_pay.rb +19 -19
- data/lib/active_merchant/billing/gateways/blue_snap.rb +42 -42
- data/lib/active_merchant/billing/gateways/bogus.rb +10 -10
- data/lib/active_merchant/billing/gateways/borgun.rb +10 -10
- data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +2 -2
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +94 -94
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +39 -39
- data/lib/active_merchant/billing/gateways/cams.rb +12 -12
- data/lib/active_merchant/billing/gateways/card_connect.rb +38 -13
- data/lib/active_merchant/billing/gateways/card_stream.rb +116 -116
- data/lib/active_merchant/billing/gateways/cardknox.rb +7 -7
- data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
- data/lib/active_merchant/billing/gateways/cashnet.rb +10 -10
- data/lib/active_merchant/billing/gateways/cc5.rb +3 -5
- data/lib/active_merchant/billing/gateways/cecabank.rb +6 -6
- data/lib/active_merchant/billing/gateways/cenpos.rb +36 -36
- data/lib/active_merchant/billing/gateways/checkout.rb +5 -5
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +31 -31
- data/lib/active_merchant/billing/gateways/clearhaus.rb +5 -5
- data/lib/active_merchant/billing/gateways/commercegate.rb +6 -6
- data/lib/active_merchant/billing/gateways/conekta.rb +24 -19
- data/lib/active_merchant/billing/gateways/creditcall.rb +41 -41
- data/lib/active_merchant/billing/gateways/credorax.rb +104 -103
- data/lib/active_merchant/billing/gateways/culqi.rb +25 -25
- data/lib/active_merchant/billing/gateways/cyber_source.rb +65 -65
- data/lib/active_merchant/billing/gateways/data_cash.rb +4 -4
- data/lib/active_merchant/billing/gateways/dibs.rb +24 -24
- data/lib/active_merchant/billing/gateways/digitzs.rb +35 -35
- data/lib/active_merchant/billing/gateways/ebanx.rb +26 -26
- data/lib/active_merchant/billing/gateways/efsnet.rb +10 -10
- data/lib/active_merchant/billing/gateways/elavon.rb +5 -5
- data/lib/active_merchant/billing/gateways/element.rb +35 -35
- data/lib/active_merchant/billing/gateways/epay.rb +4 -4
- data/lib/active_merchant/billing/gateways/evo_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/eway.rb +65 -65
- data/lib/active_merchant/billing/gateways/eway_managed.rb +11 -11
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +31 -31
- data/lib/active_merchant/billing/gateways/exact.rb +12 -12
- data/lib/active_merchant/billing/gateways/ezic.rb +13 -13
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -24
- data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -3
- data/lib/active_merchant/billing/gateways/first_giving.rb +16 -16
- data/lib/active_merchant/billing/gateways/first_pay.rb +7 -4
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +71 -71
- data/lib/active_merchant/billing/gateways/flo2cash.rb +12 -12
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
- data/lib/active_merchant/billing/gateways/forte.rb +26 -16
- data/lib/active_merchant/billing/gateways/garanti.rb +10 -12
- data/lib/active_merchant/billing/gateways/global_collect.rb +88 -88
- data/lib/active_merchant/billing/gateways/global_transport.rb +4 -4
- data/lib/active_merchant/billing/gateways/hdfc.rb +33 -33
- data/lib/active_merchant/billing/gateways/hps.rb +28 -28
- data/lib/active_merchant/billing/gateways/iats_payments.rb +26 -26
- data/lib/active_merchant/billing/gateways/inspire.rb +15 -15
- data/lib/active_merchant/billing/gateways/instapay.rb +4 -4
- data/lib/active_merchant/billing/gateways/ipp.rb +17 -17
- data/lib/active_merchant/billing/gateways/iridium.rb +207 -207
- data/lib/active_merchant/billing/gateways/iveri.rb +8 -8
- data/lib/active_merchant/billing/gateways/jetpay.rb +134 -134
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +141 -141
- data/lib/active_merchant/billing/gateways/komoju.rb +15 -15
- data/lib/active_merchant/billing/gateways/kushki.rb +31 -37
- data/lib/active_merchant/billing/gateways/latitude19.rb +64 -64
- data/lib/active_merchant/billing/gateways/linkpoint.rb +22 -22
- data/lib/active_merchant/billing/gateways/litle.rb +4 -4
- data/lib/active_merchant/billing/gateways/mastercard.rb +3 -3
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +28 -28
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +9 -9
- data/lib/active_merchant/billing/gateways/merchant_one.rb +6 -6
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +24 -24
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -49
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +36 -36
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +4 -4
- data/lib/active_merchant/billing/gateways/mercury.rb +28 -28
- data/lib/active_merchant/billing/gateways/metrics_global.rb +7 -7
- data/lib/active_merchant/billing/gateways/micropayment.rb +31 -31
- data/lib/active_merchant/billing/gateways/migs.rb +11 -9
- data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -1
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +16 -16
- data/lib/active_merchant/billing/gateways/monei.rb +5 -5
- data/lib/active_merchant/billing/gateways/moneris.rb +26 -26
- data/lib/active_merchant/billing/gateways/moneris_us.rb +81 -37
- data/lib/active_merchant/billing/gateways/money_movers.rb +3 -3
- data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
- data/lib/active_merchant/billing/gateways/nab_transact.rb +6 -6
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +3 -3
- data/lib/active_merchant/billing/gateways/netaxept.rb +15 -15
- data/lib/active_merchant/billing/gateways/netbanx.rb +2 -2
- data/lib/active_merchant/billing/gateways/netbilling.rb +1 -1
- data/lib/active_merchant/billing/gateways/netpay.rb +5 -5
- data/lib/active_merchant/billing/gateways/nmi.rb +18 -18
- data/lib/active_merchant/billing/gateways/ogone.rb +22 -22
- data/lib/active_merchant/billing/gateways/omise.rb +3 -3
- data/lib/active_merchant/billing/gateways/openpay.rb +6 -4
- data/lib/active_merchant/billing/gateways/opp.rb +4 -4
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -2
- data/lib/active_merchant/billing/gateways/orbital.rb +61 -61
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +4 -4
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +5 -5
- data/lib/active_merchant/billing/gateways/pagarme.rb +27 -27
- data/lib/active_merchant/billing/gateways/pago_facil.rb +8 -8
- data/lib/active_merchant/billing/gateways/pay_conex.rb +25 -25
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +32 -32
- data/lib/active_merchant/billing/gateways/pay_hub.rb +29 -29
- data/lib/active_merchant/billing/gateways/pay_junction.rb +7 -7
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +30 -30
- data/lib/active_merchant/billing/gateways/pay_secure.rb +4 -4
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +15 -15
- data/lib/active_merchant/billing/gateways/payeezy.rb +5 -5
- data/lib/active_merchant/billing/gateways/payex.rb +4 -4
- data/lib/active_merchant/billing/gateways/payflow.rb +7 -7
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +23 -22
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -2
- data/lib/active_merchant/billing/gateways/payment_express.rb +40 -37
- data/lib/active_merchant/billing/gateways/paymentez.rb +11 -3
- data/lib/active_merchant/billing/gateways/paymill.rb +115 -115
- data/lib/active_merchant/billing/gateways/paypal.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
- data/lib/active_merchant/billing/gateways/payscout.rb +1 -1
- data/lib/active_merchant/billing/gateways/paystation.rb +14 -14
- data/lib/active_merchant/billing/gateways/payu_in.rb +43 -43
- data/lib/active_merchant/billing/gateways/payu_latam.rb +41 -41
- data/lib/active_merchant/billing/gateways/payway.rb +6 -6
- data/lib/active_merchant/billing/gateways/pin.rb +7 -7
- data/lib/active_merchant/billing/gateways/plugnpay.rb +62 -62
- data/lib/active_merchant/billing/gateways/pro_pay.rb +123 -123
- data/lib/active_merchant/billing/gateways/psigate.rb +16 -16
- data/lib/active_merchant/billing/gateways/psl_card.rb +13 -13
- data/lib/active_merchant/billing/gateways/qbms.rb +52 -52
- data/lib/active_merchant/billing/gateways/quantum.rb +5 -5
- data/lib/active_merchant/billing/gateways/quickbooks.rb +10 -10
- data/lib/active_merchant/billing/gateways/quickpay.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +11 -11
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
- data/lib/active_merchant/billing/gateways/qvalent.rb +55 -55
- data/lib/active_merchant/billing/gateways/realex.rb +16 -15
- data/lib/active_merchant/billing/gateways/redsys.rb +128 -121
- data/lib/active_merchant/billing/gateways/s5.rb +5 -5
- data/lib/active_merchant/billing/gateways/safe_charge.rb +16 -16
- data/lib/active_merchant/billing/gateways/sage.rb +20 -20
- data/lib/active_merchant/billing/gateways/sage_pay.rb +32 -32
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +11 -11
- data/lib/active_merchant/billing/gateways/secure_net.rb +19 -19
- data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -5
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +7 -7
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +9 -9
- data/lib/active_merchant/billing/gateways/securion_pay.rb +12 -12
- data/lib/active_merchant/billing/gateways/skip_jack.rb +28 -28
- data/lib/active_merchant/billing/gateways/smart_ps.rb +31 -31
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +3 -3
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +1 -1
- data/lib/active_merchant/billing/gateways/stripe.rb +63 -63
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +5 -5
- data/lib/active_merchant/billing/gateways/telr.rb +26 -26
- data/lib/active_merchant/billing/gateways/trans_first.rb +28 -28
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +224 -224
- data/lib/active_merchant/billing/gateways/transact_pro.rb +7 -7
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -1
- data/lib/active_merchant/billing/gateways/trexle.rb +5 -5
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +38 -38
- data/lib/active_merchant/billing/gateways/usa_epay.rb +3 -3
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +37 -37
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -3
- data/lib/active_merchant/billing/gateways/vanco.rb +25 -25
- data/lib/active_merchant/billing/gateways/verifi.rb +40 -40
- data/lib/active_merchant/billing/gateways/viaklix.rb +5 -5
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +64 -36
- data/lib/active_merchant/billing/gateways/webpay.rb +8 -8
- data/lib/active_merchant/billing/gateways/wepay.rb +25 -25
- data/lib/active_merchant/billing/gateways/wirecard.rb +26 -26
- data/lib/active_merchant/billing/gateways/worldpay.rb +15 -15
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +42 -42
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +17 -17
- data/lib/active_merchant/billing/model.rb +2 -2
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/billing/rails.rb +1 -1
- data/lib/active_merchant/connection.rb +10 -8
- data/lib/active_merchant/country.rb +1 -1
- data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
- data/lib/active_merchant/network_connection_retries.rb +12 -12
- data/lib/active_merchant/post_data.rb +1 -1
- data/lib/active_merchant/posts_data.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- data/lib/certs/cacert.pem +37 -0
- data/lib/support/gateway_support.rb +2 -2
- data/lib/support/ssl_verify.rb +5 -5
- data/lib/support/ssl_version.rb +7 -7
- metadata +3 -7
- 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
@@ -7,15 +7,15 @@ module ActiveMerchant #:nodoc:
|
|
7
7
|
AUTHORIZATION_EMV_SUCCESS = '8A023030'
|
8
8
|
AUTHORIZATION_EMV_DECLINE = '8A023035'
|
9
9
|
|
10
|
-
SUCCESS_MESSAGE =
|
11
|
-
FAILURE_MESSAGE =
|
12
|
-
NUMBER_ERROR_MESSAGE =
|
13
|
-
AMOUNT_ERROR_MESSAGE =
|
14
|
-
UNSTORE_ERROR_MESSAGE =
|
15
|
-
CAPTURE_ERROR_MESSAGE =
|
16
|
-
VOID_ERROR_MESSAGE =
|
17
|
-
REFUND_ERROR_MESSAGE =
|
18
|
-
CHECK_ERROR_MESSAGE =
|
10
|
+
SUCCESS_MESSAGE = 'Bogus Gateway: Forced success'
|
11
|
+
FAILURE_MESSAGE = 'Bogus Gateway: Forced failure'
|
12
|
+
NUMBER_ERROR_MESSAGE = 'Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error'
|
13
|
+
AMOUNT_ERROR_MESSAGE = 'Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception'
|
14
|
+
UNSTORE_ERROR_MESSAGE = 'Bogus Gateway: Use trans_id ending in 1 for success, 2 for exception and anything else for error'
|
15
|
+
CAPTURE_ERROR_MESSAGE = 'Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success'
|
16
|
+
VOID_ERROR_MESSAGE = 'Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success'
|
17
|
+
REFUND_ERROR_MESSAGE = 'Bogus Gateway: Use trans_id number ending in 1 for exception, 2 for error and anything else for success'
|
18
|
+
CHECK_ERROR_MESSAGE = 'Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error'
|
19
19
|
|
20
20
|
self.supported_countries = []
|
21
21
|
self.supported_cardtypes = [:bogus]
|
@@ -129,7 +129,7 @@ module ActiveMerchant #:nodoc:
|
|
129
129
|
def authorize_swipe(money, paysource, options = {})
|
130
130
|
money = amount(money)
|
131
131
|
case normalize(paysource)
|
132
|
-
when /1
|
132
|
+
when /1$/, AUTHORIZATION
|
133
133
|
Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION )
|
134
134
|
when /2$/
|
135
135
|
Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'nokogiri'
|
2
2
|
|
3
3
|
module ActiveMerchant #:nodoc:
|
4
4
|
module Billing #:nodoc:
|
5
5
|
class BorgunGateway < Gateway
|
6
|
-
self.display_name =
|
6
|
+
self.display_name = 'Borgun'
|
7
7
|
self.homepage_url = 'http://www.borgun.com'
|
8
8
|
|
9
9
|
self.test_url = 'https://gatewaytest.borgun.is/ws/Heimir.pub.ws:Authorization'
|
@@ -77,9 +77,9 @@ module ActiveMerchant #:nodoc:
|
|
77
77
|
private
|
78
78
|
|
79
79
|
CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
|
80
|
-
CURRENCY_CODES[
|
81
|
-
CURRENCY_CODES[
|
82
|
-
CURRENCY_CODES[
|
80
|
+
CURRENCY_CODES['ISK'] = '352'
|
81
|
+
CURRENCY_CODES['EUR'] = '978'
|
82
|
+
CURRENCY_CODES['USD'] = '840'
|
83
83
|
|
84
84
|
def add_invoice(post, money, options)
|
85
85
|
post[:TrAmount] = amount(money)
|
@@ -91,12 +91,12 @@ module ActiveMerchant #:nodoc:
|
|
91
91
|
post[:PAN] = payment_method.number
|
92
92
|
post[:ExpDate] = format(payment_method.year, :two_digits) + format(payment_method.month, :two_digits)
|
93
93
|
post[:CVC2] = payment_method.verification_value
|
94
|
-
post[:DateAndTime] = Time.now.strftime(
|
94
|
+
post[:DateAndTime] = Time.now.strftime('%y%m%d%H%M%S')
|
95
95
|
post[:RRN] = 'AMRCNT' + six_random_digits
|
96
96
|
end
|
97
97
|
|
98
98
|
def add_reference(post, authorization)
|
99
|
-
dateandtime,
|
99
|
+
dateandtime, _batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization)
|
100
100
|
post[:DateAndTime] = dateandtime
|
101
101
|
post[:Transaction] = transaction
|
102
102
|
post[:RRN] = rrn
|
@@ -151,7 +151,7 @@ module ActiveMerchant #:nodoc:
|
|
151
151
|
|
152
152
|
def message_from(succeeded, response)
|
153
153
|
if succeeded
|
154
|
-
|
154
|
+
'Succeeded'
|
155
155
|
else
|
156
156
|
response[:message] || "Error with ActionCode=#{response[:actioncode]}"
|
157
157
|
end
|
@@ -167,11 +167,11 @@ module ActiveMerchant #:nodoc:
|
|
167
167
|
response[:transtype],
|
168
168
|
response[:tramount],
|
169
169
|
response[:trcurrency]
|
170
|
-
].join(
|
170
|
+
].join('|')
|
171
171
|
end
|
172
172
|
|
173
173
|
def split_authorization(authorization)
|
174
|
-
dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split(
|
174
|
+
dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split('|')
|
175
175
|
[dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency]
|
176
176
|
end
|
177
177
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module BraintreeCommon
|
2
2
|
def self.included(base)
|
3
3
|
base.supported_countries = %w(US CA AD AT BE BG HR CY CZ DK EE FI FR GI DE GR GG HU IS IM IE IT JE LV LI LT LU MT MC NL NO PL PT RO SM SK SI ES SE CH TR GB SG HK MY AU NZ)
|
4
|
-
base.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
4
|
+
base.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
|
5
5
|
base.homepage_url = 'http://www.braintreepaymentsolutions.com'
|
6
6
|
base.display_name = 'Braintree'
|
7
7
|
base.default_currency = 'USD'
|
@@ -13,7 +13,7 @@ module BraintreeCommon
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def scrub(transcript)
|
16
|
-
return
|
16
|
+
return '' if transcript.blank?
|
17
17
|
transcript.
|
18
18
|
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
19
19
|
gsub(%r((&?ccnumber=)\d*(&?)), '\1[FILTERED]\2').
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'active_merchant/billing/gateways/braintree/braintree_common'
|
2
2
|
|
3
3
|
begin
|
4
|
-
require
|
4
|
+
require 'braintree'
|
5
5
|
rescue LoadError
|
6
|
-
raise
|
6
|
+
raise 'Could not load the braintree gem. Use `gem install braintree` to install it.'
|
7
7
|
end
|
8
8
|
|
9
9
|
unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 78
|
@@ -125,7 +125,7 @@ module ActiveMerchant #:nodoc:
|
|
125
125
|
customer_exists_response = nil
|
126
126
|
r.process{customer_exists_response = check_customer_exists(options[:customer])}
|
127
127
|
r.process do
|
128
|
-
if customer_exists_response.params[
|
128
|
+
if customer_exists_response.params['exists']
|
129
129
|
add_credit_card_to_customer(creditcard, options)
|
130
130
|
else
|
131
131
|
add_customer_with_credit_card(creditcard, options)
|
@@ -149,7 +149,7 @@ module ActiveMerchant #:nodoc:
|
|
149
149
|
:cardholder_name => creditcard.name,
|
150
150
|
:number => creditcard.number,
|
151
151
|
:cvv => creditcard.verification_value,
|
152
|
-
:expiration_month => creditcard.month.to_s.rjust(2,
|
152
|
+
:expiration_month => creditcard.month.to_s.rjust(2, '0'),
|
153
153
|
:expiration_year => creditcard.year.to_s
|
154
154
|
}
|
155
155
|
}, options)[:credit_card]
|
@@ -176,7 +176,7 @@ module ActiveMerchant #:nodoc:
|
|
176
176
|
else
|
177
177
|
@braintree_gateway.customer.delete(customer_vault_id)
|
178
178
|
end
|
179
|
-
Response.new(true,
|
179
|
+
Response.new(true, 'OK')
|
180
180
|
end
|
181
181
|
end
|
182
182
|
alias_method :delete, :unstore
|
@@ -187,7 +187,7 @@ module ActiveMerchant #:nodoc:
|
|
187
187
|
|
188
188
|
def verify_credentials
|
189
189
|
begin
|
190
|
-
@braintree_gateway.transaction.find(
|
190
|
+
@braintree_gateway.transaction.find('non_existent_token')
|
191
191
|
rescue Braintree::AuthenticationError
|
192
192
|
return false
|
193
193
|
rescue Braintree::NotFoundError
|
@@ -203,9 +203,9 @@ module ActiveMerchant #:nodoc:
|
|
203
203
|
commit do
|
204
204
|
begin
|
205
205
|
@braintree_gateway.customer.find(customer_vault_id)
|
206
|
-
ActiveMerchant::Billing::Response.new(true,
|
206
|
+
ActiveMerchant::Billing::Response.new(true, 'Customer found', {exists: true}, authorization: customer_vault_id)
|
207
207
|
rescue Braintree::NotFoundError
|
208
|
-
ActiveMerchant::Billing::Response.new(true,
|
208
|
+
ActiveMerchant::Billing::Response.new(true, 'Customer not found', {exists: false})
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
@@ -220,7 +220,7 @@ module ActiveMerchant #:nodoc:
|
|
220
220
|
:cardholder_name => creditcard.name,
|
221
221
|
:number => creditcard.number,
|
222
222
|
:cvv => creditcard.verification_value,
|
223
|
-
:expiration_month => creditcard.month.to_s.rjust(2,
|
223
|
+
:expiration_month => creditcard.month.to_s.rjust(2, '0'),
|
224
224
|
:expiration_year => creditcard.year.to_s,
|
225
225
|
:token => options[:credit_card_token]
|
226
226
|
}
|
@@ -254,7 +254,7 @@ module ActiveMerchant #:nodoc:
|
|
254
254
|
cardholder_name: credit_card.name,
|
255
255
|
number: credit_card.number,
|
256
256
|
cvv: credit_card.verification_value,
|
257
|
-
expiration_month: credit_card.month.to_s.rjust(2,
|
257
|
+
expiration_month: credit_card.month.to_s.rjust(2, '0'),
|
258
258
|
expiration_year: credit_card.year.to_s,
|
259
259
|
}
|
260
260
|
parameters[:billing_address] = map_address(options[:billing_address]) if options[:billing_address]
|
@@ -336,9 +336,9 @@ module ActiveMerchant #:nodoc:
|
|
336
336
|
|
337
337
|
def message_from_result(result)
|
338
338
|
if result.success?
|
339
|
-
|
339
|
+
'OK'
|
340
340
|
elsif result.errors.any?
|
341
|
-
result.errors.map { |e| "#{e.message} (#{e.code})" }.join(
|
341
|
+
result.errors.map { |e| "#{e.message} (#{e.code})" }.join(' ')
|
342
342
|
elsif result.credit_card_verification
|
343
343
|
"Processor declined: #{result.credit_card_verification.processor_response_text} (#{result.credit_card_verification.processor_response_code})"
|
344
344
|
else
|
@@ -377,41 +377,41 @@ module ActiveMerchant #:nodoc:
|
|
377
377
|
|
378
378
|
def avs_mapping
|
379
379
|
{
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
380
|
+
'street: M, zip: M' => 'M',
|
381
|
+
'street: M, zip: N' => 'A',
|
382
|
+
'street: M, zip: U' => 'B',
|
383
|
+
'street: M, zip: I' => 'B',
|
384
|
+
'street: M, zip: A' => 'B',
|
385
|
+
|
386
|
+
'street: N, zip: M' => 'Z',
|
387
|
+
'street: N, zip: N' => 'C',
|
388
|
+
'street: N, zip: U' => 'C',
|
389
|
+
'street: N, zip: I' => 'C',
|
390
|
+
'street: N, zip: A' => 'C',
|
391
|
+
|
392
|
+
'street: U, zip: M' => 'P',
|
393
|
+
'street: U, zip: N' => 'N',
|
394
|
+
'street: U, zip: U' => 'I',
|
395
|
+
'street: U, zip: I' => 'I',
|
396
|
+
'street: U, zip: A' => 'I',
|
397
|
+
|
398
|
+
'street: I, zip: M' => 'P',
|
399
|
+
'street: I, zip: N' => 'C',
|
400
|
+
'street: I, zip: U' => 'I',
|
401
|
+
'street: I, zip: I' => 'I',
|
402
|
+
'street: I, zip: A' => 'I',
|
403
|
+
|
404
|
+
'street: A, zip: M' => 'P',
|
405
|
+
'street: A, zip: N' => 'C',
|
406
|
+
'street: A, zip: U' => 'I',
|
407
|
+
'street: A, zip: I' => 'I',
|
408
|
+
'street: A, zip: A' => 'I'
|
409
409
|
}
|
410
410
|
end
|
411
411
|
|
412
412
|
def message_from_transaction_result(result)
|
413
|
-
if result.transaction && result.transaction.status ==
|
414
|
-
|
413
|
+
if result.transaction && result.transaction.status == 'gateway_rejected'
|
414
|
+
'Transaction declined - gateway rejected'
|
415
415
|
elsif result.transaction
|
416
416
|
"#{result.transaction.processor_response_code} #{result.transaction.processor_response_text}"
|
417
417
|
else
|
@@ -454,22 +454,22 @@ module ActiveMerchant #:nodoc:
|
|
454
454
|
|
455
455
|
def customer_hash(customer, include_credit_cards=false)
|
456
456
|
hash = {
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
457
|
+
'email' => customer.email,
|
458
|
+
'phone' => customer.phone,
|
459
|
+
'first_name' => customer.first_name,
|
460
|
+
'last_name' => customer.last_name,
|
461
|
+
'id' => customer.id
|
462
462
|
}
|
463
463
|
|
464
464
|
if include_credit_cards
|
465
|
-
hash[
|
465
|
+
hash['credit_cards'] = customer.credit_cards.map do |cc|
|
466
466
|
{
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
467
|
+
'bin' => cc.bin,
|
468
|
+
'expiration_date' => cc.expiration_date,
|
469
|
+
'token' => cc.token,
|
470
|
+
'last_4' => cc.last_4,
|
471
|
+
'card_type' => cc.card_type,
|
472
|
+
'masked_number' => cc.masked_number
|
473
473
|
}
|
474
474
|
end
|
475
475
|
end
|
@@ -479,16 +479,16 @@ module ActiveMerchant #:nodoc:
|
|
479
479
|
|
480
480
|
def transaction_hash(result)
|
481
481
|
unless result.success?
|
482
|
-
return {
|
482
|
+
return { 'processor_response_code' => response_code_from_result(result) }
|
483
483
|
end
|
484
484
|
|
485
485
|
transaction = result.transaction
|
486
486
|
if transaction.vault_customer
|
487
487
|
vault_customer = {
|
488
488
|
}
|
489
|
-
vault_customer[
|
489
|
+
vault_customer['credit_cards'] = transaction.vault_customer.credit_cards.map do |cc|
|
490
490
|
{
|
491
|
-
|
491
|
+
'bin' => cc.bin
|
492
492
|
}
|
493
493
|
end
|
494
494
|
else
|
@@ -496,49 +496,49 @@ module ActiveMerchant #:nodoc:
|
|
496
496
|
end
|
497
497
|
|
498
498
|
customer_details = {
|
499
|
-
|
500
|
-
|
501
|
-
|
499
|
+
'id' => transaction.customer_details.id,
|
500
|
+
'email' => transaction.customer_details.email,
|
501
|
+
'phone' => transaction.customer_details.phone,
|
502
502
|
}
|
503
503
|
|
504
504
|
billing_details = {
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
505
|
+
'street_address' => transaction.billing_details.street_address,
|
506
|
+
'extended_address' => transaction.billing_details.extended_address,
|
507
|
+
'company' => transaction.billing_details.company,
|
508
|
+
'locality' => transaction.billing_details.locality,
|
509
|
+
'region' => transaction.billing_details.region,
|
510
|
+
'postal_code' => transaction.billing_details.postal_code,
|
511
|
+
'country_name' => transaction.billing_details.country_name,
|
512
512
|
}
|
513
513
|
|
514
514
|
shipping_details = {
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
515
|
+
'street_address' => transaction.shipping_details.street_address,
|
516
|
+
'extended_address' => transaction.shipping_details.extended_address,
|
517
|
+
'company' => transaction.shipping_details.company,
|
518
|
+
'locality' => transaction.shipping_details.locality,
|
519
|
+
'region' => transaction.shipping_details.region,
|
520
|
+
'postal_code' => transaction.shipping_details.postal_code,
|
521
|
+
'country_name' => transaction.shipping_details.country_name,
|
522
522
|
}
|
523
523
|
credit_card_details = {
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
524
|
+
'masked_number' => transaction.credit_card_details.masked_number,
|
525
|
+
'bin' => transaction.credit_card_details.bin,
|
526
|
+
'last_4' => transaction.credit_card_details.last_4,
|
527
|
+
'card_type' => transaction.credit_card_details.card_type,
|
528
|
+
'token' => transaction.credit_card_details.token
|
529
529
|
}
|
530
530
|
|
531
531
|
{
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
532
|
+
'order_id' => transaction.order_id,
|
533
|
+
'amount' => transaction.amount.to_s,
|
534
|
+
'status' => transaction.status,
|
535
|
+
'credit_card_details' => credit_card_details,
|
536
|
+
'customer_details' => customer_details,
|
537
|
+
'billing_details' => billing_details,
|
538
|
+
'shipping_details' => shipping_details,
|
539
|
+
'vault_customer' => vault_customer,
|
540
|
+
'merchant_account_id' => transaction.merchant_account_id,
|
541
|
+
'processor_response_code' => response_code_from_result(result)
|
542
542
|
}
|
543
543
|
end
|
544
544
|
|
@@ -547,7 +547,7 @@ module ActiveMerchant #:nodoc:
|
|
547
547
|
:amount => localized_amount(money, options[:currency] || default_currency).to_s,
|
548
548
|
:order_id => options[:order_id],
|
549
549
|
:customer => {
|
550
|
-
:id => options[:store] == true ?
|
550
|
+
:id => options[:store] == true ? '' : options[:store],
|
551
551
|
:email => scrub_email(options[:email]),
|
552
552
|
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
553
553
|
options[:billing_address][:phone])
|
@@ -592,7 +592,7 @@ module ActiveMerchant #:nodoc:
|
|
592
592
|
if credit_card_or_vault_id.source == :apple_pay
|
593
593
|
parameters[:apple_pay_card] = {
|
594
594
|
:number => credit_card_or_vault_id.number,
|
595
|
-
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2,
|
595
|
+
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'),
|
596
596
|
:expiration_year => credit_card_or_vault_id.year.to_s,
|
597
597
|
:cardholder_name => credit_card_or_vault_id.name,
|
598
598
|
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
|
@@ -602,7 +602,7 @@ module ActiveMerchant #:nodoc:
|
|
602
602
|
parameters[:android_pay_card] = {
|
603
603
|
:number => credit_card_or_vault_id.number,
|
604
604
|
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
|
605
|
-
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2,
|
605
|
+
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'),
|
606
606
|
:expiration_year => credit_card_or_vault_id.year.to_s,
|
607
607
|
:google_transaction_id => credit_card_or_vault_id.transaction_id,
|
608
608
|
:source_card_type => credit_card_or_vault_id.brand,
|
@@ -614,7 +614,7 @@ module ActiveMerchant #:nodoc:
|
|
614
614
|
parameters[:credit_card] = {
|
615
615
|
:number => credit_card_or_vault_id.number,
|
616
616
|
:cvv => credit_card_or_vault_id.verification_value,
|
617
|
-
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2,
|
617
|
+
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'),
|
618
618
|
:expiration_year => credit_card_or_vault_id.year.to_s,
|
619
619
|
:cardholder_name => credit_card_or_vault_id.name
|
620
620
|
}
|