class ActiveMerchant::Billing::MoneyMoversGateway

Constants

ERROR

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/money_movers.rb, line 13
def initialize(options = {})
  requires!(options, :login, :password)
  @options = options
  super
end

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 28
def authorize(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_address(post, options)
  add_customer_data(post, options)
  commit('auth', money, post)
end
capture(money, authorization, options = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 37
def capture(money, authorization, options = {})
  options[:transactionid] = authorization
  commit('capture', money, options)
end
credit(money, authorization, options = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 51
def credit(money, authorization, options = {})
  ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, authorization, options)
end
purchase(money, creditcard, options = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 19
def purchase(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_address(post, options)
  add_customer_data(post, options)
  commit('sale', money, post)
end
refund(money, authorization, options = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 47
def refund(money, authorization, options = {})
  commit('refund', money, options.merge(transactionid: authorization))
end
void(authorization, options = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 42
def void(authorization, options = {})
  options[:transactionid] = authorization
  commit('void', nil, options)
end

Private Instance Methods

add_address(post, options) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 65
def add_address(post, options)
  if address = (options[:billing_address] || options[:address])
    post[:company] = address[:company]
    post[:address1] = address[:address1]
    post[:address2] = address[:address2]
    post[:city]    = address[:city]
    post[:state]   = address[:state]
    post[:zip]     = address[:zip]
    post[:country] = address[:country]
    post[:phone] = address[:phone]
  end
  if address = options[:shipping_address]
    post[:shipping_firstname] = address[:first_name]
    post[:shipping_lastname] = address[:last_name]
    post[:shipping_company] = address[:company]
    post[:shipping_address1] = address[:address1]
    post[:shipping_address2] = address[:address2]
    post[:shipping_city]    = address[:city]
    post[:shipping_state]   = address[:state]
    post[:shipping_zip]     = address[:zip]
    post[:shipping_country] = address[:country]
    post[:shipping_email]   = address[:email]
  end
end
add_creditcard(post, creditcard) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 95
def add_creditcard(post, creditcard)
  post[:ccnumber] = creditcard.number
  post[:ccexp] = expdate(creditcard)
  post[:cvv] = creditcard.verification_value
end
add_customer_data(post, options) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 58
def add_customer_data(post, options)
  post[:firstname] = options[:first_name]
  post[:lastname] = options[:last_name]

  post[:email] = options[:email]
end
add_invoice(post, options) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 90
def add_invoice(post, options)
  post[:orderid] = options[:order_id]
  post[:orderdescription] = options[:description]
end
commit(action, money, parameters) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 109
def commit(action, money, parameters)
  parameters[:amount] = amount(money)

  data = ssl_post(self.live_url, post_data(action, parameters))
  response = parse(data)
  message = message_from(response)

  Response.new(
    success?(response),
    message,
    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/money_movers.rb, line 135
def message_from(response)
  case response['response'].to_i
  when APPROVED
    'Transaction Approved'
  when DECLINED
    'Transaction Declined'
  else
    'Error in transaction data or system error'
  end
end
parse(body) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 101
def parse(body)
  body.split('&').inject({}) do |memo, x|
    k, v = x.split('=')
    memo[k] = v
    memo
  end
end
post_data(action, parameters = {}) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 146
def post_data(action, parameters = {})
  parameters[:type] = action
  parameters[:username] = @options[:login]
  parameters[:password] = @options[:password]
  parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
success?(response) click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 127
def success?(response)
  response['response'] == '1'
end
test?() click to toggle source
# File lib/active_merchant/billing/gateways/money_movers.rb, line 131
def test?
  @options[:login].eql?('demo') && @options[:password].eql?('password')
end