Class Index [+]

Quicksearch

ActiveMerchant::Billing::FederatedCanadaGateway

Constants

URL

Same URL for both test and live, testing is done by using the test username (demo) and password (password).

ERROR

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 23
23:       def initialize(options = {})
24:         requires!(options, :login, :password)
25:         @options = options
26:         super
27:       end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 38
38:       def authorize(money, creditcard, options = {})
39:         post = {}
40:         add_invoice(post, options)
41:         add_creditcard(post, creditcard)
42:         add_address(post, options)
43:         add_customer_data(post, options)
44:         commit('auth', money, post)
45:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 47
47:       def capture(money, authorization, options = {})
48:         options[:transactionid] = authorization
49:         commit('capture', money, options)
50:       end
credit(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 61
61:       def credit(money, authorization, options = {})
62:         deprecated CREDIT_DEPRECATION_MESSAGE
63:         refund(money, authorization, options)
64:       end
purchase(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 29
29:       def purchase(money, creditcard, options = {})
30:         post = {}
31:         add_invoice(post, options)
32:         add_creditcard(post, creditcard)
33:         add_address(post, options)
34:         add_customer_data(post, options)
35:         commit('sale', money, post)
36:       end
refund(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 57
57:       def refund(money, authorization, options = {})
58:         commit('refund', money, options.merge(:transactionid => authorization))
59:       end
void(authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 52
52:       def void(authorization, options = {})
53:         options[:transactionid] = authorization
54:         commit('void', nil, options)
55:       end

Private Instance Methods

add_address(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 75
75:       def add_address(post, options)
76:         if address = (options[:billing_address] || options[:address])
77:           post[:company] = address[:company]
78:           post[:address1] = address[:address1]
79:           post[:address2] = address[:address2]
80:           post[:city]    = address[:city]
81:           post[:state]   = address[:state]
82:           post[:zip]     = address[:zip]
83:           post[:country] = address[:country]
84:           post[:phone] = address[:phone]
85:         end
86:         if address = options[:shipping_address]
87:           post[:shipping_firstname] = address[:first_name]
88:           post[:shipping_lastname] = address[:last_name]
89:           post[:shipping_company] = address[:company]
90:           post[:shipping_address1] = address[:address1]
91:           post[:shipping_address2] = address[:address2]
92:           post[:shipping_city]    = address[:city]
93:           post[:shipping_state]   = address[:state]
94:           post[:shipping_zip]     = address[:zip]
95:           post[:shipping_country] = address[:country]
96:           post[:shipping_email]   = address[:email]
97:         end
98:       end
add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 105
105:       def add_creditcard(post, creditcard)
106:         post[:ccnumber] = creditcard.number
107:         post[:ccexp] = expdate(creditcard)
108:         post[:cvv] = creditcard.verification_value
109:       end
add_customer_data(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/federated_canada.rb, line 68
68:       def add_customer_data(post, options)
69:         post[:firstname] = options[:first_name]
70:         post[:lastname] = options[:last_name]
71: 
72:         post[:email] = options[:email]
73:       end
add_invoice(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 100
100:       def add_invoice(post, options)
101:         post[:orderid] = options[:order_id]
102:         post[:orderdescription] = options[:description]
103:       end
commit(action, money, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 125
125:       def commit(action, money, parameters)
126:         parameters[:amount] = amount(money)
127:         data = ssl_post(URL, post_data(action, parameters))
128:         response = parse(data)
129:         message = message_from(response)
130:         test_mode = test?
131: 
132:         Response.new(success?(response), message, response, 
133:           :test => test?,
134:           :authorization => response['transactionid'],
135:           :avs_result => {:code =>  response['avsresponse']},
136:           :cvv_result => response['cvvresponse']
137:         )
138:       end
expdate(creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 111
111:       def expdate(creditcard)
112:         year  = sprintf("%.4i", creditcard.year)
113:         month = sprintf("%.2i", creditcard.month)
114:         "#{month}#{year[-2..-1]}"
115:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 148
148:       def message_from(response)
149:         case response['response'].to_i
150:         when APPROVED
151:           "Transaction Approved"
152:         when DECLINED
153:           "Transaction Declined"
154:         else
155:           "Error in transaction data or system error"
156:         end
157:       end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 117
117:       def parse(body)
118:         body.split('&').inject({}) do |memo, x|
119:           k, v = x.split('=')
120:           memo[k] = v
121:           memo
122:         end
123:       end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 159
159:       def post_data(action, parameters = {})
160:         parameters[:type] = action
161:         parameters[:username] = @options[:login]
162:         parameters[:password] = @options[:password]
163:         parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
164:       end
success?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 140
140:       def success?(response)
141:         response['response'] == '1'
142:       end
test?() click to toggle source
     # File lib/active_merchant/billing/gateways/federated_canada.rb, line 144
144:       def test?
145:         (@options[:login].eql?('demo')) && (@options[:password].eql?('password'))
146:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.