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
@@ -51,9 +51,9 @@ module ActiveMerchant #:nodoc:
51
51
  MultiResponse.run(:first) do |r|
52
52
  r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/", post, options) }
53
53
 
54
- return r unless options[:set_default] and r.success? and !r.params["id"].blank?
54
+ return r unless options[:set_default] and r.success? and !r.params['id'].blank?
55
55
 
56
- r.process { update_customer(options[:customer], :default_card => r.params["id"]) }
56
+ r.process { update_customer(options[:customer], :default_card => r.params['id']) }
57
57
  end
58
58
  else
59
59
  commit(:post, 'customers', post, options)
@@ -78,18 +78,18 @@ module ActiveMerchant #:nodoc:
78
78
  msg = 'Invalid response received from the WebPay API. Please contact support@webpay.jp if you continue to receive this message.'
79
79
  msg += " (The raw response returned by the API was #{raw_response.inspect})"
80
80
  {
81
- "error" => {
82
- "message" => msg
81
+ 'error' => {
82
+ 'message' => msg
83
83
  }
84
84
  }
85
85
  end
86
86
 
87
87
  def headers(options = {})
88
88
  {
89
- "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":").strip,
90
- "User-Agent" => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
91
- "X-Webpay-Client-User-Agent" => user_agent,
92
- "X-Webpay-Client-User-Metadata" => {:ip => options[:ip]}.to_json
89
+ 'Authorization' => 'Basic ' + Base64.encode64(@api_key.to_s + ':').strip,
90
+ 'User-Agent' => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
91
+ 'X-Webpay-Client-User-Agent' => user_agent,
92
+ 'X-Webpay-Client-User-Metadata' => {:ip => options[:ip]}.to_json
93
93
  }
94
94
  end
95
95
  end
@@ -57,7 +57,7 @@ module ActiveMerchant #:nodoc:
57
57
  def void(identifier, options = {})
58
58
  post = {}
59
59
  post[:checkout_id] = split_authorization(identifier).first
60
- post[:cancel_reason] = (options[:description] || "Void")
60
+ post[:cancel_reason] = (options[:description] || 'Void')
61
61
  commit('/checkout/cancel', post, options)
62
62
  end
63
63
 
@@ -69,17 +69,17 @@ module ActiveMerchant #:nodoc:
69
69
  if(money && (original_amount != amount(money)))
70
70
  post[:amount] = amount(money)
71
71
  end
72
- post[:refund_reason] = (options[:description] || "Refund")
72
+ post[:refund_reason] = (options[:description] || 'Refund')
73
73
  post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message]
74
74
  post[:payee_email_message] = options[:payee_email_message] if options[:payee_email_message]
75
- commit("/checkout/refund", post, options)
75
+ commit('/checkout/refund', post, options)
76
76
  end
77
77
 
78
78
  def store(creditcard, options = {})
79
79
  post = {}
80
80
  post[:client_id] = @options[:client_id]
81
81
  post[:user_name] = "#{creditcard.first_name} #{creditcard.last_name}"
82
- post[:email] = options[:email] || "unspecified@example.com"
82
+ post[:email] = options[:email] || 'unspecified@example.com'
83
83
  post[:cc_number] = creditcard.number
84
84
  post[:cvv] = creditcard.verification_value unless options[:recurring]
85
85
  post[:expiration_month] = creditcard.month
@@ -87,11 +87,11 @@ module ActiveMerchant #:nodoc:
87
87
 
88
88
  if(billing_address = (options[:billing_address] || options[:address]))
89
89
  post[:address] = {}
90
- post[:address]["address1"] = billing_address[:address1] if billing_address[:address1]
91
- post[:address]["city"] = billing_address[:city] if billing_address[:city]
92
- post[:address]["country"] = billing_address[:country] if billing_address[:country]
93
- post[:address]["region"] = billing_address[:state] if billing_address[:state]
94
- post[:address]["postal_code"] = billing_address[:zip]
90
+ post[:address]['address1'] = billing_address[:address1] if billing_address[:address1]
91
+ post[:address]['city'] = billing_address[:city] if billing_address[:city]
92
+ post[:address]['country'] = billing_address[:country] if billing_address[:country]
93
+ post[:address]['region'] = billing_address[:state] if billing_address[:state]
94
+ post[:address]['postal_code'] = billing_address[:zip]
95
95
  end
96
96
 
97
97
  if options[:recurring] == true
@@ -126,8 +126,8 @@ module ActiveMerchant #:nodoc:
126
126
  def add_product_data(post, money, options)
127
127
  post[:account_id] = @options[:account_id]
128
128
  post[:amount] = amount(money)
129
- post[:short_description] = (options[:description] || "Purchase")
130
- post[:type] = (options[:type] || "goods")
129
+ post[:short_description] = (options[:description] || 'Purchase')
130
+ post[:type] = (options[:type] || 'goods')
131
131
  post[:currency] = (options[:currency] || currency(money))
132
132
  post[:long_description] = options[:long_description] if options[:long_description]
133
133
  post[:payer_email_message] = options[:payer_email_message] if options[:payer_email_message]
@@ -151,7 +151,7 @@ module ActiveMerchant #:nodoc:
151
151
 
152
152
  def add_token(post, token)
153
153
  payment_method = {}
154
- payment_method[:type] = "credit_card"
154
+ payment_method[:type] = 'credit_card'
155
155
  payment_method[:credit_card] = {
156
156
  id: token,
157
157
  auto_capture: false
@@ -196,40 +196,40 @@ module ActiveMerchant #:nodoc:
196
196
  end
197
197
 
198
198
  def success_from(response)
199
- (!response["error"])
199
+ (!response['error'])
200
200
  end
201
201
 
202
202
  def message_from(response)
203
- (response["error"] ? response["error_description"] : "Success")
203
+ (response['error'] ? response['error_description'] : 'Success')
204
204
  end
205
205
 
206
206
  def authorization_from(response, params)
207
- return response["credit_card_id"].to_s if response["credit_card_id"]
207
+ return response['credit_card_id'].to_s if response['credit_card_id']
208
208
 
209
- original_amount = response["amount"].nil? ? nil : sprintf("%0.02f", response["amount"])
210
- [response["checkout_id"], original_amount].join('|')
209
+ original_amount = response['amount'].nil? ? nil : sprintf('%0.02f', response['amount'])
210
+ [response['checkout_id'], original_amount].join('|')
211
211
  end
212
212
 
213
213
  def split_authorization(authorization)
214
- auth, original_amount = authorization.to_s.split("|")
214
+ auth, original_amount = authorization.to_s.split('|')
215
215
  [auth, original_amount]
216
216
  end
217
217
 
218
218
  def unparsable_response(raw_response)
219
- message = "Invalid JSON response received from WePay. Please contact WePay support if you continue to receive this message."
219
+ message = 'Invalid JSON response received from WePay. Please contact WePay support if you continue to receive this message.'
220
220
  message += " (The raw response returned by the API was #{raw_response.inspect})"
221
221
  return Response.new(false, message)
222
222
  end
223
223
 
224
224
  def headers(options)
225
225
  headers = {
226
- "Content-Type" => "application/json",
227
- "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
228
- "Authorization" => "Bearer #{@options[:access_token]}"
226
+ 'Content-Type' => 'application/json',
227
+ 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
228
+ 'Authorization' => "Bearer #{@options[:access_token]}"
229
229
  }
230
- headers["Api-Version"] = options[:version] if options[:version]
231
- headers["Client-IP"] = options[:ip] if options[:ip]
232
- headers["WePay-Risk-Token"] = options[:risk_token] if options[:risk_token]
230
+ headers['Api-Version'] = options[:version] if options[:version]
231
+ headers['Client-IP'] = options[:ip] if options[:ip]
232
+ headers['WePay-Risk-Token'] = options[:risk_token] if options[:risk_token]
233
233
 
234
234
  headers
235
235
  end
@@ -139,7 +139,7 @@ module ActiveMerchant #:nodoc:
139
139
 
140
140
  private
141
141
  def clean_description(description)
142
- description.to_s.slice(0,32).encode("US-ASCII", invalid: :replace, undef: :replace, replace: '?')
142
+ description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?')
143
143
  end
144
144
 
145
145
  def prepare_options_hash(options)
@@ -174,7 +174,7 @@ module ActiveMerchant #:nodoc:
174
174
 
175
175
  response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers))
176
176
  # Pending Status also means Acknowledged (as stated in their specification)
177
- success = response[:FunctionResult] == "ACK" || response[:FunctionResult] == "PENDING"
177
+ success = response[:FunctionResult] == 'ACK' || response[:FunctionResult] == 'PENDING'
178
178
  message = response[:Message]
179
179
  authorization = response[:GuWID]
180
180
 
@@ -185,8 +185,8 @@ module ActiveMerchant #:nodoc:
185
185
  :cvv_result => response[:CVCResponseCode]
186
186
  )
187
187
  rescue ResponseError => e
188
- if e.response.code == "401"
189
- return Response.new(false, "Invalid Login")
188
+ if e.response.code == '401'
189
+ return Response.new(false, 'Invalid Login')
190
190
  else
191
191
  raise
192
192
  end
@@ -200,12 +200,12 @@ module ActiveMerchant #:nodoc:
200
200
  xml.instruct!
201
201
  xml.tag! 'WIRECARD_BXML' do
202
202
  xml.tag! 'W_REQUEST' do
203
- xml.tag! 'W_JOB' do
204
- xml.tag! 'JobID', ''
205
- # UserID for this transaction
206
- xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login]
207
- # Create the whole rest of the message
208
- add_transaction_data(xml, money, options)
203
+ xml.tag! 'W_JOB' do
204
+ xml.tag! 'JobID', ''
205
+ # UserID for this transaction
206
+ xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login]
207
+ # Create the whole rest of the message
208
+ add_transaction_data(xml, money, options)
209
209
  end
210
210
  end
211
211
  end
@@ -261,7 +261,7 @@ module ActiveMerchant #:nodoc:
261
261
 
262
262
  # Includes the credit-card data to the transaction-xml
263
263
  def add_creditcard(xml, creditcard)
264
- raise "Creditcard must be supplied!" if creditcard.nil?
264
+ raise 'Creditcard must be supplied!' if creditcard.nil?
265
265
  xml.tag! 'CREDIT_CARD_DATA' do
266
266
  xml.tag! 'CreditCardNumber', creditcard.number
267
267
  xml.tag! 'CVC2', creditcard.verification_value
@@ -309,7 +309,7 @@ module ActiveMerchant #:nodoc:
309
309
  xml = REXML::Document.new(xml)
310
310
  if root = REXML::XPath.first(xml, "#{basepath}/W_JOB")
311
311
  parse_response(response, root)
312
- elsif root = REXML::XPath.first(xml, "//ERROR")
312
+ elsif root = REXML::XPath.first(xml, '//ERROR')
313
313
  parse_error_only_response(response, root)
314
314
  else
315
315
  response[:Message] = "No valid XML response message received. \
@@ -320,7 +320,7 @@ module ActiveMerchant #:nodoc:
320
320
  end
321
321
 
322
322
  def parse_error_only_response(response, root)
323
- error_code = REXML::XPath.first(root, "Number")
323
+ error_code = REXML::XPath.first(root, 'Number')
324
324
  response[:ErrorCode] = error_code.text if error_code
325
325
  response[:Message] = parse_error(root)
326
326
  end
@@ -331,11 +331,11 @@ module ActiveMerchant #:nodoc:
331
331
 
332
332
  root.elements.to_a.each do |node|
333
333
  if node.name =~ /FNC_CC_/
334
- status = REXML::XPath.first(node, "CC_TRANSACTION/PROCESSING_STATUS")
334
+ status = REXML::XPath.first(node, 'CC_TRANSACTION/PROCESSING_STATUS')
335
335
  end
336
336
  end
337
337
 
338
- message = ""
338
+ message = ''
339
339
  if status
340
340
  if info = status.elements['Info']
341
341
  message << info.text
@@ -352,7 +352,7 @@ module ActiveMerchant #:nodoc:
352
352
  end
353
353
  end
354
354
 
355
- error_code = REXML::XPath.first(status, "ERROR/Number")
355
+ error_code = REXML::XPath.first(status, 'ERROR/Number')
356
356
  response['ErrorCode'] = error_code.text if error_code
357
357
  end
358
358
 
@@ -361,7 +361,7 @@ module ActiveMerchant #:nodoc:
361
361
  end
362
362
 
363
363
  # Parse a generic error response from the gateway
364
- def parse_error(root, message = "")
364
+ def parse_error(root, message = '')
365
365
  # Get errors if available and append them to the message
366
366
  errors = errors_to_string(root)
367
367
  unless errors.strip.blank?
@@ -376,7 +376,7 @@ module ActiveMerchant #:nodoc:
376
376
  def errors_to_string(root)
377
377
  # Get context error messages (can be 0..*)
378
378
  errors = []
379
- REXML::XPath.each(root, "//ERROR") do |error_elem|
379
+ REXML::XPath.each(root, '//ERROR') do |error_elem|
380
380
  error = {}
381
381
  error[:Advice] = []
382
382
  error[:Message] = error_elem.elements['Message'].text
@@ -401,18 +401,18 @@ module ActiveMerchant #:nodoc:
401
401
 
402
402
  # Amex have different AVS response codes
403
403
  AMEX_TRANSLATED_AVS_CODES = {
404
- "A" => "B", # CSC and Address Matched
405
- "F" => "D", # All Data Matched
406
- "N" => "I", # CSC Match
407
- "U" => "U", # Data Not Checked
408
- "Y" => "D", # All Data Matched
409
- "Z" => "P", # CSC and Postcode Matched
404
+ 'A' => 'B', # CSC and Address Matched
405
+ 'F' => 'D', # All Data Matched
406
+ 'N' => 'I', # CSC Match
407
+ 'U' => 'U', # Data Not Checked
408
+ 'Y' => 'D', # All Data Matched
409
+ 'Z' => 'P', # CSC and Postcode Matched
410
410
  }
411
411
 
412
412
  # Amex have different AVS response codes to visa etc
413
413
  def avs_code(response, options)
414
414
  if response.has_key?(:AVS_ProviderResultCode)
415
- if options[:credit_card].present? && ActiveMerchant::Billing::CreditCard.brand?(options[:credit_card].number) == "american_express"
415
+ if options[:credit_card].present? && ActiveMerchant::Billing::CreditCard.brand?(options[:credit_card].number) == 'american_express'
416
416
  AMEX_TRANSLATED_AVS_CODES[response[:AVS_ProviderResultCode]]
417
417
  else
418
418
  response[:AVS_ProviderResultCode]
@@ -424,7 +424,7 @@ module ActiveMerchant #:nodoc:
424
424
  # (for http basic authentication)
425
425
  def encoded_credentials
426
426
  credentials = [@options[:login], @options[:password]].join(':')
427
- "Basic " << Base64.encode64(credentials).strip
427
+ 'Basic ' << Base64.encode64(credentials).strip
428
428
  end
429
429
  end
430
430
  end
@@ -44,7 +44,7 @@ module ActiveMerchant #:nodoc:
44
44
 
45
45
  def capture(money, authorization, options = {})
46
46
  MultiResponse.run do |r|
47
- r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated]
47
+ r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated]
48
48
  if r.params
49
49
  authorization_currency = r.params['amount_currency_code']
50
50
  options = options.merge(:currency => authorization_currency) if authorization_currency.present?
@@ -55,21 +55,21 @@ module ActiveMerchant #:nodoc:
55
55
 
56
56
  def void(authorization, options = {})
57
57
  MultiResponse.run do |r|
58
- r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated]
58
+ r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated]
59
59
  r.process{cancel_request(authorization, options)}
60
60
  end
61
61
  end
62
62
 
63
63
  def refund(money, authorization, options = {})
64
64
  response = MultiResponse.run do |r|
65
- r.process { inquire_request(authorization, options, "CAPTURED", "SETTLED", "SETTLED_BY_MERCHANT") }
65
+ r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') }
66
66
  r.process { refund_request(money, authorization, options) }
67
67
  end
68
68
 
69
69
  return response if response.success?
70
70
  return response unless options[:force_full_refund_if_unsettled]
71
71
 
72
- void(authorization, options ) if response.params["last_event"] == "AUTHORISED"
72
+ void(authorization, options ) if response.params['last_event'] == 'AUTHORISED'
73
73
  end
74
74
 
75
75
  # Credits only function on a Merchant ID/login/profile flagged for Payouts
@@ -101,7 +101,7 @@ module ActiveMerchant #:nodoc:
101
101
  private
102
102
 
103
103
  def authorize_request(money, payment_method, options)
104
- commit('authorize', build_authorization_request(money, payment_method, options), "AUTHORISED", options)
104
+ commit('authorize', build_authorization_request(money, payment_method, options), 'AUTHORISED', options)
105
105
  end
106
106
 
107
107
  def capture_request(money, authorization, options)
@@ -127,8 +127,8 @@ module ActiveMerchant #:nodoc:
127
127
  def build_request
128
128
  xml = Builder::XmlMarkup.new :indent => 2
129
129
  xml.instruct! :xml, :encoding => 'UTF-8'
130
- xml.declare! :DOCTYPE, :paymentService, :PUBLIC, "-//WorldPay//DTD WorldPay PaymentService v1//EN", "http://dtd.worldpay.com/paymentService_v1.dtd"
131
- xml.tag! 'paymentService', 'version' => "1.4", 'merchantCode' => @options[:login] do
130
+ xml.declare! :DOCTYPE, :paymentService, :PUBLIC, '-//WorldPay//DTD WorldPay PaymentService v1//EN', 'http://dtd.worldpay.com/paymentService_v1.dtd'
131
+ xml.tag! 'paymentService', 'version' => '1.4', 'merchantCode' => @options[:login] do
132
132
  yield xml
133
133
  end
134
134
  xml.target!
@@ -156,7 +156,7 @@ module ActiveMerchant #:nodoc:
156
156
  build_request do |xml|
157
157
  xml.tag! 'submit' do
158
158
  xml.tag! 'order', order_tag_attributes(options) do
159
- xml.description(options[:description].blank? ? "Purchase" : options[:description])
159
+ xml.description(options[:description].blank? ? 'Purchase' : options[:description])
160
160
  add_amount(xml, money, options)
161
161
  if options[:order_content]
162
162
  xml.tag! 'orderContent' do
@@ -196,7 +196,7 @@ module ActiveMerchant #:nodoc:
196
196
  def build_refund_request(money, authorization, options)
197
197
  build_order_modify_request(authorization) do |xml|
198
198
  xml.tag! 'refund' do
199
- add_amount(xml, money, options.merge(:debit_credit_indicator => "credit"))
199
+ add_amount(xml, money, options.merge(:debit_credit_indicator => 'credit'))
200
200
  end
201
201
  end
202
202
  end
@@ -287,7 +287,7 @@ module ActiveMerchant #:nodoc:
287
287
  def add_hcg_additional_data(xml, options)
288
288
  xml.tag! 'hcgAdditionalData' do
289
289
  options[:hcg_additional_data].each do |k, v|
290
- xml.tag! "param", {name: k.to_s}, v
290
+ xml.tag! 'param', {name: k.to_s}, v
291
291
  end
292
292
  end
293
293
  end
@@ -354,8 +354,8 @@ module ActiveMerchant #:nodoc:
354
354
  :test => test?)
355
355
 
356
356
  rescue ActiveMerchant::ResponseError => e
357
- if e.response.code.to_s == "401"
358
- return Response.new(false, "Invalid credentials", {}, :test => test?)
357
+ if e.response.code.to_s == '401'
358
+ return Response.new(false, 'Invalid credentials', {}, :test => test?)
359
359
  else
360
360
  raise e
361
361
  end
@@ -384,7 +384,7 @@ module ActiveMerchant #:nodoc:
384
384
  def success_and_message_from(raw, success_criteria)
385
385
  success = (success_criteria.include?(raw[:last_event]) || raw[:ok].present?)
386
386
  if success
387
- message = "SUCCESS"
387
+ message = 'SUCCESS'
388
388
  else
389
389
  message = (raw[:iso8583_return_code_description] || raw[:error] || required_status_message(raw, success_criteria))
390
390
  end
@@ -393,7 +393,7 @@ module ActiveMerchant #:nodoc:
393
393
  end
394
394
 
395
395
  def error_code_from(success, raw)
396
- unless success == "SUCCESS"
396
+ unless success == 'SUCCESS'
397
397
  raw[:iso8583_return_code_code] || raw[:error_code] || nil
398
398
  end
399
399
  end
@@ -411,7 +411,7 @@ module ActiveMerchant #:nodoc:
411
411
 
412
412
  def credit_fund_transfer_attribute(options)
413
413
  return unless options[:credit]
414
- {'action' => "REFUND"}
414
+ {'action' => 'REFUND'}
415
415
  end
416
416
 
417
417
  def encoded_credentials
@@ -32,7 +32,7 @@ module ActiveMerchant #:nodoc:
32
32
 
33
33
  def capture(money, authorization, options={})
34
34
  if authorization
35
- commit(:post, "orders/#{CGI.escape(authorization)}/capture", {"captureAmount"=>money}, options, 'capture')
35
+ commit(:post, "orders/#{CGI.escape(authorization)}/capture", {'captureAmount'=>money}, options, 'capture')
36
36
  else
37
37
  Response.new(false,
38
38
  'FAILED',
@@ -56,7 +56,7 @@ module ActiveMerchant #:nodoc:
56
56
  end
57
57
 
58
58
  def refund(money, orderCode, options={})
59
- obj = money ? {"refundAmount" => money} : {}
59
+ obj = money ? {'refundAmount' => money} : {}
60
60
  commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund')
61
61
  end
62
62
 
@@ -76,16 +76,16 @@ module ActiveMerchant #:nodoc:
76
76
 
77
77
  def create_token(reusable, name, exp_month, exp_year, number, cvc)
78
78
  obj = {
79
- "reusable"=> reusable,
80
- "paymentMethod"=> {
81
- "type"=> "Card",
82
- "name"=> name,
83
- "expiryMonth"=> exp_month,
84
- "expiryYear"=> exp_year,
85
- "cardNumber"=> number,
86
- "cvc"=> cvc
79
+ 'reusable'=> reusable,
80
+ 'paymentMethod'=> {
81
+ 'type'=> 'Card',
82
+ 'name'=> name,
83
+ 'expiryMonth'=> exp_month,
84
+ 'expiryYear'=> exp_year,
85
+ 'cardNumber'=> number,
86
+ 'cvc'=> cvc
87
87
  },
88
- "clientKey"=> @client_key
88
+ 'clientKey'=> @client_key
89
89
  }
90
90
  token_response = commit(:post, 'tokens', obj, {'Authorization' => @service_key}, 'token')
91
91
  token_response
@@ -93,23 +93,23 @@ module ActiveMerchant #:nodoc:
93
93
 
94
94
  def create_post_for_auth_or_purchase(token, money, options)
95
95
  {
96
- "token" => token,
97
- "orderDescription" => options[:description] || 'Worldpay Order',
98
- "amount" => money,
99
- "currencyCode" => options[:currency] || default_currency,
100
- "name" => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '',
101
- "billingAddress" => {
102
- "address1"=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
103
- "address2"=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
104
- "address3"=>"",
105
- "postalCode"=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
106
- "city"=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '',
107
- "state"=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '',
108
- "countryCode"=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : ''
96
+ 'token' => token,
97
+ 'orderDescription' => options[:description] || 'Worldpay Order',
98
+ 'amount' => money,
99
+ 'currencyCode' => options[:currency] || default_currency,
100
+ 'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '',
101
+ 'billingAddress' => {
102
+ 'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
103
+ 'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
104
+ 'address3'=>'',
105
+ 'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
106
+ 'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '',
107
+ 'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '',
108
+ 'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : ''
109
109
  },
110
- "customerOrderCode" => options[:order_id],
111
- "orderType" => "ECOM",
112
- "authorizeOnly" => options[:authorizeOnly] ? true : false
110
+ 'customerOrderCode' => options[:order_id],
111
+ 'orderType' => 'ECOM',
112
+ 'authorizeOnly' => options[:authorizeOnly] ? true : false
113
113
  }
114
114
  end
115
115
 
@@ -119,11 +119,11 @@ module ActiveMerchant #:nodoc:
119
119
 
120
120
  def headers(options = {})
121
121
  headers = {
122
- "Authorization" => @service_key,
123
- "Content-Type" => 'application/json',
124
- "User-Agent" => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
125
- "X-Worldpay-Client-User-Agent" => user_agent,
126
- "X-Worldpay-Client-User-Metadata" => {:ip => options[:ip]}.to_json
122
+ 'Authorization' => @service_key,
123
+ 'Content-Type' => 'application/json',
124
+ 'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
125
+ 'X-Worldpay-Client-User-Agent' => user_agent,
126
+ 'X-Worldpay-Client-User-Metadata' => {:ip => options[:ip]}.to_json
127
127
  }
128
128
  if options['Authorization']
129
129
  headers['Authorization'] = options['Authorization']
@@ -168,27 +168,27 @@ module ActiveMerchant #:nodoc:
168
168
  response = json_error(raw_response)
169
169
  end
170
170
 
171
- if response["orderCode"]
172
- authorization = response["orderCode"]
173
- elsif response["token"]
174
- authorization = response["token"]
171
+ if response['orderCode']
172
+ authorization = response['orderCode']
173
+ elsif response['token']
174
+ authorization = response['token']
175
175
  else
176
- authorization = response["message"]
176
+ authorization = response['message']
177
177
  end
178
178
 
179
179
  Response.new(success,
180
- success ? "SUCCESS" : response["message"],
180
+ success ? 'SUCCESS' : response['message'],
181
181
  response,
182
182
  :test => test?,
183
183
  :authorization => authorization,
184
184
  :avs_result => {},
185
185
  :cvv_result => {},
186
- :error_code => success ? nil : response["customCode"]
186
+ :error_code => success ? nil : response['customCode']
187
187
  )
188
188
  end
189
189
 
190
190
  def test?
191
- @service_key[0]=="T" ? true : false
191
+ @service_key[0]=='T' ? true : false
192
192
  end
193
193
 
194
194
  def response_error(raw_response)
@@ -203,8 +203,8 @@ module ActiveMerchant #:nodoc:
203
203
  msg = 'Invalid response received from the Worldpay Online Payments API. Please contact techsupport.online@worldpay.com if you continue to receive this message.'
204
204
  msg += " (The raw response returned by the API was #{raw_response.inspect})"
205
205
  {
206
- "error" => {
207
- "message" => msg
206
+ 'error' => {
207
+ 'message' => msg
208
208
  }
209
209
  }
210
210
  end