Class: SolidusStripe::PaymentSource

Inherits:
Spree::PaymentSource
  • Object
show all
Defined in:
app/models/solidus_stripe/payment_source.rb

Instance Method Summary collapse

Instance Method Details

#actionsObject



15
16
17
# File 'app/models/solidus_stripe/payment_source.rb', line 15

def actions
  %w[capture void credit]
end

#can_capture?(payment) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/solidus_stripe/payment_source.rb', line 19

def can_capture?(payment)
  payment.pending?
end

#can_credit?(payment) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/solidus_stripe/payment_source.rb', line 27

def can_credit?(payment)
  payment.completed? && payment.credit_allowed > 0
end

#can_void?(payment) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/solidus_stripe/payment_source.rb', line 23

def can_void?(payment)
  payment.pending?
end

#stripe_payment_methodObject



7
8
9
10
11
12
13
# File 'app/models/solidus_stripe/payment_source.rb', line 7

def stripe_payment_method
  return if stripe_payment_method_id.blank?

  @stripe_payment_method ||= payment_method.gateway.request do
    Stripe::PaymentMethod.retrieve(stripe_payment_method_id)
  end
end