lib/active_merchant/billing/gateways/smart_ps.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/smart_ps.rb in activemerchant-1.80.0

- old
+ new

@@ -23,11 +23,11 @@ def authorize(money, creditcard, options = {}) post = {} add_invoice(post, options) add_payment_source(post, creditcard,options) add_address(post, options[:billing_address] || options[:address]) - add_address(post, options[:shipping_address], "shipping") + add_address(post, options[:shipping_address], 'shipping') add_customer_data(post, options) add_currency(post, money, options) add_taxes(post, options) add_processor(post, options) commit('auth', money, post) @@ -36,11 +36,11 @@ def purchase(money, payment_source, options = {}) post = {} add_invoice(post, options) add_payment_source(post, payment_source, options) add_address(post, options[:billing_address] || options[:address]) - add_address(post, options[:shipping_address], "shipping") + add_address(post, options[:shipping_address], 'shipping') add_customer_data(post, options) add_currency(post, money, options) add_taxes(post, options) add_processor(post, options) add_eci(post, options) @@ -87,11 +87,11 @@ # Update the values (such as CC expiration) stored at # the gateway. The CC number must be supplied in the # CreditCard object. def update(vault_id, creditcard, options = {}) post = {} - post[:customer_vault] = "update_customer" + post[:customer_vault] = 'update_customer' add_customer_vault_id(post, vault_id) add_creditcard(post, creditcard, options) add_address(post, options[:billing_address] || options[:address]) add_customer_data(post, options) @@ -107,11 +107,11 @@ end def delete(vault_id) post = {} - post[:customer_vault] = "delete_customer" + post[:customer_vault] = 'delete_customer' add_customer_vault_id(post, vault_id) commit(nil, nil, post) end # To match the other stored-value gateways, like TrustCommerce, @@ -136,21 +136,21 @@ if options.has_key? :ip post[:ipaddress] = options[:ip] end end - def add_address(post, address,prefix="") - prefix +="_" unless prefix.blank? + def add_address(post, address,prefix='') + prefix +='_' unless prefix.blank? unless address.blank? or address.values.blank? - post[prefix+"address1"] = address[:address1].to_s - post[prefix+"address2"] = address[:address2].to_s unless address[:address2].blank? - post[prefix+"company"] = address[:company].to_s - post[prefix+"phone"] = address[:phone].to_s - post[prefix+"zip"] = address[:zip].to_s - post[prefix+"city"] = address[:city].to_s - post[prefix+"country"] = address[:country].to_s - post[prefix+"state"] = address[:state].blank? ? 'n/a' : address[:state] + post[prefix+'address1'] = address[:address1].to_s + post[prefix+'address2'] = address[:address2].to_s unless address[:address2].blank? + post[prefix+'company'] = address[:company].to_s + post[prefix+'phone'] = address[:phone].to_s + post[prefix+'zip'] = address[:zip].to_s + post[prefix+'city'] = address[:city].to_s + post[prefix+'country'] = address[:country].to_s + post[prefix+'state'] = address[:state].blank? ? 'n/a' : address[:state] end end def add_currency(post, money, options) post[:currency] = options[:currency] || currency(money) @@ -180,11 +180,11 @@ params[:customer_vault_id] = vault_id end def add_creditcard(post, creditcard, options) if options[:store] - post[:customer_vault] = "add_customer" + post[:customer_vault] = 'add_customer' post[:customer_vault_id] = options[:store] unless options[:store] == true end post[:ccnumber] = creditcard.number post[:cvv] = creditcard.verification_value if creditcard.verification_value? post[:ccexp] = expdate(creditcard) @@ -192,11 +192,11 @@ post[:lastname] = creditcard.last_name end def add_check(post, check, options) if options[:store] - post[:customer_vault] = "add_customer" + post[:customer_vault] = 'add_customer' post[:customer_vault_id] = options[:store] unless options[:store] == true end post[:payment] = 'check' # Set transaction to ACH post[:checkname] = check.name # The name on the customer's Checking Account @@ -205,11 +205,11 @@ post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account post[:account_type] = check.account_type # The customer's type of ACH account end def add_sku(post,options) - post["product_sku_#"] = options[:sku] || options["product_sku_#"] + post['product_sku_#'] = options[:sku] || options['product_sku_#'] end def add_transaction(post, auth) post[:transactionid] = auth end @@ -229,53 +229,53 @@ end def commit(action, money, parameters) parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money response = parse( ssl_post(self.live_url, post_data(action,parameters)) ) - Response.new(response["response"] == "1", message_from(response), response, - :authorization => (response["transactionid"] || response["customer_vault_id"]), + Response.new(response['response'] == '1', message_from(response), response, + :authorization => (response['transactionid'] || response['customer_vault_id']), :test => test?, - :cvv_result => response["cvvresponse"], - :avs_result => { :code => response["avsresponse"] } + :cvv_result => response['cvvresponse'], + :avs_result => { :code => response['avsresponse'] } ) end def expdate(creditcard) - year = sprintf("%.04i", creditcard.year) - month = sprintf("%.02i", creditcard.month) + year = sprintf('%.04i', creditcard.year) + month = sprintf('%.02i', creditcard.month) "#{month}#{year[-2..-1]}" end def message_from(response) - case response["responsetext"] - when "SUCCESS", "Approved", nil # This is dubious, but responses from UPDATE are nil. - "This transaction has been approved" - when "DECLINE" - "This transaction has been declined" + case response['responsetext'] + when 'SUCCESS', 'Approved', nil # This is dubious, but responses from UPDATE are nil. + 'This transaction has been approved' + when 'DECLINE' + 'This transaction has been declined' else - response["responsetext"] + response['responsetext'] end end def post_data(action, parameters = {}) post = {} post[:username] = @options[:login] post[:password] = @options[:password] post[:type] = action if action - request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&") + request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&') request end def determine_funding_source(source) case when source.is_a?(String) then :vault when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card when card_brand(source) == 'check' then :check - else raise ArgumentError, "Unsupported funding source provided" + else raise ArgumentError, 'Unsupported funding source provided' end end end end end