lib/active_merchant/billing/gateways/psigate.rb
# Set up the parameters hash just once so we don't have to do it
# for every action. 
Set up the parameters hash just once so we don't have to do it
for every action.
Set up the parameters hash just once so we don ' t have to do it for every action .
def parameters(money, creditcard, options = {})  
        params = {
          :StoreID => @options[:login],
          :Passphrase => @options[:password],
          :TestResult => options[:test_result],
          :OrderID => options[:order_id],
          :UserID => options[:user_id],
          :Phone => options[:phone],
          :Fax => options[:fax],
          :Email => options[:email],
          :PaymentType => "CC",
          :CardAction => options[:CardAction],
          :CustomerIP => options[:ip],
          :SubTotal => amount(money),
          :Tax1 => options[:tax1],
          :Tax2 => options[:tax2],
          :ShippingTotal => options[:shipping_total],
        }
        if creditcard
          exp_month = sprintf("%.2i", creditcard.month) unless creditcard.month.blank?
          exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank?
          card_id_code = creditcard.verification_value.blank? ? nil : "1"
          params.update( 
            :CardNumber => creditcard.number,
            :CardExpMonth => exp_month,
            :CardExpYear => exp_year,
            :CardIDCode => card_id_code,
            :CardIDNumber => creditcard.verification_value
          )
        end
        if address = options[:billing_address] || options[:address]           
          params[:Bname] = address[:name] || creditcard.name 
          params[:Baddress1]    = address[:address1] unless address[:address1].blank?
          params[:Baddress2]    = address[:address2] unless address[:address2].blank?
          params[:Bcity]        = address[:city]     unless address[:city].blank?
          params[:Bprovince]    = address[:state]    unless address[:state].blank?
          params[:Bpostalcode]  = address[:zip]      unless address[:zip].blank?
          params[:Bcountry]     = address[:country]  unless address[:country].blank?
          params[:Bcompany]     = address[:company]  unless address[:company].blank?
        end
        if address = options[:shipping_address]
          params[:Sname]        = address[:name] || creditcard.name 
          params[:Saddress1]    = address[:address1] unless address[:address1].blank?
          params[:Saddress2]    = address[:address2] unless address[:address2].blank?
          params[:Scity]        = address[:city]     unless address[:city].blank?
          params[:Sprovince]    = address[:state]    unless address[:state].blank?
          params[:Spostalcode]  = address[:zip]      unless address[:zip].blank?
          params[:Scountry]     = address[:country]  unless address[:country].blank?
          params[:Scompany]     = address[:company]  unless address[:company].blank?
        end
        return params
      end
def parameters ( money , creditcard , options = { } ) params = { :StoreID => @options [ :login ] , :Passphrase => @options [ :password ] , :TestResult => options [ :test_result ] , :OrderID => options [ :order_id ] , :UserID => options [ :user_id ] , :Phone => options [ :phone ] , :Fax => options [ :fax ] , :Email => options [ :email ] , :PaymentType => "CC" , :CardAction => options [ :CardAction ] , :CustomerIP => options [ :ip ] , :SubTotal => amount ( money ) , :Tax1 => options [ :tax1 ] , :Tax2 => options [ :tax2 ] , :ShippingTotal => options [ :shipping_total ] , } if creditcard exp_month = sprintf ( "%.2i" , creditcard . month ) unless creditcard . month . blank? exp_year = creditcard . year . to_s [ 2 , 2 ] unless creditcard . year . blank? card_id_code = creditcard . verification_value . blank? ? nil : "1" params . update ( :CardNumber => creditcard . number , :CardExpMonth => exp_month , :CardExpYear => exp_year , :CardIDCode => card_id_code , :CardIDNumber => creditcard . verification_value ) end if address = options [ :billing_address ] || options [ :address ] params [ :Bname ] = address [ :name ] || creditcard . name params [ :Baddress1 ] = address [ :address1 ] unless address [ :address1 ] . blank? params [ :Baddress2 ] = address [ :address2 ] unless address [ :address2 ] . blank? params [ :Bcity ] = address [ :city ] unless address [ :city ] . blank? params [ :Bprovince ] = address [ :state ] unless address [ :state ] . blank? params [ :Bpostalcode ] = address [ :zip ] unless address [ :zip ] . blank? params [ :Bcountry ] = address [ :country ] unless address [ :country ] . blank? params [ :Bcompany ] = address [ :company ] unless address [ :company ] . blank? end if address = options [ :shipping_address ] params [ :Sname ] = address [ :name ] || creditcard . name params [ :Saddress1 ] = address [ :address1 ] unless address [ :address1 ] . blank? params [ :Saddress2 ] = address [ :address2 ] unless address [ :address2 ] . blank? params [ :Scity ] = address [ :city ] unless address [ :city ] . blank? params [ :Sprovince ] = address [ :state ] unless address [ :state ] . blank? params [ :Spostalcode ] = address [ :zip ] unless address [ :zip ] . blank? params [ :Scountry ] = address [ :country ] unless address [ :country ] . blank? params [ :Scompany ] = address [ :company ] unless address [ :company ] . blank? end return params end
Set up the parameters hash just once so we don't have to do it
for every action.
Set up the parameters hash just once so we don ' t have to do it for every action .
# General order paramters # Credit Card paramaters # Financial paramters
money
<not_specific>
creditcard
<not_specific>
options
<not_specific>