tlconnor-activemerchant 1.20.4 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG +86 -6
  2. data/CONTRIBUTORS +33 -0
  3. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -0
  4. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +4 -4
  5. data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -11
  6. data/lib/active_merchant/billing/gateways/braintree_blue.rb +46 -19
  7. data/lib/active_merchant/billing/gateways/certo_direct.rb +1 -1
  8. data/lib/active_merchant/billing/gateways/elavon.rb +2 -0
  9. data/lib/active_merchant/billing/gateways/epay.rb +3 -1
  10. data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
  11. data/lib/active_merchant/billing/gateways/litle.rb +275 -0
  12. data/lib/active_merchant/billing/gateways/migs.rb +259 -0
  13. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  14. data/lib/active_merchant/billing/gateways/moneris.rb +4 -30
  15. data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
  16. data/lib/active_merchant/billing/gateways/nab_transact.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/ogone.rb +104 -12
  18. data/lib/active_merchant/billing/gateways/orbital.rb +15 -6
  19. data/lib/active_merchant/billing/gateways/paybox_direct.rb +1 -4
  20. data/lib/active_merchant/billing/gateways/payflow.rb +8 -3
  21. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -1
  22. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -2
  23. data/lib/active_merchant/billing/gateways/payment_express.rb +60 -13
  24. data/lib/active_merchant/billing/gateways/paypal.rb +3 -18
  25. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +333 -3
  26. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
  27. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
  28. data/lib/active_merchant/billing/gateways/paypal_express.rb +14 -65
  29. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +8 -3
  30. data/lib/active_merchant/billing/gateways/realex.rb +5 -7
  31. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -2
  32. data/lib/active_merchant/billing/gateways/stripe.rb +1 -9
  33. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +1 -5
  35. data/lib/active_merchant/billing/gateways/viaklix.rb +7 -2
  36. data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
  37. data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
  38. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
  39. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
  40. data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
  41. data/lib/active_merchant/billing/integrations/epay.rb +21 -0
  42. data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
  43. data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
  44. data/lib/active_merchant/billing/integrations/paypal/notification.rb +2 -1
  45. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +2 -3
  46. data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
  47. data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
  48. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
  49. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
  50. data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
  51. data/lib/active_merchant/billing/integrations/two_checkout.rb +25 -3
  52. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +58 -26
  53. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +71 -46
  54. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
  55. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
  56. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
  57. data/lib/active_merchant/version.rb +1 -1
  58. metadata +28 -5
@@ -0,0 +1,22 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Dotpay
5
+ autoload :Return, File.dirname(__FILE__) + '/dotpay/return.rb'
6
+ autoload :Helper, File.dirname(__FILE__) + '/dotpay/helper.rb'
7
+ autoload :Notification, File.dirname(__FILE__) + '/dotpay/notification.rb'
8
+
9
+ mattr_accessor :service_url
10
+ self.service_url = 'https://ssl.dotpay.pl'
11
+
12
+ def self.notification(post, options = {})
13
+ Notification.new(post, options)
14
+ end
15
+
16
+ def self.return(post, options = {})
17
+ Return.new(post, options)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,77 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Dotpay
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ def initialize(order, account, options = {})
7
+ options = {:currency => 'PLN'}.merge options
8
+
9
+ super
10
+
11
+ add_field('channel', '0')
12
+ add_field('ch_lock', '0')
13
+ add_field('lang', 'PL')
14
+ add_field('onlinetransfer', '0')
15
+ add_field('tax', '0')
16
+ add_field('type', '2')
17
+ end
18
+
19
+ mapping :account, 'id'
20
+ mapping :amount, 'amount'
21
+
22
+ mapping :billing_address, :street => 'street',
23
+ :street_n1 => 'street_n1',
24
+ :street_n2 => 'street_n2',
25
+ :addr2 => 'addr2',
26
+ :addr3 => 'addr3',
27
+ :city => 'city',
28
+ :postcode => 'postcode',
29
+ :phone => 'phone',
30
+ :country => 'country'
31
+
32
+ mapping :buttontext, 'buttontext'
33
+ mapping :channel, 'channel'
34
+ mapping :ch_lock, 'ch_lock'
35
+ mapping :code, 'code'
36
+ mapping :control, 'control'
37
+ mapping :currency, 'currency'
38
+
39
+ mapping :customer, :firstname => 'firstname',
40
+ :lastname => 'lastname',
41
+ :email => 'email'
42
+
43
+ mapping :description, 'description'
44
+ mapping :lang, 'lang'
45
+ mapping :onlinetransfer, 'onlinetransfer'
46
+ mapping :order, 'description'
47
+ mapping :p_email, 'p_email'
48
+ mapping :p_info, 'p_info'
49
+ mapping :tax, 'tax'
50
+ mapping :type, 'type'
51
+ mapping :url, 'url'
52
+ mapping :urlc, 'urlc'
53
+
54
+ def billing_address(params = {})
55
+ country = lookup_country_code(params.delete(:country) { 'POL' }, :alpha3)
56
+ add_field(mappings[:billing_address][:country], country)
57
+
58
+ # Everything else
59
+ params.each do |k, v|
60
+ field = mappings[:billing_address][k]
61
+ add_field(field, v) unless field.nil?
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ def lookup_country_code(name_or_code, format = country_format)
68
+ country = Country.find(name_or_code)
69
+ country.code(format).to_s
70
+ rescue InvalidCountryCodeError
71
+ name_or_code
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,86 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Dotpay
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ def complete?
9
+ status == 'OK' && %w(2 4 5).include?(t_status)
10
+ end
11
+
12
+ def currency
13
+ orginal_amount.split(' ')[1]
14
+ end
15
+
16
+ # the money amount we received in X.2 decimal.
17
+ def gross
18
+ params['amount']
19
+ end
20
+
21
+ def pin=(value)
22
+ @options[:pin] = value
23
+ end
24
+
25
+ def status
26
+ params['status']
27
+ end
28
+
29
+ def test?
30
+ params['t_id'].match('.*-TST\d+') ? true : false
31
+ end
32
+
33
+ PAYMENT_HOOK_FIELDS = [
34
+ :id,
35
+ :control,
36
+ :t_id,
37
+ :orginal_amount,
38
+ :email,
39
+ :service,
40
+ :code,
41
+ :username,
42
+ :password,
43
+ :t_status,
44
+ :description,
45
+ :md5,
46
+ :p_info,
47
+ :p_email,
48
+ :t_date
49
+ ]
50
+
51
+ PAYMENT_HOOK_SIGNATURE_FIELDS = [
52
+ :id,
53
+ :control,
54
+ :t_id,
55
+ :amount,
56
+ :email,
57
+ :service,
58
+ :code,
59
+ :username,
60
+ :password,
61
+ :t_status
62
+ ]
63
+
64
+ # Provide access to raw fields
65
+ PAYMENT_HOOK_FIELDS.each do |key|
66
+ define_method(key.to_s) do
67
+ params[key.to_s]
68
+ end
69
+ end
70
+
71
+ def generate_signature_string
72
+ "#{@options[:pin]}:" + PAYMENT_HOOK_SIGNATURE_FIELDS.map {|key| params[key.to_s]} * ":"
73
+ end
74
+
75
+ def generate_signature
76
+ Digest::MD5.hexdigest(generate_signature_string)
77
+ end
78
+
79
+ def acknowledge
80
+ generate_signature.to_s == md5.to_s
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Dotpay
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,21 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Epay
5
+ autoload :Helper, File.dirname(__FILE__) + '/epay/helper.rb'
6
+ autoload :Notification, File.dirname(__FILE__) + '/epay/notification.rb'
7
+
8
+ mattr_accessor :service_url
9
+ self.service_url = 'https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx'
10
+
11
+ def self.notification(post, options = {})
12
+ Notification.new(post)
13
+ end
14
+
15
+ def self.return(post, options = {})
16
+ Return.new(post, options)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,55 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Epay
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+
7
+ def initialize(order, merchantnumber, options = {})
8
+ super
9
+ add_field('windowstate', 3)
10
+ add_field('language', '0')
11
+ add_field('orderid', format_order_number(order))
12
+ @fields = Hash[@fields.sort]
13
+ end
14
+
15
+ def md5secret(value)
16
+ @md5secret = value
17
+ end
18
+
19
+ def form_fields
20
+ @fields.merge('hash' => generate_md5hash)
21
+ end
22
+
23
+ def generate_md5string
24
+ @fields.sort.each.map { |key, value| key != 'hash' ? value.to_s : ''} * "" + @md5secret
25
+ end
26
+
27
+ def generate_md5hash
28
+ Digest::MD5.hexdigest(generate_md5string)
29
+ end
30
+
31
+ # Limited to 20 digits max
32
+ def format_order_number(number)
33
+ number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
34
+ end
35
+
36
+ mapping :account, 'merchantnumber'
37
+ mapping :language, 'language'
38
+ mapping :amount, 'amount'
39
+ mapping :currency, 'currency'
40
+ mapping :return_url, 'accepturl'
41
+ mapping :cancel_return_url, 'cancelurl'
42
+ mapping :notify_url, 'callbackurl'
43
+ mapping :autocapture, 'instantcapture'
44
+ mapping :description, 'description'
45
+ mapping :credential3, 'md5secret'
46
+ mapping :customer, ''
47
+ mapping :billing_address, {}
48
+ mapping :tax, ''
49
+ mapping :shipping, ''
50
+
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,110 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Epay
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+
9
+ CURRENCY_CODES = {
10
+ :ADP => '020', :AED => '784', :AFA => '004', :ALL => '008', :AMD => '051',
11
+ :ANG => '532', :AOA => '973', :ARS => '032', :AUD => '036', :AWG => '533',
12
+ :AZM => '031', :BAM => '977', :BBD => '052', :BDT => '050', :BGL => '100',
13
+ :BGN => '975', :BHD => '048', :BIF => '108', :BMD => '060', :BND => '096',
14
+ :BOB => '068', :BOV => '984', :BRL => '986', :BSD => '044', :BTN => '064',
15
+ :BWP => '072', :BYR => '974', :BZD => '084', :CAD => '124', :CDF => '976',
16
+ :CHF => '756', :CLF => '990', :CLP => '152', :CNY => '156', :COP => '170',
17
+ :CRC => '188', :CUP => '192', :CVE => '132', :CYP => '196', :CZK => '203',
18
+ :DJF => '262', :DKK => '208', :DOP => '214', :DZD => '012', :ECS => '218',
19
+ :ECV => '983', :EEK => '233', :EGP => '818', :ERN => '232', :ETB => '230',
20
+ :EUR => '978', :FJD => '242', :FKP => '238', :GBP => '826', :GEL => '981',
21
+ :GHC => '288', :GIP => '292', :GMD => '270', :GNF => '324', :GTQ => '320',
22
+ :GWP => '624', :GYD => '328', :HKD => '344', :HNL => '340', :HRK => '191',
23
+ :HTG => '332', :HUF => '348', :IDR => '360', :ILS => '376', :INR => '356',
24
+ :IQD => '368', :IRR => '364', :ISK => '352', :JMD => '388', :JOD => '400',
25
+ :JPY => '392', :KES => '404', :KGS => '417', :KHR => '116', :KMF => '174',
26
+ :KPW => '408', :KRW => '410', :KWD => '414', :KYD => '136', :KZT => '398',
27
+ :LAK => '418', :LBP => '422', :LKR => '144', :LRD => '430', :LSL => '426',
28
+ :LTL => '440', :LVL => '428', :LYD => '434', :MAD => '504', :MDL => '498',
29
+ :MGF => '450', :MKD => '807', :MMK => '104', :MNT => '496', :MOP => '446',
30
+ :MRO => '478', :MTL => '470', :MUR => '480', :MVR => '462', :MWK => '454',
31
+ :MXN => '484', :MXV => '979', :MYR => '458', :MZM => '508', :NAD => '516',
32
+ :NGN => '566', :NIO => '558', :NOK => '578', :NPR => '524', :NZD => '554',
33
+ :OMR => '512', :PAB => '590', :PEN => '604', :PGK => '598', :PHP => '608',
34
+ :PKR => '586', :PLN => '985', :PYG => '600', :QAR => '634', :ROL => '642',
35
+ :RUB => '643', :RUR => '810', :RWF => '646', :SAR => '682', :SBD => '090',
36
+ :SCR => '690', :SDD => '736', :SEK => '752', :SGD => '702', :SHP => '654',
37
+ :SIT => '705', :SKK => '703', :SLL => '694', :SOS => '706', :SRG => '740',
38
+ :STD => '678', :SVC => '222', :SYP => '760', :SZL => '748', :THB => '764',
39
+ :TJS => '972', :TMM => '795', :TND => '788', :TOP => '776', :TPE => '626',
40
+ :TRL => '792', :TRY => '949', :TTD => '780', :TWD => '901', :TZS => '834',
41
+ :UAH => '980', :UGX => '800', :USD => '840', :UYU => '858', :UZS => '860',
42
+ :VEB => '862', :VND => '704', :VUV => '548', :XAF => '950', :XCD => '951',
43
+ :XOF => '952', :XPF => '953', :YER => '886', :YUM => '891', :ZAR => '710',
44
+ :ZMK => '894', :ZWD => '716'
45
+ }
46
+
47
+ def complete?
48
+ Integer(transaction_id) > 0
49
+ end
50
+
51
+ def item_id
52
+ params['orderid']
53
+ end
54
+
55
+ def transaction_id
56
+ params['txnid']
57
+ end
58
+
59
+ def received_at
60
+ Time.mktime(params['date'][0..3], params['date'][4..5], params['date'][6..7], params['time'][0..1], params['time'][2..3])
61
+ end
62
+
63
+ def gross
64
+ "%.2f" % (gross_cents / 100.0)
65
+ end
66
+
67
+ def gross_cents
68
+ params['amount'].to_i
69
+ end
70
+
71
+ def test?
72
+ return false
73
+ end
74
+
75
+ %w(txnid orderid amount currency date time hash fraud payercountry issuercountry txnfee subscriptionid paymenttype cardno).each do |attr|
76
+ define_method(attr) do
77
+ params[attr]
78
+ end
79
+ end
80
+
81
+ def currency
82
+ CURRENCY_CODES.invert[params['currency']].to_s
83
+ end
84
+
85
+ def amount
86
+ Money.new(params['amount'].to_i, currency)
87
+ end
88
+
89
+ def generate_md5string
90
+ md5string = String.new
91
+ for line in @raw.split('&')
92
+ key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
93
+ md5string += params[key] if key != 'hash'
94
+ end
95
+ return md5string + @options[:credential3]
96
+ end
97
+
98
+ def generate_md5hash
99
+ Digest::MD5.hexdigest(generate_md5string)
100
+ end
101
+
102
+ def acknowledge
103
+ generate_md5hash == params['hash']
104
+ end
105
+
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -54,7 +54,8 @@ module ActiveMerchant #:nodoc:
54
54
  # One possible scenario is that our web application was down. In this case paypal tries several
55
55
  # times an hour to inform us about the notification
56
56
  def received_at
57
- Time.parse params['payment_date']
57
+ parsed_time_fields = DateTime._strptime(params['payment_date'], "%H:%M:%S %b %d, %Y %z")
58
+ Time.mktime(*parsed_time_fields.values_at(:year, :mon, :mday, :hour, :min, :sec, :zone))
58
59
  end
59
60
 
60
61
  # Status of transaction. List of possible values:
@@ -5,12 +5,13 @@ module ActiveMerchant #:nodoc:
5
5
  class Helper < ActiveMerchant::Billing::Integrations::Helper
6
6
 
7
7
  def initialize(order, account, options = {})
8
+ md5secret options.delete(:credential2)
8
9
  super
9
10
  add_field('protocol', '3')
10
11
  add_field('msgtype', 'authorize')
11
12
  add_field('language', 'da')
12
13
  add_field('autocapture', 0)
13
- add_field('testmode', 0)
14
+ add_field('testmode', test? ? 1 : 0)
14
15
  add_field('ordernumber', format_order_number(order))
15
16
  end
16
17
 
@@ -59,8 +60,6 @@ module ActiveMerchant #:nodoc:
59
60
  mapping :ipaddress, 'ipaddress'
60
61
  mapping :testmode, 'testmode'
61
62
 
62
- mapping :credential2, 'md5secret'
63
-
64
63
  mapping :customer, ''
65
64
  mapping :billing_address, {}
66
65
  mapping :tax, ''
@@ -0,0 +1,49 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+
5
+ # Documentation: http://robokassa.ru/Doc/En/Interface.aspx
6
+ module Robokassa
7
+ autoload :Helper, File.dirname(__FILE__) + '/robokassa/helper.rb'
8
+ autoload :Notification, File.dirname(__FILE__) + '/robokassa/notification.rb'
9
+ autoload :Return, File.dirname(__FILE__) + '/robokassa/return.rb'
10
+ autoload :Common, File.dirname(__FILE__) + '/robokassa/common.rb'
11
+
12
+ # Overwrite this if you want to change the Robokassa test url
13
+ mattr_accessor :test_url
14
+ self.test_url = 'http://test.robokassa.ru/Index.aspx'
15
+
16
+ # Overwrite this if you want to change the Robokassa production url
17
+ mattr_accessor :production_url
18
+ self.production_url = 'https://merchant.roboxchange.com/Index.aspx'
19
+
20
+ mattr_accessor :signature_parameter_name
21
+ self.signature_parameter_name = 'SignatureValue'
22
+
23
+ def self.service_url
24
+ mode = ActiveMerchant::Billing::Base.integration_mode
25
+ case mode
26
+ when :production
27
+ self.production_url
28
+ when :test
29
+ self.test_url
30
+ else
31
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
32
+ end
33
+ end
34
+
35
+ def self.helper(order, account, options = {})
36
+ Helper.new(order, account, options)
37
+ end
38
+
39
+ def self.notification(query_string, options = {})
40
+ Notification.new(query_string, options)
41
+ end
42
+
43
+ def self.return(query_string)
44
+ Return.new(query_string)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end