activemerchant 1.42.5 → 1.42.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG +23 -0
  5. data/CONTRIBUTORS +12 -0
  6. data/README.md +4 -1
  7. data/lib/active_merchant.rb +5 -1
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +1 -11
  9. data/lib/active_merchant/billing/gateways/balanced.rb +23 -6
  10. data/lib/active_merchant/billing/gateways/cecabank.rb +225 -0
  11. data/lib/active_merchant/billing/gateways/conekta.rb +4 -3
  12. data/lib/active_merchant/billing/gateways/litle.rb +50 -44
  13. data/lib/active_merchant/billing/gateways/maxipago.rb +190 -0
  14. data/lib/active_merchant/billing/gateways/ogone.rb +2 -1
  15. data/lib/active_merchant/billing/gateways/openpay.rb +200 -0
  16. data/lib/active_merchant/billing/gateways/orbital.rb +24 -3
  17. data/lib/active_merchant/billing/gateways/orbital/cvv_result.rb +34 -0
  18. data/lib/active_merchant/billing/gateways/paymill.rb +2 -2
  19. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -1
  20. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +2 -1
  21. data/lib/active_merchant/billing/gateways/wirecard.rb +5 -1
  22. data/lib/active_merchant/billing/integrations/alipay.rb +18 -0
  23. data/lib/active_merchant/billing/integrations/alipay/helper.rb +34 -0
  24. data/lib/active_merchant/billing/integrations/alipay/notification.rb +101 -0
  25. data/lib/active_merchant/billing/integrations/paydollar.rb +59 -0
  26. data/lib/active_merchant/billing/integrations/paydollar/helper.rb +41 -0
  27. data/lib/active_merchant/billing/integrations/paydollar/notification.rb +60 -0
  28. data/lib/active_merchant/billing/integrations/paydollar/return.rb +15 -0
  29. data/lib/active_merchant/version.rb +1 -1
  30. metadata +13 -2
  31. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjExMzYzY2FiZmNmZDE1YWI2M2VhMTU5YzY4MGM2N2FkMGEwMDQzMQ==
4
+ NzkyMTMwMmZlNGQ4MDhiNTI0NDFmYjIzOTI1ZjZjNTNjNTIwY2E1Yw==
5
5
  data.tar.gz: !binary |-
6
- MDAyMGFkMTU4MmU1MmJhOWJkNjQxYjNkNTIxODFlZjA0NWZiZTBlYw==
6
+ ZDg2OWFmMzE4NTA0NjI0MTJkZWQyYzYyZDVkMzk0MTYwODYwNDI4YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDBiZmExZjY3ZGI2OTk4ZjAwNDI2ZDk0ZWUyZjA2NWY2ODQxNWRmMWVlYTA1
10
- MzZhOTQ4YTJlYjlmNTRhOTRkNGM2OGM3MGJjNjI2ZWQwZmM5ODEzM2I3NjY1
11
- NThlMTcxZjQ3OGNjMWRmNjIzMmVjYmVhYmFlNTcwZDhhYTJjMWU=
9
+ YzM5NTgxYTc4MzU3MjY1Y2MwNGExZjAyMzVlNWIyZTJlNmI3ZWY2MzhhZjE5
10
+ ODc5OGIxMGFjMGRhZmNkOTc5YmZjNzUyZmY5ZGEwZTVhMDUzMTFkNjljYWIz
11
+ MDQzMmU3MDlmNDhkMjkxMDIwOTVkNzFjZTkyMDBjZGY0NzU4Nzg=
12
12
  data.tar.gz: !binary |-
13
- YzNmOGJiMDZmMjJlZjY3OWU0MWQ5NzM4M2M1NzI4ZmQ3OTNjNjI1ZmE0MzYz
14
- ZjRjNjdlZGNkNTc3M2YxMjFjYWQyMmJhMzZlYWM0MzhkMWVkMTdkNWNkZDM0
15
- YWIyYWJhNWQyYzE4YTVkNGVjN2ZlOTgxMzZiYWRlMmU1NTgzNWY=
13
+ MWFmNTMzZWNhMDhmOTE3MDQzYTU1ZTFlZTFkYjQ4NTMxZWM3YTBlNGU5YWM1
14
+ ZjgzMzc3MTEzOWY5ZjhkYTFmMDY5ZmI4NWFmMjI0YTA1YjMzOTM4YjUyMGEz
15
+ Y2M4YWVjOWNhZjVjMTZjOTNlMWQ4NzQ4ZjRiMWRiYWJhYjcyNTQ=
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,5 +1,28 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ == Version 1.42.6 (February 24, 2014)
4
+
5
+ * Litle: Truncate order_id [duff]
6
+ * Conekta: Fix #refund; respect :currency [leofischer]
7
+ * SagePay: Truncate description field [duff]
8
+ * Add Cecabank gateway [molpe]
9
+ * Add Openpay [darkaz]
10
+ * Openpay: Simplify test versus production mode [duff]
11
+ * Wirecard: Handle a utf-8 description [duff]
12
+ * Litle: Partial capture support [ttdonovan]
13
+ * Ogone: Allow D3D for alias purchases [pwoestelandt]
14
+ * USAePay Advanced: Fix verification_value mapping [dppcode]
15
+ * Orbital: Add additional success conditions [boone]
16
+ * Orbital: Handle special CVV responses [boone]
17
+ * Balanced: Allow working with balanced.js [michaelherold]
18
+ * Balanced: Allow passing customer name [michaelherold]
19
+ * Balanced: Add support for meta [michaelherold]
20
+ * Improve gateway generator [ntalbott]
21
+ * Add maxiPago gateway [alexandremcosta]
22
+ * Authorize.Net: Remove x_test_request support [ntalbott]
23
+ * Conekta: Add default description [bslobodin]
24
+ * Add PayDollar integration [bslobodin]
25
+
3
26
  == Version 1.42.5 (February 7th, 2014)
4
27
 
5
28
  * Add Doku Indonesia [bizla]
data/CONTRIBUTORS CHANGED
@@ -448,3 +448,15 @@ Payscout (December 2013)
448
448
  SoEasyPay (December 2013)
449
449
 
450
450
  * Ivan Radovanovic (ir-soeasycorp)
451
+
452
+ Cecabank (February 2014)
453
+
454
+ * Alberto Molpeceres (molpe)
455
+
456
+ Openpay (February 2014)
457
+
458
+ * (darkaz)
459
+
460
+ maxiPago (February 2014)
461
+
462
+ * (alexandremcosta)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Active Merchant
2
2
  [![Build Status](https://travis-ci.org/Shopify/active_merchant.png?branch=master)](https://travis-ci.org/Shopify/active_merchant)
3
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Shopify/active_merchant)
3
+ [![Code Climate](https://codeclimate.com/github/Shopify/active_merchant.png)](https://codeclimate.com/github/Shopify/active_merchant)
4
4
 
5
5
  Active Merchant is an extraction from the e-commerce system [Shopify](http://www.shopify.com).
6
6
  Shopify's requirements for a simple and unified API to access dozens of different payment
@@ -94,6 +94,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
94
94
  * [Braintree](http://www.braintreepaymentsolutions.com) - US, CA, AU, AD, AT, BE, BG, CY, CZ, DK, EE, FI, FR, GI, DE, GR, HU, IS, IM, IE, IT, LV, LI, LT, LU, MT, MC, NL, NO, PL, PT, RO, SM, SK, SI, ES, SE, CH, TR, GB
95
95
  * [CardSave](http://www.cardsave.net/) - GB
96
96
  * [CardStream](http://www.cardstream.com/) - GB
97
+ * [Cecabank](http://www.ceca.es/es/) - ES
97
98
  * [CertoDirect](http://www.certodirect.com/) - BE, BG, CZ, DK, DE, EE, IE, EL, ES, FR, IT, CY, LV, LT, LU, HU, MT, NL, AT, PL, PT, RO, SI, SK, FI, SE, GB
98
99
  * [Conekta](https://conekta.io) - MX
99
100
  * [CyberSource](http://www.cybersource.com) - US, BR, CA, CN, DK, FI, FR, DE, JP, MX, NO, SE, GB, SG
@@ -120,6 +121,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
120
121
  * [JetPay](http://www.jetpay.com/) - US
121
122
  * [LinkPoint](http://www.linkpoint.com/) - US
122
123
  * [Litle & Co.](http://www.litle.com/) - US
124
+ * [maxiPago!](http://www.maxipago.com/) - BR
123
125
  * [Merchant e-Solutions](http://www.merchante-solutions.com/) - US
124
126
  * [Merchant One Gateway](http://merchantone.com/) - US
125
127
  * [MerchantWARE](http://merchantwarehouse.com/merchantware) - US
@@ -138,6 +140,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
138
140
  * [NETPAY Gateway](http://www.netpay.com.mx) - MX
139
141
  * [NMI](http://nmi.com/) - US
140
142
  * [Ogone](http://www.ogone.com/) - BE, DE, FR, NL, AT, CH
143
+ * [Openpay](Openpay) - MX
141
144
  * [Optimal Payments](http://www.optimalpayments.com/) - CA, US, GB
142
145
  * [Orbital Paymentech](http://chasepaymentech.com/) - US, CA
143
146
  * [PayGate PayXML](http://paygate.co.za/) - US, ZA
@@ -27,7 +27,11 @@ require 'active_support/core_ext/hash/indifferent_access'
27
27
  require 'active_support/core_ext/hash/conversions'
28
28
  require 'active_support/core_ext/object/conversions'
29
29
  require 'active_support/core_ext/class/attribute'
30
- require 'active_support/core_ext/class/attribute_accessors'
30
+
31
+ if(!defined?(ActiveSupport::VERSION) || (ActiveSupport::VERSION::STRING < "4.1"))
32
+ require 'active_support/core_ext/class/attribute_accessors'
33
+ end
34
+
31
35
  require 'active_support/core_ext/class/delegating_attributes'
32
36
  require 'active_support/core_ext/module/attribute_accessors'
33
37
 
@@ -267,9 +267,6 @@ module ActiveMerchant #:nodoc:
267
267
  def commit(action, money, parameters)
268
268
  parameters[:amount] = amount(money) unless action == 'VOID'
269
269
 
270
- # Only activate the test_request when the :test option is passed in
271
- parameters[:test_request] = @options[:test] ? 'TRUE' : 'FALSE'
272
-
273
270
  url = test? ? self.test_url : self.live_url
274
271
  data = ssl_post url, post_data(action, parameters)
275
272
 
@@ -278,15 +275,8 @@ module ActiveMerchant #:nodoc:
278
275
 
279
276
  message = message_from(response)
280
277
 
281
- # Return the response. The authorization can be taken out of the transaction_id
282
- # Test Mode on/off is something we have to parse from the response text.
283
- # It usually looks something like this
284
- #
285
- # (TESTMODE) Successful Sale
286
- test_mode = test? || message =~ /TESTMODE/
287
-
288
278
  Response.new(success?(response), message, response,
289
- :test => test_mode,
279
+ :test => test?,
290
280
  :authorization => response[:transaction_id],
291
281
  :fraud_review => fraud_review?(response),
292
282
  :avs_result => { :code => response[:avs_result_code] },
@@ -131,7 +131,7 @@ module ActiveMerchant #:nodoc:
131
131
  post = {}
132
132
  post[:amount] = money
133
133
  post[:description] = options[:description]
134
- post[:appears_on_statement_as] = options[:appears_on_statement_as] if options[:appears_on_statement_as]
134
+ add_common_params(post, options)
135
135
 
136
136
  create_or_find_account(post, options)
137
137
  add_credit_card(post, credit_card, options)
@@ -161,6 +161,12 @@ module ActiveMerchant #:nodoc:
161
161
  # purchase.
162
162
  # * <tt>account_uri</tt> -- `account_uri` is the URI of an existing
163
163
  # Balanced account.
164
+ #
165
+ # If you are passing a new card URI from balanced.js, you should pass
166
+ # the customer's name
167
+ #
168
+ # * <tt>name</tt> -- the customer's name, to appear on the Account
169
+ # on Balanced.
164
170
  def purchase(money, credit_card, options = {})
165
171
  if credit_card.respond_to?('number')
166
172
  requires!(options, :email) unless options[:account_uri]
@@ -169,7 +175,7 @@ module ActiveMerchant #:nodoc:
169
175
  post = {}
170
176
  post[:amount] = money
171
177
  post[:description] = options[:description]
172
- post[:appears_on_statement_as] = options[:appears_on_statement_as] if options[:appears_on_statement_as]
178
+ add_common_params(post, options)
173
179
 
174
180
  create_or_find_account(post, options)
175
181
  add_credit_card(post, credit_card, options)
@@ -199,8 +205,7 @@ module ActiveMerchant #:nodoc:
199
205
  post[:hold_uri] = authorization
200
206
  post[:amount] = money if money
201
207
  post[:description] = options[:description] if options[:description]
202
- post[:appears_on_statement_as] = options[:appears_on_statement_as] if options[:appears_on_statement_as]
203
- post[:on_behalf_of_uri] = options[:on_behalf_of_uri] if options[:on_behalf_of_uri]
208
+ add_common_params(post, options)
204
209
 
205
210
  create_transaction(:post, @debits_uri, post)
206
211
  rescue Error => ex
@@ -216,7 +221,7 @@ module ActiveMerchant #:nodoc:
216
221
  def void(authorization, options = {})
217
222
  post = {}
218
223
  post[:is_void] = true
219
- post[:appears_on_statement_as] = options[:appears_on_statement_as] if options[:appears_on_statement_as]
224
+ add_common_params(post, options)
220
225
 
221
226
  create_transaction(:put, authorization, post)
222
227
  rescue Error => ex
@@ -250,7 +255,7 @@ module ActiveMerchant #:nodoc:
250
255
  post[:debit_uri] = debit_uri
251
256
  post[:amount] = amount
252
257
  post[:description] = options[:description]
253
- post[:appears_on_statement_as] = options[:appears_on_statement_as] if options[:appears_on_statement_as]
258
+ add_common_params(post, options)
254
259
  create_transaction(:post, @refunds_uri, post)
255
260
  rescue Error => ex
256
261
  failed_response(ex.response)
@@ -310,7 +315,9 @@ module ActiveMerchant #:nodoc:
310
315
  end
311
316
 
312
317
  if account_uri == nil
318
+ post[:name] = options[:name] if options[:name]
313
319
  post[:email_address] = options[:email]
320
+ post[:meta] = options[:meta] if options[:meta]
314
321
 
315
322
  # create an account
316
323
  response = http_request(:post, @accounts_uri, post)
@@ -340,6 +347,15 @@ module ActiveMerchant #:nodoc:
340
347
  end
341
348
  end
342
349
 
350
+ def add_common_params(post, options)
351
+ common_params = [
352
+ :appears_on_statement_as,
353
+ :on_behalf_of_uri,
354
+ :meta
355
+ ]
356
+ post.update(options.select{|key, _| common_params.include?(key)})
357
+ end
358
+
343
359
  def add_credit_card(post, credit_card, options)
344
360
  if credit_card.respond_to? :number
345
361
  card = {}
@@ -361,6 +377,7 @@ module ActiveMerchant #:nodoc:
361
377
 
362
378
  post[:card_uri] = card_uri
363
379
  elsif credit_card.kind_of?(String)
380
+ associate_card_to_account(post[:account_uri], credit_card) unless options[:account_uri]
364
381
  post[:card_uri] = credit_card
365
382
  end
366
383
 
@@ -0,0 +1,225 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CecabankGateway < Gateway
4
+ self.test_url = 'http://tpv.ceca.es:8000'
5
+ self.live_url = 'https://pgw.ceca.es'
6
+
7
+ self.supported_countries = ['ES']
8
+ self.supported_cardtypes = [:visa, :master, :american_express]
9
+ self.homepage_url = 'http://www.ceca.es/es/'
10
+ self.display_name = 'Cecabank'
11
+ self.default_currency = 'EUR'
12
+ self.money_format = :cents
13
+
14
+ #### CECA's MAGIC NUMBERS
15
+ CECA_NOTIFICATIONS_URL = 'NONE'
16
+ CECA_ENCRIPTION = 'SHA1'
17
+ CECA_DECIMALS = '2'
18
+ CECA_MODE = 'SSL'
19
+ CECA_UI_LESS_LANGUAGE = 'XML'
20
+ CECA_UI_LESS_LANGUAGE_REFUND = '1'
21
+ CECA_UI_LESS_REFUND_PAGE = 'anulacion_xml'
22
+ CECA_ACTION_REFUND = 'tpvanularparcialmente' #use partial refund's URL to avoid time frame limitations and decision logic on client side
23
+ CECA_ACTION_PURCHASE = 'tpv'
24
+ CECA_CURRENCIES_DICTIONARY = {'EUR' => 978, 'USD' => 840, 'GBP' => 826}
25
+
26
+ # Creates a new CecabankGateway
27
+ #
28
+ # The gateway requires four values for connection to be passed
29
+ # in the +options+ hash.
30
+ #
31
+ # ==== Options
32
+ #
33
+ # * <tt>:merchant_id</tt> -- Cecabank's merchant_id (REQUIRED)
34
+ # * <tt>:acquirer_bin</tt> -- Cecabank's acquirer_bin (REQUIRED)
35
+ # * <tt>:terminal_id</tt> -- Cecabank's terminal_id (REQUIRED)
36
+ # * <tt>:key</tt> -- Cecabank's cypher key (REQUIRED)
37
+ # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
38
+ # Otherwise, perform transactions against the production server.
39
+ def initialize(options = {})
40
+ requires!(options, :merchant_id, :acquirer_bin, :terminal_id, :key)
41
+ super
42
+ end
43
+
44
+ # Perform a purchase, which is essentially an authorization and capture in a single operation.
45
+ #
46
+ # ==== Parameters
47
+ #
48
+ # * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
49
+ # * <tt>creditcard</tt> -- The CreditCard details for the transaction.
50
+ # * <tt>options</tt> -- A hash of optional parameters.
51
+ #
52
+ # ==== Options
53
+ #
54
+ # * <tt>:order_id</tt> -- order_id passed used purchase. (REQUIRED)
55
+ # * <tt>:currency</tt> -- currency. Supported: EUR, USD, GBP.
56
+ # * <tt>:description</tt> -- description to be pased to the gateway.
57
+ def purchase(money, creditcard, options = {})
58
+ requires!(options, :order_id)
59
+
60
+ post = {'Descripcion' => options[:description],
61
+ 'Num_operacion' => options[:order_id],
62
+ 'Idioma' => CECA_UI_LESS_LANGUAGE,
63
+ 'Pago_soportado' => CECA_MODE,
64
+ 'URL_OK' => CECA_NOTIFICATIONS_URL,
65
+ 'URL_NOK' => CECA_NOTIFICATIONS_URL,
66
+ 'Importe' => amount(money),
67
+ 'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)]}
68
+
69
+ add_creditcard(post, creditcard)
70
+
71
+ commit(CECA_ACTION_PURCHASE, post)
72
+ end
73
+
74
+ # Refund a transaction.
75
+ #
76
+ # This transaction indicates to the gateway that
77
+ # money should flow from the merchant to the customer.
78
+ #
79
+ # ==== Parameters
80
+ #
81
+ # * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
82
+ # * <tt>identification</tt> -- The reference given from the gateway on purchase (reference, not operation).
83
+ # * <tt>options</tt> -- A hash of parameters.
84
+ def refund(money, identification, options = {})
85
+ reference, order_id = split_authorization(identification)
86
+
87
+ post = {'Referencia' => reference,
88
+ 'Num_operacion' => order_id,
89
+ 'Idioma' => CECA_UI_LESS_LANGUAGE_REFUND,
90
+ 'Pagina' => CECA_UI_LESS_REFUND_PAGE,
91
+ 'Importe' => amount(money),
92
+ 'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)]}
93
+
94
+ commit(CECA_ACTION_REFUND, post)
95
+ end
96
+
97
+ private
98
+
99
+ def add_creditcard(post, creditcard)
100
+ post['PAN'] = creditcard.number
101
+ post['Caducidad'] = "#{creditcard.year}#{creditcard.month}"
102
+ post['CVV2'] = creditcard.verification_value
103
+ post['Pago_elegido'] = CECA_MODE
104
+ end
105
+
106
+ def parse(body)
107
+ response = {}
108
+
109
+ root = REXML::Document.new(body).root
110
+
111
+ response[:success] = (root.attributes['valor'] == "OK")
112
+
113
+ #common params to all responses
114
+ response[:date] = root.attributes['fecha']
115
+ response[:operation_number] = root.attributes['numeroOperacion']
116
+ response[:message] = root.attributes['valor']
117
+
118
+ #success
119
+ if root.elements['OPERACION']
120
+ response[:operation_type] = root.elements['OPERACION'].attributes['tipo']
121
+ response[:amount] = root.elements['OPERACION/importe'].text.strip
122
+ end
123
+
124
+ #optional params
125
+ response[:description] = root.elements['OPERACION/descripcion'].text if root.elements['OPERACION/descripcion']
126
+ response[:authorization_number] = root.elements['OPERACION/numeroAutorizacion'].text if root.elements['OPERACION/numeroAutorizacion']
127
+ response[:reference] = root.elements['OPERACION/referencia'].text if root.elements['OPERACION/referencia']
128
+ response[:pan] = root.elements['OPERACION/pan'].text if root.elements['OPERACION/pan']
129
+
130
+ if root.elements['ERROR']
131
+ #error
132
+ response[:error_code] = root.elements['ERROR/codigo'].text
133
+ response[:error_message] = root.elements['ERROR/descripcion'].text
134
+ else
135
+ #authorization
136
+ if("000" == root.elements['OPERACION'].attributes['numeroOperacion'])
137
+ if(root.elements['OPERACION/numeroAutorizacion'])
138
+ response[:authorization] = root.elements['OPERACION/numeroAutorizacion'].text
139
+ end
140
+ else
141
+ response[:authorization] = root.attributes['numeroOperacion']
142
+ end
143
+ end
144
+
145
+ response
146
+ end
147
+
148
+ def commit(action, parameters)
149
+ parameters.merge!(
150
+ 'Cifrado' => CECA_ENCRIPTION,
151
+ 'Firma' => generate_signature(action, parameters),
152
+ 'Exponente' => CECA_DECIMALS,
153
+ 'MerchantID' => options[:merchant_id],
154
+ 'AcquirerBIN' => options[:acquirer_bin],
155
+ 'TerminalID' => options[:terminal_id]
156
+ )
157
+ url = (test? ? self.test_url : self.live_url) + "/cgi-bin/#{action}"
158
+ xml = ssl_post(url, post_data(parameters))
159
+ response = parse(xml)
160
+ Response.new(
161
+ response[:success],
162
+ response[:message],
163
+ response,
164
+ :test => test?,
165
+ :authorization => build_authorization(response)
166
+ )
167
+ end
168
+
169
+ def post_data(params)
170
+ return nil unless params
171
+
172
+ params.map do |key, value|
173
+ next if value.blank?
174
+ if value.is_a?(Hash)
175
+ h = {}
176
+ value.each do |k, v|
177
+ h["#{key}.#{k}"] = v unless v.blank?
178
+ end
179
+ post_data(h)
180
+ else
181
+ "#{key}=#{CGI.escape(value.to_s)}"
182
+ end
183
+ end.compact.join("&")
184
+ end
185
+
186
+ def build_authorization(response)
187
+ [response[:reference], response[:authorization]].join("|")
188
+ end
189
+
190
+ def split_authorization(authorization)
191
+ authorization.split("|")
192
+ end
193
+
194
+ def generate_signature(action, parameters)
195
+ signature_fields = case action
196
+ when CECA_ACTION_REFUND
197
+ options[:key].to_s +
198
+ options[:merchant_id].to_s +
199
+ options[:acquirer_bin].to_s +
200
+ options[:terminal_id].to_s +
201
+ parameters['Num_operacion'].to_s +
202
+ parameters['Importe'].to_s +
203
+ parameters['TipoMoneda'].to_s +
204
+ CECA_DECIMALS +
205
+ parameters['Referencia'].to_s +
206
+ CECA_ENCRIPTION
207
+ else
208
+ options[:key].to_s +
209
+ options[:merchant_id].to_s +
210
+ options[:acquirer_bin].to_s +
211
+ options[:terminal_id].to_s +
212
+ parameters['Num_operacion'].to_s +
213
+ parameters['Importe'].to_s +
214
+ parameters['TipoMoneda'].to_s +
215
+ CECA_DECIMALS +
216
+ CECA_ENCRIPTION +
217
+ CECA_NOTIFICATIONS_URL +
218
+ CECA_NOTIFICATIONS_URL
219
+ end
220
+ Digest::SHA1.hexdigest(signature_fields)
221
+ end
222
+ end
223
+ end
224
+ end
225
+