Class: Spree::PaymentSession
- Inherits:
-
Object
- Object
- Spree::PaymentSession
- Includes:
- Metafields
- Defined in:
- app/models/spree/payment_session.rb
Instance Method Summary collapse
- #amount_in_cents ⇒ Object
- #expired? ⇒ Boolean
-
#find_or_create_payment!(metadata = {}) ⇒ Spree::Payment
Creates or finds the Spree::Payment record for this session.
- #money ⇒ Object
Instance Method Details
#amount_in_cents ⇒ Object
67 68 69 |
# File 'app/models/spree/payment_session.rb', line 67 def amount_in_cents money.cents end |
#expired? ⇒ Boolean
75 76 77 |
# File 'app/models/spree/payment_session.rb', line 75 def expired? expires_at.present? && expires_at <= Time.current end |
#find_or_create_payment!(metadata = {}) ⇒ Spree::Payment
Creates or finds the Spree::Payment record for this session. Gateway subclasses can override this in their PaymentSession subclass to handle gateway-specific source creation (credit cards, wallets, etc).
85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/models/spree/payment_session.rb', line 85 def find_or_create_payment!( = {}) return payment if payment.present? order.payments.find_or_create_by!( payment_method: payment_method, response_code: external_id, ) do |p| p.amount = amount p.skip_source_requirement = true end end |