activemerchant 1.28.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data.tar.gz.sig +3 -3
  2. data/CHANGELOG +36 -0
  3. data/CONTRIBUTORS +8 -0
  4. data/README.md +5 -0
  5. data/lib/active_merchant/billing/gateway.rb +2 -1
  6. data/lib/active_merchant/billing/gateways.rb +6 -7
  7. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  9. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  10. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  11. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  15. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  16. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  20. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  21. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  22. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  23. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  24. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  25. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  26. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  27. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  28. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  29. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  30. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  31. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  32. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  33. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  34. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  36. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  37. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  38. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  39. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  40. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  41. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  42. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  43. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  44. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  45. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  46. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  47. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  48. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  49. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  50. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  51. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  54. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  55. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  56. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  57. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  58. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  59. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  62. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  63. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  64. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  65. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  66. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  67. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  68. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  69. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  70. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  71. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  72. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  75. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  76. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  77. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  78. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  79. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  80. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  81. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  82. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  83. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  84. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  85. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  86. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  87. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  88. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  89. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  90. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  91. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  92. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  93. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  94. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  95. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  99. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  102. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -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.rb +70 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -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 +19 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. metadata +45 -27
  116. metadata.gz.sig +0 -0
@@ -0,0 +1,83 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Liqpay
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ def self.recognizes?(params)
7
+ params.has_key?('amount') && params.has_key?('order_id')
8
+ end
9
+
10
+ def initialize(post)
11
+ super
12
+ xml = Base64.decode64(@params["operation_xml"])
13
+ @params.merge!(Hash.from_xml(xml)["response"])
14
+ end
15
+
16
+ def complete?
17
+ status == 'success'
18
+ end
19
+
20
+ def account
21
+ params['merchant_id']
22
+ end
23
+
24
+ def amount
25
+ BigDecimal.new(gross)
26
+ end
27
+
28
+ def item_id
29
+ params['order_id']
30
+ end
31
+
32
+ def transaction_id
33
+ params['transaction_id']
34
+ end
35
+
36
+ def action_name
37
+ params['action_name'] # either 'result_url' or 'server_url'
38
+ end
39
+
40
+ def version
41
+ params['version']
42
+ end
43
+
44
+ def sender_phone
45
+ params['sender_phone']
46
+ end
47
+
48
+ def security_key
49
+ params[ActiveMerchant::Billing::Integrations::Liqpay.signature_parameter_name]
50
+ end
51
+
52
+ def gross
53
+ params['amount']
54
+ end
55
+
56
+ def currency
57
+ params['currency']
58
+ end
59
+
60
+ def status
61
+ params['status'] # 'success', 'failure' or 'wait_secure'
62
+ end
63
+
64
+ def code
65
+ params['code']
66
+ end
67
+
68
+ def generate_signature_string
69
+ ['', version, @options[:secret], action_name, sender_phone, account, gross, currency, item_id, transaction_id, status, code, ''].flatten.compact.join('|')
70
+ end
71
+
72
+ def generate_signature
73
+ Base64.encode64(Digest::SHA1.digest(generate_signature_string)).gsub(/\n/, '')
74
+ end
75
+
76
+ def acknowledge
77
+ security_key == generate_signature
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -26,6 +26,17 @@ module ActiveMerchant #:nodoc:
26
26
  mapping :return_url, 'return_url'
27
27
  mapping :cancel_return_url, 'cancel_url'
28
28
  mapping :description, 'detail1_text'
29
+
30
+ MAPPED_COUNTRY_CODES = {
31
+ 'SE' => 'SV',
32
+ 'DK' => 'DA'
33
+ }
34
+
35
+ SUPPORTED_COUNTRY_CODES = [
36
+ 'FI', 'DE', 'ES', 'FR',
37
+ 'IT','PL', 'GR', 'RO',
38
+ 'RU', 'TR', 'CN', 'CZ', 'NL'
39
+ ]
29
40
 
30
41
  def initialize(order, account, options = {})
31
42
  super
@@ -34,7 +45,6 @@ module ActiveMerchant #:nodoc:
34
45
  add_seller_details(options)
35
46
  end
36
47
 
37
-
38
48
  private
39
49
 
40
50
  def add_tracking_token
@@ -51,6 +61,12 @@ module ActiveMerchant #:nodoc:
51
61
  def add_seller_details(options)
52
62
  add_field('recipient_description', options[:account_name]) if options[:account_name]
53
63
  add_field('country', lookup_country_code(options[:country], :alpha3)) if options[:country]
64
+ add_field('language', locale_code(options[:country])) if options[:country]
65
+ end
66
+
67
+ def locale_code(country_code)
68
+ return country_code if SUPPORTED_COUNTRY_CODES.include?(country_code)
69
+ MAPPED_COUNTRY_CODES[country_code] || 'EN'
54
70
  end
55
71
  end
56
72
  end
@@ -45,6 +45,10 @@ module ActiveMerchant #:nodoc:
45
45
  return true if ActiveMerchant::Billing::Base.integration_mode == :test || production_ips.blank?
46
46
  production_ips.include?(ip)
47
47
  end
48
+
49
+ def test?
50
+ false
51
+ end
48
52
 
49
53
  private
50
54
 
@@ -0,0 +1,70 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+
5
+ # Documentation:
6
+ # https://www.payfast.co.za/s/std/integration-guide
7
+ module PayFast
8
+ autoload :Return, File.dirname(__FILE__) + '/pay_fast/return.rb'
9
+ autoload :Helper, File.dirname(__FILE__) + '/pay_fast/helper.rb'
10
+ autoload :Notification, File.dirname(__FILE__) + '/pay_fast/notification.rb'
11
+ autoload :Common, File.dirname(__FILE__) + '/pay_fast/common.rb'
12
+
13
+ # Overwrite this if you want to change the PayFast sandbox url
14
+ mattr_accessor :process_test_url
15
+ self.process_test_url = 'https://sandbox.payfast.co.za/eng/process'
16
+
17
+ # Overwrite this if you want to change the PayFast production url
18
+ mattr_accessor :process_production_url
19
+ self.process_production_url = 'https://www.payfast.co.za/eng/process'
20
+
21
+ # Overwrite this if you want to change the PayFast sandbox url
22
+ mattr_accessor :validate_test_url
23
+ self.validate_test_url = 'https://sandbox.payfast.co.za/eng/query/validate'
24
+
25
+ # Overwrite this if you want to change the PayFast production url
26
+ mattr_accessor :validate_production_url
27
+ self.validate_production_url = 'https://www.payfast.co.za/eng/query/validate'
28
+
29
+ mattr_accessor :signature_parameter_name
30
+ self.signature_parameter_name = 'signature'
31
+
32
+ def self.service_url
33
+ mode = ActiveMerchant::Billing::Base.integration_mode
34
+ case mode
35
+ when :production
36
+ self.process_production_url
37
+ when :test
38
+ self.process_test_url
39
+ else
40
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
41
+ end
42
+ end
43
+
44
+ def self.validate_service_url
45
+ mode = ActiveMerchant::Billing::Base.integration_mode
46
+ case mode
47
+ when :production
48
+ self.validate_production_url
49
+ when :test
50
+ self.validate_test_url
51
+ else
52
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
53
+ end
54
+ end
55
+
56
+ def self.helper(order, account, options = {})
57
+ Helper.new(order, account, options)
58
+ end
59
+
60
+ def self.notification(query_string, options = {})
61
+ Notification.new(query_string, options)
62
+ end
63
+
64
+ def self.return(post, options = {})
65
+ Return.new(post, options)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,42 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module PayFast
5
+ module Common
6
+ def generate_signature(type)
7
+ string = case type
8
+ when :request
9
+ request_signature_string
10
+ when :notify
11
+ notify_signature_string
12
+ end
13
+
14
+ Digest::MD5.hexdigest(string)
15
+ end
16
+
17
+ def request_attributes
18
+ [:merchant_id, :merchant_key, :return_url, :cancel_url,
19
+ :notify_url, :name_first, :name_last, :email_address,
20
+ :payment_id, :amount, :item_name, :item_description,
21
+ :custom_str1, :custom_str2, :custom_str3, :custom_str4,
22
+ :custom_str5, :custom_int1, :custom_int2, :custom_int3,
23
+ :custom_int4, :custom_int5, :email_confirmation,
24
+ :confirmation_address]
25
+ end
26
+
27
+ def request_signature_string
28
+ request_attributes.map do |attr|
29
+ "#{mappings[attr]}=#{CGI.escape(@fields[mappings[attr]])}" if @fields[mappings[attr]].present?
30
+ end.compact.join('&')
31
+ end
32
+
33
+ def notify_signature_string
34
+ params.map do |key, value|
35
+ "#{key}=#{CGI.escape(value)}" unless key == PayFast.signature_parameter_name
36
+ end.compact.join('&')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,50 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module PayFast
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ include Common
7
+
8
+ def initialize(order, account, options = {})
9
+ super
10
+ add_field('merchant_id', account)
11
+ add_field('merchant_key', options.delete(:credential2))
12
+ add_field('m_payment_id', order)
13
+ end
14
+
15
+ def form_fields
16
+ @fields
17
+ end
18
+
19
+ def params
20
+ @fields
21
+ end
22
+
23
+ mapping :merchant_id, 'merchant_id'
24
+ mapping :merchant_key, 'merchant_key'
25
+ mapping :return_url, 'return_url'
26
+ mapping :cancel_return_url, 'cancel_url'
27
+ mapping :notify_url, 'notify_url'
28
+ mapping :name_first, 'name_first'
29
+ mapping :name_last, 'name_last'
30
+ mapping :email_address, 'email_address'
31
+ mapping :payment_id, 'm_payment_id'
32
+ mapping :amount, 'amount'
33
+ mapping :item_name, 'item_name'
34
+ mapping :description, 'item_name'
35
+
36
+ mapping :customer, :first_name => 'name_first',
37
+ :last_name => 'name_last',
38
+ :email => 'email_address',
39
+ :phone => 'phone'
40
+
41
+ 5.times { |i| mapping :"custom_str#{i}", "custom_str#{i}" }
42
+ 5.times { |i| mapping :"custom_int#{i}", "custom_int#{i}" }
43
+
44
+ mapping :email_confirmation, 'email_confirmation'
45
+ mapping :confirmation_address, 'confirmation_address'
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,134 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module PayFast
7
+ # Parser and handler for incoming ITN from PayFast.
8
+ # The Example shows a typical handler in a rails application.
9
+ #
10
+ # Example
11
+ #
12
+ # class BackendController < ApplicationController
13
+ # include ActiveMerchant::Billing::Integrations
14
+ #
15
+ # def pay_fast_itn
16
+ # notify = PayFast::Notification.new(request.raw_post)
17
+ #
18
+ # order = Order.find(notify.item_id)
19
+ #
20
+ # if notify.acknowledge
21
+ # begin
22
+ #
23
+ # if notify.complete? and order.total == notify.amount
24
+ # order.status = 'success'
25
+ #
26
+ # shop.ship(order)
27
+ # else
28
+ # logger.error("Failed to verify Paypal's notification, please investigate")
29
+ # end
30
+ #
31
+ # rescue => e
32
+ # order.status = 'failed'
33
+ # raise
34
+ # ensure
35
+ # order.save
36
+ # end
37
+ # end
38
+ #
39
+ # render :nothing
40
+ # end
41
+ # end
42
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
43
+ include PostsData
44
+ include Common
45
+
46
+ # Was the transaction complete?
47
+ def complete?
48
+ status == "Completed"
49
+ end
50
+
51
+ # Status of transaction. List of possible values:
52
+ # <tt>COMPLETE</tt>::
53
+ def status
54
+ if params['payment_status'] == "COMPLETE"
55
+ "Completed"
56
+ else
57
+ "Failed"
58
+ end
59
+ end
60
+
61
+ # Id of this transaction (uniq PayFast transaction id)
62
+ def transaction_id
63
+ params['pf_payment_id']
64
+ end
65
+
66
+ # Id of this transaction (uniq Shopify transaction id)
67
+ def item_id
68
+ params['m_payment_id']
69
+ end
70
+
71
+ # The total amount which the payer paid.
72
+ def gross
73
+ params['amount_gross']
74
+ end
75
+
76
+ # The total in fees which was deducated from the amount.
77
+ def fee
78
+ params['amount_fee']
79
+ end
80
+
81
+ # The net amount credited to the receiver's account.
82
+ def amount
83
+ params['amount_net']
84
+ end
85
+
86
+ # The name of the item being charged for.
87
+ def item_name
88
+ params['item_name']
89
+ end
90
+
91
+ # The Merchant ID as given by the PayFast system. Used to uniquely identify the receiver's account.
92
+ def merchant_id
93
+ params['merchant_id']
94
+ end
95
+
96
+ def currency
97
+ nil
98
+ end
99
+ # Generated hash depends on params order so use OrderedHash instead of Hash
100
+ def empty!
101
+ super
102
+ @params = ActiveSupport::OrderedHash.new
103
+ end
104
+
105
+ # Acknowledge the transaction to PayFast. This method has to be called after a new
106
+ # ITN arrives. PayFast will verify that all the information we received are correct and will return a
107
+ # VERIFIED or INVALID status.
108
+ #
109
+ # Example:
110
+ #
111
+ # def pay_fast_itn
112
+ # notify = PayFastNotification.new(request.raw_post)
113
+ #
114
+ # if notify.acknowledge
115
+ # ... process order ... if notify.complete?
116
+ # else
117
+ # ... log possible hacking attempt ...
118
+ # end
119
+ def acknowledge
120
+ if params[PayFast.signature_parameter_name] == generate_signature(:notify)
121
+ response = ssl_post(PayFast.validate_service_url, notify_signature_string,
122
+ 'Content-Type' => "application/x-www-form-urlencoded",
123
+ 'Content-Length' => "#{notify_signature_string.size}"
124
+ )
125
+ raise StandardError.new("Faulty PayFast result: #{response}") unless ['VALID', 'INVALID'].include?(response)
126
+
127
+ response == "VALID"
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module PayFast
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end