activemerchant 1.29.1 → 1.31.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 (53) hide show
  1. data/CHANGELOG +58 -0
  2. data/CONTRIBUTORS +27 -0
  3. data/README.md +45 -41
  4. data/lib/active_merchant/billing/check.rb +11 -11
  5. data/lib/active_merchant/billing/credit_card.rb +1 -1
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +8 -8
  7. data/lib/active_merchant/billing/gateway.rb +2 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +9 -1
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +15 -4
  10. data/lib/active_merchant/billing/gateways/balanced.rb +9 -3
  11. data/lib/active_merchant/billing/gateways/banwire.rb +15 -1
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +6 -2
  13. data/lib/active_merchant/billing/gateways/beanstream.rb +26 -24
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +5 -2
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +55 -22
  16. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  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 +232 -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 +3 -5
  25. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/nab_transact.rb +20 -3
  27. data/lib/active_merchant/billing/gateways/netbilling.rb +1 -0
  28. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  29. data/lib/active_merchant/billing/gateways/ogone.rb +6 -4
  30. data/lib/active_merchant/billing/gateways/optimal_payment.rb +18 -3
  31. data/lib/active_merchant/billing/gateways/orbital.rb +9 -5
  32. data/lib/active_merchant/billing/gateways/payment_express.rb +62 -1
  33. data/lib/active_merchant/billing/gateways/paymill.rb +161 -0
  34. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/paypal_express.rb +17 -11
  36. data/lib/active_merchant/billing/gateways/pin.rb +157 -0
  37. data/lib/active_merchant/billing/gateways/qbms.rb +3 -2
  38. data/lib/active_merchant/billing/gateways/quickpay.rb +66 -28
  39. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -0
  40. data/lib/active_merchant/billing/gateways/smart_ps.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/spreedly_core.rb +235 -0
  42. data/lib/active_merchant/billing/gateways/stripe.rb +1 -0
  43. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -9
  44. data/lib/active_merchant/billing/gateways/worldpay.rb +19 -5
  45. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +4 -1
  46. data/lib/active_merchant/billing/integrations/paypal/notification.rb +39 -31
  47. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +13 -10
  48. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +14 -14
  49. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +2 -2
  50. data/lib/active_merchant/version.rb +1 -1
  51. data.tar.gz.sig +0 -0
  52. metadata +32 -24
  53. metadata.gz.sig +0 -0
data/CHANGELOG CHANGED
@@ -1,5 +1,63 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ == Version 1.31.0 (February 20, 2013)
4
+
5
+ * Worldpay: XML encoding is required to be ISO-8859-1 [dougal]
6
+ * Worldpay: Add card code for more supported card types [dougal]
7
+ * Ogone: Add action option [pwoestelandt]
8
+ * PayPal Express gateway: Add support for BuyerEmailOptInEnable [chrisrbnelson]
9
+ * Add Paymill gateway [duff]
10
+ * Add EVO Canada gateway [alexdunae]
11
+ * Fixed credit card and check interface, used correct method for checking payment type [jduff]
12
+
13
+ == Version 1.30.0 (February 13, 2013)
14
+
15
+ * Add FirstData Global Gateway e4 [frobcode]
16
+ * PaymentExpress: Add support for optional fields: ClientType and TxnData [moklett]
17
+ * PaymentExpress: Limit MerchantReference/description to 64 chars [moklett]
18
+ * Wirecard: description must be no more than 32 characters [moklett]
19
+ * Litle: Add support for passing a token to the authorize and purchase methods [forest]
20
+ * PayPal Common: Allow searching for transactions by ProfileID [aq1018]
21
+ * Add Spreedly Core gateway [duff]
22
+ * eWay Gateway: Return proper value for authorization [duff]
23
+ * eWay Gateway: Add support for refunds [duff]
24
+ * Quickpay: Add support for protocols 5 & 6 [twarberg]
25
+ * Banwire gateway: Handle JSON::ParserError [duff]
26
+ * Balanced gateway: Fix unspecified marketplace [duff]
27
+ * QBMS gateway: Allow partial addresses [duff]
28
+ * Authorize.Net CIM: Allow omitting card expiration date [shanebonham]
29
+ * Authorize.Net CIM: Add support for extraOptions to createCustomerProfileTransaction [tpiekos]
30
+ * Add NETPAY gateway [samlown]
31
+ * Balanced gateway: Add amount to the refund method signature [ntalbott]
32
+ * Orbital gateway: Fix void method signature [aprofeit, ntalbott]
33
+ * Eway Managed: Add 'query_customer' API as #retrieve [cdaloisio]
34
+ * NetPay: Fix the signature for void [duff]
35
+ * Cybersource: Add check support [bowmande]
36
+ * Moneris: Use a capture of $0 for void [ntalbott]
37
+ * PayPal Express integration: Fix received_at time zone [ntalbott]
38
+ * NAB Transact: Add refund capability [nagash]
39
+ * Stripe: Add support for application_fee [duff]
40
+ * SagePay: Add support for GiftAidPayment [duff]
41
+ * Wirecard: Add support for partial captures [richardblair]
42
+ * Add Pin gateway [madpilot]
43
+ * Balanced: Added support for on_behalf_of_uri to capture [cwise]
44
+ * Litle: Add support for passing an order_source [forest]
45
+ * Add Merchant Warrior gateway [pronix, Fodoj, ntalbott]
46
+ * Use v4 of the MerchantWare API for voiding transactions [melari]
47
+ * Add support for Authorize.net in CA and GB [melari]
48
+ * Send customer's IP to Beanstream for fraud review [melari]
49
+
50
+ == Version 1.29.3 (December 7, 2012)
51
+
52
+ * Braintree Blue: Better wiredump_device support [ntalbott]
53
+ * Braintree: Store sets vault id as authorization [ntalbott]
54
+ * WorldPay: Fix currencies without fractions like JPY and HUF by rounding down amount [Soleone]
55
+
56
+ == Version 1.29.2 (December 7, 2012)
57
+
58
+ * Moneris: fix issue with the default options not being merged [jduff]
59
+ * Sage Pay: Make 0000 default post code for everyone if missing [BlakeMesdag]
60
+
3
61
  == Version 1.29.1 (December 5, 2012)
4
62
 
5
63
  * Add eWay Rapid 3.0 gateway [ntalbott]
data/CONTRIBUTORS CHANGED
@@ -357,3 +357,30 @@ 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 (February 2013)
374
+
375
+ * Ben Bruscella (benbruscella)
376
+ * Дмитрий Василец (pronix)
377
+ * Kirill Shirinkin (Fodoj)
378
+ * Nathaniel Talbott (ntalbott)
379
+
380
+ Paymill (February 2013)
381
+
382
+ * Duff O'Melia (duff)
383
+
384
+ EVO Canada (February 2013)
385
+
386
+ * Alex Dunae (alexdunae)
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).
@@ -99,11 +94,13 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
99
94
  * [Efsnet](http://www.concordefsnet.com/) - US
100
95
  * [Elavon MyVirtualMerchant](http://www.elavon.com) - US, CA
101
96
  * [ePay](http://www.epay.dk/) - DK, SE, NO
97
+ * [EVO Canada](http://www.evocanada.com/) - CA
102
98
  * [eWAY](http://www.eway.com.au/) - AU
103
99
  * [eWay Rapid 3.0](http://www.eway.com.au/) - AU
104
100
  * [E-xact](http://www.e-xact.com) - CA, US
105
101
  * [Fat Zebra](https://www.fatzebra.com.au) - AU
106
102
  * [Federated Canada](http://www.federatedcanada.com/) - CA
103
+ * [FirstData Global Gateway e4](http://www.firstdata.com) - CA, US
107
104
  * [FirstPay](http://www.first-pay.com) - US
108
105
  * [Garanti Sanal POS](https://ccpos.garanti.com.tr/ccRaporlar/garanti/ccReports) - US, TR
109
106
  * [HDFC](http://www.hdfcbank.com/sme/sme-details/merchant-services/guzh6m0i) - IN
@@ -116,6 +113,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
116
113
  * [Litle](http://www.litle.com/) - US
117
114
  * [Merchant e-Solutions](http://merchante-solutions.com/) - US
118
115
  * [MerchantWare](http://merchantwarehouse.com/merchantware) - US
116
+ * [Merchant Warrior] (http://merchantwarrior.com) - AU
119
117
  * [Mercury](http://www.mercurypay.com) - US
120
118
  * [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
119
  * [Modern Payments](http://www.modpay.com) - US
@@ -125,6 +123,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
125
123
  * [NELiX TransaX Gateway](http://www.nelixtransax.com) - US
126
124
  * [Netaxept](http://www.betalingsterminal.no/Netthandel-forside) - NO, DK, SE, FI
127
125
  * [NETbilling](http://www.netbilling.com) - US
126
+ * [NetPay](http://www.netpay.com.mx) - MX
128
127
  * [NetRegistry](http://www.netregistry.com.au) - AU
129
128
  * [NMI](http://nmi.com/) - US
130
129
  * [Ogone DirectLink](http://www.ogone.com) - BE, DE, FR, NL, AT, CH
@@ -134,6 +133,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
134
133
  * [PayGate PayXML](http://paygate.co.za/) - US, ZA
135
134
  * [PayJunction](http://www.payjunction.com/) - US
136
135
  * [PaymentExpress](http://www.paymentexpress.com/) - AU, MY, NZ, SG, ZA, UK, US
136
+ * [Paymill](https://www.paymill.com) - AT, BE, CH, CZ, DE, DK, EE, ES, FI, FR, GB, HU, IE, IS, IT, LI, LU, LV, NL, NO, PL, PT, SE, SI, TR
137
137
  * [PayPal Express Checkout](https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside) - US, CA, SG, AU
138
138
  * [PayPal Payflow Pro](https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside) - US, CA, SG, AU
139
139
  * [PayPal Website Payments Pro (UK)](https://www.paypal.com/uk/cgi-bin/webscr?cmd=_wp-pro-overview-outside) - UK
@@ -142,6 +142,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
142
142
  * [PayPal Website Payments Pro (US)](https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside) - US
143
143
  * [PaySecure](http://www.commsecure.com.au/paysecure.shtml) - AU
144
144
  * [PayWay](https://www.payway.com.au) - AU
145
+ * [Pin](http://www.pin.net.au/) - AU
145
146
  * [Plug'n Pay](http://www.plugnpay.com/) - US
146
147
  * [Psigate](http://www.psigate.com/) - CA
147
148
  * [PSL Payment Solutions](http://www.paymentsolutionsltd.com/) - UK
@@ -159,6 +160,7 @@ The [ActiveMerchant Wiki](http://github.com/Shopify/active_merchant/wikis) conta
159
160
  * [SecurePay](http://www.securepay.com/) - US
160
161
  * [SecurePayTech](http://www.securepaytech.com/) - NZ
161
162
  * [SkipJack](http://www.skipjack.com/) - US, CA
163
+ * [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
164
  * [Stripe](https://stripe.com/) - US
163
165
  * [TransFirst](http://www.transfirst.com/) - US
164
166
  * [TrustCommerce](http://www.trustcommerce.com/) - US
@@ -211,3 +213,5 @@ Please don't touch the CHANGELOG in your pull requests, we'll add the appropriat
211
213
  at release time.
212
214
 
213
215
  [![Build Status](https://secure.travis-ci.org/Shopify/active_merchant.png)](http://travis-ci.org/Shopify/active_merchant)
216
+
217
+ [![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,25 @@ 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
48
  # Routing numbers may be validated by calculating a checksum and dividing it by 10. The
49
49
  # formula is:
50
50
  # (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
@@ -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' ]
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
@@ -130,7 +130,7 @@ module ActiveMerchant #:nodoc:
130
130
 
131
131
  # Are we running in test mode?
132
132
  def test?
133
- (@options[:test] || Base.test?)
133
+ (@options.has_key?(:test) ? @options[:test] : Base.test?)
134
134
  end
135
135
 
136
136
  private # :nodoc: all
@@ -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
@@ -71,7 +71,13 @@ module ActiveMerchant #:nodoc:
71
71
  end
72
72
 
73
73
  def commit(money, parameters)
74
- response = parse(ssl_post(URL, post_data(parameters)))
74
+ raw_response = ssl_post(URL, post_data(parameters))
75
+ begin
76
+ response = parse(raw_response)
77
+ rescue JSON::ParserError
78
+ response = json_error(raw_response)
79
+ end
80
+
75
81
  Response.new(success?(response),
76
82
  response["message"],
77
83
  response,
@@ -86,6 +92,14 @@ module ActiveMerchant #:nodoc:
86
92
  def post_data(parameters = {})
87
93
  parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
88
94
  end
95
+
96
+ def json_error(raw_response)
97
+ msg = 'Invalid response received from the Banwire API. Please contact Banwire support if you continue to receive this message.'
98
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
99
+ {
100
+ "message" => msg
101
+ }
102
+ end
89
103
  end
90
104
  end
91
105
  end
@@ -66,7 +66,7 @@ module ActiveMerchant #:nodoc:
66
66
  base.supported_countries = ['CA']
67
67
 
68
68
  # The card types supported by the payment gateway
69
- base.supported_cardtypes = [:visa, :master, :american_express]
69
+ base.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
70
70
 
71
71
  # The homepage URL of the gateway
72
72
  base.homepage_url = 'http://www.beanstream.com/'
@@ -119,6 +119,10 @@ module ActiveMerchant #:nodoc:
119
119
  end
120
120
  end
121
121
 
122
+ def add_customer_ip(post, options)
123
+ post[:customerIP] = options[:ip] if options[:ip]
124
+ end
125
+
122
126
  def void_action(original_transaction_type)
123
127
  (original_transaction_type == TRANSACTIONS[:refund]) ? :void_refund : :void_purchase
124
128
  end
@@ -288,7 +292,7 @@ module ActiveMerchant #:nodoc:
288
292
  results = {}
289
293
  if !body.nil?
290
294
  body.split(/&/).each do |pair|
291
- key, val = pair.split(/=/)
295
+ key, val = pair.split(/\=/)
292
296
  results[key.to_sym] = val.nil? ? nil : CGI.unescape(val)
293
297
  end
294
298
  end