activemerchant 1.79.2 → 1.80.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 (219) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +33 -0
  3. data/README.md +10 -2
  4. data/lib/active_merchant.rb +1 -1
  5. data/lib/active_merchant/billing/check.rb +4 -4
  6. data/lib/active_merchant/billing/compatibility.rb +1 -1
  7. data/lib/active_merchant/billing/credit_card.rb +21 -21
  8. data/lib/active_merchant/billing/credit_card_formatting.rb +2 -2
  9. data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
  10. data/lib/active_merchant/billing/gateway.rb +13 -13
  11. data/lib/active_merchant/billing/gateways/adyen.rb +31 -15
  12. data/lib/active_merchant/billing/gateways/allied_wallet.rb +22 -22
  13. data/lib/active_merchant/billing/gateways/authorize_net.rb +72 -72
  14. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -3
  15. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -3
  16. data/lib/active_merchant/billing/gateways/axcessms.rb +51 -51
  17. data/lib/active_merchant/billing/gateways/balanced.rb +29 -29
  18. data/lib/active_merchant/billing/gateways/bank_frick.rb +3 -3
  19. data/lib/active_merchant/billing/gateways/banwire.rb +8 -8
  20. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
  21. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +6 -6
  22. data/lib/active_merchant/billing/gateways/be2bill.rb +2 -2
  23. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +69 -69
  25. data/lib/active_merchant/billing/gateways/blue_pay.rb +19 -19
  26. data/lib/active_merchant/billing/gateways/blue_snap.rb +42 -42
  27. data/lib/active_merchant/billing/gateways/bogus.rb +10 -10
  28. data/lib/active_merchant/billing/gateways/borgun.rb +10 -10
  29. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  30. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +2 -2
  31. data/lib/active_merchant/billing/gateways/braintree_blue.rb +94 -94
  32. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/bridge_pay.rb +39 -39
  34. data/lib/active_merchant/billing/gateways/cams.rb +12 -12
  35. data/lib/active_merchant/billing/gateways/card_connect.rb +38 -13
  36. data/lib/active_merchant/billing/gateways/card_stream.rb +116 -116
  37. data/lib/active_merchant/billing/gateways/cardknox.rb +7 -7
  38. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/cashnet.rb +10 -10
  40. data/lib/active_merchant/billing/gateways/cc5.rb +3 -5
  41. data/lib/active_merchant/billing/gateways/cecabank.rb +6 -6
  42. data/lib/active_merchant/billing/gateways/cenpos.rb +36 -36
  43. data/lib/active_merchant/billing/gateways/checkout.rb +5 -5
  44. data/lib/active_merchant/billing/gateways/checkout_v2.rb +31 -31
  45. data/lib/active_merchant/billing/gateways/clearhaus.rb +5 -5
  46. data/lib/active_merchant/billing/gateways/commercegate.rb +6 -6
  47. data/lib/active_merchant/billing/gateways/conekta.rb +24 -19
  48. data/lib/active_merchant/billing/gateways/creditcall.rb +41 -41
  49. data/lib/active_merchant/billing/gateways/credorax.rb +104 -103
  50. data/lib/active_merchant/billing/gateways/culqi.rb +25 -25
  51. data/lib/active_merchant/billing/gateways/cyber_source.rb +65 -65
  52. data/lib/active_merchant/billing/gateways/data_cash.rb +4 -4
  53. data/lib/active_merchant/billing/gateways/dibs.rb +24 -24
  54. data/lib/active_merchant/billing/gateways/digitzs.rb +35 -35
  55. data/lib/active_merchant/billing/gateways/ebanx.rb +26 -26
  56. data/lib/active_merchant/billing/gateways/efsnet.rb +10 -10
  57. data/lib/active_merchant/billing/gateways/elavon.rb +5 -5
  58. data/lib/active_merchant/billing/gateways/element.rb +35 -35
  59. data/lib/active_merchant/billing/gateways/epay.rb +4 -4
  60. data/lib/active_merchant/billing/gateways/evo_ca.rb +1 -1
  61. data/lib/active_merchant/billing/gateways/eway.rb +65 -65
  62. data/lib/active_merchant/billing/gateways/eway_managed.rb +11 -11
  63. data/lib/active_merchant/billing/gateways/eway_rapid.rb +31 -31
  64. data/lib/active_merchant/billing/gateways/exact.rb +12 -12
  65. data/lib/active_merchant/billing/gateways/ezic.rb +13 -13
  66. data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -24
  67. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -3
  68. data/lib/active_merchant/billing/gateways/first_giving.rb +16 -16
  69. data/lib/active_merchant/billing/gateways/first_pay.rb +7 -4
  70. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +71 -71
  71. data/lib/active_merchant/billing/gateways/flo2cash.rb +12 -12
  72. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  73. data/lib/active_merchant/billing/gateways/forte.rb +26 -16
  74. data/lib/active_merchant/billing/gateways/garanti.rb +10 -12
  75. data/lib/active_merchant/billing/gateways/global_collect.rb +88 -88
  76. data/lib/active_merchant/billing/gateways/global_transport.rb +4 -4
  77. data/lib/active_merchant/billing/gateways/hdfc.rb +33 -33
  78. data/lib/active_merchant/billing/gateways/hps.rb +28 -28
  79. data/lib/active_merchant/billing/gateways/iats_payments.rb +26 -26
  80. data/lib/active_merchant/billing/gateways/inspire.rb +15 -15
  81. data/lib/active_merchant/billing/gateways/instapay.rb +4 -4
  82. data/lib/active_merchant/billing/gateways/ipp.rb +17 -17
  83. data/lib/active_merchant/billing/gateways/iridium.rb +207 -207
  84. data/lib/active_merchant/billing/gateways/iveri.rb +8 -8
  85. data/lib/active_merchant/billing/gateways/jetpay.rb +134 -134
  86. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +141 -141
  87. data/lib/active_merchant/billing/gateways/komoju.rb +15 -15
  88. data/lib/active_merchant/billing/gateways/kushki.rb +31 -37
  89. data/lib/active_merchant/billing/gateways/latitude19.rb +64 -64
  90. data/lib/active_merchant/billing/gateways/linkpoint.rb +22 -22
  91. data/lib/active_merchant/billing/gateways/litle.rb +4 -4
  92. data/lib/active_merchant/billing/gateways/mastercard.rb +3 -3
  93. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  94. data/lib/active_merchant/billing/gateways/mercado_pago.rb +28 -28
  95. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +9 -9
  96. data/lib/active_merchant/billing/gateways/merchant_one.rb +6 -6
  97. data/lib/active_merchant/billing/gateways/merchant_partners.rb +24 -24
  98. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -49
  99. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +36 -36
  100. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +4 -4
  101. data/lib/active_merchant/billing/gateways/mercury.rb +28 -28
  102. data/lib/active_merchant/billing/gateways/metrics_global.rb +7 -7
  103. data/lib/active_merchant/billing/gateways/micropayment.rb +31 -31
  104. data/lib/active_merchant/billing/gateways/migs.rb +11 -9
  105. data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -1
  106. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +16 -16
  107. data/lib/active_merchant/billing/gateways/monei.rb +5 -5
  108. data/lib/active_merchant/billing/gateways/moneris.rb +26 -26
  109. data/lib/active_merchant/billing/gateways/moneris_us.rb +81 -37
  110. data/lib/active_merchant/billing/gateways/money_movers.rb +3 -3
  111. data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
  112. data/lib/active_merchant/billing/gateways/nab_transact.rb +6 -6
  113. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +3 -3
  114. data/lib/active_merchant/billing/gateways/netaxept.rb +15 -15
  115. data/lib/active_merchant/billing/gateways/netbanx.rb +2 -2
  116. data/lib/active_merchant/billing/gateways/netbilling.rb +1 -1
  117. data/lib/active_merchant/billing/gateways/netpay.rb +5 -5
  118. data/lib/active_merchant/billing/gateways/nmi.rb +18 -18
  119. data/lib/active_merchant/billing/gateways/ogone.rb +22 -22
  120. data/lib/active_merchant/billing/gateways/omise.rb +3 -3
  121. data/lib/active_merchant/billing/gateways/openpay.rb +6 -4
  122. data/lib/active_merchant/billing/gateways/opp.rb +4 -4
  123. data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -2
  124. data/lib/active_merchant/billing/gateways/orbital.rb +61 -61
  125. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +4 -4
  126. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +5 -5
  127. data/lib/active_merchant/billing/gateways/pagarme.rb +27 -27
  128. data/lib/active_merchant/billing/gateways/pago_facil.rb +8 -8
  129. data/lib/active_merchant/billing/gateways/pay_conex.rb +25 -25
  130. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +32 -32
  131. data/lib/active_merchant/billing/gateways/pay_hub.rb +29 -29
  132. data/lib/active_merchant/billing/gateways/pay_junction.rb +7 -7
  133. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +30 -30
  134. data/lib/active_merchant/billing/gateways/pay_secure.rb +4 -4
  135. data/lib/active_merchant/billing/gateways/paybox_direct.rb +15 -15
  136. data/lib/active_merchant/billing/gateways/payeezy.rb +5 -5
  137. data/lib/active_merchant/billing/gateways/payex.rb +4 -4
  138. data/lib/active_merchant/billing/gateways/payflow.rb +7 -7
  139. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +23 -22
  140. data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -2
  141. data/lib/active_merchant/billing/gateways/payment_express.rb +40 -37
  142. data/lib/active_merchant/billing/gateways/paymentez.rb +11 -3
  143. data/lib/active_merchant/billing/gateways/paymill.rb +115 -115
  144. data/lib/active_merchant/billing/gateways/paypal.rb +1 -1
  145. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
  146. data/lib/active_merchant/billing/gateways/payscout.rb +1 -1
  147. data/lib/active_merchant/billing/gateways/paystation.rb +14 -14
  148. data/lib/active_merchant/billing/gateways/payu_in.rb +43 -43
  149. data/lib/active_merchant/billing/gateways/payu_latam.rb +41 -41
  150. data/lib/active_merchant/billing/gateways/payway.rb +6 -6
  151. data/lib/active_merchant/billing/gateways/pin.rb +7 -7
  152. data/lib/active_merchant/billing/gateways/plugnpay.rb +62 -62
  153. data/lib/active_merchant/billing/gateways/pro_pay.rb +123 -123
  154. data/lib/active_merchant/billing/gateways/psigate.rb +16 -16
  155. data/lib/active_merchant/billing/gateways/psl_card.rb +13 -13
  156. data/lib/active_merchant/billing/gateways/qbms.rb +52 -52
  157. data/lib/active_merchant/billing/gateways/quantum.rb +5 -5
  158. data/lib/active_merchant/billing/gateways/quickbooks.rb +10 -10
  159. data/lib/active_merchant/billing/gateways/quickpay.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +11 -11
  161. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
  162. data/lib/active_merchant/billing/gateways/qvalent.rb +55 -55
  163. data/lib/active_merchant/billing/gateways/realex.rb +16 -15
  164. data/lib/active_merchant/billing/gateways/redsys.rb +128 -121
  165. data/lib/active_merchant/billing/gateways/s5.rb +5 -5
  166. data/lib/active_merchant/billing/gateways/safe_charge.rb +16 -16
  167. data/lib/active_merchant/billing/gateways/sage.rb +20 -20
  168. data/lib/active_merchant/billing/gateways/sage_pay.rb +32 -32
  169. data/lib/active_merchant/billing/gateways/sallie_mae.rb +11 -11
  170. data/lib/active_merchant/billing/gateways/secure_net.rb +19 -19
  171. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -5
  172. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +7 -7
  173. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +9 -9
  174. data/lib/active_merchant/billing/gateways/securion_pay.rb +12 -12
  175. data/lib/active_merchant/billing/gateways/skip_jack.rb +28 -28
  176. data/lib/active_merchant/billing/gateways/smart_ps.rb +31 -31
  177. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +3 -3
  178. data/lib/active_merchant/billing/gateways/spreedly_core.rb +1 -1
  179. data/lib/active_merchant/billing/gateways/stripe.rb +63 -63
  180. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +5 -5
  181. data/lib/active_merchant/billing/gateways/telr.rb +26 -26
  182. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -28
  183. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +224 -224
  184. data/lib/active_merchant/billing/gateways/transact_pro.rb +7 -7
  185. data/lib/active_merchant/billing/gateways/transnational.rb +1 -1
  186. data/lib/active_merchant/billing/gateways/trexle.rb +5 -5
  187. data/lib/active_merchant/billing/gateways/trust_commerce.rb +38 -38
  188. data/lib/active_merchant/billing/gateways/usa_epay.rb +3 -3
  189. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +37 -37
  190. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -3
  191. data/lib/active_merchant/billing/gateways/vanco.rb +25 -25
  192. data/lib/active_merchant/billing/gateways/verifi.rb +40 -40
  193. data/lib/active_merchant/billing/gateways/viaklix.rb +5 -5
  194. data/lib/active_merchant/billing/gateways/visanet_peru.rb +64 -36
  195. data/lib/active_merchant/billing/gateways/webpay.rb +8 -8
  196. data/lib/active_merchant/billing/gateways/wepay.rb +25 -25
  197. data/lib/active_merchant/billing/gateways/wirecard.rb +26 -26
  198. data/lib/active_merchant/billing/gateways/worldpay.rb +15 -15
  199. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +42 -42
  200. data/lib/active_merchant/billing/gateways/worldpay_us.rb +17 -17
  201. data/lib/active_merchant/billing/model.rb +2 -2
  202. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  203. data/lib/active_merchant/billing/rails.rb +1 -1
  204. data/lib/active_merchant/connection.rb +10 -8
  205. data/lib/active_merchant/country.rb +1 -1
  206. data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
  207. data/lib/active_merchant/network_connection_retries.rb +12 -12
  208. data/lib/active_merchant/post_data.rb +1 -1
  209. data/lib/active_merchant/posts_data.rb +1 -1
  210. data/lib/active_merchant/version.rb +1 -1
  211. data/lib/certs/cacert.pem +37 -0
  212. data/lib/support/gateway_support.rb +2 -2
  213. data/lib/support/ssl_verify.rb +5 -5
  214. data/lib/support/ssl_version.rb +7 -7
  215. metadata +3 -7
  216. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  217. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  218. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  219. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
@@ -120,7 +120,7 @@ module ActiveMerchant #:nodoc:
120
120
  gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]')
121
121
  end
122
122
 
123
- private
123
+ private
124
124
 
125
125
  def add_amount(post, money)
126
126
  post[:amount] = amount(money)
@@ -269,7 +269,7 @@ module ActiveMerchant #:nodoc:
269
269
  end
270
270
 
271
271
  def message_from(response)
272
- if response[:status] == "Approved"
272
+ if response[:status] == 'Approved'
273
273
  return 'Success'
274
274
  else
275
275
  return 'Unspecified error' if response[:error].blank?
@@ -286,7 +286,7 @@ module ActiveMerchant #:nodoc:
286
286
  hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
287
287
  parameters[:hash] = "s/#{seed}/#{hash}/n"
288
288
 
289
- parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join("&")
289
+ parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&')
290
290
  end
291
291
  end
292
292
  end
@@ -23,14 +23,14 @@ module ActiveMerchant
23
23
  def purchase(money, payment_method, options={})
24
24
  MultiResponse.run do |r|
25
25
  r.process { login }
26
- r.process { commit(purchase_request(money, payment_method, r.params["response_sessionid"], options), :response_transactionref) }
26
+ r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
27
27
  end
28
28
  end
29
29
 
30
30
  def refund(money, authorization, options={})
31
31
  MultiResponse.run do |r|
32
32
  r.process { login }
33
- r.process { commit(refund_request(money, authorization, r.params["response_sessionid"]), :response_creditrequestreceived) }
33
+ r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
34
34
  end
35
35
  end
36
36
 
@@ -66,7 +66,7 @@ module ActiveMerchant
66
66
 
67
67
  def childnode_to_response(response, node, childnode)
68
68
  name = "#{node.name.downcase}_#{childnode.name.downcase}"
69
- if name == "response_errors" && !childnode.elements.empty?
69
+ if name == 'response_errors' && !childnode.elements.empty?
70
70
  add_errors_to_response(response, childnode.to_s)
71
71
  else
72
72
  response[name.downcase.to_sym] = childnode.text
@@ -77,13 +77,13 @@ module ActiveMerchant
77
77
  errors_hash = Hash.from_xml(errors_xml).values.first
78
78
  response[:response_errors] = errors_hash
79
79
 
80
- error = errors_hash["Error"]
80
+ error = errors_hash['Error']
81
81
  if error.kind_of?(Hash)
82
- response[:error_message] = error["ErrorDescription"]
83
- response[:error_codes] = error["ErrorCode"]
82
+ response[:error_message] = error['ErrorDescription']
83
+ response[:error_codes] = error['ErrorCode']
84
84
  elsif error.kind_of?(Array)
85
- error_str = error.map { |e| e["ErrorDescription"]}.join(". ")
86
- error_codes = error.map { |e| e["ErrorCode"]}.join(", ")
85
+ error_str = error.map { |e| e['ErrorDescription']}.join('. ')
86
+ error_codes = error.map { |e| e['ErrorCode']}.join(', ')
87
87
  response[:error_message] = "#{error_str}."
88
88
  response[:error_codes] = error_codes
89
89
  end
@@ -107,7 +107,7 @@ module ActiveMerchant
107
107
  end
108
108
 
109
109
  def message_from(succeeded, response)
110
- return "Success" if succeeded
110
+ return 'Success' if succeeded
111
111
  response[:error_message]
112
112
  end
113
113
 
@@ -116,7 +116,7 @@ module ActiveMerchant
116
116
  response[:response_customerref],
117
117
  response[:response_paymentmethodref],
118
118
  response[:response_transactionref]
119
- ].join("|")
119
+ ].join('|')
120
120
  end
121
121
 
122
122
  def split_authorization(authorization)
@@ -125,7 +125,7 @@ module ActiveMerchant
125
125
 
126
126
  def purchase_request(money, payment_method, session_id, options)
127
127
  build_xml_request do |doc|
128
- add_auth(doc, "EFTAddCompleteTransaction", session_id)
128
+ add_auth(doc, 'EFTAddCompleteTransaction', session_id)
129
129
 
130
130
  doc.Request do
131
131
  doc.RequestVars do
@@ -141,7 +141,7 @@ module ActiveMerchant
141
141
 
142
142
  def refund_request(money, authorization, session_id)
143
143
  build_xml_request do |doc|
144
- add_auth(doc, "EFTAddCredit", session_id)
144
+ add_auth(doc, 'EFTAddCredit', session_id)
145
145
 
146
146
  doc.Request do
147
147
  doc.RequestVars do
@@ -203,7 +203,7 @@ module ActiveMerchant
203
203
  doc.CardExpYear(format(credit_card.year, :two_digits))
204
204
  doc.CardCVV2(credit_card.verification_value)
205
205
  doc.CardBillingName(credit_card.name)
206
- doc.AccountType("CC")
206
+ doc.AccountType('CC')
207
207
  add_billing_address(doc, options)
208
208
  end
209
209
 
@@ -220,28 +220,28 @@ module ActiveMerchant
220
220
  end
221
221
 
222
222
  def add_echeck(doc, echeck)
223
- if echeck.account_type == "savings"
224
- doc.AccountType("S")
223
+ if echeck.account_type == 'savings'
224
+ doc.AccountType('S')
225
225
  else
226
- doc.AccountType("C")
226
+ doc.AccountType('C')
227
227
  end
228
228
 
229
229
  doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}")
230
230
  doc.AccountNumber(echeck.account_number)
231
231
  doc.RoutingNumber(echeck.routing_number)
232
- doc.TransactionTypeCode("WEB")
232
+ doc.TransactionTypeCode('WEB')
233
233
  end
234
234
 
235
235
  def add_purchase_noise(doc)
236
- doc.StartDate("0000-00-00")
237
- doc.FrequencyCode("O")
236
+ doc.StartDate('0000-00-00')
237
+ doc.FrequencyCode('O')
238
238
  end
239
239
 
240
240
  def add_refund_noise(doc)
241
- doc.ContactName("Bilbo Baggins")
242
- doc.ContactPhone("1234567890")
243
- doc.ContactExtension("None")
244
- doc.ReasonForCredit("Refund requested")
241
+ doc.ContactName('Bilbo Baggins')
242
+ doc.ContactPhone('1234567890')
243
+ doc.ContactExtension('None')
244
+ doc.ReasonForCredit('Refund requested')
245
245
  end
246
246
 
247
247
  def add_options(doc, options)
@@ -259,7 +259,7 @@ module ActiveMerchant
259
259
  def login_request
260
260
  build_xml_request do |doc|
261
261
  doc.Auth do
262
- add_request(doc, "Login")
262
+ add_request(doc, 'Login')
263
263
  end
264
264
 
265
265
  doc.Request do
@@ -273,7 +273,7 @@ module ActiveMerchant
273
273
 
274
274
  def build_xml_request
275
275
  builder = Nokogiri::XML::Builder.new
276
- builder.__send__("VancoWS") do |doc|
276
+ builder.__send__('VancoWS') do |doc|
277
277
  yield(doc)
278
278
  end
279
279
  builder.to_xml
@@ -5,46 +5,46 @@ module ActiveMerchant #:nodoc:
5
5
  class VerifiGateway < Gateway
6
6
  class VerifiPostData < PostData
7
7
  # Fields that will be sent even if they are blank
8
- self.required_fields = [ :amount, :type, :ccnumber, :ccexp, :firstname, :lastname,
9
- :company, :address1, :address2, :city, :state, :zip, :country, :phone ]
8
+ self.required_fields = [:amount, :type, :ccnumber, :ccexp, :firstname, :lastname,
9
+ :company, :address1, :address2, :city, :state, :zip, :country, :phone]
10
10
  end
11
11
 
12
12
  self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php'
13
13
 
14
14
  RESPONSE_CODE_MESSAGES = {
15
- "100" => "Transaction was Approved",
16
- "200" => "Transaction was Declined by Processor",
17
- "201" => "Do Not Honor",
18
- "202" => "Insufficient Funds",
19
- "203" => "Over Limit",
20
- "204" => "Transaction not allowed",
21
- "220" => "Incorrect payment Data",
22
- "221" => "No Such Card Issuer",
23
- "222" => "No Card Number on file with Issuer",
24
- "223" => "Expired Card",
25
- "224" => "Invalid Expiration Date",
26
- "225" => "Invalid Card Security Code",
27
- "240" => "Call Issuer for Further Information",
28
- "250" => "Pick Up Card",
29
- "251" => "Lost Card",
30
- "252" => "Stolen Card",
31
- "253" => "Fraudulent Card",
32
- "260" => "Declined With further Instructions Available (see response text)",
33
- "261" => "Declined - Stop All Recurring Payments",
34
- "262" => "Declined - Stop this Recurring Program",
35
- "263" => "Declined - Update Cardholder Data Available",
36
- "264" => "Declined - Retry in a few days",
37
- "300" => "Transaction was Rejected by Gateway",
38
- "400" => "Transaction Error Returned by Processor",
39
- "410" => "Invalid Merchant Configuration",
40
- "411" => "Merchant Account is Inactive",
41
- "420" => "Communication Error",
42
- "421" => "Communication Error with Issuer",
43
- "430" => "Duplicate Transaction at Processor",
44
- "440" => "Processor Format Error",
45
- "441" => "Invalid Transaction Information",
46
- "460" => "Processor Feature Not Available",
47
- "461" => "Unsupported Card Type"
15
+ '100' => 'Transaction was Approved',
16
+ '200' => 'Transaction was Declined by Processor',
17
+ '201' => 'Do Not Honor',
18
+ '202' => 'Insufficient Funds',
19
+ '203' => 'Over Limit',
20
+ '204' => 'Transaction not allowed',
21
+ '220' => 'Incorrect payment Data',
22
+ '221' => 'No Such Card Issuer',
23
+ '222' => 'No Card Number on file with Issuer',
24
+ '223' => 'Expired Card',
25
+ '224' => 'Invalid Expiration Date',
26
+ '225' => 'Invalid Card Security Code',
27
+ '240' => 'Call Issuer for Further Information',
28
+ '250' => 'Pick Up Card',
29
+ '251' => 'Lost Card',
30
+ '252' => 'Stolen Card',
31
+ '253' => 'Fraudulent Card',
32
+ '260' => 'Declined With further Instructions Available (see response text)',
33
+ '261' => 'Declined - Stop All Recurring Payments',
34
+ '262' => 'Declined - Stop this Recurring Program',
35
+ '263' => 'Declined - Update Cardholder Data Available',
36
+ '264' => 'Declined - Retry in a few days',
37
+ '300' => 'Transaction was Rejected by Gateway',
38
+ '400' => 'Transaction Error Returned by Processor',
39
+ '410' => 'Invalid Merchant Configuration',
40
+ '411' => 'Merchant Account is Inactive',
41
+ '420' => 'Communication Error',
42
+ '421' => 'Communication Error with Issuer',
43
+ '430' => 'Duplicate Transaction at Processor',
44
+ '440' => 'Processor Format Error',
45
+ '441' => 'Invalid Transaction Information',
46
+ '460' => 'Processor Feature Not Available',
47
+ '461' => 'Unsupported Card Type'
48
48
  }
49
49
 
50
50
  SUCCESS = 1
@@ -180,10 +180,10 @@ module ActiveMerchant #:nodoc:
180
180
  # MD5(username|password|orderid|amount|time)
181
181
  now = Time.now.to_i.to_s
182
182
  md5 = Digest::MD5.new
183
- md5 << @options[:login].to_s + "|"
184
- md5 << @options[:password].to_s + "|"
185
- md5 << options[:order_id].to_s + "|"
186
- md5 << amount(money).to_s + "|"
183
+ md5 << @options[:login].to_s + '|'
184
+ md5 << @options[:password].to_s + '|'
185
+ md5 << options[:order_id].to_s + '|'
186
+ md5 << amount(money).to_s + '|'
187
187
  md5 << now
188
188
  post[:key] = md5.hexdigest
189
189
  post[:time] = now
@@ -203,7 +203,7 @@ module ActiveMerchant #:nodoc:
203
203
  end
204
204
 
205
205
  def message_from(response)
206
- response[:response_code_message] ? response[:response_code_message] : ""
206
+ response[:response_code_message] || ''
207
207
  end
208
208
 
209
209
  def parse(body)
@@ -50,7 +50,7 @@ module ActiveMerchant #:nodoc:
50
50
  # Viaklix does not support credits by reference. You must pass in the credit card
51
51
  def credit(money, creditcard, options = {})
52
52
  if creditcard.is_a?(String)
53
- raise ArgumentError, "Reference credits are not supported. Please supply the original credit card"
53
+ raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card'
54
54
  end
55
55
 
56
56
  form = {}
@@ -158,16 +158,16 @@ module ActiveMerchant #:nodoc:
158
158
  def post_data(parameters)
159
159
  result = preamble
160
160
  result.merge!(parameters)
161
- result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
161
+ result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
162
162
  end
163
163
 
164
164
  # Parse the response message
165
165
  def parse(msg)
166
166
  resp = {}
167
167
  msg.split(self.delimiter).collect{|li|
168
- key, value = li.split("=")
169
- resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
170
- }
168
+ key, value = li.split('=')
169
+ resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
170
+ }
171
171
  resp
172
172
  end
173
173
  end
@@ -2,14 +2,14 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class VisanetPeruGateway < Gateway
4
4
  include Empty
5
- self.display_name = "VisaNet Peru Gateway"
6
- self.homepage_url = "http://www.visanet.com.pe"
5
+ self.display_name = 'VisaNet Peru Gateway'
6
+ self.homepage_url = 'http://www.visanet.com.pe'
7
7
 
8
- self.test_url = "https://devapi.vnforapps.com/api.tokenization/api/v2/merchant"
9
- self.live_url = "https://api.vnforapps.com/api.tokenization/api/v2/merchant"
8
+ self.test_url = 'https://devapi.vnforapps.com/api.tokenization/api/v2/merchant'
9
+ self.live_url = 'https://api.vnforapps.com/api.tokenization/api/v2/merchant'
10
10
 
11
- self.supported_countries = ["US", "PE"]
12
- self.default_currency = "PEN"
11
+ self.supported_countries = ['US', 'PE']
12
+ self.default_currency = 'PEN'
13
13
  self.money_format = :dollars
14
14
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
15
15
 
@@ -34,25 +34,32 @@ module ActiveMerchant #:nodoc:
34
34
  params[:email] = options[:email] || 'unknown@email.com'
35
35
  params[:createAlias] = false
36
36
 
37
- commit("authorize", params)
37
+ commit('authorize', params, options)
38
38
  end
39
39
 
40
40
  def capture(authorization, options={})
41
41
  params = {}
42
+ options[:id_unico] = split_authorization(authorization)[1]
42
43
  add_auth_order_id(params, authorization, options)
43
- commit("deposit", params)
44
+ commit('deposit', params, options)
44
45
  end
45
46
 
46
47
  def void(authorization, options={})
47
48
  params = {}
48
49
  add_auth_order_id(params, authorization, options)
49
- commit("void", params)
50
+ commit('void', params, options)
50
51
  end
51
52
 
52
53
  def refund(amount, authorization, options={})
53
54
  params = {}
55
+ params[:amount] = amount(amount) if amount
54
56
  add_auth_order_id(params, authorization, options)
55
- commit("cancelDeposit", params)
57
+ response = commit('cancelDeposit', params, options)
58
+ return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled]
59
+
60
+ # Attempt RefundSingleTransaction if unsettled
61
+ prepare_refund_data(params, authorization, options)
62
+ commit('refund', params, options)
56
63
  end
57
64
 
58
65
  def verify(credit_card, options={})
@@ -76,8 +83,8 @@ module ActiveMerchant #:nodoc:
76
83
  private
77
84
 
78
85
  CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
79
- CURRENCY_CODES["USD"] = 840
80
- CURRENCY_CODES["PEN"] = 604
86
+ CURRENCY_CODES['USD'] = 840
87
+ CURRENCY_CODES['PEN'] = 604
81
88
 
82
89
  def add_invoice(params, money, options)
83
90
  # Visanet Peru expects a 9-digit numeric purchaseNumber
@@ -88,7 +95,8 @@ module ActiveMerchant #:nodoc:
88
95
  end
89
96
 
90
97
  def add_auth_order_id(params, authorization, options)
91
- params[:purchaseNumber] = authorization
98
+ purchase_number, _ = split_authorization(authorization)
99
+ params[:purchaseNumber] = purchase_number
92
100
  params[:externalTransactionId] = options[:order_id]
93
101
  end
94
102
 
@@ -118,48 +126,64 @@ module ActiveMerchant #:nodoc:
118
126
  params[:antifraud] = antifraud
119
127
  end
120
128
 
121
- def commit(action, params)
129
+ def prepare_refund_data(params, authorization, options)
130
+ params.delete(:purchaseNumber)
131
+ params[:externalReferenceId] = params.delete(:externalTransactionId)
132
+ _, transaction_id = split_authorization(authorization)
133
+
134
+ options.update(transaction_id: transaction_id)
135
+ params[:ruc] = options[:ruc]
136
+ end
137
+
138
+ def split_authorization(authorization)
139
+ authorization.split('|')
140
+ end
141
+
142
+ def commit(action, params, options={})
122
143
  begin
123
- raw_response = ssl_request(method(action), url(action, params), params.to_json, headers)
144
+ raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
124
145
  response = parse(raw_response)
125
146
  rescue ResponseError => e
126
147
  raw_response = e.response.body
127
- response_error(raw_response)
148
+ response_error(raw_response, options, action)
128
149
  rescue JSON::ParserError
129
150
  unparsable_response(raw_response)
130
151
  else
131
152
  Response.new(
132
153
  success_from(response),
133
- message_from(response),
154
+ message_from(response, options, action),
134
155
  response,
135
156
  :test => test?,
136
- :authorization => authorization_from(params),
137
- :error_code => response["errorCode"]
157
+ :authorization => authorization_from(params, response, options),
158
+ :error_code => response['errorCode']
138
159
  )
139
160
  end
140
161
  end
141
162
 
142
163
  def headers
143
164
  {
144
- "Authorization" => "Basic " + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip,
145
- "Content-Type" => "application/json"
165
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip,
166
+ 'Content-Type' => 'application/json'
146
167
  }
147
168
  end
148
169
 
149
- def url(action, params)
150
- if (action == "authorize")
170
+ def url(action, params, options={})
171
+ if (action == 'authorize')
151
172
  "#{base_url}/#{@options[:merchant_id]}"
173
+ elsif (action == 'refund')
174
+ "#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}"
152
175
  else
153
176
  "#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}"
154
177
  end
155
178
  end
156
179
 
157
180
  def method(action)
158
- (action == "authorize") ? :post : :put
181
+ (%w(authorize refund).include? action) ? :post : :put
159
182
  end
160
183
 
161
- def authorization_from(params)
162
- params[:purchaseNumber]
184
+ def authorization_from(params, response, options)
185
+ id_unico = response['data']['ID_UNICO'] || options[:id_unico]
186
+ "#{params[:purchaseNumber]}|#{id_unico}"
163
187
  end
164
188
 
165
189
  def base_url
@@ -171,18 +195,22 @@ module ActiveMerchant #:nodoc:
171
195
  end
172
196
 
173
197
  def success_from(response)
174
- response["errorCode"] == 0
198
+ response['errorCode'] == 0
175
199
  end
176
200
 
177
- def message_from(response)
178
- if empty?(response["errorMessage"]) || response["errorMessage"] == "[ ]"
179
- response["data"]["DSC_COD_ACCION"]
201
+ def message_from(response, options, action)
202
+ if empty?(response['errorMessage']) || response['errorMessage'] == '[ ]'
203
+ action == 'refund' ? "#{response['data']['DSC_COD_ACCION']}, #{options[:error_message]}" : response['data']['DSC_COD_ACCION']
204
+ elsif action == 'refund'
205
+ message = "#{response['errorMessage']}, #{options[:error_message]}"
206
+ options[:error_message] = response['errorMessage']
207
+ message
180
208
  else
181
- response["errorMessage"]
209
+ response['errorMessage']
182
210
  end
183
211
  end
184
212
 
185
- def response_error(raw_response)
213
+ def response_error(raw_response, options, action)
186
214
  begin
187
215
  response = parse(raw_response)
188
216
  rescue JSON::ParserError
@@ -190,17 +218,17 @@ module ActiveMerchant #:nodoc:
190
218
  else
191
219
  return Response.new(
192
220
  false,
193
- message_from(response),
221
+ message_from(response, options, action),
194
222
  response,
195
223
  :test => test?,
196
- :authorization => response["transactionUUID"],
197
- :error_code => response["errorCode"]
224
+ :authorization => response['transactionUUID'],
225
+ :error_code => response['errorCode']
198
226
  )
199
227
  end
200
228
  end
201
229
 
202
230
  def unparsable_response(raw_response)
203
- message = "Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message."
231
+ message = 'Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message.'
204
232
  message += " (The raw response returned by the API was #{raw_response.inspect})"
205
233
  return Response.new(false, message)
206
234
  end