Class: SpreeCmCommissioner::PaymentMethods::Find

Inherits:
Object
  • Object
show all
Defined in:
app/finders/spree_cm_commissioner/payment_methods/find.rb

Overview

Order & user independent lookup of the payment methods a vendor accepts.

Mirrors the scope selection of Vpago::OrderDecorator#available_payment_methods, minus everything that depends on the order or the current user, so the result is safe to cache on the vendor id alone:

- available_for_order?  (only Spree::PaymentMethod::StoreCredit varies, on user balance)
- available_on_frontend_for_early_adopter  (user attribute)
- support_payout?       (order line items)
- preferred_payment_method_id  (user, affects sort only)

Callers needing the per-order truth must keep using Spree::Api::V2::*::CartPaymentMethodGroupsController.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vendor:, store: nil, type: nil) ⇒ Find

Returns a new instance of Find.



19
20
21
22
23
# File 'app/finders/spree_cm_commissioner/payment_methods/find.rb', line 19

def initialize(vendor:, store: nil, type: nil)
  @vendor = vendor
  @store = store
  @type = type
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



17
18
19
# File 'app/finders/spree_cm_commissioner/payment_methods/find.rb', line 17

def store
  @store
end

#typeObject (readonly)

Returns the value of attribute type.



17
18
19
# File 'app/finders/spree_cm_commissioner/payment_methods/find.rb', line 17

def type
  @type
end

#vendorObject (readonly)

Returns the value of attribute vendor.



17
18
19
# File 'app/finders/spree_cm_commissioner/payment_methods/find.rb', line 17

def vendor
  @vendor
end

Instance Method Details

#executeObject



25
26
27
28
29
# File 'app/finders/spree_cm_commissioner/payment_methods/find.rb', line 25

def execute
  return mini_app_scope if type.present?

  scope.reject(&:mini_app?)
end