Class: Spree::SixSaferpayPayment

Inherits:
PaymentSource
  • Object
show all
Defined in:
app/models/spree/six_saferpay_payment.rb

Overview

attributes

  • :token

  • :expiration

  • :redirect_url

  • :transaction_id

  • :transaction_status

  • :transaction_date

  • :six_transaction_reference

  • :display_text

  • :masked_number

  • :expiration_year

  • :expiration_month

  • :response_hash

Instance Method Summary collapse

Instance Method Details

#addressObject



29
30
31
# File 'app/models/spree/six_saferpay_payment.rb', line 29

def address
  @address ||= order.bill_address
end

#brand_nameObject



66
67
68
# File 'app/models/spree/six_saferpay_payment.rb', line 66

def brand_name
  payment_means&.brand&.name
end

#cardObject



58
59
60
# File 'app/models/spree/six_saferpay_payment.rb', line 58

def card
  payment_means&.card
end

#create_solidus_payment!Object



25
26
27
# File 'app/models/spree/six_saferpay_payment.rb', line 25

def create_solidus_payment!
  payments.create!(order: order, response_code: transaction_id, payment_method: payment_method, amount: order.total, source: self)
end

#icon_nameObject



78
79
80
# File 'app/models/spree/six_saferpay_payment.rb', line 78

def icon_name
  payment_means&.brand&.payment_method&.downcase
end

#liabilityObject



50
51
52
53
54
55
56
# File 'app/models/spree/six_saferpay_payment.rb', line 50

def liability
  @liability ||= begin
     if liability_response = response_hash[:liability]
       ::SixSaferpay::Liability.new(liability_response)
     end
   end
end

#monthObject



70
71
72
# File 'app/models/spree/six_saferpay_payment.rb', line 70

def month
  card&.exp_month
end

#nameObject



62
63
64
# File 'app/models/spree/six_saferpay_payment.rb', line 62

def name
  card&.holder_name
end

#payment_meansObject

This memoization only works if response_payment_means is not nil.



34
35
36
37
38
39
40
# File 'app/models/spree/six_saferpay_payment.rb', line 34

def payment_means
  @payment_means ||= begin
     if payment_means_response = response_hash[:payment_means]
       ::SixSaferpay::ResponsePaymentMeans.new(payment_means_response)
     end
   end
end

#transactionObject



42
43
44
45
46
47
48
# File 'app/models/spree/six_saferpay_payment.rb', line 42

def transaction
  @transaction ||= begin
     if transaction_response = response_hash[:transaction]
       ::SixSaferpay::Transaction.new(transaction_response)
     end
   end
end

#yearObject



74
75
76
# File 'app/models/spree/six_saferpay_payment.rb', line 74

def year
  card&.exp_year
end