activemerchant 1.56.0 → 1.66.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +331 -0
- data/README.md +9 -9
- data/lib/active_merchant/billing/check.rb +3 -0
- data/lib/active_merchant/billing/credit_card.rb +8 -3
- data/lib/active_merchant/billing/credit_card_methods.rb +41 -1
- data/lib/active_merchant/billing/gateway.rb +14 -6
- data/lib/active_merchant/billing/gateways/adyen.rb +228 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +157 -44
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +7 -4
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +68 -2
- data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/blue_snap.rb +348 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +58 -20
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +37 -8
- data/lib/active_merchant/billing/gateways/card_stream.rb +161 -40
- data/lib/active_merchant/billing/gateways/cashnet.rb +1 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +5 -2
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +24 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +24 -40
- data/lib/active_merchant/billing/gateways/conekta.rb +6 -1
- data/lib/active_merchant/billing/gateways/creditcall.rb +1 -1
- data/lib/active_merchant/billing/gateways/credorax.rb +310 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +80 -64
- data/lib/active_merchant/billing/gateways/data_cash.rb +10 -304
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +40 -26
- data/lib/active_merchant/billing/gateways/element.rb +356 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +16 -2
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -1
- data/lib/active_merchant/billing/gateways/forte.rb +10 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +311 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +1 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +13 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +33 -19
- data/lib/active_merchant/billing/gateways/kushki.rb +217 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -0
- data/lib/active_merchant/billing/gateways/litle.rb +29 -13
- data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +145 -122
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +15 -1
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +10 -7
- data/lib/active_merchant/billing/gateways/mercury.rb +13 -5
- data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -1
- data/lib/active_merchant/billing/gateways/migs.rb +23 -1
- data/lib/active_merchant/billing/gateways/monei.rb +1 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +21 -1
- data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +245 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +30 -9
- data/lib/active_merchant/billing/gateways/omise.rb +9 -5
- data/lib/active_merchant/billing/gateways/openpay.rb +10 -1
- data/lib/active_merchant/billing/gateways/opp.rb +362 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +28 -7
- data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +61 -12
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +6 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/paymill.rb +29 -11
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -6
- data/lib/active_merchant/billing/gateways/payu_in.rb +3 -2
- data/lib/active_merchant/billing/gateways/payu_latam.rb +402 -0
- data/lib/active_merchant/billing/gateways/pin.rb +6 -3
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +0 -2
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
- data/lib/active_merchant/billing/gateways/qvalent.rb +44 -1
- data/lib/active_merchant/billing/gateways/redsys.rb +3 -0
- data/lib/active_merchant/billing/gateways/s5.rb +8 -5
- data/lib/active_merchant/billing/gateways/safe_charge.rb +220 -0
- data/lib/active_merchant/billing/gateways/sage.rb +397 -128
- data/lib/active_merchant/billing/gateways/sage_pay.rb +45 -20
- data/lib/active_merchant/billing/gateways/secure_net.rb +0 -5
- data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +46 -17
- data/lib/active_merchant/billing/gateways/stripe.rb +125 -29
- data/lib/active_merchant/billing/gateways/telr.rb +275 -0
- data/lib/active_merchant/billing/gateways/tns.rb +13 -222
- data/lib/active_merchant/billing/gateways/trans_first.rb +40 -16
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +606 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
- data/lib/active_merchant/billing/gateways/vanco.rb +14 -10
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +73 -38
- data/lib/active_merchant/billing/gateways/wirecard.rb +1 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +48 -16
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -0
- data/lib/active_merchant/country.rb +6 -4
- data/lib/active_merchant/posts_data.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- metadata +32 -13
- data/lib/active_merchant/billing/gateways/app55.rb +0 -176
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -89
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -115
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
@@ -13,21 +13,96 @@ module ActiveMerchant #:nodoc:
|
|
13
13
|
self.display_name = 'CardStream'
|
14
14
|
|
15
15
|
CURRENCY_CODES = {
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
16
|
+
"AED" => "784",
|
17
|
+
"ALL" => "008",
|
18
|
+
"AMD" => "051",
|
19
|
+
"ANG" => "532",
|
20
|
+
"ARS" => "032",
|
21
|
+
"AUD" => "036",
|
22
|
+
"AWG" => "533",
|
23
|
+
"BAM" => "977",
|
24
|
+
"BBD" => "052",
|
25
|
+
"BGN" => "975",
|
26
|
+
"BMD" => "060",
|
27
|
+
"BOB" => "068",
|
28
|
+
"BRL" => "986",
|
29
|
+
"BSD" => "044",
|
30
|
+
"BWP" => "072",
|
31
|
+
"BZD" => "084",
|
32
|
+
"CAD" => "124",
|
33
|
+
"CHF" => "756",
|
34
|
+
"CLP" => "152",
|
35
|
+
"CNY" => "156",
|
36
|
+
"COP" => "170",
|
37
|
+
"CRC" => "188",
|
38
|
+
"CZK" => "203",
|
39
|
+
"DKK" => "208",
|
40
|
+
"DOP" => "214",
|
41
|
+
"EGP" => "818",
|
42
|
+
"EUR" => "978",
|
43
|
+
"GBP" => "826",
|
44
|
+
"GEL" => "981",
|
45
|
+
"GIP" => "292",
|
46
|
+
"GTQ" => "320",
|
47
|
+
"GYD" => "328",
|
48
|
+
"HKD" => "344",
|
49
|
+
"HNL" => "340",
|
50
|
+
"HRK" => "191",
|
51
|
+
"HUF" => "348",
|
52
|
+
"ISK" => "352",
|
53
|
+
"IDR" => "360",
|
54
|
+
"ILS" => "376",
|
55
|
+
"INR" => "356",
|
56
|
+
"JPY" => "392",
|
57
|
+
"JMD" => "388",
|
58
|
+
"KES" => "404",
|
59
|
+
"KRW" => "410",
|
60
|
+
"KYD" => "136",
|
61
|
+
"LBP" => "422",
|
62
|
+
"LKR" => "144",
|
63
|
+
"MAD" => "504",
|
64
|
+
"MVR" => "462",
|
65
|
+
"MWK" => "454",
|
66
|
+
"MXN" => "484",
|
67
|
+
"MYR" => "458",
|
68
|
+
"NAD" => "516",
|
69
|
+
"NGN" => "566",
|
70
|
+
"NIO" => "558",
|
71
|
+
"NOK" => "578",
|
72
|
+
"NPR" => "524",
|
73
|
+
"NZD" => "554",
|
74
|
+
"PAB" => "590",
|
75
|
+
"PEN" => "604",
|
76
|
+
"PGK" => "598",
|
77
|
+
"PHP" => "608",
|
78
|
+
"PKR" => "586",
|
79
|
+
"PLN" => "985",
|
80
|
+
"PYG" => "600",
|
81
|
+
"QAR" => "634",
|
82
|
+
"RON" => "946",
|
83
|
+
"RSD" => "941",
|
84
|
+
"RUB" => "643",
|
85
|
+
"RWF" => "646",
|
86
|
+
"SAR" => "682",
|
87
|
+
"SEK" => "752",
|
88
|
+
"SGD" => "702",
|
89
|
+
"SRD" => "968",
|
90
|
+
"THB" => "764",
|
91
|
+
"TND" => "788",
|
92
|
+
"TRY" => "949",
|
93
|
+
"TTD" => "780",
|
94
|
+
"TWD" => "901",
|
95
|
+
"TZS" => "834",
|
96
|
+
"UAH" => "980",
|
97
|
+
"UGX" => "800",
|
98
|
+
"USD" => "840",
|
99
|
+
"UYU" => "858",
|
100
|
+
"VND" => "704",
|
101
|
+
"WST" => "882",
|
102
|
+
"XAF" => "950",
|
103
|
+
"XCD" => "951",
|
104
|
+
"XOF" => "952",
|
105
|
+
"ZAR" => "710"
|
31
106
|
}
|
32
107
|
|
33
108
|
CVV_CODE = {
|
@@ -73,20 +148,22 @@ module ActiveMerchant #:nodoc:
|
|
73
148
|
super
|
74
149
|
end
|
75
150
|
|
76
|
-
def authorize(money,
|
151
|
+
def authorize(money, credit_card_or_reference, options = {})
|
77
152
|
post = {}
|
153
|
+
add_pair(post, :captureDelay, -1)
|
78
154
|
add_amount(post, money, options)
|
79
|
-
add_invoice(post,
|
80
|
-
|
155
|
+
add_invoice(post, credit_card_or_reference, money, options)
|
156
|
+
add_credit_card_or_reference(post, credit_card_or_reference)
|
81
157
|
add_customer_data(post, options)
|
82
|
-
commit('
|
158
|
+
commit('SALE', post)
|
83
159
|
end
|
84
160
|
|
85
|
-
def purchase(money,
|
161
|
+
def purchase(money, credit_card_or_reference, options = {})
|
86
162
|
post = {}
|
163
|
+
add_pair(post, :captureDelay, 0)
|
87
164
|
add_amount(post, money, options)
|
88
|
-
add_invoice(post,
|
89
|
-
|
165
|
+
add_invoice(post, credit_card_or_reference, money, options)
|
166
|
+
add_credit_card_or_reference(post, credit_card_or_reference)
|
90
167
|
add_customer_data(post, options)
|
91
168
|
commit('SALE', post)
|
92
169
|
end
|
@@ -94,8 +171,9 @@ module ActiveMerchant #:nodoc:
|
|
94
171
|
def capture(money, authorization, options = {})
|
95
172
|
post = {}
|
96
173
|
add_pair(post, :xref, authorization)
|
97
|
-
|
98
|
-
|
174
|
+
add_pair(post, :amount, amount(money), :required => true)
|
175
|
+
|
176
|
+
commit('CAPTURE', post)
|
99
177
|
end
|
100
178
|
|
101
179
|
def refund(money, authorization, options = {})
|
@@ -108,7 +186,7 @@ module ActiveMerchant #:nodoc:
|
|
108
186
|
def void(authorization, options = {})
|
109
187
|
post = {}
|
110
188
|
add_pair(post, :xref, authorization)
|
111
|
-
commit('
|
189
|
+
commit('CANCEL', post)
|
112
190
|
end
|
113
191
|
|
114
192
|
def verify(creditcard, options={})
|
@@ -145,20 +223,36 @@ module ActiveMerchant #:nodoc:
|
|
145
223
|
end
|
146
224
|
end
|
147
225
|
|
148
|
-
def add_invoice(post,
|
226
|
+
def add_invoice(post, credit_card_or_reference, money, options)
|
149
227
|
add_pair(post, :transactionUnique, options[:order_id], :required => true)
|
150
228
|
add_pair(post, :orderRef, options[:description] || options[:order_id], :required => true)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
229
|
+
add_pair(post, :statementNarrative1, options[:merchant_name]) if options[:merchant_name]
|
230
|
+
add_pair(post, :statementNarrative2, options[:dynamic_descriptor]) if options[:dynamic_descriptor]
|
231
|
+
if credit_card_or_reference.respond_to?(:number)
|
232
|
+
if ['american_express', 'diners_club'].include?(card_brand(credit_card_or_reference).to_s)
|
233
|
+
add_pair(post, :item1Quantity, 1)
|
234
|
+
add_pair(post, :item1Description, (options[:description] || options[:order_id]).slice(0, 15))
|
235
|
+
add_pair(post, :item1GrossValue, amount(money))
|
236
|
+
end
|
155
237
|
end
|
156
238
|
|
157
|
-
add_pair(post, :threeDSRequired, (options[:threeds_required] || @threeds_required) ? 'Y' : 'N')
|
158
239
|
add_pair(post, :type, options[:type] || '1')
|
240
|
+
add_threeds_required(post, options)
|
241
|
+
end
|
242
|
+
|
243
|
+
def add_credit_card_or_reference(post, credit_card_or_reference)
|
244
|
+
if credit_card_or_reference.respond_to?(:number)
|
245
|
+
add_credit_card(post, credit_card_or_reference)
|
246
|
+
else
|
247
|
+
add_reference(post, credit_card_or_reference.to_s)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def add_reference(post, reference)
|
252
|
+
add_pair(post, :xref, reference, :required => true)
|
159
253
|
end
|
160
254
|
|
161
|
-
def
|
255
|
+
def add_credit_card(post, credit_card)
|
162
256
|
add_pair(post, :customerName, credit_card.name, :required => true)
|
163
257
|
add_pair(post, :cardNumber, credit_card.number, :required => true)
|
164
258
|
|
@@ -175,8 +269,16 @@ module ActiveMerchant #:nodoc:
|
|
175
269
|
add_pair(post, :cardCVV, credit_card.verification_value)
|
176
270
|
end
|
177
271
|
|
272
|
+
def add_threeds_required(post, options)
|
273
|
+
add_pair(post, :threeDSRequired, (options[:threeds_required] || @threeds_required) ? 'Y' : 'N')
|
274
|
+
end
|
275
|
+
|
276
|
+
def normalize_line_endings(str)
|
277
|
+
str.gsub(/%0D%0A|%0A%0D|%0D/, "%0A")
|
278
|
+
end
|
279
|
+
|
178
280
|
def add_hmac(post)
|
179
|
-
result = post.sort.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
281
|
+
result = post.sort.collect { |key, value| "#{key}=#{normalize_line_endings(CGI.escape(value.to_s))}" }.join("&")
|
180
282
|
result = Digest::SHA512.hexdigest("#{result}#{@options[:shared_secret]}")
|
181
283
|
|
182
284
|
add_pair(post, :signature, result)
|
@@ -194,11 +296,10 @@ module ActiveMerchant #:nodoc:
|
|
194
296
|
end
|
195
297
|
|
196
298
|
def commit(action, parameters)
|
197
|
-
|
299
|
+
parameters.update(:countryCode => self.supported_countries[0]) unless ['CAPTURE', 'CANCEL'].include?(action)
|
198
300
|
parameters.update(
|
199
301
|
:merchantID => @options[:login],
|
200
|
-
:action => action
|
201
|
-
:countryCode => self.supported_countries[0],
|
302
|
+
:action => action
|
202
303
|
)
|
203
304
|
# adds a signature to the post hash/array
|
204
305
|
add_hmac(parameters)
|
@@ -211,13 +312,32 @@ module ActiveMerchant #:nodoc:
|
|
211
312
|
:test => test?,
|
212
313
|
:authorization => response[:xref],
|
213
314
|
:cvv_result => CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]],
|
214
|
-
:avs_result =>
|
215
|
-
:postal_match => AVS_POSTAL_MATCH[response[:avscv2ResponseCode].to_s[1, 1]],
|
216
|
-
:street_match => AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]]
|
217
|
-
}
|
315
|
+
:avs_result => avs_from(response)
|
218
316
|
)
|
219
317
|
end
|
220
318
|
|
319
|
+
def avs_from(response)
|
320
|
+
postal_match = AVS_POSTAL_MATCH[response[:avscv2ResponseCode].to_s[1, 1]]
|
321
|
+
street_match = AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]]
|
322
|
+
|
323
|
+
code = if postal_match == "Y" && street_match == "Y"
|
324
|
+
"M"
|
325
|
+
elsif postal_match == "Y"
|
326
|
+
"P"
|
327
|
+
elsif street_match == "Y"
|
328
|
+
"A"
|
329
|
+
else
|
330
|
+
"I"
|
331
|
+
end
|
332
|
+
|
333
|
+
AVSResult.new({
|
334
|
+
:code => code,
|
335
|
+
:postal_match => postal_match,
|
336
|
+
:street_match => street_match
|
337
|
+
})
|
338
|
+
end
|
339
|
+
|
340
|
+
|
221
341
|
def currency_code(currency)
|
222
342
|
CURRENCY_CODES[currency]
|
223
343
|
end
|
@@ -229,6 +349,7 @@ module ActiveMerchant #:nodoc:
|
|
229
349
|
def add_pair(post, key, value, options = {})
|
230
350
|
post[key] = value if !value.blank? || options[:required]
|
231
351
|
end
|
352
|
+
|
232
353
|
end
|
233
354
|
end
|
234
355
|
end
|
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
|
|
4
4
|
self.display_name = "Checkout.com V2 Gateway"
|
5
5
|
self.homepage_url = "https://www.checkout.com/"
|
6
6
|
self.live_url = "https://api2.checkout.com/v2"
|
7
|
-
self.test_url = "
|
7
|
+
self.test_url = "https://sandbox.checkout.com/api2/v2"
|
8
8
|
|
9
9
|
self.supported_countries = ['AD', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
|
10
10
|
self.default_currency = "USD"
|
@@ -78,6 +78,9 @@ module ActiveMerchant #:nodoc:
|
|
78
78
|
post[:value] = amount(money)
|
79
79
|
post[:trackId] = options[:order_id]
|
80
80
|
post[:currency] = options[:currency] || currency(money)
|
81
|
+
post[:descriptor] = {}
|
82
|
+
post[:descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
|
83
|
+
post[:descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
|
81
84
|
end
|
82
85
|
|
83
86
|
def add_payment_method(post, payment_method)
|
@@ -162,7 +165,7 @@ module ActiveMerchant #:nodoc:
|
|
162
165
|
end
|
163
166
|
|
164
167
|
def success_from(response)
|
165
|
-
response["responseCode"] ==
|
168
|
+
response["responseCode"] == "10000" || response["responseCode"] == "10100"
|
166
169
|
end
|
167
170
|
|
168
171
|
def message_from(succeeded, response)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class CitrusPayGateway < Gateway
|
4
|
+
include MastercardGateway
|
5
|
+
|
6
|
+
class_attribute :live_na_url, :live_ap_url, :test_na_url, :test_ap_url
|
7
|
+
|
8
|
+
self.test_na_url = 'https://test-gateway.mastercard.com/api/rest/version/39/'
|
9
|
+
self.test_ap_url = 'https://test-gateway.mastercard.com/api/rest/version/39/'
|
10
|
+
|
11
|
+
self.live_na_url = 'https://na-gateway.mastercard.com/api/rest/version/39/'
|
12
|
+
self.live_ap_url = 'https://ap-gateway.mastercard.com/api/rest/version/39/'
|
13
|
+
|
14
|
+
self.display_name = 'Citrus Pay'
|
15
|
+
self.homepage_url = 'http://www.citruspay.com/'
|
16
|
+
self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US)
|
17
|
+
self.default_currency = 'USD'
|
18
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser]
|
19
|
+
self.ssl_version = :TLSv1
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -10,6 +10,7 @@ module ActiveMerchant #:nodoc:
|
|
10
10
|
'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'GB']
|
11
11
|
|
12
12
|
self.default_currency = 'EUR'
|
13
|
+
self.currencies_without_fractions = %w(BIF BYR DJF GNF JPY KMF KRW PYG RWF VND VUV XAF XOF XPF)
|
13
14
|
self.supported_cardtypes = [:visa, :master]
|
14
15
|
|
15
16
|
self.homepage_url = 'https://www.clearhaus.com'
|
@@ -37,21 +38,12 @@ module ActiveMerchant #:nodoc:
|
|
37
38
|
50000 => 'Clearhaus error'
|
38
39
|
}
|
39
40
|
|
40
|
-
# Create gateway
|
41
|
-
#
|
42
|
-
# options:
|
43
|
-
# :api_key - merchant's Clearhaus API Key
|
44
|
-
# :signing_key - merchant's private key for optionally signing request
|
45
41
|
def initialize(options={})
|
46
42
|
requires!(options, :api_key)
|
43
|
+
options[:private_key] = options[:private_key].strip if options[:private_key]
|
47
44
|
super
|
48
45
|
end
|
49
46
|
|
50
|
-
# Make a purchase (authorize and capture)
|
51
|
-
#
|
52
|
-
# amount - The monetary amount of the transaction in cents.
|
53
|
-
# payment - The CreditCard or the Clearhaus card token.
|
54
|
-
# options - A standard ActiveMerchant options hash
|
55
47
|
def purchase(amount, payment, options={})
|
56
48
|
MultiResponse.run(:use_first_response) do |r|
|
57
49
|
r.process { authorize(amount, payment, options) }
|
@@ -59,11 +51,6 @@ module ActiveMerchant #:nodoc:
|
|
59
51
|
end
|
60
52
|
end
|
61
53
|
|
62
|
-
# Authorize a transaction.
|
63
|
-
#
|
64
|
-
# amount - The monetary amount of the transaction in cents.
|
65
|
-
# payment - The CreditCard or the Clearhaus card token.
|
66
|
-
# options - A standard ActiveMerchant options hash with optional pares
|
67
54
|
def authorize(amount, payment, options={})
|
68
55
|
post = {}
|
69
56
|
add_invoice(post, amount, options)
|
@@ -83,23 +70,13 @@ module ActiveMerchant #:nodoc:
|
|
83
70
|
commit(action, post)
|
84
71
|
end
|
85
72
|
|
86
|
-
# Capture a pre-authorized transaction.
|
87
|
-
#
|
88
|
-
# amount - The monetary amount of the transaction in cents.
|
89
|
-
# authorization - The Clearhaus authorization id string.
|
90
|
-
# options - A standard ActiveMerchant options hash
|
91
73
|
def capture(amount, authorization, options={})
|
92
74
|
post = {}
|
93
|
-
|
75
|
+
add_invoice(post, amount, options)
|
94
76
|
|
95
77
|
commit("/authorizations/#{authorization}/captures", post)
|
96
78
|
end
|
97
79
|
|
98
|
-
# Refund a captured transaction (fully or partial).
|
99
|
-
#
|
100
|
-
# amount - The monetary amount of the transaction in cents.
|
101
|
-
# authorization - The Clearhaus authorization id string.
|
102
|
-
# options - A standard ActiveMerchant options hash
|
103
80
|
def refund(amount, authorization, options={})
|
104
81
|
post = {}
|
105
82
|
add_amount(post, amount, options)
|
@@ -118,10 +95,6 @@ module ActiveMerchant #:nodoc:
|
|
118
95
|
end
|
119
96
|
end
|
120
97
|
|
121
|
-
# Tokenize credit card with Clearhaus.
|
122
|
-
#
|
123
|
-
# credit_card - The CreditCard.
|
124
|
-
# options - A standard ActiveMerchant options hash
|
125
98
|
def store(credit_card, options={})
|
126
99
|
post = {}
|
127
100
|
add_payment(post, credit_card)
|
@@ -145,11 +118,11 @@ module ActiveMerchant #:nodoc:
|
|
145
118
|
def add_invoice(post, money, options)
|
146
119
|
add_amount(post, money, options)
|
147
120
|
post[:reference] = options[:order_id] if options[:order_id]
|
148
|
-
post[:text_on_statement] = options[:
|
121
|
+
post[:text_on_statement] = options[:text_on_statement] if options[:text_on_statement]
|
149
122
|
end
|
150
123
|
|
151
124
|
def add_amount(post, amount, options)
|
152
|
-
post[:amount] =
|
125
|
+
post[:amount] = localized_amount(amount, options[:currency] || default_currency)
|
153
126
|
post[:currency] = (options[:currency] || default_currency)
|
154
127
|
end
|
155
128
|
|
@@ -182,8 +155,12 @@ module ActiveMerchant #:nodoc:
|
|
182
155
|
headers = headers(@options[:api_key])
|
183
156
|
body = parameters.to_query
|
184
157
|
|
185
|
-
if signing_key
|
186
|
-
|
158
|
+
if @options[:signing_key] && @options[:private_key]
|
159
|
+
begin
|
160
|
+
headers["Signature"] = generate_signature(body)
|
161
|
+
rescue OpenSSL::PKey::RSAError => e
|
162
|
+
return Response.new(false, e.message)
|
163
|
+
end
|
187
164
|
end
|
188
165
|
|
189
166
|
response = begin
|
@@ -197,7 +174,7 @@ module ActiveMerchant #:nodoc:
|
|
197
174
|
success_from(response),
|
198
175
|
message_from(response),
|
199
176
|
response,
|
200
|
-
authorization: authorization_from(response),
|
177
|
+
authorization: authorization_from(action, response),
|
201
178
|
test: test?,
|
202
179
|
error_code: error_code_from(response)
|
203
180
|
)
|
@@ -217,15 +194,22 @@ module ActiveMerchant #:nodoc:
|
|
217
194
|
end
|
218
195
|
end
|
219
196
|
|
220
|
-
def authorization_from(response)
|
221
|
-
response['id']
|
197
|
+
def authorization_from(action, response)
|
198
|
+
id_of_auth_for_capture(action) || response['id']
|
199
|
+
end
|
200
|
+
|
201
|
+
def id_of_auth_for_capture(action)
|
202
|
+
match = action.match(/authorizations\/(.+)\/captures/)
|
203
|
+
return nil unless match
|
204
|
+
|
205
|
+
match.captures.first
|
222
206
|
end
|
223
207
|
|
224
|
-
def generate_signature(
|
225
|
-
key = OpenSSL::PKey::RSA.new(
|
208
|
+
def generate_signature(body)
|
209
|
+
key = OpenSSL::PKey::RSA.new(@options[:private_key])
|
226
210
|
hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack('H*').first
|
227
211
|
|
228
|
-
"#{
|
212
|
+
"#{@options[:signing_key]} RS256-hex #{hex}"
|
229
213
|
end
|
230
214
|
|
231
215
|
def error_code_from(response)
|
@@ -12,7 +12,7 @@ module ActiveMerchant #:nodoc:
|
|
12
12
|
|
13
13
|
def initialize(options = {})
|
14
14
|
requires!(options, :key)
|
15
|
-
options[:version] ||= '0.
|
15
|
+
options[:version] ||= '1.0.0'
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
@@ -55,6 +55,11 @@ module ActiveMerchant #:nodoc:
|
|
55
55
|
commit(:post, "charges/#{identifier}/refund", post)
|
56
56
|
end
|
57
57
|
|
58
|
+
def void(identifier, options = {})
|
59
|
+
post = {}
|
60
|
+
commit(:post, "charges/#{identifier}/void", post)
|
61
|
+
end
|
62
|
+
|
58
63
|
def supports_scrubbing
|
59
64
|
true
|
60
65
|
end
|
@@ -120,7 +120,7 @@ module ActiveMerchant #:nodoc:
|
|
120
120
|
|
121
121
|
def add_card_details(xml, payment_method, options={})
|
122
122
|
xml.CardDetails do
|
123
|
-
xml.Manual(type: "
|
123
|
+
xml.Manual(type: "ecommerce") do
|
124
124
|
xml.PAN payment_method.number
|
125
125
|
xml.ExpiryDate exp_date(payment_method)
|
126
126
|
xml.CSC payment_method.verification_value unless empty?(payment_method.verification_value)
|