Class: EwayRapid::Message::Convert::TransactionToPayment

Inherits:
Object
  • Object
show all
Defined in:
lib/eway_rapid/message/convert/transaction_to_payment.rb

Instance Method Summary collapse

Instance Method Details

#do_convert(transaction) ⇒ InternalModels::Payment

Parameters:

Returns:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/eway_rapid/message/convert/transaction_to_payment.rb', line 8

def do_convert(transaction)
  payment = InternalModels::Payment.new

  # @type [Models::PaymentDetails]
  payment_details = transaction.payment_details

  if payment_details
    payment.currency_code = payment_details.currency_code
    payment.invoice_description = payment_details.invoice_description
    payment.invoice_number = payment_details.invoice_number
    payment.invoice_reference = payment_details.invoice_reference
    payment.total_amount = payment_details.total_amount
  else
    payment.total_amount = 0
  end

  payment
end