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,19 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Robokassa
5
+ module Common
6
+ def generate_signature_string
7
+ custom_param_keys = params.keys.select {|key| key =~ /^shp/}.sort
8
+ custom_params = custom_param_keys.map {|key| "#{key}=#{params[key]}"}
9
+ [main_params, secret, custom_params].flatten.compact.join(':')
10
+ end
11
+
12
+ def generate_signature
13
+ Digest::MD5.hexdigest(generate_signature_string)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Robokassa
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ include Common
7
+
8
+ def initialize(order, account, options = {})
9
+ @md5secret = options.delete(:secret)
10
+ super
11
+ end
12
+
13
+ def form_fields
14
+ @fields.merge(ActiveMerchant::Billing::Integrations::Robokassa.signature_parameter_name => generate_signature)
15
+ end
16
+
17
+ def main_params
18
+ [:account, :amount, :order].map {|key| @fields[mappings[key]]}
19
+ end
20
+
21
+ def params
22
+ @fields
23
+ end
24
+
25
+ def secret
26
+ @md5secret
27
+ end
28
+
29
+ def method_missing(method_id, *args)
30
+ method_id = method_id.to_s.gsub(/=$/, '')
31
+
32
+ # support for robokassa custom parameters
33
+ if method_id =~ /^shp/
34
+ add_field method_id, args.last
35
+ end
36
+
37
+ super
38
+ end
39
+
40
+ mapping :account, 'MrchLogin'
41
+ mapping :amount, 'OutSum'
42
+ mapping :currency, 'IncCurrLabel'
43
+ mapping :order, 'InvId'
44
+ mapping :description, 'Desc'
45
+ mapping :email, 'Email'
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,55 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Robokassa
5
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
6
+ include Common
7
+
8
+ def self.recognizes?(params)
9
+ params.has_key?('InvId') && params.has_key?('OutSum')
10
+ end
11
+
12
+ def complete?
13
+ true
14
+ end
15
+
16
+ def amount
17
+ BigDecimal.new(gross)
18
+ end
19
+
20
+ def item_id
21
+ params['InvId']
22
+ end
23
+
24
+ def security_key
25
+ params[ActiveMerchant::Billing::Integrations::Robokassa.signature_parameter_name].to_s.downcase
26
+ end
27
+
28
+ def gross
29
+ params['OutSum']
30
+ end
31
+
32
+ def status
33
+ 'success'
34
+ end
35
+
36
+ def secret
37
+ @options[:secret]
38
+ end
39
+
40
+ def main_params
41
+ [gross, item_id]
42
+ end
43
+
44
+ def acknowledge
45
+ security_key == generate_signature
46
+ end
47
+
48
+ def success_response(*args)
49
+ "OK#{item_id}"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,17 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Robokassa
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ def item_id
7
+ @params['InvId']
8
+ end
9
+
10
+ def amount
11
+ @params['OutSum']
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,9 +6,31 @@ module ActiveMerchant #:nodoc:
6
6
  autoload 'Return', File.dirname(__FILE__) + '/two_checkout/return'
7
7
  autoload 'Notification', File.dirname(__FILE__) + '/two_checkout/notification'
8
8
 
9
- mattr_accessor :service_url
10
- self.service_url = 'https://www.2checkout.com/checkout/purchase'
11
-
9
+ mattr_accessor :payment_routine
10
+ self.payment_routine = :single_page
11
+
12
+ def self.service_url
13
+ case self.payment_routine
14
+ when :multi_page
15
+ 'https://www.2checkout.com/checkout/purchase'
16
+ when :single_page
17
+ 'https://www.2checkout.com/checkout/spurchase'
18
+ else
19
+ raise StandardError, "Integration payment routine set to an invalid value: #{self.payment_routine}"
20
+ end
21
+ end
22
+
23
+ def self.service_url=(service_url)
24
+ # Note: do not use this method, it is here for backward compatibility
25
+ # Use the payment_routine method to change service_url
26
+ if service_url =~ /spurchase/
27
+ self.payment_routine = :single_page
28
+ else
29
+ self.payment_routine = :multi_page
30
+ end
31
+ end
32
+
33
+
12
34
  def self.notification(post, options = {})
13
35
  Notification.new(post)
14
36
  end
@@ -6,52 +6,84 @@ module ActiveMerchant #:nodoc:
6
6
  def initialize(order, account, options = {})
7
7
  super
8
8
  add_field('fixed', 'Y')
9
-
9
+
10
10
  if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
11
11
  add_field('demo', 'Y')
12
- end
12
+ end
13
13
  end
14
-
14
+
15
15
  # The 2checkout vendor account number
16
16
  mapping :account, 'sid'
17
-
18
- # he total amount to be billed, in decimal form, without a currency symbol. (8 characters, decimal, 2 characters: Example: 99999999.99)
17
+
18
+ # The total amount to be billed, in decimal form, without a currency symbol. (8 characters, decimal, 2 characters: Example: 99999999.99)
19
19
  mapping :amount, 'total'
20
-
21
- # a unique order id from your program. (128 characters max)
20
+
21
+ # Pass your order id if you are using Third Part Cart Parameters. (128 characters max)
22
22
  mapping :order, 'cart_order_id'
23
23
 
24
+ # Pass your order id if you are using the Pass Through Products Parameters. (50 characters max)
25
+ mapping :invoice, 'merchant_order_id'
26
+
27
+ # Left here for backward compatibility, do not use. The line_item method will add automatically.
28
+ mapping :mode, 'mode'
24
29
 
25
30
  mapping :customer, :email => 'email',
26
- :phone => 'phone'
31
+ :phone => 'phone'
27
32
 
28
33
  mapping :billing_address, :city => 'city',
29
- :address1 => 'street_address',
30
- :address2 => 'street_address2',
31
- :state => 'state',
32
- :zip => 'zip',
33
- :country => 'country'
34
-
34
+ :address1 => 'street_address',
35
+ :address2 => 'street_address2',
36
+ :state => 'state',
37
+ :zip => 'zip',
38
+ :country => 'country'
39
+
35
40
  mapping :shipping_address, :city => 'ship_city',
36
- :address1 => 'ship_street_address',
37
- :state => 'ship_state',
38
- :zip => 'ship_zip',
39
- :country => 'ship_country'
40
-
41
- mapping :invoice, 'merchant_order_id'
42
-
41
+ :address1 => 'ship_street_address',
42
+ :state => 'ship_state',
43
+ :zip => 'ship_zip',
44
+ :country => 'ship_country'
45
+
43
46
  # Does nothing, since we've disabled the Continue Shopping button by using the fixed = Y field
44
47
  mapping :return_url, 'return_url'
45
-
46
- #mapping :description, ''
47
- #mapping :tax, ''
48
- #mapping :shipping, ''
49
-
48
+
49
+ # Approved URL path
50
+ mapping :notification_url, 'x_receipt_link_url'
51
+
50
52
  def customer(params = {})
51
53
  add_field(mappings[:customer][:email], params[:email])
52
54
  add_field(mappings[:customer][:phone], params[:phone])
53
55
  add_field('card_holder_name', "#{params[:first_name]} #{params[:last_name]}")
54
56
  end
57
+
58
+ # Uses Pass Through Product Parameters to pass in lineitems.
59
+ # (must mark tanigble sales as shipped to settle the transaction)
60
+ def line_item(params = {})
61
+ add_field('mode', '2CO')
62
+ (max_existing_line_item_id = form_fields.keys.map do |key|
63
+ i = key.to_s[/^li_(\d+)_/, 1]
64
+ (i && i.to_i)
65
+ end.compact.max || 0)
66
+
67
+ line_item_id = max_existing_line_item_id + 1
68
+ params.each do |key, value|
69
+ add_field("li_#{line_item_id}_#{key}", value)
70
+ end
71
+ end
72
+
73
+ # Uses Third Party Cart parameter set to pass in lineitem details.
74
+ # (sales settle automatically)
75
+ def auto_settle(params = {})
76
+ add_field('id_type', '1')
77
+ (max_existing_line_item_id = form_fields.keys.map do |key|
78
+ i = key.to_s[/^c_prod_(\d+)/, 1]
79
+ (i && i.to_i)
80
+ end.compact.max || 0)
81
+
82
+ line_item_id = max_existing_line_item_id + 1
83
+ params.each do |key, value|
84
+ add_field("c_#{key}_#{line_item_id}", value)
85
+ end
86
+ end
55
87
  end
56
88
  end
57
89
  end
@@ -7,44 +7,65 @@ module ActiveMerchant #:nodoc:
7
7
  module Integrations #:nodoc:
8
8
  module TwoCheckout
9
9
  class Notification < ActiveMerchant::Billing::Integrations::Notification
10
- # order_number 2Checkout.com order number
11
- # card_holder_name Card holder's name
12
- # street_address Card holder's address
13
- # city Card holder's city
14
- # state Card holder's state
15
- # zip Card holder's zip
16
- # country Card holder's country
17
- # email Card holder's email
18
- # phone Card holder's phone
19
- # credit_card_processed Y if successful, K if waiting for approval
20
- # total Total purchase amount
21
- # ship_name Shipping information
22
- # ship_street_address Shipping information
23
- # ship_city Shipping information
24
- # ship_state Shipping information
25
- # ship_zip Shipping information
26
- # ship_country Shipping information
27
- # product_id 2Checkout product ID for purchased items will append a number if more than one item.
28
- # ex. product_id,product_id1,product_id2
29
- # quantity quantity of corresponding product will append a number if more than one item.
30
- # ex. quantity,quantity1,quantity2
31
- # merchant_product_id your product ID for purchased items will append a number if more than one item.
32
- # ex. merchant_product_id,merchant_product_id1,merchant_product_id2
33
- # product_description your description for purchased items will append a number if more than one item.
34
- # ex. product_description,product_description1,product_description2
35
-
10
+ # card_holder_name - Provides the customer’s name.
11
+ # city - Provides the customer’s city.
12
+ # country - Provides the customer’s country.
13
+ # credit_card_processed - This parameter will always be passed back as Y.
14
+ # demo - Defines if an order was live, or if the order was a demo order. If the order was a demo, the MD5 hash will fail.
15
+ # email - Provides the email address the customer provided when placing the order.
16
+ # fixed - This parameter will only be passed back if it was passed into the purchase routine.
17
+ # ip_country - Provides the customer’s IP location.
18
+ # key - An MD5 hash used to confirm the validity of a sale.
19
+ # lang - Customer language
20
+ # merchant_order_id - The order ID you had assigned to the order.
21
+ # order_number - The 2Checkout order number associated with the order.
22
+ # invoice_id - The 2Checkout invoice number.
23
+ # pay_method - Provides seller with the customer’s payment method. CC for Credit Card, PPI for PayPal.
24
+ # phone - Provides the phone number the customer provided when placing the order.
25
+ # ship_name - Provides the ship to name for the order.
26
+ # ship_street_address - Provides ship to address.
27
+ # ship_street_address2 - Provides more detailed shipping address if this information was provided by the customer.
28
+ # ship_city - Provides ship to city.
29
+ # ship_state - Provides ship to state.
30
+ # ship_zip - Ship Zip
31
+
32
+ # Pass Through Products Only
33
+ # li_#_name - Name of the corresponding lineitem.
34
+ # li_#_quantity - Quantity of the corresponding lineitem.
35
+ # li_#_price - Price of the corresponding lineitem.
36
+ # li_#_tangible - Specifies if the corresponding li_#_type is a tangible or intangible. ‘Y’ OR ‘N’
37
+ # li_#_product_id - ID of the corresponding lineitem.
38
+ # li_#_product_description - Description of the corresponding lineitem.
39
+ # li_#_recurrence - # WEEK | MONTH | YEAR – always singular.
40
+ # li_#_duration - Forever or # WEEK | MONTH | YEAR – always singular, defaults to Forever.
41
+ # li_#_startup_fee - Amount in account pricing currency.
42
+ # li_#_option_#_name - Name of option. 64 characters max – cannot include '<' or '>'.
43
+ # li_#_option_#_value - Name of option. 64 characters max – cannot include '<' or '>'.
44
+ # li_#_option_#_surcharge - Amount in account pricing currency.
45
+
46
+ #Third Party Cart Only
47
+ # cart_order_id - The order ID you had assigned to the order.
48
+
49
+ # Allow seller to define default currency (should match 2Checkout account pricing currency)
36
50
  def currency
37
- 'USD'
51
+ 'USD'
38
52
  end
39
-
53
+
40
54
  def complete?
41
55
  status == 'Completed'
42
- end
56
+ end
43
57
 
58
+ # Third Party Cart parameters will return 'card_order_id'
59
+ # Pass Through Product parameters will only return 'merchant_order_id'
44
60
  def item_id
45
- params['cart_order_id']
61
+ if (params['cart_order_id'].nil?)
62
+ params['merchant_order_id']
63
+ else
64
+ params['cart_order_id']
65
+ end
46
66
  end
47
67
 
68
+ # 2Checkout Sale ID
48
69
  def transaction_id
49
70
  params['order_number']
50
71
  end
@@ -53,60 +74,64 @@ module ActiveMerchant #:nodoc:
53
74
  params['']
54
75
  end
55
76
 
77
+ #Customer Email
56
78
  def payer_email
57
79
  params['email']
58
80
  end
59
-
81
+
60
82
  def receiver_email
61
83
  params['']
62
- end
84
+ end
63
85
 
64
86
  # The MD5 Hash
65
87
  def security_key
66
88
  params['key']
67
89
  end
68
90
 
69
- # the money amount we received in X.2 decimal.
91
+ # The money amount we received in X.2 decimal.
70
92
  def gross
71
93
  params['total']
72
94
  end
73
95
 
74
96
  # Was this a test transaction? # Use the hash
97
+ # Please note 2Checkout forces the order number computed in the hash to '1' on demo sales.
75
98
  def test?
76
99
  params['demo'] == 'Y'
77
100
  end
78
101
 
102
+ # 2Checkout only returns 'Y' for this parameter. If the sale is not authorized, no passback occurs.
79
103
  def status
80
104
  case params['credit_card_processed']
81
- when 'Y'
82
- 'Completed'
83
- when 'K'
84
- 'Pending'
85
- else
86
- 'Failed'
105
+ when 'Y'
106
+ 'Completed'
107
+ else
108
+ 'Failed'
87
109
  end
88
110
  end
89
-
111
+
112
+ # Secret Word defined in 2Checkout account
90
113
  def secret
91
114
  @options[:credential2]
92
115
  end
93
-
116
+
117
+ # Checks against MD5 Hash
94
118
  def acknowledge
95
119
  return false if security_key.blank?
96
-
120
+
97
121
  Digest::MD5.hexdigest("#{secret}#{params['sid']}#{transaction_id}#{gross}").upcase == security_key.upcase
98
122
  end
99
-
123
+
100
124
  private
101
-
125
+
126
+ # Parses Header Redirect Query String
102
127
  def parse(post)
103
128
  @raw = post.to_s
104
- for line in @raw.split('&')
129
+ for line in @raw.split('&')
105
130
  key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
106
131
  params[key] = CGI.unescape(value || '')
107
132
  end
108
133
  end
109
-
134
+
110
135
  end
111
136
  end
112
137
  end