Class Index [+]

Quicksearch

ActiveMerchant::Billing::QuickpayGateway

Constants

URL
MD5_CHECK_FIELDS
APPROVED

Public Class Methods

new(options = {}) click to toggle source

The login is the QuickpayId The password is the md5checkword from the Quickpay manager To use the API-key from the Quickpay manager, specify :api-key Using the API-key, requires that you use version 4. Specify :version => 4 in options.

    # File lib/active_merchant/billing/gateways/quickpay.rb, line 93
93:       def initialize(options = {})
94:         requires!(options, :login, :password)
95:         @protocol = options.delete(:version) || 3 # default to protocol version 3
96:         @options = options
97:         super
98:       end

Public Instance Methods

authorize(money, credit_card_or_reference, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 100
100:       def authorize(money, credit_card_or_reference, options = {})
101:         post = {}
102: 
103:         add_amount(post, money, options)
104:         add_invoice(post, options)
105:         add_creditcard_or_reference(post, credit_card_or_reference, options)
106:         add_autocapture(post, false)
107:         add_fraud_parameters(post, options)
108:         add_testmode(post)
109: 
110:         commit(recurring_or_authorize(credit_card_or_reference), post)
111:       end
capture(money, authorization, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 125
125:       def capture(money, authorization, options = {})
126:         post = {}
127: 
128:         add_reference(post, authorization)
129:         add_amount_without_currency(post, money)
130:         add_fraud_parameters(post, options)
131: 
132:         commit(:capture, post)
133:       end
credit(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 154
154:       def credit(money, identification, options = {})
155:         deprecated CREDIT_DEPRECATION_MESSAGE
156:         refund(money, identification, options)
157:       end
purchase(money, credit_card_or_reference, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 113
113:       def purchase(money, credit_card_or_reference, options = {})
114:         post = {}
115: 
116:         add_amount(post, money, options)
117:         add_creditcard_or_reference(post, credit_card_or_reference, options)
118:         add_invoice(post, options)
119:         add_fraud_parameters(post, options)
120:         add_autocapture(post, true)
121: 
122:         commit(recurring_or_authorize(credit_card_or_reference), post)
123:       end
refund(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 144
144:       def refund(money, identification, options = {})
145:         post = {}
146: 
147:         add_amount_without_currency(post, money)
148:         add_reference(post, identification)
149:         add_fraud_parameters(post, options)
150: 
151:         commit(:refund, post)
152:       end
store(creditcard, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 159
159:       def store(creditcard, options = {})
160:         post = {}
161: 
162:         add_creditcard(post, creditcard, options)
163:         add_invoice(post, options)
164:         add_description(post, options)
165:         add_fraud_parameters(post, options)
166:         add_testmode(post)
167: 
168:         commit(:subscribe, post)
169:       end
void(identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 135
135:       def void(identification, options = {})
136:         post = {}
137: 
138:         add_reference(post, identification)
139:         add_fraud_parameters(post, options)
140: 
141:         commit(:cancel, post)
142:       end

Private Instance Methods

add_amount(post, money, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 173
173:       def add_amount(post, money, options = {})
174:         post[:amount]   = amount(money)
175:         post[:currency] = options[:currency] || currency(money)
176:       end
add_amount_without_currency(post, money, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 178
178:       def add_amount_without_currency(post, money, options = {})
179:         post[:amount] = amount(money)
180:       end
add_autocapture(post, autocapture) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 205
205:       def add_autocapture(post, autocapture)
206:         post[:autocapture] = autocapture ? 1 : 0
207:       end
add_creditcard(post, credit_card, options) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 186
186:       def add_creditcard(post, credit_card, options)
187:         post[:cardnumber]     = credit_card.number
188:         post[:cvd]            = credit_card.verification_value
189:         post[:expirationdate] = expdate(credit_card)
190:         post[:cardtypelock]   = options[:cardtypelock] unless options[:cardtypelock].blank?
191:       end
add_creditcard_or_reference(post, credit_card_or_reference, options) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 197
197:       def add_creditcard_or_reference(post, credit_card_or_reference, options)
198:         if credit_card_or_reference.is_a?(String)
199:           add_reference(post, credit_card_or_reference)
200:         else
201:           add_creditcard(post, credit_card_or_reference, options)
202:         end
203:       end
add_description(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 213
213:       def add_description(post, options)
214:         post[:description] = options[:description]
215:       end
add_fraud_parameters(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 221
221:       def add_fraud_parameters(post, options)
222:         if @protocol == 4
223:           post[:fraud_remote_addr] = options[:fraud_remote_addr] if options[:fraud_remote_addr]
224:           post[:fraud_http_accept] = options[:fraud_http_accept] if options[:fraud_http_accept]
225:           post[:fraud_http_accept_language] = options[:fraud_http_accept_language] if options[:fraud_http_accept_language]
226:           post[:fraud_http_accept_encoding] = options[:fraud_http_accept_encoding] if options[:fraud_http_accept_encoding]
227:           post[:fraud_http_accept_charset] = options[:fraud_http_accept_charset] if options[:fraud_http_accept_charset]
228:           post[:fraud_http_referer] = options[:fraud_http_referer] if options[:fraud_http_referer]
229:           post[:fraud_http_user_agent] = options[:fraud_http_user_agent] if options[:fraud_http_user_agent]
230:         end
231:       end
add_invoice(post, options) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 182
182:       def add_invoice(post, options)
183:         post[:ordernumber] = format_order_number(options[:order_id])
184:       end
add_reference(post, identification) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 193
193:       def add_reference(post, identification)
194:         post[:transaction] = identification
195:       end
add_testmode(post) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 217
217:       def add_testmode(post)
218:         post[:testmode] = test? ? '1' : '0'
219:       end
commit(action, params) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 233
233:       def commit(action, params)
234:         response = parse(ssl_post(URL, post_data(action, params)))
235: 
236:         Response.new(successful?(response), message_from(response), response,
237:           :test => test?,
238:           :authorization => response[:transaction]
239:         )
240:       end
expdate(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 283
283:       def expdate(credit_card)
284:         year  = format(credit_card.year, :two_digits)
285:         month = format(credit_card.month, :two_digits)
286: 
287:         "#{year}#{month}"
288:       end
format_order_number(number) click to toggle source

Limited to 20 digits max

     # File lib/active_merchant/billing/gateways/quickpay.rb, line 291
291:       def format_order_number(number)
292:         number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
293:       end
generate_check_hash(action, params) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 272
272:       def generate_check_hash(action, params)
273:         string = MD5_CHECK_FIELDS[@protocol][action].collect do |key|
274:           params[key.to_sym]
275:         end.join('')
276: 
277:         # Add the md5checkword
278:         string << @options[:password].to_s
279: 
280:         Digest::MD5.hexdigest(string)
281:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 258
258:       def message_from(response)
259:         response[:qpstatmsg].to_s
260:       end
parse(data) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 246
246:       def parse(data)
247:         response = {}
248: 
249:         doc = REXML::Document.new(data)
250: 
251:         doc.root.elements.each do |element|
252:           response[element.name.to_sym] = element.text
253:         end
254: 
255:         response
256:       end
post_data(action, params = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 262
262:       def post_data(action, params = {})
263:         params[:protocol] = @protocol
264:         params[:msgtype]  = action.to_s
265:         params[:merchant] = @options[:login]
266:         params[:apikey] = @options[:apikey] if @options[:apikey]
267:         params[:md5check] = generate_check_hash(action, params)
268: 
269:         params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
270:       end
recurring_or_authorize(credit_card_or_reference) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 209
209:       def recurring_or_authorize(credit_card_or_reference)
210:         credit_card_or_reference.is_a?(String) ? :recurring : :authorize
211:       end
successful?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/quickpay.rb, line 242
242:       def successful?(response)
243:         response[:qpstat] == APPROVED
244:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.