class ActiveMerchant::Billing::VerifiGateway
Constants
- RESPONSE_CODE_MESSAGES
- SUCCESS
- TRANSACTIONS
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/verifi.rb, line 66 def initialize(options = {}) requires!(options, :login, :password) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 79 def capture(money, authorization, options = {}) capture_void_or_refund_template(:capture, money, authorization, options) end
credit(money, credit_card_or_authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 87 def credit(money, credit_card_or_authorization, options = {}) if credit_card_or_authorization.is_a?(String) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, credit_card_or_authorization, options) else sale_authorization_or_credit_template(:credit, money, credit_card_or_authorization, options) end end
purchase(money, credit_card, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 71 def purchase(money, credit_card, options = {}) sale_authorization_or_credit_template(:purchase, money, credit_card, options) end
refund(money, reference, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 96 def refund(money, reference, options = {}) capture_void_or_refund_template(:refund, money, reference, options) end
void(authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 83 def void(authorization, options = {}) capture_void_or_refund_template(:void, 0, authorization, options) end
Private Instance Methods
add_addresses(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 128 def add_addresses(post, options) if billing_address = options[:billing_address] || options[:address] post[:company] = billing_address[:company] post[:address1] = billing_address[:address1] post[:address2] = billing_address[:address2] post[:city] = billing_address[:city] post[:state] = billing_address[:state] post[:zip] = billing_address[:zip] post[:country] = billing_address[:country] post[:phone] = billing_address[:phone] post[:fax] = billing_address[:fax] end if shipping_address = options[:shipping_address] post[:shipping_firstname] = shipping_address[:first_name] post[:shipping_lastname] = shipping_address[:last_name] post[:shipping_company] = shipping_address[:company] post[:shipping_address1] = shipping_address[:address1] post[:shipping_address2] = shipping_address[:address2] post[:shipping_city] = shipping_address[:city] post[:shipping_state] = shipping_address[:state] post[:shipping_zip] = shipping_address[:zip] post[:shipping_country] = shipping_address[:country] post[:shipping_email] = shipping_address[:email] end end
add_credit_card(post, credit_card)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 120 def add_credit_card(post, credit_card) post[:ccnumber] = credit_card.number post[:ccexp] = expdate(credit_card) post[:firstname] = credit_card.first_name post[:lastname] = credit_card.last_name post[:cvv] = credit_card.verification_value end
add_customer_data(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 155 def add_customer_data(post, options) post[:email] = options[:email] post[:ipaddress] = options[:ip] end
add_invoice_data(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 160 def add_invoice_data(post, options) post[:orderid] = options[:order_id] post[:ponumber] = options[:invoice] post[:orderdescription] = options[:description] post[:tax] = options[:tax] post[:shipping] = options[:shipping] end
add_optional_data(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 168 def add_optional_data(post, options) post[:billing_method] = options[:billing_method] post[:website] = options[:website] post[:descriptor] = options[:descriptor] post[:descriptor_phone] = options[:descriptor_phone] post[:cardholder_auth] = options[:cardholder_auth] post[:cavv] = options[:cavv] post[:xid] = options[:xid] post[:customer_receipt] = options[:customer_receipt] end
add_security_key_data(post, options, money)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 179 def add_security_key_data(post, options, money) # MD5(username|password|orderid|amount|time) now = Time.now.to_i.to_s md5 = Digest::MD5.new md5 << @options[:login].to_s + "|" md5 << @options[:password].to_s + "|" md5 << options[:order_id].to_s + "|" md5 << amount(money).to_s + "|" md5 << now post[:key] = md5.hexdigest post[:time] = now end
capture_void_or_refund_template(trx_type, money, authorization, options)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 113 def capture_void_or_refund_template(trx_type, money, authorization, options) post = VerifiPostData.new post[:transactionid] = authorization commit(trx_type, money, post) end
commit(trx_type, money, post)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 192 def commit(trx_type, money, post) post[:amount] = amount(money) response = parse( ssl_post(self.live_url, post_data(trx_type, post)) ) Response.new(response[:response].to_i == SUCCESS, message_from(response), response, :test => test?, :authorization => response[:transactionid], :avs_result => { :code => response[:avsresponse] }, :cvv_result => response[:cvvresponse] ) end
message_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 205 def message_from(response) response[:response_code_message] ? response[:response_code_message] : "" end
parse(body)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 209 def parse(body) results = {} CGI.parse(body).each { |key, value| results[key.intern] = value[0] } results[:response_code_message] = RESPONSE_CODE_MESSAGES[results[:response_code]] if results[:response_code] results end
post_data(trx_type, post)
click to toggle source
# File lib/active_merchant/billing/gateways/verifi.rb, line 216 def post_data(trx_type, post) post[:username] = @options[:login] post[:password] = @options[:password] post[:type] = TRANSACTIONS[trx_type] post.to_s end