activemerchant 1.14.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +18 -0
  3. data/CONTRIBUTORS +4 -0
  4. data/README.rdoc +1 -0
  5. data/lib/active_merchant.rb +1 -1
  6. data/lib/active_merchant/billing/credit_card.rb +53 -42
  7. data/lib/active_merchant/billing/gateway.rb +6 -6
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +4 -2
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +3 -3
  11. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +1 -1
  12. data/lib/active_merchant/billing/gateways/bogus.rb +12 -0
  13. data/lib/active_merchant/billing/gateways/braintree_blue.rb +77 -16
  14. data/lib/active_merchant/billing/gateways/eway.rb +0 -4
  15. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +1 -1
  16. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/orbital.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/pay_junction.rb +1 -1
  19. data/lib/active_merchant/billing/gateways/payflow.rb +22 -8
  20. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +10 -10
  21. data/lib/active_merchant/billing/gateways/payflow_express.rb +115 -36
  22. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/realex.rb +7 -20
  25. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +5 -5
  26. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -1
  27. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +18 -10
  28. data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
  29. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
  30. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
  31. data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
  32. data/lib/active_merchant/billing/integrations/helper.rb +4 -4
  33. data/lib/active_merchant/billing/integrations/notification.rb +1 -1
  34. data/lib/active_merchant/common/post_data.rb +1 -1
  35. data/lib/active_merchant/common/posts_data.rb +1 -1
  36. data/lib/active_merchant/common/validateable.rb +20 -15
  37. data/lib/active_merchant/version.rb +1 -1
  38. metadata +20 -21
  39. metadata.gz.sig +0 -0
@@ -272,10 +272,6 @@ module ActiveMerchant #:nodoc:
272
272
  end
273
273
  end
274
274
 
275
- def test?
276
- @options[:test] || super
277
- end
278
-
279
275
  end
280
276
  end
281
277
  end
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
6
6
  # - does not support multiple subID per merchant
7
7
  # - language is fixed to 'nl'
8
8
  class IdealBaseGateway < Gateway
9
- class_inheritable_accessor :test_url, :live_url, :server_pem, :pem_password, :default_expiration_period
9
+ class_attribute :test_url, :live_url, :server_pem, :pem_password, :default_expiration_period
10
10
  self.default_expiration_period = 'PT10M'
11
11
  self.default_currency = 'EUR'
12
12
  self.pem_password = true
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  # - does not support multiple subID per merchant
46
46
  # - language is fixed to 'nl'
47
47
  class IdealRabobankGateway < IdealBaseGateway
48
- class_inheritable_accessor :test_url, :live_url
48
+ class_attribute :test_url, :live_url
49
49
 
50
50
  self.test_url = 'https://idealtest.rabobank.nl/ideal/iDeal'
51
51
  self.live_url = 'https://ideal.rabobank.nl/ideal/iDeal'
@@ -41,7 +41,7 @@ module ActiveMerchant #:nodoc:
41
41
 
42
42
  SUCCESS, APPROVED = '0', '00'
43
43
 
44
- class_inheritable_accessor :primary_test_url, :secondary_test_url, :primary_live_url, :secondary_live_url
44
+ class_attribute :primary_test_url, :secondary_test_url, :primary_live_url, :secondary_live_url
45
45
 
46
46
  self.primary_test_url = "https://orbitalvar1.paymentech.net/authorize"
47
47
  self.secondary_test_url = "https://orbitalvar2.paymentech.net/authorize"
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
99
99
  class PayJunctionGateway < Gateway
100
100
  API_VERSION = '1.2'
101
101
 
102
- class_inheritable_accessor :test_url, :live_url
102
+ class_attribute :test_url, :live_url
103
103
 
104
104
  self.test_url = "https://www.payjunctionlabs.com/quick_link"
105
105
  self.live_url = "https://payjunction.com/quick_link"
@@ -16,13 +16,13 @@ module ActiveMerchant #:nodoc:
16
16
  def authorize(money, credit_card_or_reference, options = {})
17
17
  request = build_sale_or_authorization_request(:authorization, money, credit_card_or_reference, options)
18
18
 
19
- commit(request)
19
+ commit(request, options)
20
20
  end
21
21
 
22
22
  def purchase(money, credit_card_or_reference, options = {})
23
23
  request = build_sale_or_authorization_request(:purchase, money, credit_card_or_reference, options)
24
24
 
25
- commit(request)
25
+ commit(request, options)
26
26
  end
27
27
 
28
28
  def credit(money, identification_or_credit_card, options = {})
@@ -33,12 +33,12 @@ module ActiveMerchant #:nodoc:
33
33
  else
34
34
  # Perform non-referenced credit
35
35
  request = build_credit_card_request(:credit, money, identification_or_credit_card, options)
36
- commit(request)
36
+ commit(request, options)
37
37
  end
38
38
  end
39
39
 
40
40
  def refund(money, reference, options = {})
41
- commit(build_reference_request(:credit, money, reference, options))
41
+ commit(build_reference_request(:credit, money, reference, options), options)
42
42
  end
43
43
  # Adds or modifies a recurring Payflow profile. See the Payflow Pro Recurring Billing Guide for more details:
44
44
  # https://www.paypal.com/en_US/pdf/PayflowPro_RecurringBilling_Guide.pdf
@@ -57,17 +57,17 @@ module ActiveMerchant #:nodoc:
57
57
  request = build_recurring_request(options[:profile_id] ? :modify : :add, money, options) do |xml|
58
58
  add_credit_card(xml, credit_card) if credit_card
59
59
  end
60
- commit(request, :recurring)
60
+ commit(request, options.merge(:request_type => :recurring))
61
61
  end
62
62
 
63
63
  def cancel_recurring(profile_id)
64
64
  request = build_recurring_request(:cancel, 0, :profile_id => profile_id)
65
- commit(request, :recurring)
65
+ commit(request, options.merge(:request_type => :recurring))
66
66
  end
67
67
 
68
68
  def recurring_inquiry(profile_id, options = {})
69
69
  request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id ))
70
- commit(request, :recurring)
70
+ commit(request, options.merge(:request_type => :recurring))
71
71
  end
72
72
 
73
73
  def express
@@ -84,10 +84,21 @@ module ActiveMerchant #:nodoc:
84
84
  end
85
85
 
86
86
  def build_reference_sale_or_authorization_request(action, money, reference, options)
87
- xml = Builder::XmlMarkup.new
87
+ xml = Builder::XmlMarkup.new
88
88
  xml.tag! TRANSACTIONS[action] do
89
89
  xml.tag! 'PayData' do
90
90
  xml.tag! 'Invoice' do
91
+ # Fields accepted by PayFlow and recommended to be provided even for Reference Transaction, per Payflow docs.
92
+ xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
93
+ xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
94
+ xml.tag! 'Description', options[:description] unless options[:description].blank?
95
+ xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
96
+ xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
97
+
98
+ billing_address = options[:billing_address] || options[:address]
99
+ add_address(xml, 'BillTo', billing_address, options) if billing_address
100
+ add_address(xml, 'ShipTo', options[:shipping_address],options) if options[:shipping_address]
101
+
91
102
  xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
92
103
  end
93
104
  xml.tag! 'Tender' do
@@ -108,6 +119,9 @@ module ActiveMerchant #:nodoc:
108
119
  xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
109
120
  xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
110
121
  xml.tag! 'Description', options[:description] unless options[:description].blank?
122
+ # Comment and Comment2 will show up in manager.paypal.com as Comment1 and Comment2
123
+ xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
124
+ xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
111
125
 
112
126
  billing_address = options[:billing_address] || options[:address]
113
127
  add_address(xml, 'BillTo', billing_address, options) if billing_address
@@ -4,14 +4,14 @@ module ActiveMerchant #:nodoc:
4
4
  def self.included(base)
5
5
  base.default_currency = 'USD'
6
6
 
7
- base.class_inheritable_accessor :partner
7
+ base.class_attribute :partner
8
8
 
9
9
  # Set the default partner to PayPal
10
10
  base.partner = 'PayPal'
11
11
 
12
12
  base.supported_countries = ['US', 'CA', 'SG', 'AU']
13
13
 
14
- base.class_inheritable_accessor :timeout
14
+ base.class_attribute :timeout
15
15
  base.timeout = 60
16
16
 
17
17
  # Enable safe retry of failed connections
@@ -67,27 +67,27 @@ module ActiveMerchant #:nodoc:
67
67
 
68
68
  def capture(money, authorization, options = {})
69
69
  request = build_reference_request(:capture, money, authorization, options)
70
- commit(request)
70
+ commit(request, options)
71
71
  end
72
72
 
73
73
  def void(authorization, options = {})
74
74
  request = build_reference_request(:void, nil, authorization, options)
75
- commit(request)
75
+ commit(request, options)
76
76
  end
77
77
 
78
78
  private
79
- def build_request(body, request_type = nil)
79
+ def build_request(body, options = {})
80
80
  xml = Builder::XmlMarkup.new
81
81
  xml.instruct!
82
82
  xml.tag! 'XMLPayRequest', 'Timeout' => timeout.to_s, 'version' => "2.1", "xmlns" => XMLNS do
83
83
  xml.tag! 'RequestData' do
84
84
  xml.tag! 'Vendor', @options[:login]
85
85
  xml.tag! 'Partner', @options[:partner]
86
- if request_type == :recurring
86
+ if options[:request_type] == :recurring
87
87
  xml << body
88
88
  else
89
89
  xml.tag! 'Transactions' do
90
- xml.tag! 'Transaction' do
90
+ xml.tag! 'Transaction', 'CustRef' => options[:customer] do
91
91
  xml.tag! 'Verbosity', 'MEDIUM'
92
92
  xml << body
93
93
  end
@@ -189,8 +189,8 @@ module ActiveMerchant #:nodoc:
189
189
  }
190
190
  end
191
191
 
192
- def commit(request_body, request_type = nil)
193
- request = build_request(request_body, request_type)
192
+ def commit(request_body, options = {})
193
+ request = build_request(request_body, options)
194
194
  headers = build_headers(request.size)
195
195
 
196
196
  response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request, headers))
@@ -204,4 +204,4 @@ module ActiveMerchant #:nodoc:
204
204
  end
205
205
  end
206
206
  end
207
- end
207
+ end
@@ -4,29 +4,85 @@ require File.dirname(__FILE__) + '/paypal_express_common'
4
4
 
5
5
  module ActiveMerchant #:nodoc:
6
6
  module Billing #:nodoc:
7
- class PayflowExpressGateway < Gateway
7
+ # ==General Parameters
8
+ # The following parameters are supported for #setup_authorization, #setup_purchase, #authorize and #purchase transactions. I've read
9
+ # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase.
10
+ #
11
+ # This information was gleaned from a mix of:
12
+ # * PayFlow documentation
13
+ # * for key value pairs: {Express Checkout for Payflow Pro (PDF)}[https://cms.paypal.com/cms_content/US/en_US/files/developer/PFP_ExpressCheckout_PP.pdf]
14
+ # * XMLPay: {Payflow Pro XMLPay Developer's Guide (PDF)}[https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PayflowPro_XMLPay_Guide.pdf]
15
+ # * previous ActiveMerchant code
16
+ # * trial & error
17
+ #
18
+ # The following parameters are currently supported.
19
+ # [<tt>:ip</tt>] (opt) Customer IP Address
20
+ # [<tt>:order_id</tt>] (opt) An order or invoice number. This will be passed through to the Payflow backend at manager.paypal.com, and show up as "Supplier Reference #"
21
+ # [<tt>:description</tt>] (opt) Order description, shown to buyer (after redirected to PayPal). If Order Line Items are used (see below), then the description is suppressed. This will not be passed through to the Payflow backend.
22
+ # [<tt>:billing_address</tt>] (opt) See ActiveMerchant::Billing::Gateway for details
23
+ # [<tt>:shipping_address</tt>] (opt) See ActiveMerchant::Billing::Gateway for details
24
+ # [<tt>:currency</tt>] (req) Currency of transaction, will be set to USD by default for PayFlow Express if not specified
25
+ # [<tt>:email</tt>] (opt) Email of buyer; used to pre-fill PayPal login screen
26
+ # [<tt>:payer_id</tt>] (opt) Unique PayPal buyer account identification number, as returned by details_for request
27
+ # [<tt>:token</tt>] (req for #authorize & #purchase) Token returned by setup transaction
28
+ # [<tt>:no_shipping</tt>] (opt) Boolean for whether or not to display shipping address to buyer
29
+ # [<tt>:address_override</tt>] (opt) Boolean. If true, display shipping address passed by parameters, rather than shipping address on file with PayPal
30
+ # [<tt>:allow_note</tt>] (opt) Boolean for permitting buyer to add note during checkout. Note contents can be retrieved with details_for transaction
31
+ # [<tt>:return_url</tt>] (req) URL to which the buyer’s browser is returned after choosing to pay.
32
+ # [<tt>:cancel_return_url</tt>] (req) URL to which the buyer is returned if the buyer cancels the order.
33
+ # [<tt>:notify_url</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
34
+ # [<tt>:comment</tt>] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment1
35
+ # [<tt>:comment2</tt>] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment2
36
+ #
37
+ # ==Line Items
38
+ # Support for order line items is available, but has to be enabled on the PayFlow backend. This is what I was told by Todd Sieber at Technical Support:
39
+ #
40
+ # <em>You will need to call Payflow Support at 1-888-883-9770, choose option #2. Request that they update your account in "Pandora" under Product Settings >> PayPal Mark and update the Features Bitmap to 1111111111111112. This is 15 ones and a two.</em>
41
+ #
42
+ # See here[https://www.x.com/message/206214#206214] for the forum discussion (requires login to {x.com}[https://x.com]
43
+ #
44
+ # [<tt>:items</tt>] (opt) Array of Order Line Items hashes. These are shown to the buyer after redirect to PayPal.
45
+ #
46
+ #
47
+ #
48
+ # The following keys are supported for line items:
49
+ # [<tt>:name</tt>] Name of line item
50
+ # [<tt>:description</tt>] Description of line item
51
+ # [<tt>:amount</tt>] Line Item Amount in Cents (as Integer)
52
+ # [<tt>:quantity</tt>] Line Item Quantity (default to 1 if left blank)
53
+ #
54
+ # ====Customization of Payment Page
55
+ # [<tt>:page_style</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
56
+ # [<tt>:header_image</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
57
+ # [<tt>:background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
58
+ # ====Additional options for old Checkout Experience, being phased out in 2010 and 2011
59
+ # [<tt>:header_background_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
60
+ # [<tt>:header_border_color</tt>] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
61
+
62
+
63
+ class PayflowExpressGateway < Gateway
8
64
  include PayflowCommonAPI
9
65
  include PaypalExpressCommon
10
66
 
11
67
  self.test_redirect_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
12
68
  self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside'
13
69
  self.display_name = 'PayPal Express Checkout'
14
-
70
+
15
71
  def authorize(money, options = {})
16
72
  requires!(options, :token, :payer_id)
17
73
  request = build_sale_or_authorization_request('Authorization', money, options)
18
- commit(request)
74
+ commit(request, options)
19
75
  end
20
76
 
21
77
  def purchase(money, options = {})
22
78
  requires!(options, :token, :payer_id)
23
79
  request = build_sale_or_authorization_request('Sale', money, options)
24
- commit(request)
80
+ commit(request, options)
25
81
  end
26
82
 
27
83
  def refund(money, identification, options = {})
28
84
  request = build_reference_request(:credit, money, identification, options)
29
- commit(request)
85
+ commit(request, options)
30
86
  end
31
87
 
32
88
  def credit(money, identification, options = {})
@@ -38,19 +94,19 @@ module ActiveMerchant #:nodoc:
38
94
  requires!(options, :return_url, :cancel_return_url)
39
95
 
40
96
  request = build_setup_express_sale_or_authorization_request('Authorization', money, options)
41
- commit(request)
97
+ commit(request, options)
42
98
  end
43
99
 
44
100
  def setup_purchase(money, options = {})
45
101
  requires!(options, :return_url, :cancel_return_url)
46
102
 
47
103
  request = build_setup_express_sale_or_authorization_request('Sale', money, options)
48
- commit(request)
104
+ commit(request, options)
49
105
  end
50
106
 
51
107
  def details_for(token)
52
108
  request = build_get_express_details_request(token)
53
- commit(request)
109
+ commit(request, options)
54
110
  end
55
111
 
56
112
  private
@@ -69,28 +125,12 @@ module ActiveMerchant #:nodoc:
69
125
  end
70
126
  xml.target!
71
127
  end
72
-
128
+
73
129
  def build_setup_express_sale_or_authorization_request(action, money, options = {})
74
130
  xml = Builder::XmlMarkup.new :indent => 2
75
131
  xml.tag! 'SetExpressCheckout' do
76
132
  xml.tag! action do
77
- xml.tag! 'PayData' do
78
- xml.tag! 'Invoice' do
79
- xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
80
- xml.tag! 'InvNum', options[:order_id] unless options[:order_id].blank?
81
- xml.tag! 'Description', options[:description] unless options[:description].blank?
82
-
83
- billing_address = options[:billing_address] || options[:address]
84
- add_address(xml, 'BillTo', billing_address, options) if billing_address
85
- add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
86
-
87
- xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
88
- end
89
-
90
- xml.tag! 'Tender' do
91
- add_paypal_details(xml, options)
92
- end
93
- end
133
+ add_pay_data xml, money, options
94
134
  end
95
135
  end
96
136
  xml.target!
@@ -100,19 +140,55 @@ module ActiveMerchant #:nodoc:
100
140
  xml = Builder::XmlMarkup.new :indent => 2
101
141
  xml.tag! 'DoExpressCheckout' do
102
142
  xml.tag! action do
103
- xml.tag! 'PayData' do
104
- xml.tag! 'Invoice' do
105
- xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
106
- end
107
- xml.tag! 'Tender' do
108
- add_paypal_details xml, options
109
- end
110
- end
143
+ add_pay_data xml, money, options
111
144
  end
112
145
  end
113
146
  xml.target!
114
147
  end
115
-
148
+
149
+ def add_pay_data(xml, money, options)
150
+ xml.tag! 'PayData' do
151
+ xml.tag! 'Invoice' do
152
+ xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
153
+ xml.tag! 'InvNum', options[:order_id] unless options[:order_id].blank?
154
+ # Description field will be shown to buyer, unless line items are also being supplied (then only line items are shown).
155
+ xml.tag! 'Description', options[:description] unless options[:description].blank?
156
+ # Comment, Comment2 should make it to the backend at manager.paypal.com, as with Payflow credit card transactions
157
+ # but that doesn't seem to work (yet?). See: https://www.x.com/thread/51908?tstart=0
158
+ xml.tag! 'Comment', options[:comment] unless options[:comment].nil?
159
+ xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].nil?
160
+
161
+ billing_address = options[:billing_address] || options[:address]
162
+ add_address(xml, 'BillTo', billing_address, options) if billing_address
163
+ add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
164
+
165
+ # Note: To get order line-items to show up with Payflow Express, this feature has to be enabled on the backend.
166
+ # Call Support at 888 883 9770, press 2. Then request that they update your account in "Pandora" under Product Settings >> PayPal
167
+ # Mark and update the Features Bitmap to 1111111111111112. This is 15 ones and a two.
168
+ # See here for the forum discussion: https://www.x.com/message/206214#206214
169
+ items = options[:items] || []
170
+ items.each_with_index do |item, index|
171
+ xml.tag! 'ExtData', 'Name' => "L_DESC#{index}", 'Value' => item[:description]
172
+ xml.tag! 'ExtData', 'Name' => "L_COST#{index}", 'Value' => amount(item[:amount])
173
+ xml.tag! 'ExtData', 'Name' => "L_QTY#{index}", 'Value' => item[:quantity] || '1'
174
+ xml.tag! 'ExtData', 'Name' => "L_NAME#{index}", 'Value' => item[:name]
175
+ # Note: An ItemURL is supported in Paypal Express (different API), but not PayFlow Express, as far as I can tell.
176
+ # L_URLn nor L_ITEMURLn seem to work
177
+ end
178
+ if items.any?
179
+ xml.tag! 'ExtData', 'Name' => 'CURRENCY', 'Value' => options[:currency] || currency(money)
180
+ xml.tag! 'ExtData', 'Name' => "ITEMAMT", 'Value' => amount(money)
181
+ end
182
+
183
+ xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
184
+ end
185
+
186
+ xml.tag! 'Tender' do
187
+ add_paypal_details(xml, options)
188
+ end
189
+ end
190
+ end
191
+
116
192
  def add_paypal_details(xml, options)
117
193
  xml.tag! 'PayPal' do
118
194
  xml.tag! 'EMail', options[:email] unless options[:email].blank?
@@ -128,9 +204,12 @@ module ActiveMerchant #:nodoc:
128
204
  # Customization of the payment page
129
205
  xml.tag! 'PageStyle', options[:page_style] unless options[:page_style].blank?
130
206
  xml.tag! 'HeaderImage', options[:header_image] unless options[:header_image].blank?
207
+ xml.tag! 'PayflowColor', options[:background_color] unless options[:background_color].blank?
208
+ # Note: HeaderImage and PayflowColor apply to both the new (as of 2010) and the old checkout experience
209
+ # HeaderBackColor and HeaderBorderColor apply only to the old checkout experience which is being phased out.
131
210
  xml.tag! 'HeaderBackColor', options[:header_background_color] unless options[:header_background_color].blank?
132
211
  xml.tag! 'HeaderBorderColor', options[:header_border_color] unless options[:header_border_color].blank?
133
- xml.tag! 'PayflowColor', options[:background_color] unless options[:background_color].blank?
212
+ xml.tag! 'ExtData', 'Name' => 'ALLOWNOTE', 'Value' => options[:allow_note]
134
213
  end
135
214
  end
136
215
 
@@ -110,7 +110,7 @@ module ActiveMerchant #:nodoc:
110
110
  end
111
111
 
112
112
  def credit(money, identification, options = {})
113
- deprecated CREDIT_DEPRECATION_MESSAGE
113
+ deprecated Gateway::CREDIT_DEPRECATION_MESSAGE
114
114
  refund(money, identification, options)
115
115
  end
116
116
 
@@ -5,7 +5,7 @@ module ActiveMerchant #:nodoc:
5
5
  class QbmsGateway < Gateway
6
6
  API_VERSION = '4.0'
7
7
 
8
- class_inheritable_accessor :test_url, :live_url
8
+ class_attribute :test_url, :live_url
9
9
 
10
10
  self.test_url = "https://webmerchantaccount.ptc.quickbooks.com/j/AppGateway"
11
11
  self.live_url = "https://webmerchantaccount.quickbooks.com/j/AppGateway"
@@ -131,7 +131,7 @@ module ActiveMerchant
131
131
  add_amount(xml, money, options)
132
132
  add_card(xml, credit_card)
133
133
  xml.tag! 'autosettle', 'flag' => auto_settle_flag(action)
134
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id], amount(money), (options[:currency] || currency(money)), credit_card.number)
134
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number)
135
135
  add_comments(xml, options)
136
136
  add_address_and_customer_info(xml, options)
137
137
  end
@@ -145,7 +145,7 @@ module ActiveMerchant
145
145
  add_merchant_details(xml, options)
146
146
  add_transaction_identifiers(xml, authorization, options)
147
147
  add_comments(xml, options)
148
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id])
148
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), nil, nil, nil)
149
149
  end
150
150
  xml.target!
151
151
  end
@@ -160,7 +160,7 @@ module ActiveMerchant
160
160
  xml.tag! 'refundhash', @options[:refund_hash] if @options[:refund_hash]
161
161
  xml.tag! 'autosettle', 'flag' => 1
162
162
  add_comments(xml, options)
163
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id], amount(money), (options[:currency] || currency(money)))
163
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), nil)
164
164
  end
165
165
  xml.target!
166
166
  end
@@ -172,7 +172,7 @@ module ActiveMerchant
172
172
  add_merchant_details(xml, options)
173
173
  add_transaction_identifiers(xml, authorization, options)
174
174
  add_comments(xml, options)
175
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id])
175
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), nil, nil, nil)
176
176
  end
177
177
  xml.target!
178
178
  end
@@ -207,7 +207,7 @@ module ActiveMerchant
207
207
  def add_merchant_details(xml, options)
208
208
  xml.tag! 'merchantid', @options[:login]
209
209
  if options[:account] || @options[:account]
210
- xml.tag! 'account', options[:account] || @options[:account]
210
+ xml.tag! 'account', (options[:account] || @options[:account])
211
211
  end
212
212
  end
213
213
 
@@ -252,22 +252,13 @@ module ActiveMerchant
252
252
  string.gsub(/[\D]/,'')
253
253
  end
254
254
 
255
- def stringify_values(values)
256
- string = ""
257
- (0..5).each do |i|
258
- string << "#{values[i]}"
259
- string << "." unless i == 5
260
- end
261
- string
262
- end
263
-
264
255
  def new_timestamp
265
256
  Time.now.strftime('%Y%m%d%H%M%S')
266
257
  end
267
258
 
268
259
  def add_signed_digest(xml, *values)
269
- string = stringify_values(values)
270
- xml.tag! 'sha1hash', sha1from(string)
260
+ string = Digest::SHA1.hexdigest(values.join("."))
261
+ xml.tag! 'sha1hash', Digest::SHA1.hexdigest([string, @options[:password]].join("."))
271
262
  end
272
263
 
273
264
  def auto_settle_flag(action)
@@ -278,10 +269,6 @@ module ActiveMerchant
278
269
  "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
279
270
  end
280
271
 
281
- def sha1from(string)
282
- Digest::SHA1.hexdigest("#{Digest::SHA1.hexdigest(string)}.#{@options[:password]}")
283
- end
284
-
285
272
  def normalize(field)
286
273
  case field
287
274
  when "true" then true