activemerchant 1.62.0 → 1.79.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +420 -2
- data/README.md +1 -2
- data/lib/active_merchant/billing/credit_card.rb +13 -14
- data/lib/active_merchant/billing/credit_card_methods.rb +3 -1
- data/lib/active_merchant/billing/gateway.rb +25 -9
- data/lib/active_merchant/billing/gateways/adyen.rb +299 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +168 -56
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +4 -2
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +65 -22
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +87 -7
- data/lib/active_merchant/billing/gateways/beanstream.rb +2 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +3 -8
- data/lib/active_merchant/billing/gateways/borgun.rb +10 -10
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +1 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +49 -15
- data/lib/active_merchant/billing/gateways/card_connect.rb +286 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +97 -2
- data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +14 -2
- data/lib/active_merchant/billing/gateways/cenpos.rb +1 -1
- data/lib/active_merchant/billing/gateways/checkout.rb +1 -1
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +44 -14
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +0 -1
- data/lib/active_merchant/billing/gateways/clearhaus.rb +0 -2
- data/lib/active_merchant/billing/gateways/conekta.rb +4 -4
- data/lib/active_merchant/billing/gateways/creditcall.rb +71 -9
- data/lib/active_merchant/billing/gateways/credorax.rb +117 -5
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +54 -15
- data/lib/active_merchant/billing/gateways/data_cash.rb +12 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +0 -1
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +37 -95
- data/lib/active_merchant/billing/gateways/element.rb +11 -1
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +3 -29
- data/lib/active_merchant/billing/gateways/first_pay.rb +12 -10
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +37 -20
- data/lib/active_merchant/billing/gateways/forte.rb +0 -1
- data/lib/active_merchant/billing/gateways/global_collect.rb +55 -16
- data/lib/active_merchant/billing/gateways/global_transport.rb +16 -2
- data/lib/active_merchant/billing/gateways/hps.rb +12 -1
- data/lib/active_merchant/billing/gateways/iats_payments.rb +2 -2
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +12 -9
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +227 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -2
- data/lib/active_merchant/billing/gateways/litle.rb +107 -30
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +262 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +11 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +16 -4
- data/lib/active_merchant/billing/gateways/mercury.rb +14 -1
- data/lib/active_merchant/billing/gateways/migs.rb +28 -6
- data/lib/active_merchant/billing/gateways/moneris.rb +20 -12
- data/lib/active_merchant/billing/gateways/moneris_us.rb +11 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +4 -4
- data/lib/active_merchant/billing/gateways/netbanx.rb +60 -16
- data/lib/active_merchant/billing/gateways/netbilling.rb +0 -1
- data/lib/active_merchant/billing/gateways/nmi.rb +12 -1
- data/lib/active_merchant/billing/gateways/ogone.rb +1 -1
- data/lib/active_merchant/billing/gateways/omise.rb +9 -5
- data/lib/active_merchant/billing/gateways/openpay.rb +13 -0
- data/lib/active_merchant/billing/gateways/opp.rb +124 -114
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +14 -1
- data/lib/active_merchant/billing/gateways/orbital.rb +83 -14
- data/lib/active_merchant/billing/gateways/pay_hub.rb +2 -2
- data/lib/active_merchant/billing/gateways/payeezy.rb +152 -46
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +12 -2
- data/lib/active_merchant/billing/gateways/payflow.rb +24 -2
- data/lib/active_merchant/billing/gateways/payment_express.rb +3 -2
- data/lib/active_merchant/billing/gateways/paymentez.rb +276 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +18 -10
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +14 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +0 -12
- data/lib/active_merchant/billing/gateways/paystation.rb +14 -1
- data/lib/active_merchant/billing/gateways/payu_latam.rb +102 -62
- data/lib/active_merchant/billing/gateways/pin.rb +5 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +12 -1
- data/lib/active_merchant/billing/gateways/qbms.rb +11 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +10 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +21 -17
- data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
- data/lib/active_merchant/billing/gateways/qvalent.rb +60 -3
- data/lib/active_merchant/billing/gateways/realex.rb +16 -6
- data/lib/active_merchant/billing/gateways/redsys.rb +8 -2
- data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
- data/lib/active_merchant/billing/gateways/sage.rb +8 -3
- data/lib/active_merchant/billing/gateways/sage_pay.rb +29 -13
- data/lib/active_merchant/billing/gateways/secure_net.rb +11 -1
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +1 -1
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +53 -7
- data/lib/active_merchant/billing/gateways/stripe.rb +84 -26
- data/lib/active_merchant/billing/gateways/tns.rb +0 -1
- data/lib/active_merchant/billing/gateways/trans_first.rb +3 -2
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +61 -26
- data/lib/active_merchant/billing/gateways/trexle.rb +217 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +45 -22
- data/lib/active_merchant/billing/gateways/vanco.rb +1 -1
- data/lib/active_merchant/billing/gateways/wepay.rb +79 -46
- data/lib/active_merchant/billing/gateways/wirecard.rb +5 -4
- data/lib/active_merchant/billing/gateways/worldpay.rb +85 -20
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +27 -8
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/connection.rb +48 -12
- data/lib/active_merchant/net_http_ssl_connection.rb +9 -0
- data/lib/active_merchant/network_connection_retries.rb +6 -4
- data/lib/active_merchant/posts_data.rb +11 -1
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +2 -5
- data/lib/certs/cacert.pem +85 -0
- data/lib/support/ssl_version.rb +87 -0
- metadata +25 -9
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
@@ -1,6 +1,8 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
3
|
module BeanstreamCore
|
4
|
+
include Empty
|
5
|
+
|
4
6
|
RECURRING_URL = 'https://www.beanstream.com/scripts/recurring_billing.asp'
|
5
7
|
SECURE_PROFILE_URL = 'https://www.beanstream.com/scripts/payment_profile.asp'
|
6
8
|
|
@@ -59,6 +61,72 @@ module ActiveMerchant #:nodoc:
|
|
59
61
|
:cancel => 'C'
|
60
62
|
}
|
61
63
|
|
64
|
+
STATES = {
|
65
|
+
"ALBERTA" => "AB",
|
66
|
+
"BRITISH COLUMBIA" => "BC",
|
67
|
+
"MANITOBA" => "MB",
|
68
|
+
"NEW BRUNSWICK" => "NB",
|
69
|
+
"NEWFOUNDLAND AND LABRADOR" => "NL",
|
70
|
+
"NOVA SCOTIA" => "NS",
|
71
|
+
"ONTARIO" => "ON",
|
72
|
+
"PRINCE EDWARD ISLAND" => "PE",
|
73
|
+
"QUEBEC" => "QC",
|
74
|
+
"SASKATCHEWAN" => "SK",
|
75
|
+
"NORTHWEST TERRITORIES" => "NT",
|
76
|
+
"NUNAVUT" => "NU",
|
77
|
+
"YUKON" => "YT",
|
78
|
+
"ALABAMA" => "AL",
|
79
|
+
"ALASKA" => "AK",
|
80
|
+
"ARIZONA" => "AZ",
|
81
|
+
"ARKANSAS" => "AR",
|
82
|
+
"CALIFORNIA" => "CA",
|
83
|
+
"COLORADO" => "CO",
|
84
|
+
"CONNECTICUT" => "CT",
|
85
|
+
"DELAWARE" => "DE",
|
86
|
+
"FLORIDA" => "FL",
|
87
|
+
"GEORGIA" => "GA",
|
88
|
+
"HAWAII" => "HI",
|
89
|
+
"IDAHO" => "ID",
|
90
|
+
"ILLINOIS" => "IL",
|
91
|
+
"INDIANA" => "IN",
|
92
|
+
"IOWA" => "IA",
|
93
|
+
"KANSAS" => "KS",
|
94
|
+
"KENTUCKY" => "KY",
|
95
|
+
"LOUISIANA" => "LA",
|
96
|
+
"MAINE" => "ME",
|
97
|
+
"MARYLAND" => "MD",
|
98
|
+
"MASSACHUSETTS" => "MA",
|
99
|
+
"MICHIGAN" => "MI",
|
100
|
+
"MINNESOTA" => "MN",
|
101
|
+
"MISSISSIPPI" => "MS",
|
102
|
+
"MISSOURI" => "MO",
|
103
|
+
"MONTANA" => "MT",
|
104
|
+
"NEBRASKA" => "NE",
|
105
|
+
"NEVADA" => "NV",
|
106
|
+
"NEW HAMPSHIRE" => "NH",
|
107
|
+
"NEW JERSEY" => "NJ",
|
108
|
+
"NEW MEXICO" => "NM",
|
109
|
+
"NEW YORK" => "NY",
|
110
|
+
"NORTH CAROLINA" => "NC",
|
111
|
+
"NORTH DAKOTA" => "ND",
|
112
|
+
"OHIO" => "OH",
|
113
|
+
"OKLAHOMA" => "OK",
|
114
|
+
"OREGON" => "OR",
|
115
|
+
"PENNSYLVANIA" => "PA",
|
116
|
+
"RHODE ISLAND" => "RI",
|
117
|
+
"SOUTH CAROLINA" => "SC",
|
118
|
+
"SOUTH DAKOTA" => "SD",
|
119
|
+
"TENNESSEE" => "TN",
|
120
|
+
"TEXAS" => "TX",
|
121
|
+
"UTAH" => "UT",
|
122
|
+
"VERMONT" => "VT",
|
123
|
+
"VIRGINIA" => "VA",
|
124
|
+
"WASHINGTON" => "WA",
|
125
|
+
"WEST VIRGINIA" => "WV",
|
126
|
+
"WISCONSIN" => "WI",
|
127
|
+
"WYOMING" => "WY"
|
128
|
+
}
|
129
|
+
|
62
130
|
def self.included(base)
|
63
131
|
base.default_currency = 'CAD'
|
64
132
|
|
@@ -70,7 +138,7 @@ module ActiveMerchant #:nodoc:
|
|
70
138
|
|
71
139
|
# The homepage URL of the gateway
|
72
140
|
base.homepage_url = 'http://www.beanstream.com/'
|
73
|
-
base.live_url = 'https://
|
141
|
+
base.live_url = 'https://api.na.bambora.com/scripts/process_transaction.asp'
|
74
142
|
|
75
143
|
# The name of the gateway
|
76
144
|
base.display_name = 'Beanstream.com'
|
@@ -93,6 +161,7 @@ module ActiveMerchant #:nodoc:
|
|
93
161
|
add_amount(post, money)
|
94
162
|
add_reference(post, reference)
|
95
163
|
add_transaction_type(post, :capture)
|
164
|
+
add_recurring_payment(post, options)
|
96
165
|
commit(post)
|
97
166
|
end
|
98
167
|
|
@@ -111,6 +180,7 @@ module ActiveMerchant #:nodoc:
|
|
111
180
|
end
|
112
181
|
|
113
182
|
private
|
183
|
+
|
114
184
|
def purchase_action(source)
|
115
185
|
if source.is_a?(Check)
|
116
186
|
:check_purchase
|
@@ -120,7 +190,7 @@ module ActiveMerchant #:nodoc:
|
|
120
190
|
end
|
121
191
|
|
122
192
|
def add_customer_ip(post, options)
|
123
|
-
post[:
|
193
|
+
post[:customerIp] = options[:ip] if options[:ip]
|
124
194
|
end
|
125
195
|
|
126
196
|
def void_action(original_transaction_type)
|
@@ -152,27 +222,29 @@ module ActiveMerchant #:nodoc:
|
|
152
222
|
end
|
153
223
|
|
154
224
|
def add_address(post, options)
|
225
|
+
post[:ordEmailAddress] = options[:email] if options[:email]
|
226
|
+
post[:shipEmailAddress] = options[:shipping_email] || options[:email] if options[:email]
|
227
|
+
|
155
228
|
prepare_address_for_non_american_countries(options)
|
156
229
|
|
157
230
|
if billing_address = options[:billing_address] || options[:address]
|
158
231
|
post[:ordName] = billing_address[:name]
|
159
|
-
post[:ordEmailAddress] = options[:email]
|
160
232
|
post[:ordPhoneNumber] = billing_address[:phone]
|
161
233
|
post[:ordAddress1] = billing_address[:address1]
|
162
234
|
post[:ordAddress2] = billing_address[:address2]
|
163
235
|
post[:ordCity] = billing_address[:city]
|
164
|
-
post[:ordProvince] = billing_address
|
236
|
+
post[:ordProvince] = state_for(billing_address)
|
165
237
|
post[:ordPostalCode] = billing_address[:zip]
|
166
238
|
post[:ordCountry] = billing_address[:country]
|
167
239
|
end
|
240
|
+
|
168
241
|
if shipping_address = options[:shipping_address]
|
169
242
|
post[:shipName] = shipping_address[:name]
|
170
|
-
post[:shipEmailAddress] = options[:email]
|
171
243
|
post[:shipPhoneNumber] = shipping_address[:phone]
|
172
244
|
post[:shipAddress1] = shipping_address[:address1]
|
173
245
|
post[:shipAddress2] = shipping_address[:address2]
|
174
246
|
post[:shipCity] = shipping_address[:city]
|
175
|
-
post[:shipProvince] = shipping_address
|
247
|
+
post[:shipProvince] = state_for(shipping_address)
|
176
248
|
post[:shipPostalCode] = shipping_address[:zip]
|
177
249
|
post[:shipCountry] = shipping_address[:country]
|
178
250
|
post[:shippingMethod] = shipping_address[:shipping_method]
|
@@ -180,8 +252,13 @@ module ActiveMerchant #:nodoc:
|
|
180
252
|
end
|
181
253
|
end
|
182
254
|
|
255
|
+
def state_for(address)
|
256
|
+
STATES[address[:state].upcase] || address[:state] if address[:state]
|
257
|
+
end
|
258
|
+
|
183
259
|
def prepare_address_for_non_american_countries(options)
|
184
260
|
[ options[:billing_address], options[:shipping_address] ].compact.each do |address|
|
261
|
+
next if empty?(address[:country])
|
185
262
|
unless ['US', 'CA'].include?(address[:country])
|
186
263
|
address[:state] = '--'
|
187
264
|
address[:zip] = '000000' unless address[:zip]
|
@@ -189,6 +266,10 @@ module ActiveMerchant #:nodoc:
|
|
189
266
|
end
|
190
267
|
end
|
191
268
|
|
269
|
+
def add_recurring_payment(post, options)
|
270
|
+
post[:recurringPayment] = true if options[:recurring].to_s == 'true'
|
271
|
+
end
|
272
|
+
|
192
273
|
def add_invoice(post, options)
|
193
274
|
post[:trnOrderNumber] = options[:order_id]
|
194
275
|
post[:trnComments] = options[:description]
|
@@ -391,4 +472,3 @@ module ActiveMerchant #:nodoc:
|
|
391
472
|
end
|
392
473
|
end
|
393
474
|
end
|
394
|
-
|
@@ -75,6 +75,7 @@ module ActiveMerchant #:nodoc:
|
|
75
75
|
add_address(post, options)
|
76
76
|
add_transaction_type(post, :authorization)
|
77
77
|
add_customer_ip(post, options)
|
78
|
+
add_recurring_payment(post, options)
|
78
79
|
commit(post)
|
79
80
|
end
|
80
81
|
|
@@ -86,6 +87,7 @@ module ActiveMerchant #:nodoc:
|
|
86
87
|
add_address(post, options)
|
87
88
|
add_transaction_type(post, purchase_action(source))
|
88
89
|
add_customer_ip(post, options)
|
90
|
+
add_recurring_payment(post, options)
|
89
91
|
commit(post)
|
90
92
|
end
|
91
93
|
|
@@ -86,7 +86,7 @@ module ActiveMerchant
|
|
86
86
|
def refund(money, authorization, options={})
|
87
87
|
commit(:refund, :put) do |doc|
|
88
88
|
add_authorization(doc, authorization)
|
89
|
-
add_amount(doc, money)
|
89
|
+
add_amount(doc, money, options)
|
90
90
|
add_order(doc, options)
|
91
91
|
end
|
92
92
|
end
|
@@ -140,7 +140,7 @@ module ActiveMerchant
|
|
140
140
|
def add_auth_purchase(doc, money, payment_method, options)
|
141
141
|
doc.send("recurring-transaction", options[:recurring] ? "RECURRING" : "ECOMMERCE")
|
142
142
|
add_order(doc, options)
|
143
|
-
add_amount(doc, money)
|
143
|
+
add_amount(doc, money, options)
|
144
144
|
doc.send("transaction-fraud-info") do
|
145
145
|
doc.send("shopper-ip-address", options[:ip]) if options[:ip]
|
146
146
|
end
|
@@ -155,7 +155,7 @@ module ActiveMerchant
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
def add_amount(doc, money)
|
158
|
+
def add_amount(doc, money, options)
|
159
159
|
doc.amount(amount(money))
|
160
160
|
doc.currency(options[:currency] || currency(money))
|
161
161
|
end
|
@@ -203,11 +203,6 @@ module ActiveMerchant
|
|
203
203
|
doc.zip(address[:zip]) if address[:zip]
|
204
204
|
end
|
205
205
|
|
206
|
-
def add_invoice(post, money, options)
|
207
|
-
post[:amount] = amount(money)
|
208
|
-
post[:currency] = (options[:currency] || currency(money))
|
209
|
-
end
|
210
|
-
|
211
206
|
def add_authorization(doc, authorization)
|
212
207
|
doc.send("transaction-id", authorization)
|
213
208
|
end
|
@@ -26,7 +26,6 @@ module ActiveMerchant #:nodoc:
|
|
26
26
|
post[:TransType] = '1'
|
27
27
|
add_invoice(post, money, options)
|
28
28
|
add_payment_method(post, payment)
|
29
|
-
|
30
29
|
commit('sale', post)
|
31
30
|
end
|
32
31
|
|
@@ -35,7 +34,6 @@ module ActiveMerchant #:nodoc:
|
|
35
34
|
post[:TransType] = '5'
|
36
35
|
add_invoice(post, money, options)
|
37
36
|
add_payment_method(post, payment)
|
38
|
-
|
39
37
|
commit('authonly', post)
|
40
38
|
end
|
41
39
|
|
@@ -57,9 +55,10 @@ module ActiveMerchant #:nodoc:
|
|
57
55
|
|
58
56
|
def void(authorization, options={})
|
59
57
|
post = {}
|
60
|
-
# TransType and
|
61
|
-
_, _, _, _, _, transtype, tramount = split_authorization(authorization)
|
58
|
+
# TransType, TrAmount, and currency must match original values from auth or purchase.
|
59
|
+
_, _, _, _, _, transtype, tramount, currency = split_authorization(authorization)
|
62
60
|
post[:TransType] = transtype
|
61
|
+
options[:currency] = options[:currency] || CURRENCY_CODES.key(currency)
|
63
62
|
add_invoice(post, tramount.to_i, options)
|
64
63
|
add_reference(post, authorization)
|
65
64
|
commit('void', post)
|
@@ -80,10 +79,12 @@ module ActiveMerchant #:nodoc:
|
|
80
79
|
CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
|
81
80
|
CURRENCY_CODES["ISK"] = "352"
|
82
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)
|
86
86
|
post[:TrCurrency] = CURRENCY_CODES[options[:currency] || currency(money)]
|
87
|
+
post[:TerminalID] = options[:terminal_id] || '1'
|
87
88
|
end
|
88
89
|
|
89
90
|
def add_payment_method(post, payment_method)
|
@@ -95,9 +96,8 @@ module ActiveMerchant #:nodoc:
|
|
95
96
|
end
|
96
97
|
|
97
98
|
def add_reference(post, authorization)
|
98
|
-
dateandtime, batch, transaction, rrn, authcode, _, _ = split_authorization(authorization)
|
99
|
+
dateandtime, batch, transaction, rrn, authcode, _, _, _ = split_authorization(authorization)
|
99
100
|
post[:DateAndTime] = dateandtime
|
100
|
-
post[:Batch] = batch
|
101
101
|
post[:Transaction] = transaction
|
102
102
|
post[:RRN] = rrn
|
103
103
|
post[:AuthCode] = authcode
|
@@ -129,7 +129,6 @@ module ActiveMerchant #:nodoc:
|
|
129
129
|
post[:Version] = '1000'
|
130
130
|
post[:Processor] = @options[:processor]
|
131
131
|
post[:MerchantID] = @options[:merchant_id]
|
132
|
-
post[:TerminalID] = 1
|
133
132
|
|
134
133
|
url = (test? ? test_url : live_url)
|
135
134
|
request = build_request(action, post)
|
@@ -166,13 +165,14 @@ module ActiveMerchant #:nodoc:
|
|
166
165
|
response[:rrn],
|
167
166
|
response[:authcode],
|
168
167
|
response[:transtype],
|
169
|
-
response[:tramount]
|
168
|
+
response[:tramount],
|
169
|
+
response[:trcurrency]
|
170
170
|
].join("|")
|
171
171
|
end
|
172
172
|
|
173
173
|
def split_authorization(authorization)
|
174
|
-
dateandtime, batch, transaction, rrn, authcode, transtype, tramount = authorization.split("|")
|
175
|
-
[dateandtime, batch, transaction, rrn, authcode, transtype, tramount]
|
174
|
+
dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency = authorization.split("|")
|
175
|
+
[dateandtime, batch, transaction, rrn, authcode, transtype, tramount, currency]
|
176
176
|
end
|
177
177
|
|
178
178
|
def headers
|
@@ -5,6 +5,7 @@ module BraintreeCommon
|
|
5
5
|
base.homepage_url = 'http://www.braintreepaymentsolutions.com'
|
6
6
|
base.display_name = 'Braintree'
|
7
7
|
base.default_currency = 'USD'
|
8
|
+
base.currencies_without_fractions = %w(BIF CLP DJF GNF JPY KMF KRW LAK PYG RWF UGX VND VUV XAF XOF XPF)
|
8
9
|
end
|
9
10
|
|
10
11
|
def supports_scrubbing
|
@@ -6,8 +6,8 @@ rescue LoadError
|
|
6
6
|
raise "Could not load the braintree gem. Use `gem install braintree` to install it."
|
7
7
|
end
|
8
8
|
|
9
|
-
unless Braintree::Version::Major == 2 && Braintree::Version::Minor >=
|
10
|
-
raise "Need braintree gem >= 2.
|
9
|
+
unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 78
|
10
|
+
raise "Need braintree gem >= 2.78.0. Run `gem install braintree --version '~>2.78'` to get the correct version."
|
11
11
|
end
|
12
12
|
|
13
13
|
module ActiveMerchant #:nodoc:
|
@@ -42,6 +42,10 @@ module ActiveMerchant #:nodoc:
|
|
42
42
|
|
43
43
|
self.display_name = 'Braintree (Blue Platform)'
|
44
44
|
|
45
|
+
ERROR_CODES = {
|
46
|
+
cannot_refund_if_unsettled: 91506
|
47
|
+
}
|
48
|
+
|
45
49
|
def initialize(options = {})
|
46
50
|
requires!(options, :merchant_id, :public_key, :private_key)
|
47
51
|
@merchant_account_id = options[:merchant_account_id]
|
@@ -74,7 +78,7 @@ module ActiveMerchant #:nodoc:
|
|
74
78
|
|
75
79
|
def capture(money, authorization, options = {})
|
76
80
|
commit do
|
77
|
-
result = @braintree_gateway.transaction.submit_for_settlement(authorization,
|
81
|
+
result = @braintree_gateway.transaction.submit_for_settlement(authorization, localized_amount(money, options[:currency] || default_currency).to_s)
|
78
82
|
response_from_result(result)
|
79
83
|
end
|
80
84
|
end
|
@@ -90,11 +94,15 @@ module ActiveMerchant #:nodoc:
|
|
90
94
|
def refund(*args)
|
91
95
|
# legacy signature: #refund(transaction_id, options = {})
|
92
96
|
# new signature: #refund(money, transaction_id, options = {})
|
93
|
-
money, transaction_id,
|
94
|
-
money =
|
97
|
+
money, transaction_id, options = extract_refund_args(args)
|
98
|
+
money = localized_amount(money, options[:currency] || default_currency).to_s if money
|
95
99
|
|
96
100
|
commit do
|
97
|
-
response_from_result(@braintree_gateway.transaction.refund(transaction_id, money))
|
101
|
+
response = response_from_result(@braintree_gateway.transaction.refund(transaction_id, money))
|
102
|
+
return response if response.success?
|
103
|
+
return response unless options[:force_full_refund_if_unsettled]
|
104
|
+
|
105
|
+
void(transaction_id) if response.message =~ /#{ERROR_CODES[:cannot_refund_if_unsettled]}/
|
98
106
|
end
|
99
107
|
end
|
100
108
|
|
@@ -150,6 +158,8 @@ module ActiveMerchant #:nodoc:
|
|
150
158
|
:first_name => creditcard.first_name,
|
151
159
|
:last_name => creditcard.last_name,
|
152
160
|
:email => scrub_email(options[:email]),
|
161
|
+
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
162
|
+
options[:billing_address][:phone]),
|
153
163
|
:credit_card => credit_card_params
|
154
164
|
)
|
155
165
|
Response.new(result.success?, message_from_result(result),
|
@@ -220,6 +230,8 @@ module ActiveMerchant #:nodoc:
|
|
220
230
|
:first_name => creditcard.first_name,
|
221
231
|
:last_name => creditcard.last_name,
|
222
232
|
:email => scrub_email(options[:email]),
|
233
|
+
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
234
|
+
options[:billing_address][:phone]),
|
223
235
|
:id => options[:customer],
|
224
236
|
}.merge credit_card_params
|
225
237
|
result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
|
@@ -304,7 +316,7 @@ module ActiveMerchant #:nodoc:
|
|
304
316
|
:region => address[:state],
|
305
317
|
:postal_code => scrub_zip(address[:zip]),
|
306
318
|
}
|
307
|
-
if(address[:country] || address[:country_code_alpha2])
|
319
|
+
if (address[:country] || address[:country_code_alpha2])
|
308
320
|
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2])
|
309
321
|
elsif address[:country_name]
|
310
322
|
mapped[:country_name] = address[:country_name]
|
@@ -443,6 +455,7 @@ module ActiveMerchant #:nodoc:
|
|
443
455
|
def customer_hash(customer, include_credit_cards=false)
|
444
456
|
hash = {
|
445
457
|
"email" => customer.email,
|
458
|
+
"phone" => customer.phone,
|
446
459
|
"first_name" => customer.first_name,
|
447
460
|
"last_name" => customer.last_name,
|
448
461
|
"id" => customer.id
|
@@ -484,7 +497,8 @@ module ActiveMerchant #:nodoc:
|
|
484
497
|
|
485
498
|
customer_details = {
|
486
499
|
"id" => transaction.customer_details.id,
|
487
|
-
"email" => transaction.customer_details.email
|
500
|
+
"email" => transaction.customer_details.email,
|
501
|
+
"phone" => transaction.customer_details.phone,
|
488
502
|
}
|
489
503
|
|
490
504
|
billing_details = {
|
@@ -516,6 +530,7 @@ module ActiveMerchant #:nodoc:
|
|
516
530
|
|
517
531
|
{
|
518
532
|
"order_id" => transaction.order_id,
|
533
|
+
"amount" => transaction.amount.to_s,
|
519
534
|
"status" => transaction.status,
|
520
535
|
"credit_card_details" => credit_card_details,
|
521
536
|
"customer_details" => customer_details,
|
@@ -529,19 +544,25 @@ module ActiveMerchant #:nodoc:
|
|
529
544
|
|
530
545
|
def create_transaction_parameters(money, credit_card_or_vault_id, options)
|
531
546
|
parameters = {
|
532
|
-
:amount =>
|
547
|
+
:amount => localized_amount(money, options[:currency] || default_currency).to_s,
|
533
548
|
:order_id => options[:order_id],
|
534
549
|
:customer => {
|
535
550
|
:id => options[:store] == true ? "" : options[:store],
|
536
|
-
:email => scrub_email(options[:email])
|
551
|
+
:email => scrub_email(options[:email]),
|
552
|
+
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
|
553
|
+
options[:billing_address][:phone])
|
537
554
|
},
|
538
555
|
:options => {
|
539
556
|
:store_in_vault => options[:store] ? true : false,
|
540
557
|
:submit_for_settlement => options[:submit_for_settlement],
|
541
|
-
:hold_in_escrow => options[:hold_in_escrow]
|
558
|
+
:hold_in_escrow => options[:hold_in_escrow],
|
542
559
|
}
|
543
560
|
}
|
544
561
|
|
562
|
+
if options[:skip_advanced_fraud_checking]
|
563
|
+
parameters[:options].merge!({ :skip_advanced_fraud_checking => options[:skip_advanced_fraud_checking] })
|
564
|
+
end
|
565
|
+
|
545
566
|
parameters[:custom_fields] = options[:custom_fields]
|
546
567
|
parameters[:device_data] = options[:device_data] if options[:device_data]
|
547
568
|
parameters[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount]
|
@@ -573,8 +594,9 @@ module ActiveMerchant #:nodoc:
|
|
573
594
|
:number => credit_card_or_vault_id.number,
|
574
595
|
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
|
575
596
|
:expiration_year => credit_card_or_vault_id.year.to_s,
|
576
|
-
:cardholder_name =>
|
577
|
-
:cryptogram => credit_card_or_vault_id.payment_cryptogram
|
597
|
+
:cardholder_name => credit_card_or_vault_id.name,
|
598
|
+
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
|
599
|
+
:eci_indicator => credit_card_or_vault_id.eci
|
578
600
|
}
|
579
601
|
elsif credit_card_or_vault_id.source == :android_pay
|
580
602
|
parameters[:android_pay_card] = {
|
@@ -582,7 +604,10 @@ module ActiveMerchant #:nodoc:
|
|
582
604
|
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
|
583
605
|
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
|
584
606
|
:expiration_year => credit_card_or_vault_id.year.to_s,
|
585
|
-
:google_transaction_id => credit_card_or_vault_id.transaction_id
|
607
|
+
:google_transaction_id => credit_card_or_vault_id.transaction_id,
|
608
|
+
:source_card_type => credit_card_or_vault_id.brand,
|
609
|
+
:source_card_last_four => credit_card_or_vault_id.last_digits,
|
610
|
+
:eci_indicator => credit_card_or_vault_id.eci
|
586
611
|
}
|
587
612
|
end
|
588
613
|
else
|
@@ -590,7 +615,8 @@ module ActiveMerchant #:nodoc:
|
|
590
615
|
:number => credit_card_or_vault_id.number,
|
591
616
|
:cvv => credit_card_or_vault_id.verification_value,
|
592
617
|
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
|
593
|
-
:expiration_year => credit_card_or_vault_id.year.to_s
|
618
|
+
:expiration_year => credit_card_or_vault_id.year.to_s,
|
619
|
+
:cardholder_name => credit_card_or_vault_id.name
|
594
620
|
}
|
595
621
|
end
|
596
622
|
end
|
@@ -608,6 +634,14 @@ module ActiveMerchant #:nodoc:
|
|
608
634
|
}
|
609
635
|
end
|
610
636
|
|
637
|
+
if options[:three_d_secure]
|
638
|
+
parameters[:three_d_secure_pass_thru] = {
|
639
|
+
cavv: options[:three_d_secure][:cavv],
|
640
|
+
eci_flag: options[:three_d_secure][:eci],
|
641
|
+
xid: options[:three_d_secure][:xid],
|
642
|
+
}
|
643
|
+
end
|
644
|
+
|
611
645
|
parameters
|
612
646
|
end
|
613
647
|
end
|