Class: Spree::Api::V2::Tenant::PaymentMethodsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/tenant/payment_methods_controller.rb

Overview

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

vendor_id is a required query param. A vendor id is globally unique and belongs to exactly one tenant, so it is what identifies tenant, vendor and store here — the tenant itself comes from the Doorkeeper token, not the URL.

IMPORTANT for caching (see SpreeCmCommissioner::ContentCachable): the CDN must include vendor_id in its cache key. If query strings are stripped, every vendor collapses into one cache entry and the wrong payment methods are served. Moving to /vendors/:vendor_id/payment_methods would remove that dependency — tracked as a follow-up.

For the per-order truth (store credit, early adopter, payout filtering) use CartPaymentMethodGroupsController instead.

Instance Method Summary collapse

Methods inherited from BaseController

#current_vendor, #render_serialized_payload, #require_tenant, #scope

Instance Method Details

#collectionObject

override



28
29
30
31
32
33
34
# File 'app/controllers/spree/api/v2/tenant/payment_methods_controller.rb', line 28

def collection
  @collection ||= SpreeCmCommissioner::PaymentMethods::Find.new(
    vendor: vendor,
    store: current_store,
    type: params[:type]
  ).execute
end

#collection_serializerObject

override



37
38
39
# File 'app/controllers/spree/api/v2/tenant/payment_methods_controller.rb', line 37

def collection_serializer
  Spree::V2::Tenant::PaymentMethodSerializer
end

#indexObject

override



21
22
23
24
25
# File 'app/controllers/spree/api/v2/tenant/payment_methods_controller.rb', line 21

def index
  render_serialized_payload do
    collection_serializer.new(collection).serializable_hash
  end
end