activemerchant 1.56.0 → 1.66.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +331 -0
  3. data/README.md +9 -9
  4. data/lib/active_merchant/billing/check.rb +3 -0
  5. data/lib/active_merchant/billing/credit_card.rb +8 -3
  6. data/lib/active_merchant/billing/credit_card_methods.rb +41 -1
  7. data/lib/active_merchant/billing/gateway.rb +14 -6
  8. data/lib/active_merchant/billing/gateways/adyen.rb +228 -0
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +157 -44
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +7 -4
  11. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +283 -0
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +68 -2
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -2
  14. data/lib/active_merchant/billing/gateways/blue_snap.rb +348 -0
  15. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  16. data/lib/active_merchant/billing/gateways/braintree_blue.rb +58 -20
  17. data/lib/active_merchant/billing/gateways/bridge_pay.rb +37 -8
  18. data/lib/active_merchant/billing/gateways/card_stream.rb +161 -40
  19. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -0
  20. data/lib/active_merchant/billing/gateways/checkout_v2.rb +5 -2
  21. data/lib/active_merchant/billing/gateways/citrus_pay.rb +24 -0
  22. data/lib/active_merchant/billing/gateways/clearhaus.rb +24 -40
  23. data/lib/active_merchant/billing/gateways/conekta.rb +6 -1
  24. data/lib/active_merchant/billing/gateways/creditcall.rb +1 -1
  25. data/lib/active_merchant/billing/gateways/credorax.rb +310 -0
  26. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  27. data/lib/active_merchant/billing/gateways/cyber_source.rb +80 -64
  28. data/lib/active_merchant/billing/gateways/data_cash.rb +10 -304
  29. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  30. data/lib/active_merchant/billing/gateways/elavon.rb +40 -26
  31. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  32. data/lib/active_merchant/billing/gateways/fat_zebra.rb +16 -2
  33. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -1
  34. data/lib/active_merchant/billing/gateways/forte.rb +10 -2
  35. data/lib/active_merchant/billing/gateways/global_collect.rb +311 -0
  36. data/lib/active_merchant/billing/gateways/global_transport.rb +1 -0
  37. data/lib/active_merchant/billing/gateways/iats_payments.rb +13 -0
  38. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  39. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  40. data/lib/active_merchant/billing/gateways/jetpay.rb +33 -19
  41. data/lib/active_merchant/billing/gateways/kushki.rb +217 -0
  42. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  43. data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -0
  44. data/lib/active_merchant/billing/gateways/litle.rb +29 -13
  45. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  46. data/lib/active_merchant/billing/gateways/maxipago.rb +145 -122
  47. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +15 -1
  48. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +10 -7
  49. data/lib/active_merchant/billing/gateways/mercury.rb +13 -5
  50. data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -1
  51. data/lib/active_merchant/billing/gateways/migs.rb +23 -1
  52. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  53. data/lib/active_merchant/billing/gateways/moneris.rb +21 -1
  54. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -0
  55. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  56. data/lib/active_merchant/billing/gateways/netbanx.rb +245 -0
  57. data/lib/active_merchant/billing/gateways/nmi.rb +30 -9
  58. data/lib/active_merchant/billing/gateways/omise.rb +9 -5
  59. data/lib/active_merchant/billing/gateways/openpay.rb +10 -1
  60. data/lib/active_merchant/billing/gateways/opp.rb +362 -0
  61. data/lib/active_merchant/billing/gateways/orbital.rb +28 -7
  62. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  63. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  64. data/lib/active_merchant/billing/gateways/payeezy.rb +61 -12
  65. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/payflow.rb +6 -0
  67. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/paymill.rb +29 -11
  69. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -6
  71. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -2
  72. data/lib/active_merchant/billing/gateways/payu_latam.rb +402 -0
  73. data/lib/active_merchant/billing/gateways/pin.rb +6 -3
  74. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  75. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  76. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +0 -2
  78. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -1
  79. data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
  80. data/lib/active_merchant/billing/gateways/qvalent.rb +44 -1
  81. data/lib/active_merchant/billing/gateways/redsys.rb +3 -0
  82. data/lib/active_merchant/billing/gateways/s5.rb +8 -5
  83. data/lib/active_merchant/billing/gateways/safe_charge.rb +220 -0
  84. data/lib/active_merchant/billing/gateways/sage.rb +397 -128
  85. data/lib/active_merchant/billing/gateways/sage_pay.rb +45 -20
  86. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -5
  87. data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
  89. data/lib/active_merchant/billing/gateways/securion_pay.rb +46 -17
  90. data/lib/active_merchant/billing/gateways/stripe.rb +125 -29
  91. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  92. data/lib/active_merchant/billing/gateways/tns.rb +13 -222
  93. data/lib/active_merchant/billing/gateways/trans_first.rb +40 -16
  94. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +606 -0
  95. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
  96. data/lib/active_merchant/billing/gateways/vanco.rb +14 -10
  97. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  98. data/lib/active_merchant/billing/gateways/wepay.rb +73 -38
  99. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -0
  100. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  101. data/lib/active_merchant/billing/gateways/worldpay.rb +48 -16
  102. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -0
  103. data/lib/active_merchant/country.rb +6 -4
  104. data/lib/active_merchant/posts_data.rb +1 -1
  105. data/lib/active_merchant/version.rb +1 -1
  106. metadata +32 -13
  107. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  108. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  109. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  110. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -89
  111. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -115
  112. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  113. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
@@ -0,0 +1,220 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class SafeChargeGateway < Gateway
6
+ self.test_url = 'https://process.sandbox.safecharge.com/service.asmx/Process'
7
+ self.live_url = 'https://process.safecharge.com/service.asmx/Process'
8
+
9
+ self.supported_countries = ['US']
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = [:visa, :master]
12
+
13
+ self.homepage_url = 'https://www.safecharge.com'
14
+ self.display_name = 'SafeCharge'
15
+
16
+ VERSION = '4.0.4'
17
+
18
+ def initialize(options={})
19
+ requires!(options, :client_login_id, :client_password)
20
+ super
21
+ end
22
+
23
+ def purchase(money, payment, options={})
24
+ post = {}
25
+ add_transaction_data("Sale", post, money, options)
26
+ add_payment(post, payment)
27
+
28
+ commit(post)
29
+ end
30
+
31
+ def authorize(money, payment, options={})
32
+ post = {}
33
+ add_transaction_data("Auth", post, money, options)
34
+ add_payment(post, payment)
35
+
36
+ commit(post)
37
+ end
38
+
39
+ def capture(money, authorization, options={})
40
+ post = {}
41
+ add_transaction_data("Settle", post, money, options)
42
+ auth, transaction_id, token, exp_month, exp_year, _ = authorization.split("|")
43
+ post[:sg_AuthCode] = auth
44
+ post[:sg_TransactionID] = transaction_id
45
+ post[:sg_CCToken] = token
46
+ post[:sg_ExpMonth] = exp_month
47
+ post[:sg_ExpYear] = exp_year
48
+
49
+ commit(post)
50
+ end
51
+
52
+ def refund(money, authorization, options={})
53
+ post = {}
54
+ add_transaction_data("Credit", post, money, options)
55
+ auth, transaction_id, token, exp_month, exp_year, _ = authorization.split("|")
56
+ post[:sg_CreditType] = 2
57
+ post[:sg_AuthCode] = auth
58
+ post[:sg_TransactionID] = transaction_id
59
+ post[:sg_CCToken] = token
60
+ post[:sg_ExpMonth] = exp_month
61
+ post[:sg_ExpYear] = exp_year
62
+
63
+ commit(post)
64
+ end
65
+
66
+ def credit(money, payment, options={})
67
+ post = {}
68
+ add_payment(post, payment)
69
+ add_transaction_data("Credit", post, money, options)
70
+ post[:sg_CreditType] = 1
71
+
72
+ commit(post)
73
+ end
74
+
75
+ def void(authorization, options={})
76
+ post = {}
77
+ auth, transaction_id, token, exp_month, exp_year, original_amount = authorization.split("|")
78
+ add_transaction_data("Void", post, (original_amount.to_f * 100), options)
79
+ post[:sg_CreditType] = 2
80
+ post[:sg_AuthCode] = auth
81
+ post[:sg_TransactionID] = transaction_id
82
+ post[:sg_CCToken] = token
83
+ post[:sg_ExpMonth] = exp_month
84
+ post[:sg_ExpYear] = exp_year
85
+
86
+ commit(post)
87
+ end
88
+
89
+ def verify(credit_card, options={})
90
+ MultiResponse.run(:use_first_response) do |r|
91
+ r.process { authorize(100, credit_card, options) }
92
+ r.process(:ignore_result) { void(r.authorization, options) }
93
+ end
94
+ end
95
+
96
+ def supports_scrubbing?
97
+ true
98
+ end
99
+
100
+ def scrub(transcript)
101
+ transcript.
102
+ gsub(%r((sg_ClientPassword=)[^&]+(&?)), '\1[FILTERED]\2').
103
+ gsub(%r((sg_CardNumber=)[^&]+(&?)), '\1[FILTERED]\2').
104
+ gsub(%r((sg_CVV2=)\d+), '\1[FILTERED]')
105
+ end
106
+
107
+ private
108
+
109
+ def add_transaction_data(trans_type, post, money, options)
110
+ post[:sg_TransType] = trans_type
111
+ post[:sg_Currency] = (options[:currency] || currency(money))
112
+ post[:sg_Amount] = amount(money)
113
+ post[:sg_ClientLoginID] = @options[:client_login_id]
114
+ post[:sg_ClientPassword] = @options[:client_password]
115
+ post[:sg_ResponseFormat] = "4"
116
+ post[:sg_Version] = VERSION
117
+ end
118
+
119
+ def add_payment(post, payment)
120
+ post[:sg_NameOnCard] = payment.name
121
+ post[:sg_CardNumber] = payment.number
122
+ post[:sg_ExpMonth] = format(payment.month, :two_digits)
123
+ post[:sg_ExpYear] = format(payment.year, :two_digits)
124
+ post[:sg_CVV2] = payment.verification_value
125
+ end
126
+
127
+ def parse(xml)
128
+ response = {}
129
+
130
+ doc = Nokogiri::XML(xml)
131
+ doc.root.xpath('*').each do |node|
132
+ response[node.name.underscore.downcase.to_sym] = node.text
133
+ end
134
+
135
+ response
136
+ end
137
+
138
+ def childnode_to_response(response, node, childnode)
139
+ name = "#{node.name.downcase}_#{childnode.name.downcase}"
140
+ if name == 'payment_method_data' && !childnode.elements.empty?
141
+ response[name.to_sym] = Hash.from_xml(childnode.to_s).values.first
142
+ else
143
+ response[name.to_sym] = childnode.text
144
+ end
145
+ end
146
+
147
+ def commit(parameters)
148
+ url = (test? ? test_url : live_url)
149
+ response = parse(ssl_post(url, post_data(parameters)))
150
+
151
+ Response.new(
152
+ success_from(response),
153
+ message_from(response),
154
+ response,
155
+ authorization: authorization_from(response, parameters),
156
+ avs_result: AVSResult.new(code: response[:avs_code]),
157
+ cvv_result: CVVResult.new(response[:cvv2_reply]),
158
+ test: test?,
159
+ error_code: error_code_from(response)
160
+ )
161
+ end
162
+
163
+ def success_from(response)
164
+ response[:status] == "APPROVED"
165
+ end
166
+
167
+ def message_from(response)
168
+ return "Success" if success_from(response)
169
+ response[:reason_codes] || response[:reason]
170
+ end
171
+
172
+ def authorization_from(response, parameters)
173
+ [
174
+ response[:auth_code],
175
+ response[:transaction_id],
176
+ response[:token],
177
+ parameters[:sg_ExpMonth],
178
+ parameters[:sg_ExpYear],
179
+ parameters[:sg_Amount]
180
+ ].join("|")
181
+ end
182
+
183
+ def split_authorization(authorization)
184
+ auth_code, transaction_id, token, month, year, original_amount = authorization.split("|")
185
+
186
+ {
187
+ auth_code: auth_code,
188
+ transaction_id: transaction_id,
189
+ token: token,
190
+ exp_month: month,
191
+ exp_year: year,
192
+ original_amount: amount(original_amount.to_f * 100)
193
+ }
194
+ end
195
+
196
+ def post_data(params)
197
+ return nil unless params
198
+
199
+ params.map do |key, value|
200
+ next if value != false && value.blank?
201
+ "#{key}=#{CGI.escape(value.to_s)}"
202
+ end.compact.join("&")
203
+ end
204
+
205
+ def error_code_from(response)
206
+ unless success_from(response)
207
+ response[:ex_err_code] || response[:err_code]
208
+ end
209
+ end
210
+
211
+ def underscore(camel_cased_word)
212
+ camel_cased_word.to_s.gsub(/::/, '/').
213
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
214
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
215
+ tr("-", "_").
216
+ downcase
217
+ end
218
+ end
219
+ end
220
+ end