Class Index [+]

Quicksearch

ActiveMerchant::Billing::FirstPayGateway

Constants

TEST_URL

both URLs are IP restricted

LIVE_URL
ACTIONS

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 34
34:       def initialize(options = {})
35:         requires!(options, :login, :password)
36:         @options = options
37:         super
38:       end

Public Instance Methods

credit(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 63
63:       def credit(money, reference, options = {})
64:         deprecated CREDIT_DEPRECATION_MESSAGE
65:         refund(money, reference, options)
66:       end
purchase(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 40
40:       def purchase(money, creditcard, options = {})
41:         post = FirstPayPostData.new
42:         add_invoice(post, options)
43:         add_creditcard(post, creditcard)
44:         add_address(post, options)
45:         add_customer_data(post, options)
46:         
47:         commit('sale', money, post)
48:       end
refund(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 50
50:       def refund(money, reference, options = {})
51:         requires!(options, :credit_card)
52: 
53:         post = FirstPayPostData.new
54:         add_invoice(post, options)
55:         add_creditcard(post, options[:credit_card])
56:         add_address(post, options)
57:         add_customer_data(post, options)
58:         add_credit_data(post, reference)
59:       
60:         commit('credit', money, post)
61:       end
void(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 68
68:       def void(money, creditcard, options = {})
69:         post = FirstPayPostData.new
70:         add_creditcard(post, creditcard)
71:         add_void_data(post, options)
72:         add_invoice(post, options)
73:         add_customer_data(post, options)
74:         
75:         commit('void', money, post)
76:       end

Private Instance Methods

add_address(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 86
86:       def add_address(post, options)
87:         if billing_address = options[:billing_address] || options[:address]
88:           post[:addr]     = billing_address[:address1].to_s + ' ' + billing_address[:address2].to_s
89:           post[:city]     = billing_address[:city]
90:           post[:state]    = billing_address[:state]
91:           post[:zip]      = billing_address[:zip]                             
92:           post[:country]  = billing_address[:country]
93:         end
94:       end
add_credit_data(post, transaction_id) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 113
113:       def add_credit_data(post, transaction_id)
114:         post[:transid] = transaction_id
115:       end
add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 100
100:       def add_creditcard(post, creditcard)
101:         post[:member] = creditcard.first_name.to_s + " " + creditcard.last_name.to_s
102:         post[:card] = creditcard.number
103:         post[:exp] = expdate(creditcard)
104:       end
add_customer_data(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 81
81:       def add_customer_data(post, options)
82:         post[:cardip] = options[:ip]
83:         post[:email] = options[:email]
84:       end
add_invoice(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/first_pay.rb, line 96
96:       def add_invoice(post, options)
97:         post[:trackid] = rand(Time.now.to_i)
98:       end
add_void_data(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 117
117:       def add_void_data(post, options)
118:         post[:transid] = options[:transactionid]
119:       end
commit(action, money, post) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 121
121:       def commit(action, money, post)
122:         response = parse( ssl_post(test? ? TEST_URL : LIVE_URL, post_data(action, post, money)) )
123:                 
124:         Response.new(response[:response] == 'CAPTURED', response[:message], response,
125:           :test => test?,
126:           :authorization => response[:authorization],
127:           :avs_result => { :code => response[:avsresponse] },
128:           :cvv_result => response[:cvvresponse])
129:       end
error_message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 161
161:       def error_message_from(response)
162:         # error messages use this format - '!ERROR! 704-MISSING BASIC DATA TYPE:card, exp, zip, addr, member, amount\n'
163:         response.split("! ")[1].chomp
164:       end
expdate(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 106
106:       def expdate(credit_card)
107:         year  = sprintf("%.4i", credit_card.year)
108:         month = sprintf("%.2i", credit_card.month)
109: 
110:         "#{month}#{year[-2..-1]}"
111:       end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 131
131:       def parse(body)
132:         response = {}
133:         
134:         # check for an error first
135:         if body.include?('!ERROR!')
136:           response[:response] = 'ERROR'
137:           response[:message] = error_message_from(body)
138:         else
139:           # a capture / not captured response will be : delimited
140:           split = body.split(':')
141:           response[:response] = split[0]
142:           
143:           # FirstPay docs are worthless. turns out the transactionid is required for credits
144:           # so we need to store that in authorization, not the actual auth.
145:           if response[:response] == 'CAPTURED'
146:             response[:message] = 'CAPTURED'
147:             response[:authorization] = split[9] # actually the transactionid
148:             response[:auth] = split[1]
149:             response[:avsresponse] = split[3]
150:             response[:cvvresponse] = split[17]
151:           else
152:             # NOT CAPTURED response
153:             response[:message] = split[1]
154:             response[:transactionid] = split[9]
155:           end
156:         end
157:         
158:         return response
159:       end
post_data(action, post, money) click to toggle source
     # File lib/active_merchant/billing/gateways/first_pay.rb, line 166
166:       def post_data(action, post, money)
167:         post[:vid]        = @options[:login]  
168:         post[:password]   = @options[:password]
169:         post[:action]     = ACTIONS[action]
170:         post[:amount]     = amount(money)
171:         
172:         return post.to_post_data
173:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.