Class: Spree::PaymentSessions::BankTransfer

Inherits:
Spree::PaymentSession
  • Object
show all
Defined in:
app/models/spree/payment_sessions/bank_transfer.rb

Instance Method Summary collapse

Instance Method Details

#bank_detail_setsArray<Spree::BankPayments::DetailSet>

The coordinates this session was actually quoted against -- the single source of truth for every customer-facing surface (the instructions partial and both InstructionsMailer actions).

Reading payment_method.bank_details_for(currency) here instead would render whatever account is offered now, not what the customer was told: switch the offered GBP account from A to B and every open session's reminder starts quoting B's coordinates against a reference generated for A, sending the money to the wrong account. Un-offer the currency entirely and the block renders empty -- a reference, an amount, a deadline, and nowhere to send it. bank_account is scoped -> { with_deleted } precisely so a soft-deleted account still resolves here.

The fallback covers the two cases with no recorded account: sessions created before 5.2.0, and reconcilers (e.g. Manual) running against a gateway whose account was never linked.

Returns:



56
57
58
59
60
# File 'app/models/spree/payment_sessions/bank_transfer.rb', line 56

def bank_detail_sets
  return payment_method.bank_details_for(currency) if .nil?

  .detail_sets.select(&:usable?)
end

#notification_payloadObject

Event subscribers may run async via ActiveJob, so payloads must be serializable primitives — never AR objects.



64
65
66
67
68
69
70
71
72
73
74
# File 'app/models/spree/payment_sessions/bank_transfer.rb', line 64

def notification_payload
  {
    payment_session_id: id,
    order_number: order&.number,
    order_email: order&.email,
    reference: reference,
    amount: amount.to_s,
    currency: currency,
    expires_at: expires_at&.iso8601
  }
end

#referenceObject

NB: #expired? is deliberately NOT redefined here -- it was a byte-identical copy of Spree::PaymentSession#expired?, which is inherited.



33
34
35
# File 'app/models/spree/payment_sessions/bank_transfer.rb', line 33

def reference
  external_id
end