activemerchant 1.26.0 → 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/CHANGELOG +17 -0
  2. data/CONTRIBUTORS +20 -0
  3. data/README.md +5 -0
  4. data/lib/active_merchant/billing/base.rb +2 -2
  5. data/lib/active_merchant/billing/gateway.rb +6 -0
  6. data/lib/active_merchant/billing/gateways/authorize_net.rb +1 -1
  7. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +0 -3
  8. data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
  9. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +3 -3
  10. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
  11. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -2
  12. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  13. data/lib/active_merchant/billing/gateways/braintree.rb +2 -0
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +11 -1
  15. data/lib/active_merchant/billing/gateways/braintree_orange.rb +2 -4
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  17. data/lib/active_merchant/billing/gateways/certo_direct.rb +2 -3
  18. data/lib/active_merchant/billing/gateways/cyber_source.rb +3 -3
  19. data/lib/active_merchant/billing/gateways/data_cash.rb +3 -3
  20. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -3
  21. data/lib/active_merchant/billing/gateways/epay.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/eway.rb +8 -7
  23. data/lib/active_merchant/billing/gateways/eway_managed.rb +3 -3
  24. data/lib/active_merchant/billing/gateways/exact.rb +2 -2
  25. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  26. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -2
  27. data/lib/active_merchant/billing/gateways/first_pay.rb +3 -3
  28. data/lib/active_merchant/billing/gateways/garanti.rb +2 -2
  29. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +3 -1
  30. data/lib/active_merchant/billing/gateways/inspire.rb +2 -2
  31. data/lib/active_merchant/billing/gateways/instapay.rb +2 -2
  32. data/lib/active_merchant/billing/gateways/iridium.rb +4 -5
  33. data/lib/active_merchant/billing/gateways/itransact.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/jetpay.rb +3 -3
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +3 -6
  36. data/lib/active_merchant/billing/gateways/litle.rb +50 -34
  37. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +3 -3
  38. data/lib/active_merchant/billing/gateways/merchant_ware.rb +2 -2
  39. data/lib/active_merchant/billing/gateways/migs.rb +8 -4
  40. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -0
  41. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +4 -4
  42. data/lib/active_merchant/billing/gateways/moneris.rb +3 -3
  43. data/lib/active_merchant/billing/gateways/moneris_us.rb +3 -3
  44. data/lib/active_merchant/billing/gateways/nab_transact.rb +8 -6
  45. data/lib/active_merchant/billing/gateways/net_registry.rb +2 -2
  46. data/lib/active_merchant/billing/gateways/netaxept.rb +4 -4
  47. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  48. data/lib/active_merchant/billing/gateways/ogone.rb +10 -5
  49. data/lib/active_merchant/billing/gateways/optimal_payment.rb +3 -3
  50. data/lib/active_merchant/billing/gateways/orbital.rb +4 -4
  51. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +2 -2
  52. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -2
  53. data/lib/active_merchant/billing/gateways/paybox_direct.rb +7 -5
  54. data/lib/active_merchant/billing/gateways/payflow.rb +39 -37
  55. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -3
  56. data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
  57. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +98 -85
  58. data/lib/active_merchant/billing/gateways/paystation.rb +2 -2
  59. data/lib/active_merchant/billing/gateways/payway.rb +3 -2
  60. data/lib/active_merchant/billing/gateways/plugnpay.rb +63 -66
  61. data/lib/active_merchant/billing/gateways/psigate.rb +3 -3
  62. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  63. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  64. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -2
  65. data/lib/active_merchant/billing/gateways/realex.rb +7 -7
  66. data/lib/active_merchant/billing/gateways/sage.rb +2 -0
  67. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +2 -3
  69. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/sage_pay.rb +8 -6
  71. data/lib/active_merchant/billing/gateways/sallie_mae.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/secure_net.rb +4 -4
  73. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +9 -6
  74. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +2 -2
  75. data/lib/active_merchant/billing/gateways/skip_jack.rb +3 -3
  76. data/lib/active_merchant/billing/gateways/smart_ps.rb +3 -1
  77. data/lib/active_merchant/billing/gateways/stripe.rb +2 -2
  78. data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/transax.rb +1 -3
  80. data/lib/active_merchant/billing/gateways/trust_commerce.rb +3 -3
  81. data/lib/active_merchant/billing/gateways/usa_epay.rb +2 -0
  82. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +3 -2
  83. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -6
  84. data/lib/active_merchant/billing/gateways/verifi.rb +2 -2
  85. data/lib/active_merchant/billing/gateways/wirecard.rb +4 -4
  86. data/lib/active_merchant/billing/gateways/worldpay.rb +37 -18
  87. data/lib/active_merchant/billing/integrations/action_view_helper.rb +6 -5
  88. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  89. data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
  90. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  91. data/lib/active_merchant/billing/integrations/helper.rb +4 -0
  92. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  93. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  94. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  95. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  96. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  97. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  98. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  99. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  100. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
  101. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  102. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  103. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  104. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  105. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  106. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  107. data/lib/active_merchant/version.rb +1 -1
  108. data/lib/support/gateway_support.rb +9 -2
  109. data/lib/support/ssl_verify.rb +93 -0
  110. metadata +45 -71
  111. data.tar.gz.sig +0 -3
  112. metadata.gz.sig +0 -0
@@ -0,0 +1,44 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+
5
+ # Documentation:
6
+ # https://www.paxum.com/payment_docs/page.php?name=apiIntroduction
7
+ module Paxum
8
+ autoload :Helper, File.dirname(__FILE__) + '/paxum/helper.rb'
9
+ autoload :Notification, File.dirname(__FILE__) + '/paxum/notification.rb'
10
+ autoload :Return, File.dirname(__FILE__) + '/paxum/return.rb'
11
+ autoload :Common, File.dirname(__FILE__) + '/paxum/common.rb'
12
+
13
+ mattr_accessor :test_url
14
+ self.test_url = 'https://paxum.com/payment/phrame.php?action=displayProcessPaymentLogin'
15
+
16
+ mattr_accessor :production_url
17
+ self.production_url = 'https://paxum.com/payment/phrame.php?action=displayProcessPaymentLogin'
18
+
19
+ mattr_accessor :signature_parameter_name
20
+ self.signature_parameter_name = 'key'
21
+
22
+ def self.service_url
23
+ mode = ActiveMerchant::Billing::Base.integration_mode
24
+ case mode
25
+ when :production
26
+ self.production_url
27
+ when :test
28
+ self.test_url
29
+ else
30
+ raise StandardError, "Integration mode set to an invalid value: #{mode}"
31
+ end
32
+ end
33
+
34
+ def self.helper(order, account, options = {})
35
+ Helper.new(order, account, options)
36
+ end
37
+
38
+ def self.notification(query_string, options = {})
39
+ Notification.new(query_string, options)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Paxum
5
+ module Common
6
+ def generate_signature_string
7
+ @raw_post.slice!(0) if @raw_post.starts_with?("&")
8
+ @raw_post = CGI.unescape(@raw_post)
9
+ @raw_post = "&#{@raw_post}" unless @raw_post.starts_with?("&")
10
+ arr = @raw_post.split('&')
11
+ arr.delete(arr.last)
12
+ data = arr.join('&')
13
+
14
+ (data + secret)
15
+ end
16
+
17
+ def generate_signature
18
+ Digest::MD5.hexdigest(generate_signature_string)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,42 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Paxum
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+ include Common
7
+
8
+ def initialize(order, account, options = {})
9
+ @paxum_options = options.dup
10
+ options.delete(:description)
11
+ options.delete(:fail_url)
12
+ options.delete(:success_url)
13
+ options.delete(:result_url)
14
+ super
15
+ add_field "button_type_id", "1"
16
+ add_field "variables", "notify_url=#{@paxum_options[:result_url]}"
17
+ @paxum_options.each do |key, value|
18
+ add_field mappings[key], value
19
+ end
20
+ end
21
+
22
+ def form_fields
23
+ @fields
24
+ end
25
+
26
+ def params
27
+ @fields
28
+ end
29
+
30
+ mapping :account, 'business_email'
31
+ mapping :amount, 'amount'
32
+ mapping :currency, 'currency'
33
+ mapping :order, 'item_id'
34
+ mapping :description, 'item_name'
35
+ mapping :fail_url, 'cancel_url'
36
+ mapping :success_url, 'finish_url'
37
+ mapping :result_url, 'notify_url'
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,33 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Paxum
5
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
6
+ include Common
7
+
8
+ def initialize(post, options = {})
9
+ @raw_post = post.dup
10
+ post.slice!(0)
11
+ super
12
+ end
13
+
14
+ def self.recognizes?(params)
15
+ (params.has_key?('transaction_item_id') && params.has_key?('transaction_amount'))
16
+ end
17
+
18
+ def security_key
19
+ params["key"]
20
+ end
21
+
22
+ def secret
23
+ @options[:secret]
24
+ end
25
+
26
+ def acknowledge
27
+ (security_key == generate_signature)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Pxpay
5
+ autoload :Helper, 'active_merchant/billing/integrations/pxpay/helper.rb'
6
+ autoload :Notification, 'active_merchant/billing/integrations/pxpay/notification.rb'
7
+ autoload :Return, 'active_merchant/billing/integrations/pxpay/return.rb'
8
+
9
+ TOKEN_URL = 'https://sec.paymentexpress.com/pxpay/pxaccess.aspx'
10
+
11
+ LIVE_URL = 'https://sec.paymentexpress.com/pxpay/pxpay.aspx'
12
+
13
+ def self.token_url
14
+ TOKEN_URL
15
+ end
16
+
17
+ def self.service_url
18
+ LIVE_URL
19
+ end
20
+
21
+ def self.notification(post, options={})
22
+ Notification.new(post, options)
23
+ end
24
+
25
+ def self.return(query_string, options={})
26
+ Return.new(query_string, options)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,110 @@
1
+ require 'active_support/core_ext/float/rounding.rb' # Float#round(precision)
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module Pxpay
7
+ # An example. Note the username as a parameter and transaction key you
8
+ # will want to use later. The amount that you pass in will be *rounded*,
9
+ # so preferably pass in X.2 decimal so that no rounding occurs. You need
10
+ # to set :credential2 to your PxPay secret key.
11
+ #
12
+ # PxPay accounts have Failproof Notification enabled by default which means
13
+ # in addition to the user being redirected to your return_url, the return_url will
14
+ # be accessed by the PxPay servers directly, immediately after transaction success.
15
+ #
16
+ # payment_service_for('order_id', 'pxpay_user_ID', :service => :pxpay,
17
+ # :amount => 157.0, :currency => 'USD', :credential2 => 'pxpay_key') do |service|
18
+ #
19
+ # service.customer :email => 'customer@email.com'
20
+ #
21
+ # service.description 'Order 123 for MyStore'
22
+ #
23
+ # # Must specify both a return_url or PxPay will show an error instead of
24
+ # # capturing credit card details.
25
+ #
26
+ # service.return_url "http://t/pxpay/payment_received_notification_sub_step"
27
+ #
28
+ # # These fields will be copied verbatim to the Notification
29
+ # service.custom1 'custom text 1'
30
+ # service.custom2 ''
31
+ # service.custom3 ''
32
+ # # See the helper.rb file for various custom fields
33
+ # end
34
+
35
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
36
+ include PostsData
37
+ mapping :account, 'PxPayUserId'
38
+ mapping :credential2, 'PxPayKey'
39
+ mapping :currency, 'CurrencyInput'
40
+ mapping :description, 'MerchantReference'
41
+ mapping :order, 'TxnId'
42
+ mapping :customer, :email => 'EmailAddress'
43
+
44
+ mapping :custom1, 'TxnData1'
45
+ mapping :custom2, 'TxnData2'
46
+ mapping :custom3, 'TxnData3'
47
+
48
+ def initialize(order, account, options = {})
49
+ super
50
+ add_field 'AmountInput', "%.2f" % options[:amount].to_f.round(2)
51
+ add_field 'EnableAddBillCard', '0'
52
+ add_field 'TxnType', 'Purchase'
53
+ end
54
+
55
+ def return_url(url)
56
+ add_field 'UrlSuccess', url
57
+ add_field 'UrlFail', url
58
+ end
59
+
60
+ def form_fields
61
+ # if either return URLs are blank PxPay will generate a token but redirect user to error page.
62
+ raise "error - must specify return_url" if @fields['UrlSuccess'].blank?
63
+ raise "error - must specify cancel_return_url" if @fields['UrlFail'].blank?
64
+
65
+ result = request_secure_redirect
66
+ raise "error - failed to get token - message was #{result[:redirect]}" unless result[:valid] == "1"
67
+
68
+ url = URI.parse(result[:redirect])
69
+
70
+ CGI.parse(url.query)
71
+ end
72
+
73
+ def form_method
74
+ "GET"
75
+ end
76
+
77
+ private
78
+ def generate_request
79
+ xml = REXML::Document.new
80
+ root = xml.add_element('GenerateRequest')
81
+
82
+ @fields.each do | k, v |
83
+ root.add_element(k).text = v
84
+ end
85
+
86
+ xml.to_s
87
+ end
88
+
89
+ def request_secure_redirect
90
+ request = generate_request
91
+
92
+ response = ssl_post(Pxpay.token_url, request)
93
+ xml = REXML::Document.new(response)
94
+ root = REXML::XPath.first(xml, "//Request")
95
+ valid = root.attributes["valid"]
96
+ redirect = root.elements["URI"].text
97
+
98
+ # example positive response:
99
+ # <Request valid="1"><URI>https://sec.paymentexpress.com/pxpay/pxpay.aspx?userid=PxpayUser&amp;request=REQUEST_TOKEN</URI></Request>
100
+
101
+ # example negative response:
102
+ # <Request valid="0"><URI>Invalid TxnType</URI></Request>
103
+
104
+ {:valid => valid, :redirect => redirect}
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,157 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+
5
+ module Pxpay
6
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
7
+ include PostsData
8
+ include RequiresParameters
9
+
10
+ def initialize(query_string, options={})
11
+ # PxPay appends ?result=...&userid=... to whatever return_url was specified, even if that URL ended with a ?query.
12
+ # So switch the first ? if present to a &
13
+ query_string[/\?/] = '&' if query_string[/\?/]
14
+ super
15
+
16
+ @encrypted_params = @params
17
+ @params = {}
18
+
19
+ requires! @encrypted_params, "result"
20
+ requires! @options, :credential1, :credential2
21
+
22
+ decrypt_transaction_result(@encrypted_params["result"])
23
+ end
24
+
25
+ # was the notification a validly formed request?
26
+ def acknowledge
27
+ @valid == '1'
28
+ end
29
+
30
+ def status
31
+ return 'Failed' unless success?
32
+ return 'Completed' if complete?
33
+ 'Error'
34
+ end
35
+
36
+ def complete?
37
+ @params['TxnType'] == 'Purchase' && success?
38
+ end
39
+
40
+ def cancelled?
41
+ !success?
42
+ end
43
+
44
+ # for field definitions see
45
+ # http://www.paymentexpress.com/Technical_Resources/Ecommerce_Hosted/PxPay
46
+
47
+ def success?
48
+ @params['Success'] == '1'
49
+ end
50
+
51
+ def gross
52
+ @params['AmountSettlement']
53
+ end
54
+
55
+ def currency
56
+ @params['CurrencySettlement']
57
+ end
58
+
59
+ def account
60
+ @params['userid']
61
+ end
62
+
63
+ def item_id
64
+ @params['TxnId']
65
+ end
66
+
67
+ def currency_input
68
+ @params['CurrencyInput']
69
+ end
70
+
71
+ def auth_code
72
+ @params['AuthCode']
73
+ end
74
+
75
+ def card_type
76
+ @params['CardName']
77
+ end
78
+
79
+ def card_holder_name
80
+ @params['CardHolderName']
81
+ end
82
+
83
+ def card_number
84
+ @params['CardNumber']
85
+ end
86
+
87
+ def expiry_date
88
+ @params['DateExpiry']
89
+ end
90
+
91
+ def client_ip
92
+ @params['ClientInfo']
93
+ end
94
+
95
+ def order_id
96
+ item_id
97
+ end
98
+
99
+ def payer_email
100
+ @params['EmailAddress']
101
+ end
102
+
103
+ def transaction_id
104
+ @params['DpsTxnRef']
105
+ end
106
+
107
+ def settlement_date
108
+ @params['DateSettlement']
109
+ end
110
+
111
+ # Indication of the uniqueness of a card number
112
+ def txn_mac
113
+ @params['TxnMac']
114
+ end
115
+
116
+ def message
117
+ @params['ResponseText']
118
+ end
119
+
120
+ def optional_data
121
+ [@params['TxnData1'],@fields['TxnData2'],@fields['TxnData3']]
122
+ end
123
+
124
+ # When was this payment was received by the client.
125
+ def received_at
126
+ settlement_date
127
+ end
128
+
129
+ # Was this a test transaction?
130
+ def test?
131
+ nil
132
+ end
133
+
134
+ private
135
+
136
+ def decrypt_transaction_result(encrypted_result)
137
+ request_xml = REXML::Document.new
138
+ root = request_xml.add_element('ProcessResponse')
139
+
140
+ root.add_element('PxPayUserId').text = @options[:credential1]
141
+ root.add_element('PxPayKey').text = @options[:credential2]
142
+ root.add_element('Response').text = encrypted_result
143
+
144
+ @raw = ssl_post(Pxpay.token_url, request_xml.to_s)
145
+
146
+ response_xml = REXML::Document.new(@raw)
147
+ root = REXML::XPath.first(response_xml)
148
+ @valid = root.attributes["valid"]
149
+ @params = {}
150
+ root.elements.each { |e| @params[e.name] = e.text }
151
+ end
152
+
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end