class ActiveMerchant::Billing::SallieMaeGateway
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 18 def initialize(options = {}) requires!(options, :login) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 47 def capture(money, authorization, options = {}) post = PostData.new post[:postonly] = authorization commit(:capture, money, post) end
purchase(money, creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 37 def purchase(money, creditcard, options = {}) post = PostData.new add_invoice(post, options) add_creditcard(post, creditcard) add_address(post, creditcard, options) add_customer_data(post, options) commit(:sale, money, post) end
test?()
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 23 def test? @options[:login] == "TEST0" end
Private Instance Methods
add_address(post, creditcard, options)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 64 def add_address(post, creditcard, options) if address = options[:billing_address] || options[:address] post[:ci_billaddr1] = address[:address1].to_s post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank? post[:ci_billcity] = address[:city].to_s post[:ci_billstate] = address[:state].to_s post[:ci_billzip] = address[:zip].to_s end if shipping_address = options[:shipping_address] || options[:address] post[:ci_shipaddr1] = shipping_address[:address1].to_s post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank? post[:ci_shipcity] = shipping_address[:city].to_s post[:ci_shipstate] = shipping_address[:state].to_s post[:ci_shipzip] = shipping_address[:zip].to_s end end
add_creditcard(post, creditcard)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 87 def add_creditcard(post, creditcard) post[:ccnum] = creditcard.number.to_s post[:ccname] = creditcard.name.to_s post[:cvv2] = creditcard.verification_value.to_s if creditcard.verification_value? post[:expmon] = creditcard.month.to_s post[:expyear] = creditcard.year.to_s end
add_customer_data(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 55 def add_customer_data(post, options) if address = options[:billing_address] || options[:shipping_address] || options[:address] post[:ci_phone] = address[:phone].to_s end post[:ci_email] = options[:email].to_s unless options[:email].blank? post[:ci_IP] = options[:ip].to_s unless options[:ip].blank? end
add_invoice(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 82 def add_invoice(post, options) memo = "OrderID: #{options[:order_id]}\nDescription: #{options[:description]}" post[:ci_memo] = memo end
commit(action, money, parameters)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 107 def commit(action, money, parameters) parameters[:acctid] = @options[:login].to_s parameters[:subid] = @options[:sub_id].to_s unless @options[:sub_id].blank? parameters[:amount] = amount(money) case action when :sale parameters[:action] = "ns_quicksale_cc" when :authonly parameters[:action] = "ns_quicksale_cc" parameters[:authonly] = 1 when :capture parameters[:action] = "ns_quicksale_cc" end response = parse(ssl_post(self.live_url, parameters.to_post_data) || "") Response.new(successful?(response), message_from(response), response, :test => test?, :authorization => response["refcode"] ) end
message_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 133 def message_from(response) if successful?(response) "Accepted" else response["Reason"].split(":")[2].capitalize unless response["Reason"].nil? end end
parse(body)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 95 def parse(body) h = {} body.gsub!("<html><body><plaintext>", "") body. split("\r\n"). map do |i| a = i.split("=") h[a.first] = a.last unless a.first.nil? end h end
successful?(response)
click to toggle source
# File lib/active_merchant/billing/gateways/sallie_mae.rb, line 129 def successful?(response) response["Status"] == "Accepted" end