Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Changed integrations gallery to list only third-party payment methods (#14819)

Damian Legawiec8ef9d015cbf8
diff --git a/.changeset/admin-sdk-provider-listing.md b/.changeset/admin-sdk-provider-listing.md
index 1adbba3995..b937cd1c3a 100644
--- a/.changeset/admin-sdk-provider-listing.md
+++ b/.changeset/admin-sdk-provider-listing.md
@@ -2,4 +2,4 @@
"@spree/admin-sdk": minor
---
-Payment methods, payment method types and integration types now carry `logo_url` and `docs_url`, the provider's logo and setup guide. `PaymentMethodType` is its own interface rather than an alias of `ResourceTypeDefinition`.
+Payment methods, payment method types and integration types now carry `logo_url` and `docs_url`, the provider's logo and setup guide. Payment methods and their types also carry `third_party`, true for methods backed by an external payment provider. `PaymentMethodType` is its own interface rather than an alias of `ResourceTypeDefinition`.
diff --git a/.changeset/dashboard-integrations-gallery.md b/.changeset/dashboard-integrations-gallery.md
index c39eb3e037..5aa7828100 100644
--- a/.changeset/dashboard-integrations-gallery.md
+++ b/.changeset/dashboard-integrations-gallery.md
@@ -2,4 +2,4 @@
"@spree/dashboard": minor
---
-Settings → Integrations is now a card gallery with tabs, and it lists payment providers next to service integrations. Each card switches its integration or payment method on and off straight away, opens its setup panel, and links to the provider's setup guide when one is declared.
+Settings → Integrations is now a card gallery with tabs, and it lists third-party payment providers next to service integrations. Each card switches its integration or payment method on and off straight away, opens its setup panel, and links to the provider's setup guide when one is declared — on the card and in its setup panel.
diff --git a/docs/developer/how-to/custom-payment-method.mdx b/docs/developer/how-to/custom-payment-method.mdx
index 0b450577c4..595185f9f3 100644
--- a/docs/developer/how-to/custom-payment-method.mdx
+++ b/docs/developer/how-to/custom-payment-method.mdx
@@ -45,10 +45,16 @@ After restarting your server, you can select "MyGateway" when creating a new pay
### Show a logo and setup guide (optional)
-Payment providers also appear in the admin dashboard under **Settings > Integrations**. Declare a logo and a link to your setup guide so merchants recognise the provider and know how to connect it:
+Payment methods backed by an external provider also appear in the admin dashboard under **Settings > Integrations**, next to other connected services. A method is listed there when it inherits from `Spree::Gateway`, or when its class defines `self.third_party?` to return `true`. Declare a logo and a link to your setup guide so merchants recognise the provider and know how to connect it:
```ruby app/models/my_gateway.rb
class MyGateway < Spree::PaymentMethod
+ # Lists MyGateway under Settings > Integrations. Not needed when the class
+ # inherits from Spree::Gateway.
+ def self.third_party?
+ true
+ end
+
def self.logo_url
'https://my-gateway.example.com/logo.svg'
end
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index e1f5419284..156afb06f8 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -2414,6 +2414,8 @@ export interface PaymentMethodType extends ResourceTypeDefinition {
logo_url: string | null
/** Absolute URL of the provider's setup guide. */
docs_url: string | null
+ /** Backed by an external payment provider rather than handled by the store itself. */
+ third_party: boolean
}
/**
diff --git a/packages/admin-sdk/src/types/generated/PaymentMethod.ts b/packages/admin-sdk/src/types/generated/PaymentMethod.ts
index a83fb9eed2..a7f1b466d3 100644
--- a/packages/admin-sdk/src/types/generated/PaymentMethod.ts
+++ b/packages/admin-sdk/src/types/generated/PaymentMethod.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 7cc02be62c6e93ce605d1ac420f2d252
+// Typelizer digest c025e1be7880524db5ffd127b7c975c2
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -23,6 +23,7 @@ interface PaymentMethod {
preference_schema: Array<{ key: string; type: string; default: unknown; choices?: string[] }>;
logo_url: string | null;
docs_url: string | null;
+ third_party: boolean;
}
export default PaymentMethod;
diff --git a/packages/admin-sdk/src/types/generated/Store.ts b/packages/admin-sdk/src/types/generated/Store.ts
index c21d733878..157df6dd4f 100644
--- a/packages/admin-sdk/src/types/generated/Store.ts
+++ b/packages/admin-sdk/src/types/generated/Store.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 47bfb18008b234c2cb3e2b867d4cc347
+// Typelizer digest f552723a571754fb2dc4b977b2226a9e
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {SetupTask} from '@/types'
@@ -41,11 +41,9 @@ interface Store {
preferred_inventory_provider_failure_policy: string;
preferred_payout_provider: string | null;
preferred_default_payouts_schedule_interval: string;
- preferred_default_minimum_payout_amount: number;
preferred_auto_approve_sellers: boolean;
preferred_auto_approve_seller_products: boolean;
preferred_send_seller_transactional_emails: boolean;
- preferred_default_commission_tax_rate: number;
preferred_document_number_format: string;
preferred_order_number_prefix: string;
preferred_order_number_suffix: string;
@@ -57,6 +55,8 @@ interface Store {
created_at: string;
updated_at: string;
order_number_sequence_started: boolean;
+ preferred_default_minimum_payout_amount: number;
+ preferred_default_commission_tax_rate: number;
url: string;
api_url: string;
setup_tasks: Array<SetupTask>;
diff --git a/packages/admin-sdk/src/zod/generated/PaymentMethod.ts b/packages/admin-sdk/src/zod/generated/PaymentMethod.ts
index 66edd6a831..2cb2b23dc2 100644
--- a/packages/admin-sdk/src/zod/generated/PaymentMethod.ts
+++ b/packages/admin-sdk/src/zod/generated/PaymentMethod.ts
@@ -21,6 +21,7 @@ export const PaymentMethodSchema = z.object({
preference_schema: z.array(z.object({ key: z.string(), type: z.string(), default: z.unknown(), choices: z.array(z.string()).optional() })),
logo_url: z.string().nullable(),
docs_url: z.string().nullable(),
+ third_party: z.boolean(),
});
export type PaymentMethod = z.infer<typeof PaymentMethodSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/Store.ts b/packages/admin-sdk/src/zod/generated/Store.ts
index 4a6e851f9e..ea17a537fe 100644
--- a/packages/admin-sdk/src/zod/generated/Store.ts
+++ b/packages/admin-sdk/src/zod/generated/Store.ts
@@ -40,11 +40,9 @@ export const StoreSchema = z.object({
preferred_inventory_provider_failure_policy: z.string(),
preferred_payout_provider: z.string().nullable(),
preferred_default_payouts_schedule_interval: z.string(),
- preferred_default_minimum_payout_amount: z.number(),
preferred_auto_approve_sellers: z.boolean(),
preferred_auto_approve_seller_products: z.boolean(),
preferred_send_seller_transactional_emails: z.boolean(),
- preferred_default_commission_tax_rate: z.number(),
preferred_document_number_format: z.string(),
preferred_order_number_prefix: z.string(),
preferred_order_number_suffix: z.string(),
@@ -56,6 +54,8 @@ export const StoreSchema = z.object({
created_at: z.string(),
updated_at: z.string(),
order_number_sequence_started: z.boolean(),
+ preferred_default_minimum_payout_amount: z.number(),
+ preferred_default_commission_tax_rate: z.number(),
url: z.string(),
api_url: z.string(),
setup_tasks: z.array(SetupTaskSchema),
diff --git a/packages/dashboard/e2e/integrations.spec.ts b/packages/dashboard/e2e/integrations.spec.ts
index 31e39a0ced..272a441f24 100644
--- a/packages/dashboard/e2e/integrations.spec.ts
+++ b/packages/dashboard/e2e/integrations.spec.ts
@@ -3,13 +3,15 @@ import { login } from './helpers'
const INTEGRATIONS_PATH = (storeId: string) => `/${storeId}/settings/integrations`
-// Seeds its own payment method rather than toggling a shared one. The custom
-// payment source type is hidden from the add-provider picker, so creating it
-// cannot starve payment-methods.spec.ts of a provider it installs.
+// Seeds its own payment method rather than toggling a shared one. Bogus is the
+// only third-party gateway the test app ships, and only third-party methods
+// are listed here. payment-methods.spec.ts installs Bogus through its picker
+// too, so every test deletes the one it seeded — a deleted method no longer
+// counts as installed.
async function seedPaymentMethod(page: Page, storeId: string, accessToken: string, name: string) {
const res = await page.request.post('/api/v3/admin/payment_methods', {
headers: { 'X-Spree-Store-Id': storeId, Authorization: `Bearer ${accessToken}` },
- data: { type: 'custom_payment_source_method', name, active: true },
+ data: { type: 'bogus', name, active: true },
})
if (!res.ok()) {
throw new Error(`Failed to seed payment method "${name}": ${res.status()} ${await res.text()}`)
@@ -29,9 +31,10 @@ function paymentMethodCard(page: Page, name: string) {
}
test.describe('integrations', () => {
- // The test app installs no provider gems, but payment providers ship with
- // core — so the gallery always lists them next to any service integrations.
- test('lists payment providers alongside integrations', async ({ page }) => {
+ // The test app installs no provider gems, but core ships a third-party
+ // gateway (Bogus), so the gallery always has a Payments section. Methods
+ // the store handles itself, like store credit, stay off it.
+ test('lists third-party payment providers alongside integrations', async ({ page }) => {
const creds = await login(page)
await page.goto(INTEGRATIONS_PATH(creds.store_id))
@@ -40,6 +43,24 @@ test.describe('integrations', () => {
})
await expect(page.getByRole('heading', { name: /^payments$/i })).toBeVisible()
await expect(page.getByRole('link', { name: /manage payment methods/i })).toBeVisible()
+ await expect(page.getByRole('switch', { name: /store credit/i })).toHaveCount(0)
+ })
+
+ // Setting up a provider from its card already says which provider, so the
+ // add sheet skips the provider picker.
+ test('opens the add sheet for the chosen provider without a provider picker', async ({
+ page,
+ }) => {
+ const creds = await login(page)
+ await page.goto(`${INTEGRATIONS_PATH(creds.store_id)}?add_payment_method=bogus`)
+
+ const sheet = page.getByRole('dialog')
+ await expect(sheet.getByRole('heading', { name: /add payment method/i })).toBeVisible({
+ timeout: 15_000,
+ })
+ await expect(sheet.getByText(/provider: bogus/i)).toBeVisible()
+ await expect(sheet.locator('#type')).toHaveCount(0)
+ await expect(sheet.locator('#name')).toHaveValue('Bogus')
})
test('switches a payment method off and back on from its card', async ({ page }) => {
diff --git a/packages/dashboard/src/components/spree/integrations/configure-integration-sheet.tsx b/packages/dashboard/src/components/spree/integrations/configure-integration-sheet.tsx
index f4a922261c..aac1b954e0 100644
--- a/packages/dashboard/src/components/spree/integrations/configure-integration-sheet.tsx
+++ b/packages/dashboard/src/components/spree/integrations/configure-integration-sheet.tsx
@@ -19,6 +19,7 @@ import {
useTestIntegration,
useUpdateIntegration,
} from '../../../hooks/use-integrations'
+import { SetupGuideLink } from './setup-guide-link'
/**
* Connect/configure sheet for one integration type. Shared between the
@@ -98,6 +99,7 @@ export function ConfigureIntegrationSheet({
? t('admin.integrations.edit_description')
: t('admin.integrations.connect_description')}
</SheetDescription>
+ <SetupGuideLink url={type.docs_url} />
</SheetHeader>
<div className="flex min-h-0 flex-1 flex-col">
<div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
diff --git a/packages/dashboard/src/components/spree/integrations/integration-card.tsx b/packages/dashboard/src/components/spree/integrations/integration-card.tsx
index 3bd0b44b68..344a183540 100644
--- a/packages/dashboard/src/components/spree/integrations/integration-card.tsx
+++ b/packages/dashboard/src/components/spree/integrations/integration-card.tsx
@@ -9,8 +9,8 @@ import {
cn,
Switch,
} from '@spree/dashboard-ui'
-import { ExternalLinkIcon } from '@spree/dashboard-ui/icons'
import { type ReactNode, useEffect, useRef, useState } from 'react'
+import { SetupGuideLink } from './setup-guide-link'
export type IntegrationCardStatus = 'active' | 'inactive' | 'not_connected'
@@ -28,7 +28,6 @@ export function IntegrationCard({
tags,
toggle,
docsUrl,
- docsLabel,
actionLabel,
onAction,
}: {
@@ -50,9 +49,8 @@ export function IntegrationCard({
*/
onCheckedChange: (checked: boolean) => Promise<boolean> | undefined
}
- /** Setup guide, opened in a new tab. Only absolute http(s) URLs are linked. */
+ /** Setup guide linked from the footer. */
docsUrl?: string | null
- docsLabel: string
actionLabel: string
onAction: () => void
}) {
@@ -145,21 +143,10 @@ export function IntegrationCard({
{tags && <div className="mt-auto flex flex-wrap gap-1.5">{tags}</div>}
</CardContent>
<CardFooter className="justify-between gap-2 bg-muted/40 px-4 py-2">
- {docsUrl && /^https?:\/\//.test(docsUrl) ? (
- <a
- href={docsUrl}
- target="_blank"
- rel="noopener noreferrer"
- className="link inline-flex items-center gap-1 text-sm"
- >
- {docsLabel}
- <ExternalLinkIcon className="size-3.5" />
- </a>
- ) : (
- <span />
- )}
+ <SetupGuideLink url={docsUrl} />
<Button
size="sm"
+ className="ml-auto"
variant={status === 'not_connected' ? 'default' : 'ghost'}
onClick={onAction}
>
@@ -175,7 +162,14 @@ export function IntegrationCard({
// unreachable URLs alike — same pattern as the store switcher.
function IntegrationLogo({ name, logoUrl }: { name: string; logoUrl: string | null }) {
return (
- <Avatar className="size-10 shrink-0 rounded-lg bg-background p-1.5 after:rounded-lg after:border-border-subtle">
+ // Brand logos are drawn for a light background, so the tile behind one
+ // stays white in dark mode too; the letter fallback follows the theme.
+ <Avatar
+ className={cn(
+ 'size-10 shrink-0 rounded-lg p-1.5 after:rounded-lg after:border-border-subtle',
+ logoUrl ? 'bg-white' : 'bg-background',
+ )}
+ >
{logoUrl && <AvatarImage src={logoUrl} className="rounded-none object-contain" />}
<AvatarFallback className="rounded-md bg-transparent font-semibold">
{name.charAt(0).toUpperCase()}
diff --git a/packages/dashboard/src/components/spree/integrations/setup-guide-link.tsx b/packages/dashboard/src/components/spree/integrations/setup-guide-link.tsx
new file mode 100644
index 0000000000..cc98bda715
--- /dev/null
+++ b/packages/dashboard/src/components/spree/integrations/setup-guide-link.tsx
@@ -0,0 +1,24 @@
+import { ExternalLinkIcon } from '@spree/dashboard-ui/icons'
+import { useTranslation } from 'react-i18next'
+
+/**
+ * Link to a provider's setup guide, opened in a new tab. Renders nothing for
+ * a missing URL or anything but an absolute http(s) one, since the URL comes
+ * from provider gem code rather than the dashboard.
+ */
+export function SetupGuideLink({ url }: { url: string | null | undefined }) {
+ const { t } = useTranslation()
+ if (!url || !/^https?:\/\//.test(url)) return null
+
+ return (
+ <a
+ href={url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="link inline-flex w-fit items-center gap-1 text-sm"
+ >
+ {t('admin.integrations.setup_guide')}
+ <ExternalLinkIcon className="size-3.5" />
+ </a>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx b/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx
index 193e2d63a4..bc73eec246 100644
--- a/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx
+++ b/packages/dashboard/src/components/spree/payment-method-editors/payment-method-form.tsx
@@ -53,6 +53,8 @@ interface PaymentMethodFormProps {
onPreferencesChange: (next: Record<string, unknown>) => void
/** Called when the user picks a different provider in the create dropdown. */
onProviderTypeChange?: (next: string) => void
+ /** Create mode with the provider already chosen by the caller: no dropdown. */
+ providerLocked?: boolean
}
export function PaymentMethodForm({
@@ -66,6 +68,7 @@ export function PaymentMethodForm({
preferences,
onPreferencesChange,
onProviderTypeChange,
+ providerLocked = false,
}: PaymentMethodFormProps) {
const { t } = useTranslation()
// Per-provider slot lookups. If a plugin has registered a `form` slot
@@ -92,7 +95,7 @@ export function PaymentMethodForm({
return (
<div className="flex flex-1 flex-col gap-4">
- {mode === 'create' && (
+ {mode === 'create' && !providerLocked && (
<Field>
<FieldLabel htmlFor="type">{t('admin.fields.payment_method.type.label')}</FieldLabel>
<Controller
diff --git a/packages/dashboard/src/components/spree/payment-method-editors/payment-method-sheets.tsx b/packages/dashboard/src/components/spree/payment-method-editors/payment-method-sheets.tsx
index 1ebcc09c3d..6838488c18 100644
--- a/packages/dashboard/src/components/spree/payment-method-editors/payment-method-sheets.tsx
+++ b/packages/dashboard/src/components/spree/payment-method-editors/payment-method-sheets.tsx
@@ -27,6 +27,7 @@ import {
paymentMethodValuesToCreateParams,
paymentMethodValuesToUpdateParams,
} from '../../../schemas/payment-method'
+import { SetupGuideLink } from '../integrations/setup-guide-link'
import { PaymentMethodForm } from './payment-method-form'
import type { PaymentMethodFormValues } from './types'
@@ -111,7 +112,14 @@ export function CreatePaymentMethodSheet({
<SheetContent>
<SheetHeader>
<SheetTitle>{t('admin.pages.settings.payment_methods.add_sheet_title')}</SheetTitle>
- <SheetDescription>{t('admin.payment_methods.create_description')}</SheetDescription>
+ <SheetDescription>
+ {initialType
+ ? t('admin.payment_methods.provider_description', { provider: initialType.label })
+ : t('admin.payment_methods.create_description')}
+ </SheetDescription>
+ <SetupGuideLink
+ url={providerTypes.find((entry) => entry.type === providerType)?.docs_url}
+ />
</SheetHeader>
<form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
<div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
@@ -131,6 +139,7 @@ export function CreatePaymentMethodSheet({
preferences={preferences}
onPreferencesChange={setPreferences}
onProviderTypeChange={handleProviderTypeChange}
+ providerLocked={!!initialType}
/>
</div>
<SheetFooter>
@@ -231,6 +240,7 @@ export function EditPaymentMethodSheet({
? t('admin.payment_methods.provider_description', { provider: providerLabel })
: t('admin.payment_methods.edit_description')}
</SheetDescription>
+ <SetupGuideLink url={paymentMethod?.docs_url} />
</SheetHeader>
{isLoading ? (
<div className="p-4 text-sm text-muted-foreground">{t('admin.common.loading')}</div>
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/integrations.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/integrations.tsx
index ed32285dd8..2b01006202 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/integrations.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/integrations.tsx
@@ -89,14 +89,19 @@ function IntegrationsPage() {
() => new Map((integrationsResponse?.data ?? []).map((record) => [record.type, record])),
[integrationsResponse],
)
+ // Only methods backed by an external provider belong with integrations;
+ // checks, store credit and the like stay on the Payment methods page.
const paymentMethods = useMemo(
- () => (canReadPayments ? (paymentMethodsResponse?.data ?? []) : []),
+ () =>
+ canReadPayments
+ ? (paymentMethodsResponse?.data ?? []).filter((method) => method.third_party)
+ : [],
[canReadPayments, paymentMethodsResponse],
)
// The server already leaves out providers installed on this store, so
// these are only the ones still to set up.
const availablePaymentTypes = useMemo(
- () => (paymentTypesResponse?.data ?? []).filter((type) => !type.superseded),
+ () => (paymentTypesResponse?.data ?? []).filter((type) => type.third_party && !type.superseded),
[paymentTypesResponse],
)
@@ -309,7 +314,6 @@ function ServiceIntegrationCard({
name={type.name}
logoUrl={type.logo_url}
docsUrl={type.docs_url}
- docsLabel={t('admin.integrations.setup_guide')}
status={status}
statusLabels={{
active: t('admin.integrations.status.active'),
@@ -373,7 +377,6 @@ function PaymentMethodCard({
name={paymentMethod.name}
logoUrl={paymentMethod.logo_url}
docsUrl={paymentMethod.docs_url}
- docsLabel={t('admin.integrations.setup_guide')}
status={paymentMethod.active ? 'active' : 'inactive'}
statusLabels={paymentStatusLabels(t)}
description={
@@ -412,7 +415,6 @@ function PaymentProviderCard({ type, onSetUp }: { type: PaymentMethodType; onSet
name={type.label}
logoUrl={type.logo_url}
docsUrl={type.docs_url}
- docsLabel={t('admin.integrations.setup_guide')}
status="not_connected"
statusLabels={paymentStatusLabels(t)}
description={type.description ?? undefined}
diff --git a/spree/api/app/serializers/spree/api/v3/admin/payment_method_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/payment_method_serializer.rb
index 85523b74cf..345f1dea80 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/payment_method_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/payment_method_serializer.rb
@@ -13,7 +13,8 @@ module Spree
preferences: 'Record<string, unknown>',
preference_schema: "Array<{ key: string; type: string; default: unknown; choices?: string[] }>",
logo_url: [:string, nullable: true],
- docs_url: [:string, nullable: true]
+ docs_url: [:string, nullable: true],
+ third_party: :boolean
# Null capture_method means the method inherits from its store;
# resolved_capture_method is what actually applies, so the dashboard
@@ -26,6 +27,7 @@ module Spree
attribute :preference_schema, &:serialized_preference_schema
attribute(:logo_url) { |payment_method| payment_method.class.logo_url }
attribute(:docs_url) { |payment_method| payment_method.class.docs_url }
+ attribute(:third_party) { |payment_method| payment_method.class.third_party? }
end
end
end
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb
index d628564f0f..430d2921cb 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/payment_methods_controller_spec.rb
@@ -319,6 +319,13 @@ RSpec.describe Spree::Api::V3::Admin::PaymentMethodsController, type: :controlle
expect(response.body).not_to include('SECRETKEY123')
end
+ it 'flags providers backed by a third-party gateway' do
+ get :types, as: :json
+
+ third_party = json_response['data'].to_h { |entry| [entry['type'], entry['third_party']] }
+ expect(third_party).to include('bogus' => true, 'store_credit' => false, 'custom_payment_source_method' => false)
+ end
+
it 'exposes the logo and setup guide a provider declares' do
allow(Spree::Gateway::Bogus).to receive_messages(
logo_url: 'https://example.com/bogus.png',
diff --git a/spree/api/spec/serializers/spree/api/v3/admin/payment_method_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/admin/payment_method_serializer_spec.rb
index 0812f74dfd..75abaea2bb 100644
--- a/spree/api/spec/serializers/spree/api/v3/admin/payment_method_serializer_spec.rb
+++ b/spree/api/spec/serializers/spree/api/v3/admin/payment_method_serializer_spec.rb
@@ -49,4 +49,18 @@ RSpec.describe Spree::Api::V3::Admin::PaymentMethodSerializer do
expect(payload['preference_schema']).not_to include(have_key(:key_string))
end
end
+
+ describe 'third_party' do
+ it 'is true for a gateway backed by an external provider' do
+ payload = described_class.new(create(:bogus_payment_method), params: base_params).to_h
+
+ expect(payload['third_party']).to be(true)
+ end
+
+ it 'is false for a method the store handles itself' do
+ payload = described_class.new(create(:check_payment_method), params: base_params).to_h
+
+ expect(payload['third_party']).to be(false)
+ end
+ end
end
diff --git a/spree/core/app/models/spree/gateway.rb b/spree/core/app/models/spree/gateway.rb
index 4c0b97f2a4..d49227521a 100644
--- a/spree/core/app/models/spree/gateway.rb
+++ b/spree/core/app/models/spree/gateway.rb
@@ -31,6 +31,10 @@ module Spree
outer ? outer.underscore : leaf
end
+ def self.third_party?
+ true
+ end
+
def payment_source_class
CreditCard
end
diff --git a/spree/core/app/models/spree/gateway/custom_payment_source_method.rb b/spree/core/app/models/spree/gateway/custom_payment_source_method.rb
index 459e6fc4d4..872b1c9780 100644
--- a/spree/core/app/models/spree/gateway/custom_payment_source_method.rb
+++ b/spree/core/app/models/spree/gateway/custom_payment_source_method.rb
@@ -1,5 +1,10 @@
module Spree
class Gateway::CustomPaymentSourceMethod < Gateway
+ # Sources recorded by the merchant, not charged through a provider.
+ def self.third_party?
+ false
+ end
+
def provider_class
self.class
end
diff --git a/spree/core/app/models/spree/payment_method.rb b/spree/core/app/models/spree/payment_method.rb
index 0548fd787b..8871ab5bbe 100644
--- a/spree/core/app/models/spree/payment_method.rb
+++ b/spree/core/app/models/spree/payment_method.rb
@@ -75,6 +75,20 @@ module Spree
# `providers`; declaring it keeps subclass resolution to a single rule.
registers_subclasses_via { providers }
+ # Whether this method is backed by an external payment provider (Stripe,
+ # Adyen…) rather than handled by the store itself (check, store credit).
+ # Only third-party methods are listed under Settings → Integrations.
+ #
+ # @return [Boolean]
+ def self.third_party?
+ false
+ end
+
+ # @return [Hash] the listing attributes, plus whether the method is third-party
+ def self.provider_listing
+ super.merge(third_party: third_party?)
+ end
+
def provider_class
raise ::NotImplementedError, 'You must implement provider_class method for this gateway.'
end