activemerchant 1.29.3 → 1.30.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.
Files changed (47) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +39 -0
  3. data/CONTRIBUTORS +19 -0
  4. data/README.md +43 -41
  5. data/lib/active_merchant/billing/check.rb +15 -11
  6. data/lib/active_merchant/billing/credit_card.rb +5 -1
  7. data/lib/active_merchant/billing/credit_card_formatting.rb +8 -8
  8. data/lib/active_merchant/billing/gateway.rb +1 -1
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +9 -1
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +15 -4
  11. data/lib/active_merchant/billing/gateways/balanced.rb +9 -3
  12. data/lib/active_merchant/billing/gateways/banwire.rb +15 -1
  13. data/lib/active_merchant/billing/gateways/beanstream.rb +26 -24
  14. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +6 -2
  15. data/lib/active_merchant/billing/gateways/braintree_blue.rb +5 -2
  16. data/lib/active_merchant/billing/gateways/cyber_source.rb +55 -22
  17. data/lib/active_merchant/billing/gateways/eway.rb +114 -171
  18. data/lib/active_merchant/billing/gateways/eway_managed.rb +52 -22
  19. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +222 -0
  20. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +13 -2
  21. data/lib/active_merchant/billing/gateways/litle.rb +50 -19
  22. data/lib/active_merchant/billing/gateways/merchant_ware.rb +44 -9
  23. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +190 -0
  24. data/lib/active_merchant/billing/gateways/moneris.rb +2 -4
  25. data/lib/active_merchant/billing/gateways/nab_transact.rb +20 -3
  26. data/lib/active_merchant/billing/gateways/netbilling.rb +1 -0
  27. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  28. data/lib/active_merchant/billing/gateways/optimal_payment.rb +18 -3
  29. data/lib/active_merchant/billing/gateways/orbital.rb +9 -5
  30. data/lib/active_merchant/billing/gateways/payment_express.rb +62 -1
  31. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/paypal_express.rb +2 -0
  33. data/lib/active_merchant/billing/gateways/pin.rb +157 -0
  34. data/lib/active_merchant/billing/gateways/qbms.rb +3 -2
  35. data/lib/active_merchant/billing/gateways/quickpay.rb +66 -28
  36. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -0
  37. data/lib/active_merchant/billing/gateways/smart_ps.rb +1 -1
  38. data/lib/active_merchant/billing/gateways/spreedly_core.rb +235 -0
  39. data/lib/active_merchant/billing/gateways/stripe.rb +1 -0
  40. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -9
  41. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +4 -1
  42. data/lib/active_merchant/billing/integrations/paypal/notification.rb +39 -31
  43. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +13 -10
  44. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +14 -14
  45. data/lib/active_merchant/version.rb +1 -1
  46. metadata +109 -49
  47. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,7 +1,46 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ == Version 1.30.0 (February 13, 2013)
4
+
5
+ * Add FirstData Global Gateway e4 [frobcode]
6
+ * PaymentExpress: Add support for optional fields: ClientType and TxnData [moklett]
7
+ * PaymentExpress: Limit MerchantReference/description to 64 chars [moklett]
8
+ * Wirecard: description must be no more than 32 characters [moklett]
9
+ * Litle: Add support for passing a token to the authorize and purchase methods [forest]
10
+ * PayPal Common: Allow searching for transactions by ProfileID [aq1018]
11
+ * Add Spreedly Core gateway [duff]
12
+ * eWay Gateway: Return proper value for authorization [duff]
13
+ * eWay Gateway: Add support for refunds [duff]
14
+ * Quickpay: Add support for protocols 5 & 6 [twarberg]
15
+ * Banwire gateway: Handle JSON::ParserError [duff]
16
+ * Balanced gateway: Fix unspecified marketplace [duff]
17
+ * QBMS gateway: Allow partial addresses [duff]
18
+ * Authorize.Net CIM: Allow omitting card expiration date [shanebonham]
19
+ * Authorize.Net CIM: Add support for extraOptions to createCustomerProfileTransaction [tpiekos]
20
+ * Add NETPAY gateway [samlown]
21
+ * Balanced gateway: Add amount to the refund method signature [ntalbott]
22
+ * Orbital gateway: Fix void method signature [aprofeit, ntalbott]
23
+ * Eway Managed: Add 'query_customer' API as #retrieve [cdaloisio]
24
+ * NetPay: Fix the signature for void [duff]
25
+ * Cybersource: Add check support [bowmande]
26
+ * Moneris: Use a capture of $0 for void [ntalbott]
27
+ * PayPal Express integration: Fix received_at time zone [ntalbott]
28
+ * NAB Transact: Add refund capability [nagash]
29
+ * Stripe: Add support for application_fee [duff]
30
+ * SagePay: Add support for GiftAidPayment [duff]
31
+ * Wirecard: Add support for partial captures [richardblair]
32
+ * Add Pin gateway [madpilot]
33
+ * Balanced: Added support for on_behalf_of_uri to capture [cwise]
34
+ * Litle: Add support for passing an order_source [forest]
35
+ * Add Merchant Warrior gateway [pronix, Fodoj, ntalbott]
36
+ * Use v4 of the MerchantWare API for voiding transactions [melari]
37
+ * Add support for Authorize.net in CA and GB [melari]
38
+ * Send customer's IP to Beanstream for fraud review [melari]
39
+
3
40
  == Version 1.29.3 (December 7, 2012)
4
41
 
42
+ * Braintree Blue: Better wiredump_device support [ntalbott]
43
+ * Braintree: Store sets vault id as authorization [ntalbott]
5
44
  * WorldPay: Fix currencies without fractions like JPY and HUF by rounding down amount [Soleone]
6
45
 
7
46
  == Version 1.29.2 (December 7, 2012)
@@ -357,3 +357,22 @@ Liqpay integration (November 2012)
357
357
  eWay Rapid 3.0 gateway (December 2012)
358
358
 
359
359
  * Nathaniel Talbott (ntalbott)
360
+
361
+ FirstData Global Gateway e4 (December 2012)
362
+
363
+ * Chris Sheppard (frobcode)
364
+
365
+ Spreedly Core gateway (December 2012)
366
+
367
+ * Duff OMelia (duff)
368
+
369
+ Pin gateway (February 2013)
370
+
371
+ * Myles Eftos (madpilot)
372
+
373
+ Merchant Warrior
374
+
375
+ * Ben Bruscella (benbruscella)
376
+ * Дмитрий Василец (pronix)
377
+ * Kirill Shirinkin (Fodoj)
378
+ * Nathaniel Talbott (ntalbott)
data/README.md CHANGED
@@ -4,11 +4,13 @@ Active Merchant is an extraction from the e-commerce system [Shopify](http://www
4
4
  Shopify's requirements for a simple and unified API to access dozens of different payment
5
5
  gateways with very different internal APIs was the chief principle in designing the library.
6
6
 
7
- Active Merchant has been in production use since June 2006 and is now used in most modern
8
- Ruby applications which deal with financial transactions.
9
-
10
7
  It was developed for usage in Ruby on Rails web applications and integrates seamlessly
11
- as a plugin but it also works excellently as a stand alone library.
8
+ as a Rails plugin, but it also works excellently as a stand alone Ruby library.
9
+
10
+ Active Merchant has been in production use since June 2006 and is now used in most modern
11
+ Ruby applications which deal with financial transactions. It is maintained by the
12
+ [Shopify](http://www.shopify.com) and [Spreedly](https://spreedly.com) teams, with much help
13
+ from an ever-growing set of contributors.
12
14
 
13
15
  See {file:GettingStarted.md} if you want to learn more about using Active Merchant in your
14
16
  applications.
@@ -21,61 +23,54 @@ You can check out the latest source from git:
21
23
 
22
24
  git clone git://github.com/Shopify/active_merchant.git
23
25
 
24
- ### As a Rails plugin
25
-
26
- ActiveMerchant includes an init.rb file. This means that Rails will automatically load ActiveMerchant on startup. Run
27
- the following command from the root directory of your Rails project to install ActiveMerchant as a Rails plugin:
28
-
29
- script/plugin install git://github.com/Shopify/active_merchant.git
30
-
31
26
  ### From RubyGems
32
27
 
33
- Installation from RubyGems
28
+ Installation from RubyGems:
34
29
 
35
30
  gem install activemerchant
36
31
 
37
- Alternatively, add the following to your Gemfile
32
+ Or, if you're using Bundler, just add the following to your Gemfile:
38
33
 
39
- gem 'activemerchant', :require => 'active_merchant'
34
+ gem 'activemerchant'
40
35
 
41
36
  ## Usage
42
37
 
43
38
  This simple example demonstrates how a purchase can be made using a person's
44
39
  credit card details.
45
40
 
46
- require 'rubygems'
47
- require 'active_merchant'
41
+ require 'rubygems'
42
+ require 'active_merchant'
48
43
 
49
- # Use the TrustCommerce test servers
50
- ActiveMerchant::Billing::Base.mode = :test
44
+ # Use the TrustCommerce test servers
45
+ ActiveMerchant::Billing::Base.mode = :test
51
46
 
52
- gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
53
- :login => 'TestMerchant',
54
- :password => 'password')
47
+ gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
48
+ :login => 'TestMerchant',
49
+ :password => 'password')
55
50
 
56
- # ActiveMerchant accepts all amounts as Integer values in cents
57
- amount = 1000 # $10.00
51
+ # ActiveMerchant accepts all amounts as Integer values in cents
52
+ amount = 1000 # $10.00
58
53
 
59
- # The card verification value is also known as CVV2, CVC2, or CID
60
- credit_card = ActiveMerchant::Billing::CreditCard.new(
61
- :first_name => 'Bob',
62
- :last_name => 'Bobsen',
63
- :number => '4242424242424242',
64
- :month => '8',
65
- :year => '2012',
66
- :verification_value => '123')
54
+ # The card verification value is also known as CVV2, CVC2, or CID
55
+ credit_card = ActiveMerchant::Billing::CreditCard.new(
56
+ :first_name => 'Bob',
57
+ :last_name => 'Bobsen',
58
+ :number => '4242424242424242',
59
+ :month => '8',
60
+ :year => Time.now.year+1,
61
+ :verification_value => '000')
67
62
 
68
- # Validating the card automatically detects the card type
69
- if credit_card.valid?
70
- # Capture $10 from the credit card
71
- response = gateway.purchase(amount, credit_card)
63
+ # Validating the card automatically detects the card type
64
+ if credit_card.valid?
65
+ # Capture $10 from the credit card
66
+ response = gateway.purchase(amount, credit_card)
72
67
 
73
- if response.success?
74
- puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
75
- else
76
- raise StandardError, response.message
77
- end
78
- end
68
+ if response.success?
69
+ puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
70
+ else
71
+ raise StandardError, response.message
72
+ end
73
+ end
79
74
 
80
75
  For more in-depth documentation and tutorials, see {file:GettingStarted.md} and the
81
76
  [API documentation](http://rubydoc.info/github/Shopify/active_merchant/master/file/README.md).
@@ -104,6 +99,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
104
99
  * [E-xact](http://www.e-xact.com) - CA, US
105
100
  * [Fat Zebra](https://www.fatzebra.com.au) - AU
106
101
  * [Federated Canada](http://www.federatedcanada.com/) - CA
102
+ * [FirstData Global Gateway e4](http://www.firstdata.com) - CA, US
107
103
  * [FirstPay](http://www.first-pay.com) - US
108
104
  * [Garanti Sanal POS](https://ccpos.garanti.com.tr/ccRaporlar/garanti/ccReports) - US, TR
109
105
  * [HDFC](http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i) - IN
@@ -116,6 +112,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
116
112
  * [Litle](http://www.litle.com/) - US
117
113
  * [Merchant e-Solutions](http://merchante-solutions.com/) - US
118
114
  * [MerchantWare](http://merchantwarehouse.com/merchantware) - US
115
+ * [Merchant Warrior] (http://merchantwarrior.com) - AU
119
116
  * [Mercury](http://www.mercurypay.com) - US
120
117
  * [MasterCard Internet Gateway Service (MiGS)](http://mastercard.com/mastercardsps) - AU, AE, BD, BN, EG, HK, ID, IN, JO, KW, LB, LK, MU, MV, MY, NZ, OM, PH, QA, SA, SG, TT, VN
121
118
  * [Modern Payments](http://www.modpay.com) - US
@@ -125,6 +122,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
125
122
  * [NELiX TransaX Gateway](http://www.nelixtransax.com) - US
126
123
  * [Netaxept](http://www.betalingsterminal.no/Netthandel-forside) - NO, DK, SE, FI
127
124
  * [NETbilling](http://www.netbilling.com) - US
125
+ * [NetPay](http://www.netpay.com.mx) - MX
128
126
  * [NetRegistry](http://www.netregistry.com.au) - AU
129
127
  * [NMI](http://nmi.com/) - US
130
128
  * [Ogone DirectLink](http://www.ogone.com) - BE, DE, FR, NL, AT, CH
@@ -142,6 +140,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
142
140
  * [PayPal Website Payments Pro (US)](https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside) - US
143
141
  * [PaySecure](http://www.commsecure.com.au/paysecure.shtml) - AU
144
142
  * [PayWay](https://www.payway.com.au) - AU
143
+ * [Pin](http://www.pin.net.au/) - AU
145
144
  * [Plug'n Pay](http://www.plugnpay.com/) - US
146
145
  * [Psigate](http://www.psigate.com/) - CA
147
146
  * [PSL Payment Solutions](http://www.paymentsolutionsltd.com/) - UK
@@ -159,6 +158,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
159
158
  * [SecurePay](http://www.securepay.com/) - US
160
159
  * [SecurePayTech](http://www.securepaytech.com/) - NZ
161
160
  * [SkipJack](http://www.skipjack.com/) - US, CA
161
+ * [Spreedly Core](https://spreedlycore.com/) - AD, AE, AT, AU, BD, BE, BG, BN, CA, CH, CY, CZ, DE, DK, EE, EG, ES, FI, FR, GB, GI, GR, HK, HU, ID, IE, IL, IM, IN, IS, IT, JO, KW, LB, LI, LK, LT, LU, LV, MC, MT, MU, MV, MX, MY, NL, NO, NZ, OM, PH, PL, PT, QA, RO, SA, SE, SG, SI, SK, SM, TR, TT, UM, US, VA, VN, ZA
162
162
  * [Stripe](https://stripe.com/) - US
163
163
  * [TransFirst](http://www.transfirst.com/) - US
164
164
  * [TrustCommerce](http://www.trustcommerce.com/) - US
@@ -211,3 +211,5 @@ Please don't touch the CHANGELOG in your pull requests, we'll add the appropriat
211
211
  at release time.
212
212
 
213
213
  [![Build Status](https://secure.travis-ci.org/Shopify/active_merchant.png)](http://travis-ci.org/Shopify/active_merchant)
214
+
215
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Shopify/active_merchant)
@@ -3,21 +3,21 @@ module ActiveMerchant #:nodoc:
3
3
  # The Check object is a plain old Ruby object, similar to CreditCard. It supports validation
4
4
  # of necessary attributes such as checkholder's name, routing and account numbers, but it is
5
5
  # not backed by any database.
6
- #
6
+ #
7
7
  # You may use Check in place of CreditCard with any gateway that supports it. Currently, only
8
8
  # +BraintreeGateway+ supports the Check object.
9
9
  class Check
10
10
  include Validateable
11
-
11
+
12
12
  attr_accessor :first_name, :last_name, :routing_number, :account_number, :account_holder_type, :account_type, :number
13
-
13
+
14
14
  # Used for Canadian bank accounts
15
15
  attr_accessor :institution_number, :transit_number
16
-
16
+
17
17
  def name
18
18
  @name ||= "#{@first_name} #{@last_name}".strip
19
19
  end
20
-
20
+
21
21
  def name=(value)
22
22
  return if value.blank?
23
23
 
@@ -26,25 +26,29 @@ module ActiveMerchant #:nodoc:
26
26
  @last_name = segments.pop
27
27
  @first_name = segments.join(' ')
28
28
  end
29
-
29
+
30
30
  def validate
31
31
  [:name, :routing_number, :account_number].each do |attr|
32
32
  errors.add(attr, "cannot be empty") if self.send(attr).blank?
33
33
  end
34
-
34
+
35
35
  errors.add(:routing_number, "is invalid") unless valid_routing_number?
36
-
36
+
37
37
  errors.add(:account_holder_type, "must be personal or business") if
38
38
  !account_holder_type.blank? && !%w[business personal].include?(account_holder_type.to_s)
39
-
39
+
40
40
  errors.add(:account_type, "must be checking or savings") if
41
41
  !account_type.blank? && !%w[checking savings].include?(account_type.to_s)
42
42
  end
43
-
43
+
44
44
  def type
45
45
  'check'
46
46
  end
47
-
47
+
48
+ def check?
49
+ true
50
+ end
51
+
48
52
  # Routing numbers may be validated by calculating a checksum and dividing it by 10. The
49
53
  # formula is:
50
54
  # (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
@@ -181,7 +181,7 @@ module ActiveMerchant #:nodoc:
181
181
  def display_number
182
182
  self.class.mask(number)
183
183
  end
184
-
184
+
185
185
  def first_digits
186
186
  self.class.first_digits(number)
187
187
  end
@@ -209,6 +209,10 @@ module ActiveMerchant #:nodoc:
209
209
  require_verification_value
210
210
  end
211
211
 
212
+ def check?
213
+ false
214
+ end
215
+
212
216
  private
213
217
 
214
218
  def before_validate #:nodoc:
@@ -1,21 +1,21 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  module CreditCardFormatting
4
-
5
- # This method is used to format numerical information pertaining to credit cards.
6
- #
4
+
5
+ # This method is used to format numerical information pertaining to credit cards.
6
+ #
7
7
  # format(2005, :two_digits) # => "05"
8
8
  # format(05, :four_digits) # => "0005"
9
9
  def format(number, option)
10
10
  return '' if number.blank?
11
-
11
+
12
12
  case option
13
- when :two_digits ; sprintf("%.2i", number)[-2..-1]
14
- when :four_digits ; sprintf("%.4i", number)[-4..-1]
13
+ when :two_digits ; sprintf("%.2i", number.to_i)[-2..-1]
14
+ when :four_digits ; sprintf("%.4i", number.to_i)[-4..-1]
15
15
  else number
16
16
  end
17
17
  end
18
-
18
+
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -62,7 +62,7 @@ module ActiveMerchant #:nodoc:
62
62
  include Utils
63
63
 
64
64
  DEBIT_CARDS = [ :switch, :solo ]
65
- CURRENCIES_WITHOUT_FRACTIONS = [ 'JPY', 'HUF' ]
65
+ CURRENCIES_WITHOUT_FRACTIONS = [ 'JPY', 'HUF', 'TWD' ]
66
66
  CREDIT_DEPRECATION_MESSAGE = "Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead."
67
67
 
68
68
  cattr_reader :implementations
@@ -41,7 +41,9 @@ module ActiveMerchant #:nodoc:
41
41
  RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT = 0, 2, 3
42
42
  AVS_RESULT_CODE, TRANSACTION_ID, CARD_CODE_RESPONSE_CODE = 5, 6, 38
43
43
 
44
- self.supported_countries = ['US']
44
+ self.default_currency = 'USD'
45
+
46
+ self.supported_countries = ['US', 'CA', 'GB']
45
47
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
46
48
  self.homepage_url = 'http://www.authorize.net/'
47
49
  self.display_name = 'Authorize.Net'
@@ -85,6 +87,7 @@ module ActiveMerchant #:nodoc:
85
87
  # * <tt>options</tt> -- A hash of optional parameters.
86
88
  def authorize(money, creditcard, options = {})
87
89
  post = {}
90
+ add_currency_code(post, money, options)
88
91
  add_invoice(post, options)
89
92
  add_creditcard(post, creditcard)
90
93
  add_address(post, options)
@@ -103,6 +106,7 @@ module ActiveMerchant #:nodoc:
103
106
  # * <tt>options</tt> -- A hash of optional parameters.
104
107
  def purchase(money, creditcard, options = {})
105
108
  post = {}
109
+ add_currency_code(post, money, options)
106
110
  add_invoice(post, options)
107
111
  add_creditcard(post, creditcard)
108
112
  add_address(post, options)
@@ -328,6 +332,10 @@ module ActiveMerchant #:nodoc:
328
332
  request
329
333
  end
330
334
 
335
+ def add_currency_code(post, money, options)
336
+ post[:currency_code] = options[:currency] || currency(money)
337
+ end
338
+
331
339
  def add_invoice(post, options)
332
340
  post[:invoice_num] = options[:order_id]
333
341
  post[:description] = options[:description]
@@ -93,8 +93,8 @@ module ActiveMerchant #:nodoc:
93
93
  # * <tt>:login</tt> -- The Authorize.Net API Login ID (REQUIRED)
94
94
  # * <tt>:password</tt> -- The Authorize.Net Transaction Key. (REQUIRED)
95
95
  # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
96
- # * <tt>:delimiter</tt> -- The delimiter used in the direct response. Default is ',' (comma).
97
96
  # Otherwise, perform transactions against the production server.
97
+ # * <tt>:delimiter</tt> -- The delimiter used in the direct response. Default is ',' (comma).
98
98
  def initialize(options = {})
99
99
  requires!(options, :login, :password)
100
100
  super
@@ -468,7 +468,11 @@ module ActiveMerchant #:nodoc:
468
468
  private
469
469
 
470
470
  def expdate(credit_card)
471
- sprintf('%04d-%02d', credit_card.year, credit_card.month)
471
+ if credit_card.year.present? && credit_card.month.present?
472
+ sprintf('%04d-%02d', credit_card.year, credit_card.month)
473
+ else
474
+ 'XXXX'
475
+ end
472
476
  end
473
477
 
474
478
  def build_request(action, options = {})
@@ -599,8 +603,11 @@ module ActiveMerchant #:nodoc:
599
603
  end
600
604
 
601
605
  def build_create_customer_profile_transaction_request(xml, options)
606
+ options[:extra_options] ||= {}
607
+ options[:extra_options].merge!('x_test_request' => 'TRUE') if @options[:test]
608
+
602
609
  add_transaction(xml, options[:transaction])
603
- xml.tag!('extraOptions', "x_test_request=TRUE") if @options[:test]
610
+ tag_unless_blank(xml, 'extraOptions', format_extra_options(options[:extra_options]))
604
611
 
605
612
  xml.target!
606
613
  end
@@ -652,7 +659,7 @@ module ActiveMerchant #:nodoc:
652
659
  tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
653
660
  xml.tag!('transId', transaction[:trans_id])
654
661
  when :refund
655
- #TODO - add lineItems and extraOptions fields
662
+ #TODO - add lineItems field
656
663
  xml.tag!('amount', transaction[:amount])
657
664
  tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
658
665
  tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
@@ -849,6 +856,10 @@ module ActiveMerchant #:nodoc:
849
856
  xml.tag!(tag_name, data) unless data.blank? || data.nil?
850
857
  end
851
858
 
859
+ def format_extra_options(options)
860
+ options.map{ |k, v| "#{k}=#{v}" }.join(',') unless options.nil?
861
+ end
862
+
852
863
  def parse_direct_response(params)
853
864
  delimiter = @options[:delimiter] || ','
854
865
  direct_response = {'raw' => params}
@@ -91,8 +91,8 @@ module ActiveMerchant #:nodoc:
91
91
  # * <tt>:login</tt> -- The Balanced API Secret (REQUIRED)
92
92
  def initialize(options = {})
93
93
  requires!(options, :login)
94
- initialize_marketplace(options[:marketplace] || load_marketplace)
95
94
  super
95
+ initialize_marketplace(options[:marketplace] || load_marketplace)
96
96
  end
97
97
 
98
98
  # Performs an authorization (Hold in Balanced nonclementure), which
@@ -197,6 +197,7 @@ module ActiveMerchant #:nodoc:
197
197
  post[:hold_uri] = authorization
198
198
  post[:amount] = money if money
199
199
  post[:description] = options[:description] if options[:description]
200
+ post[:on_behalf_of_uri] = options[:on_behalf_of_uri] if options[:on_behalf_of_uri]
200
201
 
201
202
  create_transaction(:post, @debits_uri, post)
202
203
  rescue Error => ex
@@ -234,11 +235,16 @@ module ActiveMerchant #:nodoc:
234
235
  # * <tt>`:amount`<tt> -- specify an amount if you want to perform a
235
236
  # partial refund. This value will default to the total amount of the
236
237
  # debit that has not been refunded so far.
237
- def refund(debit_uri, options = {})
238
+ def refund(amount, debit_uri = "deprecated", options = {})
239
+ if(debit_uri == "deprecated" || debit_uri.kind_of?(Hash))
240
+ deprecated "Calling the refund method without an amount parameter is deprecated and will be removed in a future version."
241
+ return refund(options[:amount], amount, options)
242
+ end
243
+
238
244
  requires!(debit_uri)
239
245
  post = {}
240
246
  post[:debit_uri] = debit_uri
241
- post[:amount] = options[:amount] if options[:amount]
247
+ post[:amount] = amount
242
248
  post[:description] = options[:description]
243
249
  create_transaction(:post, @refunds_uri, post)
244
250
  rescue Error => ex