Class: EwayRapid::Message::CustomerProcess::CustDirectPaymentMsgProcess

Inherits:
Object
  • Object
show all
Includes:
RestProcess
Defined in:
lib/eway_rapid/message/process/customer_process.rb

Overview

Create customer with direct payment method message process

Class Method Summary collapse

Methods included from RestProcess

#do_get, #do_post

Class Method Details

.create_request(input) ⇒ DirectPaymentRequest

Parameters:

Returns:



11
12
13
14
15
16
17
18
19
# 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
end

.make_result(response) ⇒ CreateCustomerResponse

Parameters:

  • response (String)

Returns:



42
43
44
45
46
# File 'lib/eway_rapid/message/process/customer_process.rb', line 42

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, request) ⇒ String

Parameters:

Returns:

  • (String)


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/eway_rapid/message/process/customer_process.rb', line 26

def self.send_request(url, api_key, password, request)
  begin
    CustDirectPaymentMsgProcess.new.do_post(url, api_key, password, 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