Class: SolidusPaypalCommercePlatform::PaymentSource

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

Instance Method Summary collapse

Instance Method Details

#actionsObject



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

def actions
  %w(capture void credit)
end

#can_capture?(payment) ⇒ Boolean

Returns:

  • (Boolean)


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

def can_capture?(payment)
  payment.pending? || payment.checkout?
end

#can_credit?(payment) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'app/models/solidus_paypal_commerce_platform/payment_source.rb', line 31

def can_credit?(payment)
  payment.completed? &&
  payment.credit_allowed > 0 &&
  capture_id &&
  payment_method.gateway.get_order(paypal_order_id).status == "COMPLETED"
end

#can_void?(payment) ⇒ Boolean

Returns:

  • (Boolean)


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

def can_void?(payment)
  can_capture?(payment)
end

#display_paypal_funding_sourceObject



13
14
15
16
17
# File 'app/models/solidus_paypal_commerce_platform/payment_source.rb', line 13

def display_paypal_funding_source
  I18n.t(paypal_funding_source,
    scope: 'solidus_paypal_commerce_platform.paypal_funding_sources',
    default: paypal_funding_source)
end