Class: Workarea::Orderbot::Order::Tender::CreditCard

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/orderbot/order/tender/credit_card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tender, options = {}) ⇒ CreditCard

Returns a new instance of CreditCard.



8
9
10
11
# File 'app/services/workarea/orderbot/order/tender/credit_card.rb', line 8

def initialize(tender, options = {})
  @tender = tender
  @option = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'app/services/workarea/orderbot/order/tender/credit_card.rb', line 6

def options
  @options
end

#tenderObject (readonly)

Returns the value of attribute tender.



6
7
8
# File 'app/services/workarea/orderbot/order/tender/credit_card.rb', line 6

def tender
  @tender
end

Instance Method Details

#to_hObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/workarea/orderbot/order/tender/credit_card.rb', line 13

def to_h
  {
    payment_reference_id: tender.id.to_s,
    payment_type: "credit_card",
    payment_method_type:  tender.issuer.optionize,
    amount_paid: tender.amount.to_f,
    payment_date: transaction.created_at.iso8601,
    auth_code: transaction.response.authorization,
    credit_card: {
      transaction_id: transaction_id,
      authorization_code: transaction.response.authorization,
      last_four_digits: tender.display_number.last(4)
    }
  }
end