class EwayRapid::Message::CustomerProcess::CustDirectPaymentMsgProcess

Create customer with direct payment method message process

Public Class Methods

create_request(input) click to toggle source

@param [Models::Customer] input @return [DirectPaymentRequest]

# File lib/eway_rapid/message/process/customer_process.rb, line 11
def self.create_request(input)
  request = DirectPaymentRequest.new
  convert = Convert::CustomerToInternalCustomer.new(false)
  request.customer = convert.do_convert(input)
  request.customer_ip = input.customer_device_ip
  request.method = Constants::CREATE_TOKEN_CUSTOMER_METHOD
  request.transaction_type = Enums::TransactionType::MOTO
  request.secured_card_data = input.secured_card_data
  request
end
make_result(response) click to toggle source

@param [String] response @return [CreateCustomerResponse]

# File lib/eway_rapid/message/process/customer_process.rb, line 43
def self.make_result(response)
  direct_payment_response = DirectPaymentResponse.from_json(response)
  convert = Convert::Response::DirectPaymentToCreateCust.new
  convert.do_convert(direct_payment_response)
end
send_request(url, api_key, password, version, request) click to toggle source

@param [String] url @param [String] api_key @param [String] password @param [DirectPaymentRequest] request @return [String]

# File lib/eway_rapid/message/process/customer_process.rb, line 27
def self.send_request(url, api_key, password, version, request)
  begin
    CustDirectPaymentMsgProcess.new.do_post(url, api_key, password, version, request)
  rescue SocketError => e
    raise Exceptions::CommunicationFailureException.new(e.message)
  rescue RestClient::Exception => e
    if e.http_code == 401 || e.http_code == 403 || e.http_code == 404
      raise Exceptions::AuthenticationFailureException.new(e.message)
    else
      raise Exceptions::SystemErrorException.new(e.message)
    end
  end
end