activemerchant 1.29.1 → 1.33.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 (92) hide show
  1. data/CHANGELOG +137 -0
  2. data/CONTRIBUTORS +43 -0
  3. data/README.md +59 -51
  4. data/lib/active_merchant/billing/check.rb +15 -14
  5. data/lib/active_merchant/billing/credit_card.rb +9 -5
  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 +36 -8
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +17 -5
  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/barclays_epdq.rb +8 -1
  13. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -2
  14. data/lib/active_merchant/billing/gateways/beanstream.rb +26 -24
  15. data/lib/active_merchant/billing/gateways/blue_pay.rb +201 -185
  16. data/lib/active_merchant/billing/gateways/bogus.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/braintree_blue.rb +6 -2
  18. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +155 -0
  19. data/lib/active_merchant/billing/gateways/cc5.rb +156 -0
  20. data/lib/active_merchant/billing/gateways/cyber_source.rb +55 -22
  21. data/lib/active_merchant/billing/gateways/data_cash.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  23. data/lib/active_merchant/billing/gateways/eway.rb +114 -171
  24. data/lib/active_merchant/billing/gateways/eway_managed.rb +52 -22
  25. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  26. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +314 -0
  27. data/lib/active_merchant/billing/gateways/garanti.rb +0 -4
  28. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +13 -2
  29. data/lib/active_merchant/billing/gateways/iridium.rb +8 -2
  30. data/lib/active_merchant/billing/gateways/litle.rb +354 -105
  31. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +27 -6
  32. data/lib/active_merchant/billing/gateways/merchant_ware.rb +44 -9
  33. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +190 -0
  34. data/lib/active_merchant/billing/gateways/moneris.rb +3 -5
  35. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -1
  36. data/lib/active_merchant/billing/gateways/nab_transact.rb +20 -3
  37. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  38. data/lib/active_merchant/billing/gateways/netaxept.rb +65 -117
  39. data/lib/active_merchant/billing/gateways/netbilling.rb +1 -0
  40. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  41. data/lib/active_merchant/billing/gateways/ogone.rb +7 -5
  42. data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -18
  43. data/lib/active_merchant/billing/gateways/orbital.rb +190 -53
  44. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +14 -11
  45. data/lib/active_merchant/billing/gateways/payment_express.rb +62 -1
  46. data/lib/active_merchant/billing/gateways/paymill.rb +179 -0
  47. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +12 -7
  48. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +14 -9
  49. data/lib/active_merchant/billing/gateways/paypal_express.rb +42 -18
  50. data/lib/active_merchant/billing/gateways/pin.rb +165 -0
  51. data/lib/active_merchant/billing/gateways/qbms.rb +3 -2
  52. data/lib/active_merchant/billing/gateways/quickpay.rb +66 -28
  53. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +16 -11
  54. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +1 -1
  55. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +21 -16
  56. data/lib/active_merchant/billing/gateways/sage.rb +10 -5
  57. data/lib/active_merchant/billing/gateways/sage_pay.rb +7 -0
  58. data/lib/active_merchant/billing/gateways/smart_ps.rb +1 -1
  59. data/lib/active_merchant/billing/gateways/spreedly_core.rb +233 -0
  60. data/lib/active_merchant/billing/gateways/stripe.rb +25 -11
  61. data/lib/active_merchant/billing/gateways/transnational.rb +239 -0
  62. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -4
  63. data/lib/active_merchant/billing/gateways/webpay.rb +8 -0
  64. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -9
  65. data/lib/active_merchant/billing/gateways/worldpay.rb +60 -24
  66. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +1 -1
  67. data/lib/active_merchant/billing/integrations/direc_pay.rb +1 -1
  68. data/lib/active_merchant/billing/integrations/dwolla/common.rb +21 -0
  69. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +15 -6
  70. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +11 -6
  71. data/lib/active_merchant/billing/integrations/dwolla/return.rb +12 -4
  72. data/lib/active_merchant/billing/integrations/dwolla.rb +5 -12
  73. data/lib/active_merchant/billing/integrations/notification.rb +13 -8
  74. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +19 -3
  75. data/lib/active_merchant/billing/integrations/paypal/notification.rb +39 -31
  76. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +74 -0
  77. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +167 -0
  78. data/lib/active_merchant/billing/integrations/payu_in/return.rb +53 -0
  79. data/lib/active_merchant/billing/integrations/payu_in.rb +43 -0
  80. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +1 -0
  81. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +13 -10
  82. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +78 -15
  83. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +23 -0
  84. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +91 -0
  85. data/lib/active_merchant/billing/integrations/rbkmoney.rb +17 -0
  86. data/lib/active_merchant/billing/integrations/robokassa/common.rb +1 -1
  87. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +7 -3
  88. data/lib/active_merchant/billing/integrations/world_pay.rb +15 -8
  89. data/lib/active_merchant/version.rb +1 -1
  90. data.tar.gz.sig +0 -0
  91. metadata +124 -50
  92. metadata.gz.sig +0 -0
@@ -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
@@ -338,7 +338,8 @@ module ActiveMerchant #:nodoc:
338
338
  # * <tt>:type</tt> -- The type of transaction. Can be either <tt>:auth_only</tt>, <tt>:capture_only</tt>, <tt>:auth_capture</tt>, <tt>:prior_auth_capture</tt>, <tt>:refund</tt> or <tt>:void</tt>. (REQUIRED)
339
339
  # * <tt>:amount</tt> -- The amount for the tranaction. Formatted with a decimal. For example "4.95" (CONDITIONAL)
340
340
  # - :type == :void (NOT USED)
341
- # - :type == (:refund, :auth_only, :capture_only, :auth_capture, :prior_auth_capture) (REQUIRED)
341
+ # - :type == :refund (OPTIONAL)
342
+ # - :type == (:auth_only, :capture_only, :auth_capture, :prior_auth_capture) (REQUIRED)
342
343
  #
343
344
  # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL)
344
345
  # - :type == (:void, :prior_auth_capture) (OPTIONAL)
@@ -468,7 +469,11 @@ module ActiveMerchant #:nodoc:
468
469
  private
469
470
 
470
471
  def expdate(credit_card)
471
- sprintf('%04d-%02d', credit_card.year, credit_card.month)
472
+ if credit_card.year.present? && credit_card.month.present?
473
+ sprintf('%04d-%02d', credit_card.year, credit_card.month)
474
+ else
475
+ 'XXXX'
476
+ end
472
477
  end
473
478
 
474
479
  def build_request(action, options = {})
@@ -599,8 +604,11 @@ module ActiveMerchant #:nodoc:
599
604
  end
600
605
 
601
606
  def build_create_customer_profile_transaction_request(xml, options)
607
+ options[:extra_options] ||= {}
608
+ options[:extra_options].merge!('x_test_request' => 'TRUE') if @options[:test]
609
+
602
610
  add_transaction(xml, options[:transaction])
603
- xml.tag!('extraOptions', "x_test_request=TRUE") if @options[:test]
611
+ tag_unless_blank(xml, 'extraOptions', format_extra_options(options[:extra_options]))
604
612
 
605
613
  xml.target!
606
614
  end
@@ -652,7 +660,7 @@ module ActiveMerchant #:nodoc:
652
660
  tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
653
661
  xml.tag!('transId', transaction[:trans_id])
654
662
  when :refund
655
- #TODO - add lineItems and extraOptions fields
663
+ #TODO - add lineItems field
656
664
  xml.tag!('amount', transaction[:amount])
657
665
  tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
658
666
  tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
@@ -849,6 +857,10 @@ module ActiveMerchant #:nodoc:
849
857
  xml.tag!(tag_name, data) unless data.blank? || data.nil?
850
858
  end
851
859
 
860
+ def format_extra_options(options)
861
+ options.map{ |k, v| "#{k}=#{v}" }.join(',') unless options.nil?
862
+ end
863
+
852
864
  def parse_direct_response(params)
853
865
  delimiter = @options[:delimiter] || ','
854
866
  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
@@ -134,7 +134,14 @@ module ActiveMerchant #:nodoc:
134
134
  end
135
135
 
136
136
  def parse
137
- doc = REXML::Document.new(@response)
137
+ require 'iconv' unless String.method_defined?(:encode)
138
+ if String.method_defined?(:encode)
139
+ doc = REXML::Document.new(@response.encode("UTF-8", "ISO-8859-1"))
140
+ else
141
+ ic = Iconv.new('UTF-8', 'ISO-8859-1')
142
+ doc = REXML::Document.new(ic.iconv(@response))
143
+ end
144
+
138
145
  auth_type = find(doc, "//Transaction/Type").to_s
139
146
 
140
147
  message = find(doc, "//Message/Text")
@@ -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
@@ -235,6 +239,7 @@ module ActiveMerchant #:nodoc:
235
239
 
236
240
  def add_recurring_invoice(post, options)
237
241
  post[:rbApplyTax1] = options[:apply_tax1]
242
+ post[:rbApplyTax2] = options[:apply_tax2]
238
243
  end
239
244
 
240
245
  def add_recurring_operation_type(post, operation)
@@ -288,7 +293,7 @@ module ActiveMerchant #:nodoc:
288
293
  results = {}
289
294
  if !body.nil?
290
295
  body.split(/&/).each do |pair|
291
- key, val = pair.split(/=/)
296
+ key, val = pair.split(/\=/)
292
297
  results[key.to_sym] = val.nil? ? nil : CGI.unescape(val)
293
298
  end
294
299
  end
@@ -6,34 +6,34 @@ module ActiveMerchant #:nodoc:
6
6
  # It is also named TD Canada Trust Online Mart payment gateway.
7
7
  # To learn more about the specification of Beanstream gateway, please read the OM_Direct_Interface_API.pdf,
8
8
  # which you can get from your Beanstream account or get from me by email.
9
- #
9
+ #
10
10
  # == Supported transaction types by Beanstream:
11
11
  # * +P+ - Purchase
12
12
  # * +PA+ - Pre Authorization
13
13
  # * +PAC+ - Pre Authorization Completion
14
- #
14
+ #
15
15
  # == Secure Payment Profiles:
16
16
  # BeanStream supports payment profiles (vaults). This allows you to store cc information with BeanStream and process subsequent transactions with a customer id.
17
17
  # Secure Payment Profiles must be enabled on your account (must be done over the phone).
18
18
  # Your API Access Passcode must be set in Administration => account settings => order settings.
19
19
  # To learn more about storing credit cards with the Beanstream gateway, please read the BEAN_Payment_Profiles.pdf (I had to phone BeanStream to request it.)
20
- #
21
- # == Notes
20
+ #
21
+ # == Notes
22
22
  # * Adding of order products information is not implemented.
23
23
  # * Ensure that country and province data is provided as a code such as "CA", "US", "QC".
24
24
  # * login is the Beanstream merchant ID, username and password should be enabled in your Beanstream account and passed in using the <tt>:user</tt> and <tt>:password</tt> options.
25
25
  # * Test your app with your true merchant id and test credit card information provided in the api pdf document.
26
- # * Beanstream does not allow Payment Profiles to be deleted with their API. The accounts are 'closed', but have to be deleted manually.
27
- #
26
+ # * Beanstream does not allow Payment Profiles to be deleted with their API. The accounts are 'closed', but have to be deleted manually.
27
+ #
28
28
  # Example authorization (Beanstream PA transaction type):
29
- #
29
+ #
30
30
  # twenty = 2000
31
31
  # gateway = BeanstreamGateway.new(
32
32
  # :login => '100200000',
33
33
  # :user => 'xiaobozz',
34
34
  # :password => 'password'
35
35
  # )
36
- #
36
+ #
37
37
  # credit_card = CreditCard.new(
38
38
  # :number => '4030000010001234',
39
39
  # :month => 8,
@@ -63,37 +63,39 @@ module ActiveMerchant #:nodoc:
63
63
  # )
64
64
  class BeanstreamGateway < Gateway
65
65
  include BeanstreamCore
66
-
66
+
67
67
  def authorize(money, source, options = {})
68
68
  post = {}
69
69
  add_amount(post, money)
70
70
  add_invoice(post, options)
71
- add_source(post, source)
71
+ add_source(post, source)
72
72
  add_address(post, options)
73
73
  add_transaction_type(post, :authorization)
74
+ add_customer_ip(post, options)
74
75
  commit(post)
75
76
  end
76
-
77
+
77
78
  def purchase(money, source, options = {})
78
79
  post = {}
79
- add_amount(post, money)
80
+ add_amount(post, money)
80
81
  add_invoice(post, options)
81
82
  add_source(post, source)
82
83
  add_address(post, options)
83
84
  add_transaction_type(post, purchase_action(source))
85
+ add_customer_ip(post, options)
84
86
  commit(post)
85
- end
86
-
87
+ end
88
+
87
89
  def void(authorization, options = {})
88
90
  reference, amount, type = split_auth(authorization)
89
-
91
+
90
92
  post = {}
91
93
  add_reference(post, reference)
92
94
  add_original_amount(post, amount)
93
95
  add_transaction_type(post, void_action(type))
94
96
  commit(post)
95
97
  end
96
-
98
+
97
99
  def recurring(money, source, options = {})
98
100
  post = {}
99
101
  add_amount(post, money)
@@ -104,7 +106,7 @@ module ActiveMerchant #:nodoc:
104
106
  add_recurring_type(post, options)
105
107
  commit(post)
106
108
  end
107
-
109
+
108
110
  def update_recurring(amount, source, options = {})
109
111
  post = {}
110
112
  add_recurring_amount(post, amount)
@@ -115,7 +117,7 @@ module ActiveMerchant #:nodoc:
115
117
  add_recurring_service(post, options)
116
118
  recurring_commit(post)
117
119
  end
118
-
120
+
119
121
  def cancel_recurring(options = {})
120
122
  post = {}
121
123
  add_recurring_operation_type(post, :cancel)
@@ -126,25 +128,25 @@ module ActiveMerchant #:nodoc:
126
128
  def interac
127
129
  @interac ||= BeanstreamInteracGateway.new(@options)
128
130
  end
129
-
131
+
130
132
  # To match the other stored-value gateways, like TrustCommerce,
131
133
  # store and unstore need to be defined
132
134
  def store(credit_card, options = {})
133
- post = {}
135
+ post = {}
134
136
  add_address(post, options)
135
- add_credit_card(post, credit_card)
137
+ add_credit_card(post, credit_card)
136
138
  add_secure_profile_variables(post,options)
137
139
  commit(post, true)
138
140
  end
139
-
141
+
140
142
  #can't actually delete a secure profile with the supplicaed API. This function sets the status of the profile to closed (C).
141
143
  #Closed profiles will have to removed manually.
142
144
  def delete(vault_id)
143
145
  update(vault_id, false, {:status => "C"})
144
146
  end
145
-
147
+
146
148
  alias_method :unstore, :delete
147
-
149
+
148
150
  # Update the values (such as CC expiration) stored at
149
151
  # the gateway. The CC number must be supplied in the
150
152
  # CreditCard object.