Class Index [+]

Quicksearch

ActiveMerchant::Billing::PsigateGateway

Constants

TEST_URL
LIVE_URL
SUCCESS_MESSAGE
FAILURE_MESSAGE

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/psigate.rb, line 53
53:       def initialize(options = {})
54:         requires!(options, :login, :password)
55:         @options = options                          
56:         super      
57:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source

Psigate PreAuth

    # File lib/active_merchant/billing/gateways/psigate.rb, line 60
60:       def authorize(money, creditcard, options = {})
61:         requires!(options, :order_id)                                                          
62:         options.update({ :CardAction => "1" })
63:         commit(money, creditcard, options)      
64:       end
capture(money, authorization, options = {}) click to toggle source

Psigate PostAuth

    # File lib/active_merchant/billing/gateways/psigate.rb, line 74
74:       def capture(money, authorization, options = {})
75:         options.update({ :CardAction => "2", :order_id => authorization })
76:         commit(money, nil, options)
77:       end
credit(money, authorization, options = {}) click to toggle source

Psigate Credit

    # File lib/active_merchant/billing/gateways/psigate.rb, line 81
81:       def credit(money, authorization, options = {})
82:         deprecated CREDIT_DEPRECATION_MESSAGE
83:         refund(money, authorization, options)
84:       end
purchase(money, creditcard, options = {}) click to toggle source

Psigate Sale

    # File lib/active_merchant/billing/gateways/psigate.rb, line 67
67:       def purchase(money, creditcard, options = {})
68:         requires!(options, :order_id)                                                          
69:         options.update({ :CardAction => "0" })
70:         commit(money, creditcard, options)     
71:       end
refund(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/psigate.rb, line 86
86:       def refund(money, authorization, options = {})
87:         options.update({ :CardAction => "3", :order_id => authorization })
88:         commit(money, nil, options)
89:       end

Private Instance Methods

commit(money, creditcard, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/psigate.rb, line 93
 93:       def commit(money, creditcard, options = {}) 
 94:         response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(money, creditcard, options)))
 95: 
 96:         Response.new(successful?(response), message_from(response), response, 
 97:           :test => test?, 
 98:           :authorization => response[:orderid],
 99:           :avs_result => { :code => response[:avsresult] },
100:           :cvv_result => response[:cardidresult]
101:         )
102:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/psigate.rb, line 198
198:       def message_from(response)
199:         if response[:approved] == "APPROVED"
200:           return SUCCESS_MESSAGE
201:         else
202:           return FAILURE_MESSAGE if response[:errmsg].blank?
203:           return response[:errmsg].gsub(/[^\w]/, ' ').split.join(" ").capitalize
204:         end
205:       end
normalize(field) click to toggle source

Make a ruby type out of the response string

     # File lib/active_merchant/billing/gateways/psigate.rb, line 208
208:       def normalize(field)
209:         case field
210:         when "true"   then true
211:         when "false"  then false
212:         when ""       then nil
213:         when "null"   then nil
214:         else field
215:         end
216:       end
parameters(money, creditcard, options = {}) click to toggle source

Set up the parameters hash just once so we don’t have to do it for every action.

     # File lib/active_merchant/billing/gateways/psigate.rb, line 135
135:       def parameters(money, creditcard, options = {})  
136:         params = {
137:           # General order paramters
138:           :StoreID => @options[:login],
139:           :Passphrase => @options[:password],
140:           :TestResult => options[:test_result],
141:           :OrderID => options[:order_id],
142:           :UserID => options[:user_id],
143:           :Phone => options[:phone],
144:           :Fax => options[:fax],
145:           :Email => options[:email],
146:           
147:           # Credit Card paramaters
148:           :PaymentType => "CC",
149:           :CardAction => options[:CardAction],
150:           
151:           # Financial paramters
152:           :CustomerIP => options[:ip],
153:           :SubTotal => amount(money),
154:           :Tax1 => options[:tax1],
155:           :Tax2 => options[:tax2],
156:           :ShippingTotal => options[:shipping_total],
157:         }
158: 
159:         if creditcard
160:           exp_month = sprintf("%.2i", creditcard.month) unless creditcard.month.blank?
161:           exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank?
162:           card_id_code = creditcard.verification_value.blank? ? nil : "1"
163: 
164:           params.update( 
165:             :CardNumber => creditcard.number,
166:             :CardExpMonth => exp_month,
167:             :CardExpYear => exp_year,
168:             :CardIDCode => card_id_code,
169:             :CardIDNumber => creditcard.verification_value
170:           )
171:         end
172:         
173:         if address = options[:billing_address] || options[:address]           
174:           params[:Bname] = address[:name] || creditcard.name 
175:           params[:Baddress1]    = address[:address1] unless address[:address1].blank?
176:           params[:Baddress2]    = address[:address2] unless address[:address2].blank?
177:           params[:Bcity]        = address[:city]     unless address[:city].blank?
178:           params[:Bprovince]    = address[:state]    unless address[:state].blank?
179:           params[:Bpostalcode]  = address[:zip]      unless address[:zip].blank?
180:           params[:Bcountry]     = address[:country]  unless address[:country].blank?
181:           params[:Bcompany]     = address[:company]  unless address[:company].blank?
182:         end
183:         
184:         if address = options[:shipping_address]
185:           params[:Sname]        = address[:name] || creditcard.name 
186:           params[:Saddress1]    = address[:address1] unless address[:address1].blank?
187:           params[:Saddress2]    = address[:address2] unless address[:address2].blank?
188:           params[:Scity]        = address[:city]     unless address[:city].blank?
189:           params[:Sprovince]    = address[:state]    unless address[:state].blank?
190:           params[:Spostalcode]  = address[:zip]      unless address[:zip].blank?
191:           params[:Scountry]     = address[:country]  unless address[:country].blank?
192:           params[:Scompany]     = address[:company]  unless address[:company].blank?
193:         end
194:                 
195:         return params
196:       end
parse(xml) click to toggle source
     # File lib/active_merchant/billing/gateways/psigate.rb, line 108
108:       def parse(xml)
109:         response = {:message => "Global Error Receipt", :complete => false}
110: 
111:         xml = REXML::Document.new(xml)          
112:         xml.elements.each('//Result/*') do |node|
113: 
114:           response[node.name.downcase.to_sym] = normalize(node.text)
115: 
116:         end unless xml.root.nil?
117: 
118:         response
119:       end
post_data(money, creditcard, options) click to toggle source
     # File lib/active_merchant/billing/gateways/psigate.rb, line 121
121:       def post_data(money, creditcard, options)
122:         xml = REXML::Document.new
123:         xml << REXML::XMLDecl.new
124:         root  = xml.add_element("Order")
125:         
126:         for key, value in parameters(money, creditcard, options)
127:           root.add_element(key.to_s).text = value if value
128:         end    
129: 
130:         xml.to_s
131:       end
successful?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/psigate.rb, line 104
104:       def successful?(response)
105:         response[:approved] == "APPROVED"
106:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.