activemerchant 1.33.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,5 +1,11 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ * PayPal Express gateway: Add unstore support [duff]
4
+ * Stripe: Send application_fee with capture requests [melari]
5
+ * Make #unstore method signature consistent across gateways [duff]
6
+ * Dwolla: Major bug fixes. [capablemonkey, melari]
7
+ * Stripe: Add support for including track data [melari]
8
+
3
9
  == Version 1.33.0 (May 30, 2013)
4
10
 
5
11
  * Netaxept: Completely revamped to use the "M" service type [rbjordan3, ntalbott]
@@ -112,6 +112,11 @@ module ActiveMerchant #:nodoc:
112
112
  # @return [String] the verification value
113
113
  attr_accessor :verification_value
114
114
 
115
+ # Returns or sets the track data for the card
116
+ #
117
+ # @return [String]
118
+ attr_accessor :track_data
119
+
115
120
  def type
116
121
  self.class.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead."
117
122
  brand
@@ -422,8 +422,6 @@ module ActiveMerchant #:nodoc:
422
422
 
423
423
  def add_address(post, options)
424
424
  if address = (options[:shipping_address] || options[:billing_address] || options[:address])
425
- post[:NAME1] = address[:first_name]
426
- post[:NAME2] = address[:last_name]
427
425
  post[:ADDR1] = address[:address1]
428
426
  post[:ADDR2] = address[:address2]
429
427
  post[:COMPANY_NAME] = address[:company]
@@ -172,7 +172,7 @@ module ActiveMerchant #:nodoc:
172
172
  end
173
173
  end
174
174
 
175
- def unstore(customer_vault_id)
175
+ def unstore(customer_vault_id, options = {})
176
176
  commit do
177
177
  Braintree::Customer.delete(customer_vault_id)
178
178
  Response.new(true, "OK")
@@ -55,7 +55,7 @@ module ActiveMerchant #:nodoc:
55
55
  commit('T', nil, post)
56
56
  end
57
57
 
58
- def unstore(card_id)
58
+ def unstore(card_id, options = {})
59
59
  post = {}
60
60
  post[:client_reference_number] = options[:customer] if options.has_key?(:customer)
61
61
  post[:card_id] = card_id
@@ -101,7 +101,7 @@ module ActiveMerchant #:nodoc:
101
101
  commit('res_add_cc', post)
102
102
  end
103
103
 
104
- def unstore(data_key)
104
+ def unstore(data_key, options = {})
105
105
  post = {}
106
106
  post[:data_key] = data_key
107
107
  commit('res_delete', post)
@@ -122,8 +122,7 @@ module ActiveMerchant #:nodoc:
122
122
  def add_address(xml, tag, address, options)
123
123
  return if address.nil?
124
124
  xml.tag! tag do
125
- xml.tag! 'FirstName', address[:first_name] unless address[:first_name].blank?
126
- xml.tag! 'LastName', address[:last_name] unless address[:last_name].blank?
125
+ xml.tag! 'Name', address[:name] unless address[:name].blank?
127
126
  xml.tag! 'EMail', options[:email] unless options[:email].blank?
128
127
  xml.tag! 'Phone', address[:phone] unless address[:phone].blank?
129
128
  xml.tag! 'CustCode', options[:customer] if !options[:customer].blank? && tag == 'BillTo'
@@ -63,6 +63,10 @@ module ActiveMerchant #:nodoc:
63
63
  commit 'CreateBillingAgreement', build_create_billing_agreement_request(token, options)
64
64
  end
65
65
 
66
+ def unstore(token, options = {})
67
+ commit 'BAUpdate', build_cancel_billing_agreement_request(token)
68
+ end
69
+
66
70
  def authorize_reference_transaction(money, options = {})
67
71
  requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip)
68
72
 
@@ -188,6 +192,19 @@ module ActiveMerchant #:nodoc:
188
192
  xml.target!
189
193
  end
190
194
 
195
+ def build_cancel_billing_agreement_request(token)
196
+ xml = Builder::XmlMarkup.new :indent => 2
197
+ xml.tag! 'BillAgreementUpdateReq', 'xmlns' => PAYPAL_NAMESPACE do
198
+ xml.tag! 'BAUpdateRequest', 'xmlns:n2' => EBAY_NAMESPACE do
199
+ xml.tag! 'n2:Version', API_VERSION
200
+ xml.tag! 'ReferenceID', token
201
+ xml.tag! 'BillingAgreementStatus', "Canceled"
202
+ end
203
+ end
204
+
205
+ xml.target!
206
+ end
207
+
191
208
  def build_reference_transaction_request(action, money, options)
192
209
  currency_code = options[:currency] || currency(money)
193
210
 
@@ -1,5 +1,3 @@
1
- require 'json'
2
-
3
1
  module ActiveMerchant #:nodoc:
4
2
  module Billing #:nodoc:
5
3
  class StripeGateway < Gateway
@@ -58,7 +56,11 @@ module ActiveMerchant #:nodoc:
58
56
  end
59
57
 
60
58
  def capture(money, authorization, options = {})
61
- commit(:post, "charges/#{CGI.escape(authorization)}/capture", {:amount => amount(money)})
59
+ post = {}
60
+ post[:amount] = amount(money)
61
+ add_application_fee(post, options)
62
+
63
+ commit(:post, "charges/#{CGI.escape(authorization)}/capture", post)
62
64
  end
63
65
 
64
66
  def void(identification, options = {})
@@ -109,8 +111,8 @@ module ActiveMerchant #:nodoc:
109
111
  add_customer(post, options)
110
112
  add_customer_data(post,options)
111
113
  post[:description] = options[:description] || options[:email]
112
- post[:application_fee] = options[:application_fee] if options[:application_fee]
113
114
  add_flags(post, options)
115
+ add_application_fee(post, options)
114
116
  post
115
117
  end
116
118
 
@@ -119,6 +121,10 @@ module ActiveMerchant #:nodoc:
119
121
  post[:currency] = (options[:currency] || currency(money)).downcase
120
122
  end
121
123
 
124
+ def add_application_fee(post, options)
125
+ post[:application_fee] = options[:application_fee] if options[:application_fee]
126
+ end
127
+
122
128
  def add_customer_data(post, options)
123
129
  metadata_options = [:description,:browser_ip,:user_agent,:referrer]
124
130
  post.update(options.slice(*metadata_options))
@@ -140,19 +146,27 @@ module ActiveMerchant #:nodoc:
140
146
  end
141
147
 
142
148
  def add_creditcard(post, creditcard, options)
149
+ card = {}
143
150
  if creditcard.respond_to?(:number)
144
- card = {}
145
- card[:number] = creditcard.number
146
- card[:exp_month] = creditcard.month
147
- card[:exp_year] = creditcard.year
148
- card[:cvc] = creditcard.verification_value if creditcard.verification_value?
149
- card[:name] = creditcard.name if creditcard.name
150
- post[:card] = card
151
+ if creditcard.respond_to?(:track_data) && creditcard.track_data.present?
152
+ card[:swipe_data] = creditcard.track_data
153
+ else
154
+ card[:number] = creditcard.number
155
+ card[:exp_month] = creditcard.month
156
+ card[:exp_year] = creditcard.year
157
+ card[:cvc] = creditcard.verification_value if creditcard.verification_value?
158
+ card[:name] = creditcard.name if creditcard.name
159
+ end
151
160
 
152
161
  add_address(post, options)
153
162
  elsif creditcard.kind_of?(String)
154
- post[:card] = creditcard
163
+ if options[:track_data]
164
+ card[:swipe_data] = options[:track_data]
165
+ else
166
+ card[:number] = creditcard
167
+ end
155
168
  end
169
+ post[:card] = card
156
170
  end
157
171
 
158
172
  def add_customer(post, options)
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
6
6
  autoload :Helper, 'active_merchant/billing/integrations/dwolla/helper.rb'
7
7
  autoload :Notification, 'active_merchant/billing/integrations/dwolla/notification.rb'
8
8
  autoload :Common, 'active_merchant/billing/integrations/dwolla/common.rb'
9
-
9
+
10
10
  mattr_accessor :service_url
11
11
  self.service_url = 'https://www.dwolla.com/payment/pay'
12
12
 
@@ -1,3 +1,5 @@
1
+ require "openssl"
2
+
1
3
  module ActiveMerchant #:nodoc:
2
4
  module Billing #:nodoc:
3
5
  module Integrations #:nodoc:
@@ -8,7 +10,7 @@ module ActiveMerchant #:nodoc:
8
10
  raise ArgumentError, "You need to provide the Application secret as the option :credential3 to verify that the notification originated from Dwolla"
9
11
  end
10
12
 
11
- expected_signature = Digest::SHA1.hexdigest(secret + ('%s&%.2f' % [checkoutId, amount]))
13
+ expected_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "%s&%.2f" % [checkoutId, amount])
12
14
 
13
15
  if notification_signature != expected_signature
14
16
  raise StandardError, "Dwolla signature verification failed."
@@ -1,4 +1,4 @@
1
- require 'digest/sha1'
1
+ require "openssl"
2
2
 
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
@@ -9,18 +9,21 @@ module ActiveMerchant #:nodoc:
9
9
  super
10
10
  add_field('name', 'Store Purchase')
11
11
 
12
+ timestamp = Time.now.to_i.to_s
13
+
12
14
  if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
13
15
  add_field('test', 'true')
16
+ # timestamp used for test signature generation:
17
+ timestamp = "1370726016"
14
18
  end
15
19
 
16
- timestamp = Time.now.to_i.to_s
17
20
  add_field('timestamp', timestamp)
18
21
  add_field('allowFundingSources', 'true')
19
22
 
20
23
  key = options[:credential2].to_s
21
24
  secret = options[:credential3].to_s
22
25
  orderid = order.to_s
23
- signature = Digest::SHA1.hexdigest(secret + "#{key}&#{timestamp}&#{orderid}")
26
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "#{key}&#{timestamp}&#{orderid}")
24
27
  add_field('signature', signature)
25
28
  end
26
29
 
@@ -8,6 +8,10 @@ module ActiveMerchant #:nodoc:
8
8
  class Notification < ActiveMerchant::Billing::Integrations::Notification
9
9
  include Common
10
10
 
11
+ def initialize(data, options)
12
+ super
13
+ end
14
+
11
15
  def complete?
12
16
  (status == "Completed")
13
17
  end
@@ -37,14 +41,14 @@ module ActiveMerchant #:nodoc:
37
41
  end
38
42
 
39
43
  def test?
40
- params['TestMode']
44
+ params['TestMode'] != "false"
41
45
  end
42
46
 
43
47
  def acknowledge
44
48
  true
45
49
  end
46
-
47
- private
50
+
51
+ private
48
52
 
49
53
  def parse(post)
50
54
  @raw = post.to_s
@@ -7,7 +7,10 @@ module ActiveMerchant #:nodoc:
7
7
 
8
8
  def initialize(data, options)
9
9
  params = parse(data)
10
- verify_signature(params['checkoutId'], params['amount'], params['signature'], options[:credential3])
10
+
11
+ if params['error'] != 'failure'
12
+ verify_signature(params['checkoutId'], params['amount'], params['signature'], options[:credential3])
13
+ end
11
14
 
12
15
  super
13
16
  end
@@ -33,7 +36,7 @@ module ActiveMerchant #:nodoc:
33
36
  end
34
37
 
35
38
  def test?
36
- params['test']
39
+ params['test'] != nil
37
40
  end
38
41
 
39
42
  def callback_success?
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = "1.33.0"
2
+ VERSION = "1.34.0"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.33.0
5
+ version: 1.34.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tobias Luetke
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Z1BvU1BxN25rK3MyRlFVQko5VVpGSzFsZ016aG8vNGZaZ3pKd2J1K2NPOFNO
38
38
  dWFMUy9iagpoUGFTVHlWVTB5Q1Nudz09Ci0tLS0tRU5EIENFUlRJRklDQVRF
39
39
  LS0tLS0K
40
- date: 2013-05-30 00:00:00.000000000 Z
40
+ date: 2013-06-20 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  version_requirements: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file