activemerchant 1.133.0 → 1.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +240 -0
  3. data/lib/active_merchant/billing/check.rb +2 -2
  4. data/lib/active_merchant/billing/compatibility.rb +4 -4
  5. data/lib/active_merchant/billing/credit_card.rb +11 -8
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +59 -6
  8. data/lib/active_merchant/billing/gateway.rb +9 -0
  9. data/lib/active_merchant/billing/gateways/adyen.rb +162 -43
  10. data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
  11. data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +43 -35
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
  16. data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
  17. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
  18. data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
  19. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  20. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
  21. data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
  22. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
  24. data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
  25. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  27. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
  28. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  29. data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
  30. data/lib/active_merchant/billing/gateways/checkout_v2.rb +238 -34
  31. data/lib/active_merchant/billing/gateways/commerce_hub.rb +63 -6
  32. data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
  33. data/lib/active_merchant/billing/gateways/cyber_source.rb +185 -47
  34. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
  35. data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
  36. data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
  37. data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
  38. data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
  39. data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
  40. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  41. data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
  42. data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
  43. data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
  44. data/lib/active_merchant/billing/gateways/element.rb +36 -7
  45. data/lib/active_merchant/billing/gateways/epay.rb +6 -2
  46. data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
  47. data/lib/active_merchant/billing/gateways/eway.rb +4 -2
  48. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
  49. data/lib/active_merchant/billing/gateways/exact.rb +6 -2
  50. data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
  51. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
  52. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  53. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  54. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  55. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
  56. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
  57. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
  58. data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
  59. data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
  61. data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
  62. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  63. data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
  64. data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
  65. data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
  66. data/lib/active_merchant/billing/gateways/ipg.rb +9 -5
  67. data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
  68. data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
  69. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  70. data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
  71. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
  72. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
  73. data/lib/active_merchant/billing/gateways/kushki.rb +72 -12
  74. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
  75. data/lib/active_merchant/billing/gateways/litle.rb +33 -50
  76. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  77. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  78. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
  79. data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
  80. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
  81. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
  82. data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
  83. data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
  84. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
  85. data/lib/active_merchant/billing/gateways/migs.rb +6 -2
  86. data/lib/active_merchant/billing/gateways/mit.rb +8 -3
  87. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
  88. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  89. data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
  90. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
  91. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
  92. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  93. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
  94. data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
  95. data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
  96. data/lib/active_merchant/billing/gateways/nmi.rb +18 -6
  97. data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
  98. data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
  99. data/lib/active_merchant/billing/gateways/opp.rb +1 -2
  100. data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
  101. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
  102. data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
  103. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
  104. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
  105. data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
  106. data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
  107. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
  108. data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
  109. data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
  110. data/lib/active_merchant/billing/gateways/payex.rb +4 -2
  111. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  112. data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
  113. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  114. data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
  115. data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
  116. data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
  117. data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
  118. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  119. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +2 -2
  120. data/lib/active_merchant/billing/gateways/pin.rb +22 -4
  121. data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
  122. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  123. data/lib/active_merchant/billing/gateways/priority.rb +6 -5
  124. data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
  125. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  126. data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
  127. data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
  128. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
  129. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  130. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
  131. data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
  132. data/lib/active_merchant/billing/gateways/reach.rb +11 -4
  133. data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
  134. data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
  135. data/lib/active_merchant/billing/gateways/s5.rb +3 -3
  136. data/lib/active_merchant/billing/gateways/safe_charge.rb +36 -16
  137. data/lib/active_merchant/billing/gateways/sage.rb +12 -4
  138. data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
  139. data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
  140. data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
  141. data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
  142. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
  143. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
  144. data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
  145. data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
  146. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  147. data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
  148. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
  149. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
  150. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
  151. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
  152. data/lib/active_merchant/billing/gateways/stripe.rb +53 -21
  153. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +199 -50
  154. data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
  155. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
  156. data/lib/active_merchant/billing/gateways/telr.rb +3 -4
  157. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
  159. data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
  161. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
  162. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
  163. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  164. data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
  165. data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
  166. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
  167. data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
  168. data/lib/active_merchant/billing/gateways/vpos.rb +3 -3
  169. data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
  170. data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
  171. data/lib/active_merchant/billing/gateways/worldpay.rb +140 -73
  172. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
  173. data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
  174. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  175. data/lib/active_merchant/billing/response.rb +2 -2
  176. data/lib/active_merchant/connection.rb +3 -17
  177. data/lib/active_merchant/country.rb +1 -0
  178. data/lib/active_merchant/errors.rb +10 -0
  179. data/lib/active_merchant/version.rb +1 -1
  180. data/lib/support/gateway_support.rb +2 -2
  181. data/lib/support/ssl_verify.rb +4 -4
  182. data/lib/support/ssl_version.rb +6 -6
  183. metadata +30 -9
@@ -0,0 +1,223 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class SumUpGateway < Gateway
4
+ self.live_url = 'https://api.sumup.com/v0.1/'
5
+
6
+ self.supported_countries = %w(AT BE BG BR CH CL CO CY CZ DE DK EE ES FI FR
7
+ GB GR HR HU IE IT LT LU LV MT NL NO PL PT RO
8
+ SE SI SK US)
9
+ self.currencies_with_three_decimal_places = %w(EUR BGN BRL CHF CZK DKK GBP
10
+ HUF NOK PLN SEK USD)
11
+ self.default_currency = 'USD'
12
+
13
+ self.homepage_url = 'https://www.sumup.com/'
14
+ self.display_name = 'SumUp'
15
+
16
+ STANDARD_ERROR_CODE_MAPPING = {
17
+ multiple_invalid_parameters: 'MULTIPLE_INVALID_PARAMETERS'
18
+ }
19
+
20
+ def initialize(options = {})
21
+ requires!(options, :access_token, :pay_to_email)
22
+ super
23
+ end
24
+
25
+ def purchase(money, payment, options = {})
26
+ MultiResponse.run do |r|
27
+ r.process { create_checkout(money, payment, options) } unless options[:checkout_id]
28
+ r.process { complete_checkout(options[:checkout_id] || r.params['id'], payment, options) }
29
+ end
30
+ end
31
+
32
+ def refund(money, authorization, options = {})
33
+ transaction_id = authorization.split('#').last
34
+ post = money ? { amount: amount(money) } : {}
35
+ add_merchant_data(post, options)
36
+
37
+ commit('me/refund/' + transaction_id, post)
38
+ end
39
+
40
+ def supports_scrubbing?
41
+ true
42
+ end
43
+
44
+ def scrub(transcript)
45
+ transcript.
46
+ gsub(%r((Authorization: Bearer )\w+), '\1[FILTERED]').
47
+ gsub(%r(("pay_to_email\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
48
+ gsub(%r(("number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
49
+ gsub(%r(("cvv\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
50
+ end
51
+
52
+ private
53
+
54
+ def create_checkout(money, payment, options)
55
+ post = {}
56
+
57
+ add_merchant_data(post, options)
58
+ add_invoice(post, money, options)
59
+ add_address(post, options)
60
+ add_customer_data(post, payment, options)
61
+ add_3ds_data(post, options)
62
+
63
+ commit('checkouts', post)
64
+ end
65
+
66
+ def complete_checkout(checkout_id, payment, options = {})
67
+ post = {}
68
+
69
+ add_payment(post, payment, options)
70
+
71
+ commit('checkouts/' + checkout_id, post, :put)
72
+ end
73
+
74
+ def add_customer_data(post, payment, options)
75
+ post[:customer_id] = options[:customer_id]
76
+ post[:personal_details] = {
77
+ email: options[:email],
78
+ first_name: payment&.first_name,
79
+ last_name: payment&.last_name,
80
+ tax_id: options[:tax_id]
81
+ }
82
+ end
83
+
84
+ def add_merchant_data(post, options)
85
+ # Required field: pay_to_email
86
+ # Description: Email address of the merchant to whom the payment is made.
87
+ post[:pay_to_email] = @options[:pay_to_email]
88
+ end
89
+
90
+ def add_address(post, options)
91
+ post[:personal_details] ||= {}
92
+ if address = (options[:billing_address] || options[:shipping_address] || options[:address])
93
+ post[:personal_details][:address] = {
94
+ city: address[:city],
95
+ state: address[:state],
96
+ country: address[:country],
97
+ line_1: address[:address1],
98
+ postal_code: address[:zip]
99
+ }
100
+ end
101
+ end
102
+
103
+ def add_invoice(post, money, options)
104
+ post[:checkout_reference] = options[:order_id]
105
+ post[:amount] = amount(money)
106
+ post[:currency] = options[:currency] || currency(money)
107
+ post[:description] = options[:description]
108
+ end
109
+
110
+ def add_payment(post, payment, options)
111
+ post[:payment_type] = options[:payment_type] || 'card'
112
+
113
+ post[:card] = {
114
+ name: payment.name,
115
+ number: payment.number,
116
+ expiry_month: format(payment.month, :two_digits),
117
+ expiry_year: payment.year,
118
+ cvv: payment.verification_value
119
+ }
120
+ end
121
+
122
+ def add_3ds_data(post, options)
123
+ post[:redirect_url] = options[:redirect_url] if options[:redirect_url]
124
+ end
125
+
126
+ def commit(action, post, method = :post)
127
+ response = api_request(action, post.compact, method)
128
+ succeeded = success_from(response)
129
+
130
+ Response.new(
131
+ succeeded,
132
+ message_from(succeeded, response),
133
+ action.include?('refund') ? { response_code: response.to_s } : response,
134
+ authorization: authorization_from(response),
135
+ test: test?,
136
+ error_code: error_code_from(succeeded, response)
137
+ )
138
+ end
139
+
140
+ def api_request(action, post, method)
141
+ raw_response =
142
+ begin
143
+ ssl_request(method, live_url + action, post.to_json, auth_headers)
144
+ rescue ResponseError => e
145
+ e.response.body
146
+ end
147
+ response = parse(raw_response)
148
+ response = response.is_a?(Hash) ? response.symbolize_keys : response
149
+
150
+ return format_errors(response) if raw_response.include?('error_code') && response.is_a?(Array)
151
+
152
+ response
153
+ end
154
+
155
+ def parse(body)
156
+ JSON.parse(body)
157
+ end
158
+
159
+ def success_from(response)
160
+ (response.is_a?(Hash) && response[:next_step]) ||
161
+ response == 204 ||
162
+ %w(PENDING PAID).include?(response[:status]) ||
163
+ response[:transactions]&.all? { |transaction| transaction.symbolize_keys[:status] == 'SUCCESSFUL' }
164
+ end
165
+
166
+ def message_from(succeeded, response)
167
+ if succeeded
168
+ return 'Succeeded' if (response.is_a?(Hash) && response[:next_step]) || response == 204
169
+
170
+ return response[:status]
171
+ end
172
+
173
+ response[:message] || response[:error_message] || response[:status]
174
+ end
175
+
176
+ def authorization_from(response)
177
+ return nil if response.is_a?(Integer)
178
+
179
+ return response[:id] unless response[:transaction_id]
180
+
181
+ [response[:id], response[:transaction_id]].join('#')
182
+ end
183
+
184
+ def auth_headers
185
+ {
186
+ 'Content-Type' => 'application/json',
187
+ 'Authorization' => "Bearer #{options[:access_token]}"
188
+ }
189
+ end
190
+
191
+ def error_code_from(succeeded, response)
192
+ response[:error_code] unless succeeded
193
+ end
194
+
195
+ def format_error(error, key)
196
+ {
197
+ :error_code => error['error_code'],
198
+ key => error['param']
199
+ }
200
+ end
201
+
202
+ def format_errors(errors)
203
+ return format_error(errors.first, :message) if errors.size == 1
204
+
205
+ return {
206
+ error_code: STANDARD_ERROR_CODE_MAPPING[:multiple_invalid_parameters],
207
+ message: 'Validation error',
208
+ errors: errors.map { |error| format_error(error, :param) }
209
+ }
210
+ end
211
+
212
+ def handle_response(response)
213
+ case response.code.to_i
214
+ # to get the response code (204) when the body is nil
215
+ when 200...300
216
+ response.body || response.code
217
+ else
218
+ raise ResponseError.new(response)
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
@@ -104,12 +104,14 @@ module ActiveMerchant #:nodoc:
104
104
  result = response['data']['result']
105
105
  success = (result == 'accepted' || (test? && result == 'test-accepted'))
106
106
 
107
- Response.new(success,
107
+ Response.new(
108
+ success,
108
109
  success ?
109
110
  TRANSACTION_APPROVED_MSG :
110
111
  TRANSACTION_DECLINED_MSG,
111
112
  response,
112
- test: test?)
113
+ test: test?
114
+ )
113
115
  else
114
116
  build_error_response(message, response)
115
117
  end
@@ -162,9 +162,9 @@ module ActiveMerchant #:nodoc:
162
162
  country.code(:alpha2)
163
163
  end
164
164
 
165
- def commit(action, amount = nil, currency = nil)
165
+ def commit(action, amount = nil, currency = nil, &block)
166
166
  currency = default_currency if currency == nil
167
- request = build_xml_request { |doc| yield(doc) }
167
+ request = build_xml_request(&block)
168
168
  response = ssl_post(live_url, request, headers)
169
169
  parsed = parse(response)
170
170
 
@@ -231,8 +231,7 @@ module ActiveMerchant #:nodoc:
231
231
 
232
232
  def authorization_from(action, response, amount, currency)
233
233
  auth = response[:tranref]
234
- auth = [auth, amount, currency].join('|')
235
- auth
234
+ [auth, amount, currency].join('|')
236
235
  end
237
236
 
238
237
  def split_authorization(authorization)
@@ -219,8 +219,7 @@ module ActiveMerchant #:nodoc:
219
219
  params[:MerchantID] = @options[:login]
220
220
  params[:RegKey] = @options[:password]
221
221
 
222
- request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
223
- request
222
+ params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
224
223
  end
225
224
 
226
225
  def add_pair(post, key, value, options = {})
@@ -438,29 +438,21 @@ module ActiveMerchant #:nodoc:
438
438
  end
439
439
 
440
440
  # -- request methods ---------------------------------------------------
441
- def build_xml_transaction_request
442
- build_xml_request('SendTranRequest') do |doc|
443
- yield doc
444
- end
441
+ def build_xml_transaction_request(&block)
442
+ build_xml_request('SendTranRequest', &block)
445
443
  end
446
444
 
447
- def build_xml_payment_storage_request
448
- build_xml_request('UpdtRecurrProfRequest') do |doc|
449
- yield doc
450
- end
445
+ def build_xml_payment_storage_request(&block)
446
+ build_xml_request('UpdtRecurrProfRequest', &block)
451
447
  end
452
448
 
453
- def build_xml_payment_update_request
449
+ def build_xml_payment_update_request(&block)
454
450
  merchant_product_type = 5 # credit card
455
- build_xml_request('UpdtRecurrProfRequest', merchant_product_type) do |doc|
456
- yield doc
457
- end
451
+ build_xml_request('UpdtRecurrProfRequest', merchant_product_type, &block)
458
452
  end
459
453
 
460
- def build_xml_payment_search_request
461
- build_xml_request('FndRecurrProfRequest') do |doc|
462
- yield doc
463
- end
454
+ def build_xml_payment_search_request(&block)
455
+ build_xml_request('FndRecurrProfRequest', &block)
464
456
  end
465
457
 
466
458
  def build_xml_request(wrapper, merchant_product_type = nil)
@@ -172,7 +172,7 @@ module ActiveMerchant #:nodoc:
172
172
  { status: 'success', id: m[2] } :
173
173
  { status: 'failure', message: m[2] }
174
174
  else
175
- Hash[status: body]
175
+ { status: body }
176
176
  end
177
177
  end
178
178
 
@@ -450,11 +450,15 @@ module ActiveMerchant #:nodoc:
450
450
  # to be considered successful, transaction status must be either "approved" or "accepted"
451
451
  success = SUCCESS_TYPES.include?(data['status'])
452
452
  message = message_from(data)
453
- Response.new(success, message, data,
453
+ Response.new(
454
+ success,
455
+ message,
456
+ data,
454
457
  test: test?,
455
458
  authorization: authorization_from(action, data),
456
459
  cvv_result: data['cvv'],
457
- avs_result: { code: data['avs'] })
460
+ avs_result: { code: data['avs'] }
461
+ )
458
462
  end
459
463
 
460
464
  def parse(body)
@@ -1030,15 +1030,17 @@ module ActiveMerchant #:nodoc:
1030
1030
 
1031
1031
  # Build soap header, etc.
1032
1032
  def build_request(action, options = {})
1033
- soap = Builder::XmlMarkup.new
1034
- soap.instruct!(:xml, version: '1.0', encoding: 'utf-8')
1035
- soap.tag! 'SOAP-ENV:Envelope',
1033
+ envelope_obj = {
1036
1034
  'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
1037
1035
  'xmlns:ns1' => 'urn:usaepay',
1038
1036
  'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
1039
1037
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
1040
1038
  'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
1041
- 'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/' do
1039
+ 'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
1040
+ }
1041
+ soap = Builder::XmlMarkup.new
1042
+ soap.instruct!(:xml, version: '1.0', encoding: 'utf-8')
1043
+ soap.tag! 'SOAP-ENV:Envelope', envelope_obj do
1042
1044
  soap.tag! 'SOAP-ENV:Body' do
1043
1045
  send("build_#{action}", soap, options)
1044
1046
  end
@@ -1335,8 +1337,7 @@ module ActiveMerchant #:nodoc:
1335
1337
  case
1336
1338
  when payment_method[:method].kind_of?(ActiveMerchant::Billing::CreditCard)
1337
1339
  build_tag soap, :string, 'CardNumber', payment_method[:method].number
1338
- build_tag soap, :string, 'CardExpiration',
1339
- "#{'%02d' % payment_method[:method].month}#{payment_method[:method].year.to_s[-2..-1]}"
1340
+ build_tag soap, :string, 'CardExpiration', "#{'%02d' % payment_method[:method].month}#{payment_method[:method].year.to_s[-2..-1]}"
1340
1341
  if options[:billing_address]
1341
1342
  build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
1342
1343
  build_tag soap, :string, 'AvsZip', options[:billing_address][:zip]
@@ -1520,8 +1521,8 @@ module ActiveMerchant #:nodoc:
1520
1521
 
1521
1522
  begin
1522
1523
  soap = ssl_post(url, request, 'Content-Type' => 'text/xml')
1523
- rescue ActiveMerchant::ResponseError => error
1524
- soap = error.response.body
1524
+ rescue ActiveMerchant::ResponseError => e
1525
+ soap = e.response.body
1525
1526
  end
1526
1527
 
1527
1528
  build_response(action, soap)
@@ -329,12 +329,16 @@ module ActiveMerchant #:nodoc:
329
329
  approved = response[:status] == 'Approved'
330
330
  error_code = nil
331
331
  error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
332
- Response.new(approved, message_from(response), response,
332
+ Response.new(
333
+ approved,
334
+ message_from(response),
335
+ response,
333
336
  test: test?,
334
337
  authorization: authorization_from(action, response),
335
338
  cvv_result: response[:cvv2_result_code],
336
339
  avs_result: { code: response[:avs_result_code] },
337
- error_code: error_code)
340
+ error_code: error_code
341
+ )
338
342
  end
339
343
 
340
344
  def message_from(response)
@@ -281,11 +281,9 @@ module ActiveMerchant
281
281
  end
282
282
  end
283
283
 
284
- def build_xml_request
284
+ def build_xml_request(&block)
285
285
  builder = Nokogiri::XML::Builder.new
286
- builder.__send__('VancoWS') do |doc|
287
- yield(doc)
288
- end
286
+ builder.__send__('VancoWS', &block)
289
287
  builder.to_xml
290
288
  end
291
289