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, and payout is an optional one (caller passes Order#required_payway_payout? — see PaymentMethods::Find). 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 full per-order truth (store credit, early adopter 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



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

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

#collection_serializerObject

override



40
41
42
# File 'app/controllers/spree/api/v2/tenant/payment_methods_controller.rb', line 40

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

#indexObject

override



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

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