activemerchant 1.62.0 → 1.79.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +420 -2
  3. data/README.md +1 -2
  4. data/lib/active_merchant/billing/credit_card.rb +13 -14
  5. data/lib/active_merchant/billing/credit_card_methods.rb +3 -1
  6. data/lib/active_merchant/billing/gateway.rb +25 -9
  7. data/lib/active_merchant/billing/gateways/adyen.rb +299 -0
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +168 -56
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +4 -2
  10. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +65 -22
  11. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +87 -7
  12. data/lib/active_merchant/billing/gateways/beanstream.rb +2 -0
  13. data/lib/active_merchant/billing/gateways/blue_snap.rb +3 -8
  14. data/lib/active_merchant/billing/gateways/borgun.rb +10 -10
  15. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +1 -0
  16. data/lib/active_merchant/billing/gateways/braintree_blue.rb +49 -15
  17. data/lib/active_merchant/billing/gateways/card_connect.rb +286 -0
  18. data/lib/active_merchant/billing/gateways/card_stream.rb +97 -2
  19. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  20. data/lib/active_merchant/billing/gateways/cashnet.rb +14 -2
  21. data/lib/active_merchant/billing/gateways/cenpos.rb +1 -1
  22. data/lib/active_merchant/billing/gateways/checkout.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/checkout_v2.rb +44 -14
  24. data/lib/active_merchant/billing/gateways/citrus_pay.rb +0 -1
  25. data/lib/active_merchant/billing/gateways/clearhaus.rb +0 -2
  26. data/lib/active_merchant/billing/gateways/conekta.rb +4 -4
  27. data/lib/active_merchant/billing/gateways/creditcall.rb +71 -9
  28. data/lib/active_merchant/billing/gateways/credorax.rb +117 -5
  29. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  30. data/lib/active_merchant/billing/gateways/cyber_source.rb +54 -15
  31. data/lib/active_merchant/billing/gateways/data_cash.rb +12 -0
  32. data/lib/active_merchant/billing/gateways/dibs.rb +0 -1
  33. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  34. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  35. data/lib/active_merchant/billing/gateways/elavon.rb +37 -95
  36. data/lib/active_merchant/billing/gateways/element.rb +11 -1
  37. data/lib/active_merchant/billing/gateways/fat_zebra.rb +3 -29
  38. data/lib/active_merchant/billing/gateways/first_pay.rb +12 -10
  39. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +37 -20
  40. data/lib/active_merchant/billing/gateways/forte.rb +0 -1
  41. data/lib/active_merchant/billing/gateways/global_collect.rb +55 -16
  42. data/lib/active_merchant/billing/gateways/global_transport.rb +16 -2
  43. data/lib/active_merchant/billing/gateways/hps.rb +12 -1
  44. data/lib/active_merchant/billing/gateways/iats_payments.rb +2 -2
  45. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  46. data/lib/active_merchant/billing/gateways/jetpay.rb +12 -9
  47. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  48. data/lib/active_merchant/billing/gateways/kushki.rb +227 -0
  49. data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -2
  50. data/lib/active_merchant/billing/gateways/litle.rb +107 -30
  51. data/lib/active_merchant/billing/gateways/mercado_pago.rb +262 -0
  52. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +11 -0
  53. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +16 -4
  54. data/lib/active_merchant/billing/gateways/mercury.rb +14 -1
  55. data/lib/active_merchant/billing/gateways/migs.rb +28 -6
  56. data/lib/active_merchant/billing/gateways/moneris.rb +20 -12
  57. data/lib/active_merchant/billing/gateways/moneris_us.rb +11 -0
  58. data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
  59. data/lib/active_merchant/billing/gateways/nab_transact.rb +4 -4
  60. data/lib/active_merchant/billing/gateways/netbanx.rb +60 -16
  61. data/lib/active_merchant/billing/gateways/netbilling.rb +0 -1
  62. data/lib/active_merchant/billing/gateways/nmi.rb +12 -1
  63. data/lib/active_merchant/billing/gateways/ogone.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/omise.rb +9 -5
  65. data/lib/active_merchant/billing/gateways/openpay.rb +13 -0
  66. data/lib/active_merchant/billing/gateways/opp.rb +124 -114
  67. data/lib/active_merchant/billing/gateways/optimal_payment.rb +14 -1
  68. data/lib/active_merchant/billing/gateways/orbital.rb +83 -14
  69. data/lib/active_merchant/billing/gateways/pay_hub.rb +2 -2
  70. data/lib/active_merchant/billing/gateways/payeezy.rb +152 -46
  71. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +12 -2
  72. data/lib/active_merchant/billing/gateways/payflow.rb +24 -2
  73. data/lib/active_merchant/billing/gateways/payment_express.rb +3 -2
  74. data/lib/active_merchant/billing/gateways/paymentez.rb +276 -0
  75. data/lib/active_merchant/billing/gateways/paymill.rb +18 -10
  76. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +14 -0
  77. data/lib/active_merchant/billing/gateways/paypal.rb +0 -12
  78. data/lib/active_merchant/billing/gateways/paystation.rb +14 -1
  79. data/lib/active_merchant/billing/gateways/payu_latam.rb +102 -62
  80. data/lib/active_merchant/billing/gateways/pin.rb +5 -0
  81. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  82. data/lib/active_merchant/billing/gateways/psigate.rb +12 -1
  83. data/lib/active_merchant/billing/gateways/qbms.rb +11 -0
  84. data/lib/active_merchant/billing/gateways/quickbooks.rb +10 -0
  85. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +21 -17
  86. data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
  87. data/lib/active_merchant/billing/gateways/qvalent.rb +60 -3
  88. data/lib/active_merchant/billing/gateways/realex.rb +16 -6
  89. data/lib/active_merchant/billing/gateways/redsys.rb +8 -2
  90. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  91. data/lib/active_merchant/billing/gateways/sage.rb +8 -3
  92. data/lib/active_merchant/billing/gateways/sage_pay.rb +29 -13
  93. data/lib/active_merchant/billing/gateways/secure_net.rb +11 -1
  94. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
  95. data/lib/active_merchant/billing/gateways/smart_ps.rb +1 -1
  96. data/lib/active_merchant/billing/gateways/spreedly_core.rb +53 -7
  97. data/lib/active_merchant/billing/gateways/stripe.rb +84 -26
  98. data/lib/active_merchant/billing/gateways/tns.rb +0 -1
  99. data/lib/active_merchant/billing/gateways/trans_first.rb +3 -2
  100. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +61 -26
  101. data/lib/active_merchant/billing/gateways/trexle.rb +217 -0
  102. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
  103. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +45 -22
  104. data/lib/active_merchant/billing/gateways/vanco.rb +1 -1
  105. data/lib/active_merchant/billing/gateways/wepay.rb +79 -46
  106. data/lib/active_merchant/billing/gateways/wirecard.rb +5 -4
  107. data/lib/active_merchant/billing/gateways/worldpay.rb +85 -20
  108. data/lib/active_merchant/billing/gateways/worldpay_us.rb +27 -8
  109. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  110. data/lib/active_merchant/connection.rb +48 -12
  111. data/lib/active_merchant/net_http_ssl_connection.rb +9 -0
  112. data/lib/active_merchant/network_connection_retries.rb +6 -4
  113. data/lib/active_merchant/posts_data.rb +11 -1
  114. data/lib/active_merchant/version.rb +1 -1
  115. data/lib/active_merchant.rb +2 -5
  116. data/lib/certs/cacert.pem +85 -0
  117. data/lib/support/ssl_version.rb +87 -0
  118. metadata +25 -9
  119. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
@@ -0,0 +1,299 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class AdyenGateway < Gateway
4
+
5
+ # we recommend setting up merchant-specific endpoints.
6
+ # https://docs.adyen.com/developers/api-manual#apiendpoints
7
+ self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v18'
8
+ self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v18'
9
+
10
+ self.supported_countries = ['AT','AU','BE','BG','BR','CH','CY','CZ','DE','DK','EE','ES','FI','FR','GB','GI','GR','HK','HU','IE','IS','IT','LI','LT','LU','LV','MC','MT','MX','NL','NO','PL','PT','RO','SE','SG','SK','SI','US']
11
+ self.default_currency = 'USD'
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover]
13
+
14
+ self.money_format = :cents
15
+
16
+ self.homepage_url = 'https://www.adyen.com/'
17
+ self.display_name = 'Adyen'
18
+
19
+ STANDARD_ERROR_CODE_MAPPING = {
20
+ '101' => STANDARD_ERROR_CODE[:incorrect_number],
21
+ '103' => STANDARD_ERROR_CODE[:invalid_cvc],
22
+ '131' => STANDARD_ERROR_CODE[:incorrect_address],
23
+ '132' => STANDARD_ERROR_CODE[:incorrect_address],
24
+ '133' => STANDARD_ERROR_CODE[:incorrect_address],
25
+ '134' => STANDARD_ERROR_CODE[:incorrect_address],
26
+ '135' => STANDARD_ERROR_CODE[:incorrect_address],
27
+ }
28
+
29
+ def initialize(options={})
30
+ requires!(options, :username, :password, :merchant_account)
31
+ @username, @password, @merchant_account = options.values_at(:username, :password, :merchant_account)
32
+ super
33
+ end
34
+
35
+ def purchase(money, payment, options={})
36
+ MultiResponse.run do |r|
37
+ r.process{authorize(money, payment, options)}
38
+ r.process{capture(money, r.authorization, options)}
39
+ end
40
+ end
41
+
42
+ def authorize(money, payment, options={})
43
+ requires!(options, :order_id)
44
+ post = init_post(options)
45
+ add_invoice(post, money, options)
46
+ add_payment(post, payment)
47
+ add_extra_data(post, options)
48
+ add_shopper_interaction(post, payment, options)
49
+ add_address(post, options)
50
+ add_installments(post, options) if options[:installments]
51
+ commit('authorise', post)
52
+ end
53
+
54
+ def capture(money, authorization, options={})
55
+ post = init_post(options)
56
+ add_invoice_for_modification(post, money, options)
57
+ add_reference(post, authorization, options)
58
+ commit('capture', post)
59
+ end
60
+
61
+ def refund(money, authorization, options={})
62
+ post = init_post(options)
63
+ add_invoice_for_modification(post, money, options)
64
+ add_original_reference(post, authorization, options)
65
+ commit('refund', post)
66
+ end
67
+
68
+ def void(authorization, options={})
69
+ post = init_post(options)
70
+ add_reference(post, authorization, options)
71
+ commit('cancel', post)
72
+ end
73
+
74
+ def store(credit_card, options={})
75
+ requires!(options, :order_id)
76
+ post = init_post(options)
77
+ add_invoice(post, 0, options)
78
+ add_payment(post, credit_card)
79
+ add_extra_data(post, options)
80
+ add_recurring_contract(post, options)
81
+ add_address(post, options)
82
+ commit('authorise', post)
83
+ end
84
+
85
+ def verify(credit_card, options={})
86
+ MultiResponse.run(:use_first_response) do |r|
87
+ r.process { authorize(0, credit_card, options) }
88
+ r.process(:ignore_result) { void(r.authorization, options) }
89
+ end
90
+ end
91
+
92
+ def supports_scrubbing?
93
+ true
94
+ end
95
+
96
+ def scrub(transcript)
97
+ transcript.
98
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
99
+ gsub(%r(("number\\?":\\?")[^"]*)i, '\1[FILTERED]').
100
+ gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]')
101
+ end
102
+
103
+ private
104
+
105
+ def add_extra_data(post, options)
106
+ post[:shopperEmail] = options[:shopper_email] if options[:shopper_email]
107
+ post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip]
108
+ post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference]
109
+ post[:fraudOffset] = options[:fraud_offset] if options[:fraud_offset]
110
+ post[:selectedBrand] = options[:selected_brand] if options[:selected_brand]
111
+ post[:deliveryDate] = options[:delivery_date] if options[:delivery_date]
112
+ post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference]
113
+ end
114
+
115
+ def add_shopper_interaction(post, payment, options={})
116
+ if payment.respond_to?(:verification_value) && payment.verification_value
117
+ shopper_interaction = "Ecommerce"
118
+ else
119
+ shopper_interaction = "ContAuth"
120
+ end
121
+
122
+ post[:shopperInteraction] = options[:shopper_interaction] || shopper_interaction
123
+ end
124
+
125
+ def add_address(post, options)
126
+ return unless post[:card] && post[:card].kind_of?(Hash)
127
+ if (address = options[:billing_address] || options[:address]) && address[:country]
128
+ post[:card][:billingAddress] = {}
129
+ post[:card][:billingAddress][:street] = address[:address1] || 'N/A'
130
+ post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
131
+ post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip]
132
+ post[:card][:billingAddress][:city] = address[:city] || 'N/A'
133
+ post[:card][:billingAddress][:stateOrProvince] = address[:state] if address[:state]
134
+ post[:card][:billingAddress][:country] = address[:country] if address[:country]
135
+ end
136
+ end
137
+
138
+ def add_invoice(post, money, options)
139
+ amount = {
140
+ value: amount(money),
141
+ currency: options[:currency] || currency(money)
142
+ }
143
+ post[:amount] = amount
144
+ end
145
+
146
+ def add_invoice_for_modification(post, money, options)
147
+ amount = {
148
+ value: amount(money),
149
+ currency: options[:currency] || currency(money)
150
+ }
151
+ post[:modificationAmount] = amount
152
+ end
153
+
154
+ def add_payment(post, payment)
155
+ if payment.is_a?(String)
156
+ _, _, recurring_detail_reference = payment.split("#")
157
+ post[:selectedRecurringDetailReference] = recurring_detail_reference
158
+ add_recurring_contract(post, options)
159
+ else
160
+ add_card(post, payment)
161
+ end
162
+ end
163
+
164
+ def add_card(post, credit_card)
165
+ card = {
166
+ expiryMonth: credit_card.month,
167
+ expiryYear: credit_card.year,
168
+ holderName: credit_card.name,
169
+ number: credit_card.number,
170
+ cvc: credit_card.verification_value
171
+ }
172
+
173
+ card.delete_if{|k,v| v.blank? }
174
+ requires!(card, :expiryMonth, :expiryYear, :holderName, :number)
175
+ post[:card] = card
176
+ end
177
+
178
+ def add_reference(post, authorization, options = {})
179
+ _, psp_reference, _ = authorization.split("#")
180
+ post[:originalReference] = single_reference(authorization) || psp_reference
181
+ end
182
+
183
+ def add_original_reference(post, authorization, options = {})
184
+ original_psp_reference, _, _ = authorization.split("#")
185
+ post[:originalReference] = single_reference(authorization) || original_psp_reference
186
+ end
187
+
188
+ def single_reference(authorization)
189
+ authorization if !authorization.include?("#")
190
+ end
191
+
192
+ def add_recurring_contract(post, options = {})
193
+ recurring = {
194
+ contract: "RECURRING"
195
+ }
196
+
197
+ post[:recurring] = recurring
198
+ end
199
+
200
+ def add_installments(post, options)
201
+ post[:installments] = {
202
+ value: options[:installments]
203
+ }
204
+ end
205
+
206
+ def parse(body)
207
+ return {} if body.blank?
208
+ JSON.parse(body)
209
+ end
210
+
211
+ def commit(action, parameters)
212
+ begin
213
+ raw_response = ssl_post("#{url}/#{action.to_s}", post_data(action, parameters), request_headers)
214
+ response = parse(raw_response)
215
+ rescue ResponseError => e
216
+ raw_response = e.response.body
217
+ response = parse(raw_response)
218
+ end
219
+
220
+ success = success_from(action, response)
221
+ Response.new(
222
+ success,
223
+ message_from(action, response),
224
+ response,
225
+ authorization: authorization_from(action, parameters, response),
226
+ test: test?,
227
+ error_code: success ? nil : error_code_from(response)
228
+ )
229
+
230
+ end
231
+
232
+ def url
233
+ if test?
234
+ test_url
235
+ elsif @options[:subdomain]
236
+ "https://#{@options[:subdomain]}-pal-live.adyenpayments.com/pal/servlet/Payment/v18"
237
+ else
238
+ live_url
239
+ end
240
+ end
241
+
242
+ def basic_auth
243
+ Base64.strict_encode64("#{@username}:#{@password}")
244
+ end
245
+
246
+ def request_headers
247
+ {
248
+ "Content-Type" => "application/json",
249
+ "Authorization" => "Basic #{basic_auth}"
250
+ }
251
+ end
252
+
253
+ def success_from(action, response)
254
+ case action.to_s
255
+ when 'authorise'
256
+ ['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode'])
257
+ when 'capture', 'refund', 'cancel'
258
+ response['response'] == "[#{action}-received]"
259
+ else
260
+ false
261
+ end
262
+ end
263
+
264
+ def message_from(action, response)
265
+ return authorize_message_from(response) if action.to_s == 'authorise'
266
+ response['response'] || response['message']
267
+ end
268
+
269
+ def authorize_message_from(response)
270
+ if response['refusalReason'] && response['additionalData'] && response['additionalData']['refusalReasonRaw']
271
+ "#{response['refusalReason']} | #{response['additionalData']['refusalReasonRaw']}"
272
+ else
273
+ response['refusalReason'] || response['resultCode'] || response['message']
274
+ end
275
+ end
276
+
277
+ def authorization_from(action, parameters, response)
278
+ return nil if response['pspReference'].nil?
279
+ recurring = response['additionalData']['recurring.recurringDetailReference'] if response['additionalData']
280
+ "#{parameters[:originalReference]}##{response['pspReference']}##{recurring}"
281
+ end
282
+
283
+ def init_post(options = {})
284
+ post = {}
285
+ post[:merchantAccount] = options[:merchant_account] || @merchant_account
286
+ post[:reference] = options[:order_id] if options[:order_id]
287
+ post
288
+ end
289
+
290
+ def post_data(action, parameters = {})
291
+ JSON.generate(parameters)
292
+ end
293
+
294
+ def error_code_from(response)
295
+ STANDARD_ERROR_CODE_MAPPING[response['errorCode']]
296
+ end
297
+ end
298
+ end
299
+ end