activemerchant 1.28.0 → 1.29.1

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 (117) hide show
  1. data/CHANGELOG +41 -0
  2. data/CONTRIBUTORS +12 -0
  3. data/README.md +6 -0
  4. data/lib/active_merchant/billing/gateway.rb +2 -1
  5. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  6. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  7. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  8. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  9. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  10. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  11. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  12. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  13. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  14. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  16. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  17. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  18. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  19. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  20. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  21. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  22. data/lib/active_merchant/billing/gateways/eway_rapid.rb +300 -0
  23. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  24. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  25. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  26. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  27. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  28. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  29. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  30. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  31. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  32. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  33. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  34. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  35. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  36. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  37. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  38. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  39. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  40. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  41. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  42. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  43. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  44. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  45. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  46. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  47. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  48. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  49. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  50. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  51. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  54. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  55. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  56. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  57. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  58. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  59. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  62. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  63. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  64. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  65. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  66. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  67. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  68. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  69. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  70. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  71. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  72. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  75. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  76. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  77. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  78. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  79. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  80. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  81. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  82. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  83. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  84. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  85. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  86. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  87. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  88. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  89. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  90. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  91. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  92. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  93. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  94. data/lib/active_merchant/billing/gateways.rb +6 -7
  95. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  99. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
  102. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  103. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
  104. data/lib/active_merchant/billing/integrations/notification.rb +4 -0
  105. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
  110. data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
  111. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
  112. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
  113. data/lib/active_merchant/billing/response.rb +17 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. data.tar.gz.sig +0 -0
  116. metadata +46 -27
  117. metadata.gz.sig +0 -0
@@ -4,12 +4,14 @@ rescue LoadError
4
4
  raise "Could not load the vindicia-api gem. Use `gem install vindicia-api` to install it."
5
5
  end
6
6
 
7
+ require 'i18n/core_ext/string/interpolate'
8
+
7
9
  module ActiveMerchant #:nodoc:
8
10
  module Billing #:nodoc:
9
11
 
10
12
  # For more information on the Vindicia Gateway please visit their {website}[http://vindicia.com/]
11
13
  #
12
- # The login and password are not the username and password you use to
14
+ # The login and password are not the username and password you use to
13
15
  # login to the Vindicia Merchant Portal.
14
16
  #
15
17
  # ==== Recurring Billing
@@ -25,8 +27,8 @@ module ActiveMerchant #:nodoc:
25
27
 
26
28
  class_attribute :test_url, :live_url
27
29
 
28
- self.test_url = "https://soap.prodtest.sj.vindicia.com/soap.pl"
29
- self.live_url = "http://soap.vindicia.com/soap.pl"
30
+ self.test_url = "https://soap.prodtest.sj.vindicia.com/soap.pl"
31
+ self.live_url = "http://soap.vindicia.com/soap.pl"
30
32
 
31
33
  # Creates a new VindiciaGateway
32
34
  #
@@ -40,24 +42,25 @@ module ActiveMerchant #:nodoc:
40
42
  # * <tt>:api_version</tt> -- Vindicia API Version - defaults to 3.6 (OPTIONAL)
41
43
  # * <tt>:account_id</tt> -- Account Id which all transactions will be run against. (REQUIRED)
42
44
  # * <tt>:transaction_prefix</tt> -- Prefix to order id for one-time transactions - defaults to 'X' (OPTIONAL
43
- # * <tt>:min_chargeback_probability</tt> -- Minimum score for chargebacks - defaults to 65 (OPTIONAL)
45
+ # * <tt>:min_chargeback_probability</tt> -- Minimum score for chargebacks - defaults to 65 (OPTIONAL)
44
46
  # * <tt>:cvn_success</tt> -- Array of valid CVN Check return values - defaults to [M, P] (OPTIONAL)
45
47
  # * <tt>:avs_success</tt> -- Array of valid AVS Check return values - defaults to [X, Y, A, W, Z] (OPTIONAL)
46
48
  def initialize(options = {})
47
49
  requires!(options, :login, :password)
50
+ super
48
51
 
49
52
  config = lambda do |config|
50
- config.login = options[:login]
51
- config.password = options[:password]
53
+ config.login = options[:login]
54
+ config.password = options[:password]
52
55
  config.api_version = options[:api_version] || "3.6"
53
- config.endpoint = test? ? self.test_url : self.live_url
56
+ config.endpoint = test? ? self.test_url : self.live_url
54
57
  config.namespace = "http://soap.vindicia.com"
55
58
  end
56
59
 
57
- if Vindicia.config.is_configured?
60
+ if Vindicia.config.is_configured?
58
61
  config.call(Vindicia.config)
59
62
  else
60
- Vindicia.configure(&config)
63
+ Vindicia.configure(&config)
61
64
  end
62
65
 
63
66
  requires!(options, :account_id)
@@ -66,10 +69,9 @@ module ActiveMerchant #:nodoc:
66
69
  @transaction_prefix = options[:transaction_prefix] || "X"
67
70
 
68
71
  @min_chargeback_probability = options[:min_chargeback_probability] || 65
69
- @cvn_success = options[:cvn_success] || %w{M P}
72
+ @cvn_success = options[:cvn_success] || %w{M P}
70
73
  @avs_success = options[:avs_success] || %w{X Y A W Z}
71
74
 
72
- @options = options
73
75
  @allowed_authorization_statuses = %w{Authorized}
74
76
  end
75
77
 
@@ -103,7 +105,7 @@ module ActiveMerchant #:nodoc:
103
105
  if !response.success? && response.fraud_review? && !response.authorization.blank?
104
106
  void_response = void([vindicia_transaction[:transaction][:merchantTransactionId]], options)
105
107
  if void_response.success?
106
- return response
108
+ return response
107
109
  else
108
110
  return void_response
109
111
  end
@@ -142,10 +144,10 @@ module ActiveMerchant #:nodoc:
142
144
  :account => { :merchantAccountId => @account_id },
143
145
  :merchantTransactionId => identification,
144
146
  :sourceIp => options[:ip]
145
- }]
147
+ }]
146
148
  }))
147
149
 
148
- if response[:return][:returnCode] == '200' && response[:qtyFail].to_i == 0
150
+ if response[:return][:returnCode] == '200' && response[:qtyFail].to_i == 0
149
151
  success(response, identification)
150
152
  else
151
153
  fail(response)
@@ -204,22 +206,22 @@ module ActiveMerchant #:nodoc:
204
206
 
205
207
  def check_transaction(vindicia_transaction)
206
208
  if vindicia_transaction[:return][:returnCode] == '200'
207
- status_log = vindicia_transaction[:transaction][:statusLog].first
209
+ status_log = vindicia_transaction[:transaction][:statusLog].first
208
210
  if status_log[:creditCardStatus]
209
211
  avs = status_log[:creditCardStatus][:avsCode]
210
212
  cvn = status_log[:creditCardStatus][:cvnCode]
211
213
  end
212
214
 
213
- if @allowed_authorization_statuses.include?(status_log[:status]) &&
215
+ if @allowed_authorization_statuses.include?(status_log[:status]) &&
214
216
  check_cvn(cvn) && check_avs(avs)
215
217
 
216
- success(vindicia_transaction,
217
- vindicia_transaction[:transaction][:merchantTransactionId],
218
+ success(vindicia_transaction,
219
+ vindicia_transaction[:transaction][:merchantTransactionId],
218
220
  avs, cvn)
219
221
  else
220
222
  # If the transaction is authorized, but it didn't pass our AVS/CVV checks send the authorization along so
221
223
  # that is gets voided. Otherwise, send no authorization.
222
- fail(vindicia_transaction, avs, cvn, false,
224
+ fail(vindicia_transaction, avs, cvn, false,
223
225
  @allowed_authorization_statuses.include?(status_log[:status]) ? vindicia_transaction[:transaction][:merchantTransactionId] : "")
224
226
  end
225
227
  else
@@ -238,9 +240,9 @@ module ActiveMerchant #:nodoc:
238
240
  add_customer_data(parameters, options)
239
241
  add_payment_source(parameters, creditcard, options)
240
242
 
241
- post(Vindicia::Transaction.auth({
242
- :transaction => parameters,
243
- :minChargebackProbability => @min_chargeback_probability
243
+ post(Vindicia::Transaction.auth({
244
+ :transaction => parameters,
245
+ :minChargebackProbability => @min_chargeback_probability
244
246
  }))
245
247
  end
246
248
 
@@ -281,8 +283,8 @@ module ActiveMerchant #:nodoc:
281
283
  add_subscription_information(parameters, options)
282
284
 
283
285
  post(Vindicia::AutoBill.update({
284
- :autobill => parameters,
285
- :validatePaymentMethod => false,
286
+ :autobill => parameters,
287
+ :validatePaymentMethod => false,
286
288
  :minChargebackProbability => 100
287
289
  }))
288
290
  end
@@ -290,8 +292,8 @@ module ActiveMerchant #:nodoc:
290
292
  def check_subscription(vindicia_transaction)
291
293
  if vindicia_transaction[:return][:returnCode] == '200'
292
294
  if vindicia_transaction[:autobill] && vindicia_transaction[:autobill][:status] == "Active"
293
- success(vindicia_transaction,
294
- vindicia_transaction[:autobill][:merchantAutoBillId])
295
+ success(vindicia_transaction,
296
+ vindicia_transaction[:autobill][:merchantAutoBillId])
295
297
  else
296
298
  fail(vindicia_transaction)
297
299
  end
@@ -326,8 +328,8 @@ module ActiveMerchant #:nodoc:
326
328
  end
327
329
 
328
330
  def fail(response, avs_code = nil, cvn_code = nil, fraud_review = false, authorization = "")
329
- ActiveMerchant::Billing::Response.new(false, response[:return][:returnString], response,
330
- { :fraud_review => fraud_review || !authorization.blank?,
331
+ ActiveMerchant::Billing::Response.new(false, response[:return][:returnString], response,
332
+ { :fraud_review => fraud_review || !authorization.blank?,
331
333
  :authorization => authorization, :test => test?,
332
334
  :avs_result => { :code => avs_code }, :cvv_result => cvn_code })
333
335
 
@@ -0,0 +1,45 @@
1
+ require 'json'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class WebpayGateway < StripeGateway
6
+ self.live_url = 'https://api.webpay.jp/v1/'
7
+
8
+ self.supported_countries = ['JP']
9
+ self.default_currency = 'JPY'
10
+ self.money_format = :cents
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :diners_club]
12
+
13
+ self.homepage_url = 'https://webpay.jp/'
14
+ self.display_name = 'WebPay'
15
+
16
+ def json_error(raw_response)
17
+ msg = 'Invalid response received from the WebPay API. Please contact support@webpay.jp if you continue to receive this message.'
18
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
19
+ {
20
+ "error" => {
21
+ "message" => msg
22
+ }
23
+ }
24
+ end
25
+
26
+ def headers(meta={})
27
+ @@ua ||= JSON.dump({
28
+ :bindings_version => ActiveMerchant::VERSION,
29
+ :lang => 'ruby',
30
+ :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
31
+ :platform => RUBY_PLATFORM,
32
+ :publisher => 'active_merchant',
33
+ :uname => (RUBY_PLATFORM =~ /linux|darwin/i ? `uname -a 2>/dev/null`.strip : nil)
34
+ })
35
+
36
+ {
37
+ "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":").strip,
38
+ "User-Agent" => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
39
+ "X-Webpay-Client-User-Agent" => @@ua,
40
+ "X-Webpay-Client-User-Metadata" => meta.to_json
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -57,15 +57,9 @@ module ActiveMerchant #:nodoc:
57
57
  requires!(options, :login, :password)
58
58
  # unfortunately Wirecard also requires a BusinessCaseSignature in the XML request
59
59
  requires!(options, :signature)
60
- @options = options
61
60
  super
62
61
  end
63
62
 
64
- # Should run against the test servers or not?
65
- def test?
66
- @options[:test] || super
67
- end
68
-
69
63
  # Authorization
70
64
  def authorize(money, creditcard, options = {})
71
65
  options[:credit_card] = creditcard
@@ -20,12 +20,11 @@ module ActiveMerchant #:nodoc:
20
20
 
21
21
  def initialize(options = {})
22
22
  requires!(options, :login, :password)
23
- @options = options
24
23
  super
25
24
  end
26
25
 
27
26
  def purchase(money, payment_method, options = {})
28
- MultiResponse.new.tap do |r|
27
+ MultiResponse.run do |r|
29
28
  r.process{authorize(money, payment_method, options)}
30
29
  r.process{capture(money, r.authorization, options.merge(:authorization_validated => true))}
31
30
  end
@@ -37,30 +36,26 @@ module ActiveMerchant #:nodoc:
37
36
  end
38
37
 
39
38
  def capture(money, authorization, options = {})
40
- MultiResponse.new.tap do |r|
39
+ MultiResponse.run do |r|
41
40
  r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated]
42
41
  r.process{capture_request(money, authorization, options)}
43
42
  end
44
43
  end
45
44
 
46
45
  def void(authorization, options = {})
47
- MultiResponse.new.tap do |r|
46
+ MultiResponse.run do |r|
48
47
  r.process{inquire_request(authorization, options, "AUTHORISED")}
49
48
  r.process{cancel_request(authorization, options)}
50
49
  end
51
50
  end
52
51
 
53
52
  def refund(money, authorization, options = {})
54
- MultiResponse.new.tap do |r|
53
+ MultiResponse.run do |r|
55
54
  r.process{inquire_request(authorization, options, "CAPTURED")}
56
55
  r.process{refund_request(money, authorization, options)}
57
56
  end
58
57
  end
59
58
 
60
- def test?
61
- @options[:test] || super
62
- end
63
-
64
59
  private
65
60
 
66
61
  def authorize_request(money, payment_method, options)
@@ -1,18 +1,17 @@
1
1
  module ActiveMerchant
2
2
  module Billing
3
3
  autoload :Gateway, 'active_merchant/billing/gateway'
4
-
5
- Dir[File.dirname(__FILE__) + '/gateways/**/*.rb'].each do |f|
6
-
7
- # Get camelized class name
4
+
5
+ Dir[File.dirname(__FILE__) + '/gateways/**/*.rb'].each do |f|
6
+ # Get camelized class name
8
7
  filename = File.basename(f, '.rb')
9
8
  # Add _gateway suffix
10
9
  gateway_name = filename + '_gateway'
11
10
  # Camelize the string to get the class name
12
- gateway_class = gateway_name.camelize
13
-
11
+ gateway_class = gateway_name.camelize
12
+
14
13
  # Register for autoloading
15
- autoload gateway_class, f
14
+ autoload gateway_class, f
16
15
  end
17
16
  end
18
17
  end
@@ -0,0 +1,31 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module A1agregator
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+
7
+ # public key
8
+ mapping :account, 'key'
9
+
10
+ mapping :amount, 'cost'
11
+
12
+ mapping :order, 'order_id'
13
+
14
+ mapping :customer, :email => 'email',
15
+ :phone => 'phone_number'
16
+
17
+ # payment description
18
+ mapping :credential2, 'name'
19
+
20
+ mapping :credential3, 'comment'
21
+
22
+ # on error
23
+ # 1 - raise error
24
+ # 0 - redirect
25
+ mapping :credential4, 'verbose'
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,186 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module A1agregator
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+
9
+ self.production_ips = [
10
+ '78.108.178.206',
11
+ '79.137.235.129',
12
+ '95.163.96.79',
13
+ '212.24.38.100'
14
+ ]
15
+
16
+ def initialize(*args)
17
+ super
18
+ guess_notification_type
19
+ end
20
+
21
+ # Simple notification request params:
22
+ # tid
23
+ # name
24
+ # comment
25
+ # partner_id
26
+ # service_id
27
+ # order_id
28
+ # type
29
+ # partner_income
30
+ # system_income
31
+
32
+ def complete?
33
+ true
34
+ end
35
+
36
+ def transaction_id
37
+ params['tid']
38
+ end
39
+
40
+ def title
41
+ params['name']
42
+ end
43
+
44
+ def comment
45
+ params['comment']
46
+ end
47
+
48
+ def partner_id
49
+ params['partner_id']
50
+ end
51
+
52
+ def service_id
53
+ params['service_id']
54
+ end
55
+
56
+ def item_id
57
+ params['order_id']
58
+ end
59
+
60
+ def type
61
+ params['type']
62
+ end
63
+
64
+ def partner_income
65
+ params['partner_income']
66
+ end
67
+
68
+ def system_income
69
+ params['system_income']
70
+ end
71
+
72
+ # Additional notification request params:
73
+ # tid
74
+ # name
75
+ # comment
76
+ # partner_id
77
+ # service_id
78
+ # order_id
79
+ # type
80
+ # cost
81
+ # income_total
82
+ # income
83
+ # partner_income
84
+ # system_income
85
+ # command
86
+ # phone_number
87
+ # email
88
+ # resultStr
89
+ # date_created
90
+ # version
91
+ # check
92
+
93
+ def inclome_total
94
+ params['income_total']
95
+ end
96
+
97
+ def income
98
+ params['income']
99
+ end
100
+
101
+ def partner_income
102
+ params['partner_income']
103
+ end
104
+
105
+ def system_income
106
+ params['system_income']
107
+ end
108
+
109
+ def command
110
+ params['command']
111
+ end
112
+
113
+ def phone_number
114
+ params['phone_number']
115
+ end
116
+
117
+ def payer_email
118
+ params['email']
119
+ end
120
+
121
+ def result_string
122
+ params['resultStr']
123
+ end
124
+
125
+ def received_at
126
+ params['date_created']
127
+ end
128
+
129
+ def version
130
+ params['version']
131
+ end
132
+
133
+ def security_key
134
+ params[A1agregator.signature_parameter_name].to_s.downcase
135
+ end
136
+
137
+ # the money amount we received in X.2 decimal.
138
+ alias_method :gross, :system_income
139
+
140
+ def currency
141
+ 'RUB'
142
+ end
143
+
144
+ # Was this a test transaction?
145
+ def test?
146
+ params['test'] == '1'
147
+ end
148
+
149
+ def simple_notification?
150
+ @notification_type == :simple
151
+ end
152
+
153
+ def additional_notification?
154
+ @notification_type == :additional
155
+ end
156
+
157
+ def acknowledge
158
+ security_key == signature
159
+ end
160
+
161
+ private
162
+
163
+ def signature
164
+ data = "#{params['tid']}\
165
+ #{params['name']}\
166
+ #{params['comment']}\
167
+ #{params['partner_id']}\
168
+ #{params['service_id']}\
169
+ #{params['order_id']}\
170
+ #{params['type']}\
171
+ #{params['partner_income']}\
172
+ #{params['system_income']}\
173
+ #{params['test']}\
174
+ #{@options[:secret]}"
175
+ Digest::MD5.hexdigest(data)
176
+ end
177
+
178
+ def guess_notification_type
179
+ @notification_type = params['version'] ? :additional : :simple
180
+ end
181
+
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,38 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module A1agregator
5
+
6
+ class Status
7
+ include PostsData
8
+
9
+ STATUS_TEST_URL = 'https://partner.a1pay.ru/a1lite/info/'
10
+
11
+ attr_accessor :login, :password
12
+
13
+ def initialize(login, password)
14
+ @login, @password = login, password
15
+ end
16
+
17
+ # agregator provides two methods:
18
+ # by tid - transaction id
19
+ # by order_id & service_id
20
+ def update(options = {})
21
+ data = PostData.new
22
+ data[:user] = @login
23
+ data[:pass] = @password
24
+ if options[:tid]
25
+ data[:tid] = options[:tid]
26
+ else
27
+ data[:ord_id] = options[:ord_id]
28
+ data[:service_id] = options[:service_id]
29
+ end
30
+
31
+ ssl_post(STATUS_TEST_URL, data.to_post_data)
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/a1agregator/helper.rb'
2
+ require File.dirname(__FILE__) + '/a1agregator/notification.rb'
3
+ require File.dirname(__FILE__) + '/a1agregator/status.rb'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ module Integrations #:nodoc:
8
+ module A1agregator
9
+
10
+ mattr_accessor :service_url
11
+ self.service_url = 'https://partner.a1agregator.ru/a1lite/input/'
12
+
13
+ mattr_accessor :signature_parameter_name
14
+ self.signature_parameter_name = 'check'
15
+
16
+ def self.notification(*args)
17
+ Notification.new(*args)
18
+ end
19
+
20
+ def self.status(login, password)
21
+ Status.new(login, password)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,43 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Liqpay
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ def initialize(order, account, options = {})
7
+ @secret = options.delete(:secret)
8
+ super
9
+
10
+ add_field 'version', '1.2'
11
+ end
12
+
13
+ def form_fields
14
+ xml = "<request>
15
+ <version>1.2</version>
16
+ <result_url>#{@fields["result_url"]}</result_url>
17
+ <server_url>#{@fields["server_url"]}</server_url>
18
+ <merchant_id>#{@fields["merchant_id"]}</merchant_id>
19
+ <order_id>#{@fields["order_id"]}</order_id>
20
+ <amount>#{@fields["amount"]}</amount>
21
+ <currency>#{@fields["currency"]}</currency>
22
+ <description>#{@fields["description"]}</description>
23
+ <default_phone>#{@fields["default_phone"]}</default_phone>
24
+ <pay_way>card</pay_way>
25
+ </request>".strip
26
+ sign = Base64.encode64(Digest::SHA1.digest("#{@secret}#{xml}#{@secret}")).strip
27
+ {"operation_xml" => Base64.encode64(xml), "signature" => sign}
28
+ end
29
+
30
+ mapping :account, 'merchant_id'
31
+ mapping :amount, 'amount'
32
+ mapping :currency, 'currency'
33
+ mapping :order, 'order_id'
34
+ mapping :description, 'description'
35
+ mapping :phone, 'default_phone'
36
+
37
+ mapping :notify_url, 'server_url'
38
+ mapping :return_url, 'result_url'
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end