Permalink
Browse files

Added following gateways: beeline, interkassa, liqpay, robokassa, pre…

…mium, qiwi, masterbank, euroset
  • Loading branch information...
nebolsin authored and nashby committed Nov 11, 2010
1 parent e041b97 commit ec801d3d4f8074c514d8facc573286f35c1cafde
Showing with 1,903 additions and 0 deletions.
  1. +33 −0 lib/active_merchant/billing/integrations/assist.rb
  2. +44 −0 lib/active_merchant/billing/integrations/assist/helper.rb
  3. +95 −0 lib/active_merchant/billing/integrations/assist/notification.rb
  4. +13 −0 lib/active_merchant/billing/integrations/assist/return.rb
  5. +24 −0 lib/active_merchant/billing/integrations/beeline.rb
  6. +47 −0 lib/active_merchant/billing/integrations/beeline/helper.rb
  7. +87 −0 lib/active_merchant/billing/integrations/beeline/notification.rb
  8. +15 −0 lib/active_merchant/billing/integrations/euroset.rb
  9. +77 −0 lib/active_merchant/billing/integrations/euroset/notification.rb
  10. +31 −0 lib/active_merchant/billing/integrations/interkassa.rb
  11. +44 −0 lib/active_merchant/billing/integrations/interkassa/helper.rb
  12. +78 −0 lib/active_merchant/billing/integrations/interkassa/notification.rb
  13. +41 −0 lib/active_merchant/billing/integrations/interkassa/return.rb
  14. +32 −0 lib/active_merchant/billing/integrations/liqpay.rb
  15. +43 −0 lib/active_merchant/billing/integrations/liqpay/helper.rb
  16. +90 −0 lib/active_merchant/billing/integrations/liqpay/notification.rb
  17. +83 −0 lib/active_merchant/billing/integrations/liqpay/return.rb
  18. +28 −0 lib/active_merchant/billing/integrations/masterbank.rb
  19. +49 −0 lib/active_merchant/billing/integrations/masterbank/helper.rb
  20. +59 −0 lib/active_merchant/billing/integrations/masterbank/notification.rb
  21. +13 −0 lib/active_merchant/billing/integrations/masterbank/return.rb
  22. +17 −0 lib/active_merchant/billing/integrations/premium.rb
  23. +98 −0 lib/active_merchant/billing/integrations/premium/notification.rb
  24. +16 −0 lib/active_merchant/billing/integrations/qiwi.rb
  25. +77 −0 lib/active_merchant/billing/integrations/qiwi/notification.rb
  26. +16 −0 lib/active_merchant/billing/integrations/qiwi2.rb
  27. +82 −0 lib/active_merchant/billing/integrations/qiwi2/notification.rb
  28. +32 −0 lib/active_merchant/billing/integrations/robokassa.rb
  29. +47 −0 lib/active_merchant/billing/integrations/robokassa/helper.rb
  30. +56 −0 lib/active_merchant/billing/integrations/robokassa/notification.rb
  31. +17 −0 lib/active_merchant/billing/integrations/robokassa/return.rb
  32. +13 −0 test/unit/integrations/beeline_module_test.rb
  33. +46 −0 test/unit/integrations/helpers/beeline_helper_test.rb
  34. +35 −0 test/unit/integrations/helpers/interkassa_helper_test.rb
  35. +33 −0 test/unit/integrations/helpers/liqpay_helper_test.rb
  36. +35 −0 test/unit/integrations/helpers/robokassa_helper_test.rb
  37. +17 −0 test/unit/integrations/interkassa_module_test.rb
  38. +13 −0 test/unit/integrations/liqpay_module_test.rb
  39. +35 −0 test/unit/integrations/notifications/beeline_notification_test.rb
  40. +31 −0 test/unit/integrations/notifications/interkassa_notification_test.rb
  41. +34 −0 test/unit/integrations/notifications/liqpay_notification_test.rb
  42. +55 −0 test/unit/integrations/notifications/premium_notification_test.rb
  43. +42 −0 test/unit/integrations/notifications/robokassa_notification_test.rb
  44. +13 −0 test/unit/integrations/premium_module_test.rb
  45. +17 −0 test/unit/integrations/robokassa_module_test.rb
@@ -0,0 +1,33 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
# Documentation: http://assist.ru/support_center/setup/mode2.htm
module Assist
autoload :Helper, File.dirname(__FILE__) + '/assist/helper.rb'
autoload :Notification, File.dirname(__FILE__) + '/assist/notification.rb'
autoload :Return, File.dirname(__FILE__) + '/assist/return.rb'
mattr_accessor :service_url
self.service_url = 'https://secure5.assist.ru/shops/cardpayment.cfm'
mattr_accessor :signature_parameter_name
self.signature_parameter_name = 'CheckValue'
def self.helper(order, account, options = {})
Helper.new(order, account, options)
end
def self.notification(query_string, options = {})
Notification.new(query_string, options)
end
def self.return(query_string)
Return.new(query_string)
end
end
end
end
end
@@ -0,0 +1,44 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Assist
class Helper < ActiveMerchant::Billing::Integrations::Helper
def initialize(order, account, options = {})
@md5secret = options.delete(:secret)
@payment_methods = options.delete(:payments)
super
end
def form_fields
@fields.merge(payment_method_fields)
end
def payment_method_fields
return {} unless @payment_methods
fields = {}
fields["CardPayment"] = @payment_methods.include?(:card) ? "1" : "0"
fields["AssistIDCCPayment"] = @payment_methods.include?(:assist) ? "1" : "0"
fields["PayCashPayment"] = @payment_methods.include?(:cash) ? "1" : "0"
fields["WebMoneyPayment"] = @payment_methods.include?(:webmoney) ? "1" : "0"
fields["EPBeelinePayment"] = @payment_methods.include?(:beeline) ? "1" : "0"
fields
end
mapping :account, 'Shop_IDP'
mapping :amount, 'Subtotal_P'
mapping :currency, 'Currency'
mapping :order, 'Order_IDP'
mapping :description, 'Comment'
mapping :notify_url, 'URL_RETURN'
mapping :return_url, 'URL_RETURN_OK'
mapping :cancel_return_url, 'URL_RETURN_NO'
mapping :first_name, 'FirstName'
mapping :last_name, 'LastName'
mapping :email, 'Email'
end
end
end
end
end
@@ -0,0 +1,95 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Assist
class Notification < ActiveMerchant::Billing::Integrations::Notification
def self.recognizes?(params)
params.has_key?('OrderNumber') && params.has_key?('Shop_IDP')
end
def complete?
status == 'AS000'
end
def account
params['Shop_IDP']
end
def amount
BigDecimal.new(gross)
end
def item_id
params['OrderNumber']
end
def transaction_id
params['BillNumber']
end
def received_at
params['Date']
end
def security_key
params[ActiveMerchant::Billing::Integrations::Assist.signature_parameter_name]
end
def currency
params['Currency']
end
def status
params['Response_Code']
end
# the money amount we received in X.2 decimal.
def gross
params['Total']
end
def generate_signature_string
[account, item_id, gross, currency, @options[:secret]].flatten.compact.join('')
end
def generate_signature
Digest::MD5.hexdigest(generate_signature_string).upcase
end
def acknowledge
security_key == generate_signature
end
def response_content_type
'application/xml'
end
def success_response(*args)
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<pushpaymentresult firstcode="0" secondcode="0">
<order>
<billnumber>#{item_id}</billnumber>
<packetdate>#{received_at}</packetdate>
</order>
</pushpaymentresult>
XML
end
def error_response(error_type, options = {})
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<pushpaymentresult firstcode="0" secondcode="0">
<order>
<billnumber>#{item_id}</billnumber>
<packetdate>#{received_at}</packetdate>
</order>
</pushpaymentresult>
XML
end
end
end
end
end
end
@@ -0,0 +1,13 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Assist
class Return < ActiveMerchant::Billing::Integrations::Return
def item_id
params['order_idp']
end
end
end
end
end
end
@@ -0,0 +1,24 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Beeline
autoload :Helper, File.dirname(__FILE__) + '/beeline/helper.rb'
autoload :Notification, File.dirname(__FILE__) + '/beeline/notification.rb'
mattr_accessor :service_url
self.service_url = 'http://b2b.m-commerce.ru/store'
mattr_accessor :signature_parameter_name
self.signature_parameter_name = 'control'
def self.helper(order, account, options = {})
Helper.new(order, account, options)
end
def self.notification(query_string, options = {})
Notification.new(query_string, options)
end
end
end
end
end
@@ -0,0 +1,47 @@
require 'net/http'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Beeline
class Helper < ActiveMerchant::Billing::Integrations::Helper
def initialize(order, account, options = {})
@secret = options.delete(:secret)
super
add_field(:dt, Time.now.strftime('%Y%m%d%H%M%S'))
add_field(:cmd, 'create')
end
def form_fields
returning @fields.merge("cs" => generate_signature) do |fields|
fields.delete(mappings[:account])
end
end
def generate_signature_string
[@fields['dt'], @secret, @fields[mappings[:order]], @fields[mappings[:amount]]].flatten.compact.join(':')
end
def generate_signature
Digest::MD5.hexdigest(generate_signature_string)
end
def full_service_url
"#{ActiveMerchant::Billing::Integrations::Beeline.service_url}/#{@fields[mappings[:account]]}"
end
def announce_invoice
response = Net::HTTP.post_form(URI.parse(full_service_url), form_fields)
return ['0', '3'].include?(response.body)
end
mapping :account, 'account'
mapping :order, 'ic'
mapping :amount, 'os'
mapping :answer, 'an'
end
end
end
end
end
@@ -0,0 +1,87 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Beeline
class Notification < ActiveMerchant::Billing::Integrations::Notification
def self.recognizes?(params)
params.has_key?('order') && params.has_key?('sum')
end
def complete?
status == 'success'
end
def transaction_id
params['id']
end
def gross
params['sum']
end
def amount
BigDecimal.new(gross)
end
def item_id
params['order']
end
def received_at
params['datetime']
end
def phone
params['phone']
end
def status
'success'
end
def security_key
params[ActiveMerchant::Billing::Integrations::Beeline.signature_parameter_name]
end
def generate_signature_string
[transaction_id, @options[:secret], phone, item_id, gross, received_at].flatten.compact.join('')
end
def generate_signature
Digest::MD5.hexdigest(generate_signature_string)
end
def acknowledge
security_key == generate_signature
end
def response_content_type
'application/xml'
end
@@response_codes = {:fatal_error => 2, :error => 1, :ok => 0}
def response(response_code, options = {})
answer = options[:answer] || options[:payment].try(:answer) || ""
description = answer.blank? ? '' : "<description>#{answer}</description>"
<<-XML
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<result>#{response_code}</result>
#{description}
</response>
XML
end
def success_response(options = {}, *args)
response(@@response_codes[:ok], options, *args)
end
def error_response(error_type, options = {})
response(@@response_codes[error_type], options)
end
end
end
end
end
end
@@ -0,0 +1,15 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module Integrations #:nodoc:
module Euroset
autoload :Notification, File.dirname(__FILE__) + '/euroset/notification.rb'
def self.notification(query_string, options = {})
Notification.new(query_string, options)
end
end
end
end
end
Oops, something went wrong.

0 comments on commit ec801d3

Please sign in to comment.