Class Index [+]

Quicksearch

ActiveMerchant::Billing::InstapayGateway

Constants

GATEWAY_URL
SUCCESS
SUCCESS_MESSAGE

Public Class Methods

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

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 28
28:       def authorize(money, creditcard, options = {})
29:         post = {}
30:         post[:authonly] = 1
31:         add_amount(post, money)
32:         add_invoice(post, options)
33:         add_creditcard(post, creditcard)
34:         add_address(post, options)
35:         add_customer_data(post, options)
36: 
37:         commit('ns_quicksale_cc', post)
38:       end
capture(money, authorization, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 51
51:       def capture(money, authorization, options = {})
52:         post = {}
53:         add_amount(post, money)
54:         add_reference(post, authorization)        
55:         commit('ns_quicksale_cc', post)
56:       end
purchase(money, creditcard, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 40
40:       def purchase(money, creditcard, options = {})
41:         post = {}
42:         add_amount(post, money)
43:         add_invoice(post, options)
44:         add_creditcard(post, creditcard)
45:         add_address(post, options)
46:         add_customer_data(post, options)
47: 
48:         commit('ns_quicksale_cc', post)
49:       end

Private Instance Methods

add_address(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 73
73:       def add_address(post, options)
74:         if address = options[:billing_address] || options[:address]
75:           post[:ci_billaddr1]   = address[:address1]
76:           post[:ci_billaddr2]   = address[:address2]
77:           post[:ci_billcity]    = address[:city]
78:           post[:ci_billstate]   = address[:state]
79:           post[:ci_billzip]     = address[:zip]
80:           post[:ci_billcountry] = address[:country]
81:           post[:ci_phone]       = address[:phone]
82:         end
83: 
84:         if address = options[:shipping_address]
85:           post[:ci_shipaddr1]   = address[:address1]
86:           post[:ci_shipaddr2]   = address[:address2]
87:           post[:ci_shipcity]    = address[:city]
88:           post[:ci_shipstate]   = address[:state]
89:           post[:ci_shipzip]     = address[:zip]
90:           post[:ci_shipcountry] = address[:country]  
91:         end
92:       end
add_amount(post, money) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 60
60:       def add_amount(post, money)
61:         post[:amount] = amount(money)
62:       end
add_creditcard(post, creditcard) click to toggle source
     # File lib/active_merchant/billing/gateways/instapay.rb, line 100
100:       def add_creditcard(post, creditcard)
101:         post[:ccnum]   = creditcard.number
102:         post[:expmon]  = format(creditcard.month, :two_digits)
103:         post[:cvv2]    = creditcard.verification_value if creditcard.verification_value?
104:         post[:expyear] = creditcard.year
105:         post[:ccname]  = creditcard.name
106:       end
add_customer_data(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 68
68:       def add_customer_data(post, options)
69:         post[:ci_email]       = options[:email]
70:         post["ci_IP Address"] = options[:ip]
71:       end
add_invoice(post, options) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 94
94:       def add_invoice(post, options)
95:         post[:merchantordernumber] = options[:order_id]
96:         post[:ci_memo]             = options[:description]
97:         post[:pocustomerrefid]     = options[:invoice]
98:       end
add_reference(post, reference) click to toggle source
    # File lib/active_merchant/billing/gateways/instapay.rb, line 64
64:       def add_reference(post, reference)
65:         post[:postonly] = reference
66:       end
commit(action, parameters) click to toggle source
     # File lib/active_merchant/billing/gateways/instapay.rb, line 140
140:       def commit(action, parameters)
141:         data = ssl_post GATEWAY_URL , post_data(action, parameters)
142:         response = parse(data)
143: 
144:         Response.new(response[:success] , response[:message], response,
145:           :authorization => response[:transaction_id],
146:           :avs_result => { :code => response[:avs_result] },
147:           :cvv_result => response[:cvv_result]
148:         )
149:       end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/instapay.rb, line 108
108:       def parse(body)
109:         results = {}
110:         fields = body.split("\r\n")
111:         
112:         response = fields[1].split('=')        
113:         response_data = response[1].split(':')
114:         
115:         if response[0] == SUCCESS
116:           results[:success] = true
117:           results[:message] = SUCCESS_MESSAGE
118:           results[:transaction_type] = response_data[0]
119:           results[:authorization_code] = response_data[1]
120:           results[:reference_number] = response_data[2]
121:           results[:batch_number] = response_data[3]
122:           results[:transaction_id] = response_data[4]
123:           results[:avs_result] = response_data[5]
124:           results[:authorize_net] = response_data[6]
125:           results[:cvv_result] = response_data[7]
126:         else
127:           results[:success] = false
128:           results[:result] = response_data[0]
129:           results[:response_code] = response_data[1]
130:           results[:message] = response_data[2]
131:         end
132: 
133:         fields[1..1].each do |pair|
134:           key, value = pair.split('=')
135:           results[key] = value
136:         end
137:         results
138:       end
post_data(action, parameters = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/instapay.rb, line 151
151:       def post_data(action, parameters = {})
152:         post = {}
153:         post[:acctid] = @options[:login]
154:         if(@options[:password])
155:           post[:merchantpin] = @options[:password]
156:         end
157:         post[:action] = action
158:         request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
159:         request
160:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.