lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.29.3 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.30.0

- old
+ new

@@ -39,11 +39,13 @@ APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4 RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT = 0, 2, 3 AVS_RESULT_CODE, TRANSACTION_ID, CARD_CODE_RESPONSE_CODE = 5, 6, 38 - self.supported_countries = ['US'] + self.default_currency = 'USD' + + self.supported_countries = ['US', 'CA', 'GB'] self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb] self.homepage_url = 'http://www.authorize.net/' self.display_name = 'Authorize.Net' CARD_CODE_ERRORS = %w( N S ) @@ -83,10 +85,11 @@ # * <tt>money</tt> -- The amount to be authorized as an Integer value in cents. # * <tt>creditcard</tt> -- The CreditCard details for the transaction. # * <tt>options</tt> -- A hash of optional parameters. def authorize(money, creditcard, options = {}) post = {} + add_currency_code(post, money, options) add_invoice(post, options) add_creditcard(post, creditcard) add_address(post, options) add_customer_data(post, options) add_duplicate_window(post) @@ -101,10 +104,11 @@ # * <tt>money</tt> -- The amount to be purchased as an Integer value in cents. # * <tt>creditcard</tt> -- The CreditCard details for the transaction. # * <tt>options</tt> -- A hash of optional parameters. def purchase(money, creditcard, options = {}) post = {} + add_currency_code(post, money, options) add_invoice(post, options) add_creditcard(post, creditcard) add_address(post, options) add_customer_data(post, options) add_duplicate_window(post) @@ -324,9 +328,13 @@ post[:encap_char] = "$" post[:solution_ID] = application_id if application_id.present? && application_id != "ActiveMerchant" request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join("&") request + end + + def add_currency_code(post, money, options) + post[:currency_code] = options[:currency] || currency(money) end def add_invoice(post, options) post[:invoice_num] = options[:order_id] post[:description] = options[:description]