/** * The overview at the top of Funnelforms → Integrations: every service a form can use, by * category, with search and a filter for what is connected. Each tile says whether the site is * connected, whether it runs in test mode and whether something is missing; a click opens the * service with where to find the keys, the connections with the forms that use them, and the * form to connect. Payments are checked with the provider right away, and the Stripe webhook is * set up with one click. Calendars open the calendar section below; CRM tools their dialog. This * is the only place for CRM, newsletter and spreadsheet connections: they are added, changed, * tested and deleted here. */ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import type { FormsApi } from '../api'; import type { ConnectApi, CrmConnection, CrmProvider } from '../connect'; import { connectionsOf, deletable, filterServices, hubServices, hubSummary, HUB_CATEGORIES, type HubApi, type HubCategory, type HubConnection, type HubOverview, type HubService } from '../hub'; import type { CalendarService } from './BookingTypes'; import { CrmConnectionDialog } from './CrmConnections'; import { __, sprintf } from './i18n'; import { Button, Dialog, Notice, Spinner, TextInput, Toggle } from './ui'; export interface HubConfig { interfacesUrl?: string; /** Funnelforms → AI Phone Agent, where ElevenLabs is connected. */ leadcallerUrl?: string; builderUrl?: string; } /** What the overview needs of the API. */ export type HubScreenApi = Pick & Required> & { hub: HubApi; connect: ConnectApi }; const message = ( e: unknown ): string => ( e instanceof Error ? e.message : String( e ) ); const PATHS = { search: 'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM21 21l-4.35-4.35', calendar: 'M8 2v4M16 2v4M3 10h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z', bolt: 'M13 2 3 14h9l-1 8 10-12h-9l1-8z', external: 'M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5', }; function Icon( { name }: { name: keyof typeof PATHS } ) { return ( ); } export function categoryName( category: HubCategory ): string { const names: Record = { payments: __( 'Payments', 'funnelforms-pro' ), crm: __( 'CRM', 'funnelforms-pro' ), newsletter: __( 'Newsletter', 'funnelforms-pro' ), spreadsheet: __( 'Spreadsheets', 'funnelforms-pro' ), calendars: __( 'Calendars', 'funnelforms-pro' ), meetings: __( 'Video meetings', 'funnelforms-pro' ), messages: __( 'Messages', 'funnelforms-pro' ), tracking: __( 'Conversion tracking', 'funnelforms-pro' ), automation: __( 'Automation', 'funnelforms-pro' ), }; return names[ category ]; } /** One line under the name of a tile. */ function hint( service: HubService ): string { const hints: Record = { stripe: __( 'Cards, Apple Pay, Google Pay, SEPA, Klarna and subscriptions', 'funnelforms-pro' ), paypal: __( 'PayPal, Pay Later and cards', 'funnelforms-pro' ), mollie: __( 'iDEAL, Bancontact, cards, SEPA and more', 'funnelforms-pro' ), google: __( 'Google Workspace and Gmail', 'funnelforms-pro' ), microsoft: __( 'Microsoft 365, Outlook.com and Exchange Online', 'funnelforms-pro' ), icloud: __( 'With an app-specific password', 'funnelforms-pro' ), caldav: __( 'Nextcloud, Fastmail, mailbox.org and more', 'funnelforms-pro' ), zoom: __( 'A Zoom meeting for each appointment', 'funnelforms-pro' ), meet: __( 'With your Google calendar', 'funnelforms-pro' ), 'teams-meetings': __( 'With your Microsoft 365 calendar', 'funnelforms-pro' ), slack: __( 'A message in a channel for each entry', 'funnelforms-pro' ), teams: __( 'A message in a channel for each entry', 'funnelforms-pro' ), whatsapp: __( 'WhatsApp message', 'funnelforms-pro' ), twilio: __( 'Text message (SMS)', 'funnelforms-pro' ), bird: __( 'Text message (SMS)', 'funnelforms-pro' ), elevenlabs: __( 'An AI agent calls new leads', 'funnelforms-pro' ), meta: __( 'Conversions from the server, with consent', 'funnelforms-pro' ), ga4: __( 'Conversions from the server, with consent', 'funnelforms-pro' ), tiktok: __( 'Conversions from the server, with consent', 'funnelforms-pro' ), automation: __( 'Webhooks and API tokens for Zapier, Make, n8n and your own tools', 'funnelforms-pro' ), }; const byCategory: Partial> = { crm: __( 'Contacts and deals in your CRM', 'funnelforms-pro' ), newsletter: __( 'Subscribers for your lists, with double opt-in', 'funnelforms-pro' ), spreadsheet: __( 'Each entry as a row', 'funnelforms-pro' ), }; return hints[ service.id ] ?? byCategory[ service.category ] ?? ''; } /** * Where a connected service is used: the place in the form builder, or the page that uses it. * Empty for services the page itself uses (calendars) or that are set up elsewhere. */ export function usage( service: Pick ): string { if ( 'payments' === service.category ) { return __( 'In the form builder open Settings → Payment and choose this connection. The form then asks for the payment before the entry is sent.', 'funnelforms-pro' ); } if ( 'twilio' === service.id || 'bird' === service.id ) { return __( 'In the form builder select the contact step and open “After sending”: the connection is listed under “Your connected tools” and sends a text message for each entry, to you or to the visitor. A phone field can also confirm numbers by text message.', 'funnelforms-pro' ); } if ( 'elevenlabs' === service.id ) { return __( 'Under Funnelforms → AI Phone Agent you create agents once. In the form builder add “AI Phone Agent” after sending and choose the agent: each lead who agreed is called within its call hours.', 'funnelforms-pro' ); } if ( 'crm' === service.kind || 'messages' === service.category || 'tracking' === service.category ) { return __( 'In the form builder select the contact step and open “After sending”: the connection is listed under “Your connected tools”. One click adds it, and every entry of the form goes there.', 'funnelforms-pro' ); } return ''; } /** Where the customer finds the keys of a connection type. */ function steps( type: string ): string { const all: Record = { stripe: __( 'In Stripe open Developers → API keys and copy the secret key. Funnelforms then sets up the webhook for payments, refunds and subscriptions itself.', 'funnelforms-pro' ), paypal: __( 'In the PayPal developer dashboard open Apps & Credentials, create an app and copy its client ID and secret. A sandbox app takes test payments.', 'funnelforms-pro' ), mollie: __( 'In Mollie open Developers → API keys and copy the live or test API key of your website profile.', 'funnelforms-pro' ), slack: __( 'In Slack create an incoming webhook for the channel and paste its address here.', 'funnelforms-pro' ), teams: __( 'In Teams add the workflow “Post to a channel when a webhook request is received” to the channel and paste its address here.', 'funnelforms-pro' ), whatsapp: __( 'In the WhatsApp Manager of Meta open API Setup and copy the phone number ID and a permanent access token of a system user.', 'funnelforms-pro' ), twilio: __( 'In the Twilio console copy the account SID and the auth token from the account info.', 'funnelforms-pro' ), bird: __( 'In Bird open Settings → Developer and copy the workspace ID, the channel ID of your SMS channel and an access key.', 'funnelforms-pro' ), elevenlabs: __( 'In ElevenLabs open Developers → API keys and create a key with access to the Agents Platform. Everything else is set up under Funnelforms → AI Phone Agent.', 'funnelforms-pro' ), meta: __( 'In the Meta Events Manager open your pixel, then Settings → Conversions API: copy the pixel ID and generate an access token.', 'funnelforms-pro' ), ga4: __( 'In Google Analytics open Admin → Data streams → your web stream, copy the measurement ID and create a Measurement Protocol API secret.', 'funnelforms-pro' ), tiktok: __( 'In the TikTok Events Manager open your pixel, then Settings: copy the pixel code and generate an access token.', 'funnelforms-pro' ), }; return all[ type ] ?? ''; } /** Credentials each connection type asks for: parameter, label, secret, optional (as in the form builder). */ function credentials( type: string ): Array<[ string, string, boolean, boolean? ]> { const webhook = __( 'Webhook URL', 'funnelforms-pro' ); const accessKey = __( 'Access key', 'funnelforms-pro' ); const accessToken = __( 'Access token', 'funnelforms-pro' ); const all: Record> = { slack: [ [ 'url', webhook, true ] ], teams: [ [ 'url', webhook, true ] ], twilio: [ [ 'accountSid', __( 'Account SID', 'funnelforms-pro' ), false ], [ 'authToken', __( 'Auth token', 'funnelforms-pro' ), true ], ], bird: [ [ 'workspaceId', __( 'Workspace ID', 'funnelforms-pro' ), false ], [ 'channelId', __( 'Channel ID', 'funnelforms-pro' ), false ], [ 'accessKey', accessKey, true ], ], whatsapp: [ [ 'phoneNumberId', __( 'Phone number ID', 'funnelforms-pro' ), false ], [ 'accessToken', accessToken, true ], [ 'businessAccountId', __( 'WhatsApp Business account ID (for templates)', 'funnelforms-pro' ), false, true ], ], meta: [ [ 'pixelId', __( 'Pixel ID', 'funnelforms-pro' ), false ], [ 'accessToken', accessToken, true ], ], ga4: [ [ 'measurementId', __( 'Measurement ID', 'funnelforms-pro' ), false ], [ 'apiSecret', __( 'API secret', 'funnelforms-pro' ), true ], ], tiktok: [ [ 'pixelCode', __( 'Pixel code', 'funnelforms-pro' ), false ], [ 'accessToken', accessToken, true ], ], stripe: [ [ 'secretKey', __( 'Secret key (sk_… or rk_…)', 'funnelforms-pro' ), true ] ], paypal: [ [ 'clientId', __( 'Client ID', 'funnelforms-pro' ), false ], [ 'clientSecret', __( 'Client secret', 'funnelforms-pro' ), true ], ], mollie: [ [ 'apiKey', __( 'API key (live_… or test_…)', 'funnelforms-pro' ), true ] ], elevenlabs: [ [ 'apiKey', __( 'API key', 'funnelforms-pro' ), true ] ], }; return all[ type ] ?? []; } const PAYMENTS = [ 'stripe', 'paypal', 'mollie' ]; const SMS = [ 'twilio', 'bird' ]; function Mark( { service }: { service: HubService } ) { return ( ); } function States( { list }: { list: HubConnection[] } ) { if ( ! list.length ) { return null; } return ( { list.length > 1 ? __( 'Connected', 'funnelforms-pro' ) + ' · ' + list.length : __( 'Connected', 'funnelforms-pro' ) } { list.some( ( c ) => null !== c.attention ) ? { __( 'Needs attention', 'funnelforms-pro' ) } : null } { list.some( ( c ) => c.testMode ) ? { __( 'Test mode', 'funnelforms-pro' ) } : null } ); } type Result = { tone: 'success' | 'danger' | 'warning' | 'info'; text: string }; export function IntegrationsHub( { api, config, onCalendar, stamp }: { api: HubScreenApi; config: HubConfig; onCalendar: ( service: CalendarService ) => void; stamp?: unknown } ) { const [ data, setData ] = useState( null ); const [ providers, setProviders ] = useState( [] ); const [ error, setError ] = useState( null ); const [ query, setQuery ] = useState( '' ); const [ category, setCategory ] = useState( 'all' ); const [ connectedOnly, setConnectedOnly ] = useState( false ); const [ open, setOpen ] = useState( null ); const [ crm, setCrm ] = useState<{ provider: string; connection?: CrmConnection } | null>( null ); const [ results, setResults ] = useState>( {} ); const [ busy, setBusy ] = useState( null ); const [ said, say ] = useState( '' ); const reload = useCallback( async (): Promise => { setError( null ); try { setData( await api.hub.overview() ); } catch ( e ) { setError( message( e ) ); } }, [ api ] ); useEffect( () => { void reload(); api.connect.crmProviders().then( setProviders, () => setProviders( [] ) ); }, [ api, reload ] ); // Calendars change in the section below; the counts follow (not on the first answer). const seen = useRef( false ); useEffect( () => { if ( undefined === stamp || null === stamp ) { return; } if ( seen.current ) { void reload(); } seen.current = true; }, [ stamp, reload ] ); const services = useMemo( () => hubServices( providers ), [ providers ] ); const connections = data?.connections ?? []; const shown = filterServices( services, { query, category, connectedOnly }, connections, categoryName ); const figures = hubSummary( connections ); const service = services.find( ( s ) => s.id === open ) ?? null; const nameOf = ( type: string ): string => services.find( ( s ) => s.types.includes( type ) )?.name ?? type; const note = ( ref: string, result: Result | null ): void => setResults( ( r ) => { if ( result ) { return { ...r, [ ref ]: result }; } return Object.fromEntries( Object.entries( r ).filter( ( [ key ] ) => key !== ref ) ); } ); /** Asks the provider whether the keys work; for Stripe then sets up the webhook when it is missing. */ const checkPayment = async ( connection: Pick, webhook: boolean ): Promise => { setBusy( connection.ref ); note( connection.ref, null ); try { const check = await api.hub.checkPayment( connection.ref ); const lines = [ __( 'The keys work.', 'funnelforms-pro' ) ]; if ( check.account ) { lines.push( sprintf( __( 'Account: %s.', 'funnelforms-pro' ), check.account ) ); } if ( check.methods.length ) { lines.push( sprintf( __( 'Payment methods switched on: %s.', 'funnelforms-pro' ), check.methods.join( ', ' ) ) ); } if ( check.testMode ) { lines.push( __( 'These are test keys: nothing is charged. Switch to the live keys before your form goes live.', 'funnelforms-pro' ) ); } if ( webhook && 'stripe' === connection.type ) { try { await api.hub.setUpStripeWebhook( connection.ref ); lines.push( __( 'The webhook is set up: Stripe now reports payments, refunds and subscriptions to this website.', 'funnelforms-pro' ) ); } catch ( e ) { note( connection.ref, { tone: 'warning', text: lines.join( ' ' ) + ' ' + message( e ) } ); return; } } note( connection.ref, { tone: check.testMode ? 'warning' : 'success', text: lines.join( ' ' ) } ); } catch ( e ) { note( connection.ref, { tone: 'danger', text: message( e ) } ); } finally { setBusy( null ); await reload(); } }; const setUpWebhook = async ( ref: string ): Promise => { setBusy( ref ); note( ref, null ); try { await api.hub.setUpStripeWebhook( ref ); note( ref, { tone: 'success', text: __( 'The webhook is set up: Stripe now reports payments, refunds and subscriptions to this website.', 'funnelforms-pro' ) } ); await reload(); } catch ( e ) { note( ref, { tone: 'danger', text: message( e ) } ); } finally { setBusy( null ); } }; const crmConnection = ( c: HubConnection ): CrmConnection => ( { ref: c.ref, provider: c.type, label: c.label, legacy: ! deletable( c.ref ), createdAt: c.createdAt, forms: c.formCount } ); const openService = ( s: HubService ): void => { if ( 'calendar' === s.kind ) { onCalendar( s.id as CalendarService ); return; } if ( 'meeting' === s.kind ) { document.getElementById( 'ffx-meetings-title' )?.scrollIntoView( { behavior: 'smooth', block: 'start' } ); return; } if ( 'crm' === s.kind && ! connectionsOf( s, connections ).length ) { setCrm( { provider: s.id } ); return; } setOpen( s.id ); }; const attention = connections.filter( ( c ) => null !== c.attention ); const groups: Array<[ HubCategory | null, HubService[] ]> = 'all' === category && '' === query.trim() ? HUB_CATEGORIES.map( ( c ) => [ c, shown.filter( ( s ) => s.category === c ) ] ) : [ [ null, shown ] ]; return (

{ __( 'All integrations', 'funnelforms-pro' ) }

{ __( 'Choose a service, paste its key and you are done. Each connection works in every form.', 'funnelforms-pro' ) }

{ __( 'Then decide per form what happens with each entry: in the form builder select the contact step and open “After sending”, where your connected tools are ready to add.', 'funnelforms-pro' ) }

{ data ? (
{ __( 'Connections', 'funnelforms-pro' ) }
{ figures.connected }
{ __( 'Used in forms', 'funnelforms-pro' ) }
{ figures.inUse }
{ __( 'Need attention', 'funnelforms-pro' ) }
{ figures.attention }
) : null }
{ error ? (

{ error }{ ' ' }

) : null } { ! error && ! data ? : null } { attention.length ? (
    { attention.map( ( c ) => (
  • { c.label } ({ nameOf( c.type ) }){ ' ' } { 'webhook_missing' === c.attention ? __( 'Payments are confirmed through the webhook, also when visitors close the page. It is not set up yet.', 'funnelforms-pro' ) : __( 'Google no longer accepts this connection. Connect the account again.', 'funnelforms-pro' ) } { results[ c.ref ] && 'danger' === results[ c.ref ]?.tone ? { results[ c.ref ]?.text } : null } { 'webhook_missing' === c.attention ? ( ) : ( ) }
  • ) ) }
) : null }
{ ( [ 'all', ...HUB_CATEGORIES ] as Array ).map( ( c ) => ( ) ) }
{ data && ! shown.length ?

{ __( 'No integration matches your search.', 'funnelforms-pro' ) }

: null } { data ? groups .filter( ( [ , list ] ) => list.length ) .map( ( [ c, list ] ) => (
{ c ?

{ categoryName( c ) }

: null }
    { list.map( ( s ) => (
  • { 'link' === s.kind ? ( { s.name } { hint( s ) } ) : ( ) }
  • ) ) }
) ) : null }

{ said }

{ service ? ( p.provider === service.id ) } list={ connectionsOf( service, connections ) } api={ api } config={ config } results={ results } busy={ busy } onClose={ () => setOpen( null ) } onCheck={ ( c, webhook ) => void checkPayment( c, webhook ) } onWebhook={ ( ref ) => void setUpWebhook( ref ) } onCrm={ ( c ) => { setOpen( null ); setCrm( { provider: service.id, connection: c ? crmConnection( c ) : undefined } ); } } onChanged={ async ( text ) => { say( text ); await reload(); } } /> ) : null } { crm ? ( setCrm( null ) } onSaved={ ( c ) => { setCrm( null ); say( sprintf( __( '%s was saved.', 'funnelforms-pro' ), c.label ) ); void reload(); } } /> ) : null }
); } function ServicePanel( { service, provider, list, api, config, results, busy, onClose, onCheck, onWebhook, onCrm, onChanged, }: { service: HubService; provider?: CrmProvider; list: HubConnection[]; api: HubScreenApi; config: HubConfig; results: Record; busy: string | null; onClose: () => void; onCheck: ( c: Pick, webhook: boolean ) => void; onWebhook: ( ref: string ) => void; onCrm: ( c?: HubConnection ) => void; onChanged: ( text: string ) => Promise; } ) { const type = service.types[ 0 ] ?? service.id; const [ adding, setAdding ] = useState( 0 === list.length ); const [ editing, setEditing ] = useState( null ); const crm = 'crm' === service.kind; const how = crm ? provider?.help ?? '' : steps( type ); return ( { __( 'Close', 'funnelforms-pro' ) } } >

{ hint( service ) }

{ how ? (

{ __( 'How to connect', 'funnelforms-pro' ) }

{ how }

{ service.dashboard ? ( { sprintf( __( 'Open %s', 'funnelforms-pro' ), service.name ) } ) : null }
) : null } { usage( service ) ? (

{ __( 'Use it in a form', 'funnelforms-pro' ) }

{ usage( service ) }

{ config.builderUrl && list.length ? ( { __( 'Open the forms', 'funnelforms-pro' ) } ) : null }
) : null } { list.length ? ( <>

{ __( 'Your connections', 'funnelforms-pro' ) }

    { list.map( ( c ) => editing === c.ref ? (
  • setEditing( null ) } onSaved={ async ( saved ) => { setEditing( null ); await onChanged( sprintf( __( '%s was saved.', 'funnelforms-pro' ), saved.label ) ); if ( PAYMENTS.includes( c.type ) ) { onCheck( c, false ); } } } />
  • ) : ( onCheck( c, false ) } onWebhook={ () => onWebhook( c.ref ) } onEdit={ () => ( crm ? onCrm( c ) : setEditing( c.ref ) ) } onChanged={ onChanged } /> ) ) }
) : null } { crm ? (
) : adding ? ( setAdding( false ) : undefined } onSaved={ async ( saved ) => { setAdding( false ); await onChanged( sprintf( __( '%s was saved.', 'funnelforms-pro' ), saved.label ) ); if ( PAYMENTS.includes( type ) ) { onCheck( saved, 'stripe' === type ); } } } /> ) : (
) }
); } function ConnectionRow( { connection, crm, api, config, result, busy, onCheck, onWebhook, onEdit, onChanged, }: { connection: HubConnection; crm: boolean; api: HubScreenApi; config: HubConfig; result?: Result; busy: boolean; onCheck: () => void; onWebhook: () => void; onEdit: () => void; onChanged: ( text: string ) => Promise; } ) { const [ removing, setRemoving ] = useState( false ); const [ testing, setTesting ] = useState( false ); const [ to, setTo ] = useState( '' ); const [ own, setOwn ] = useState( null ); const [ secret, setSecret ] = useState( '' ); const [ copied, setCopied ] = useState( false ); const c = connection; const payment = PAYMENTS.includes( c.type ); const number = SMS.includes( c.type ) || 'whatsapp' === c.type; const direct = [ 'slack', 'teams' ].includes( c.type ); // The voice connection places no call for a test: it reads the account. const voice = 'elevenlabs' === c.type; // CRM tools brought over from Funnelforms 3 are still used there: they can be changed, not deleted. const legacy = crm && ! deletable( c.ref ); const formUrl = ( id: number ): string => ( config.builderUrl ? config.builderUrl + ( config.builderUrl.includes( '?' ) ? '&' : '?' ) + 'form=' + id : '' ); const test = async (): Promise => { setTesting( true ); setOwn( null ); try { if ( crm ) { // Reading the choices of the account (lists, pipelines) checks the access data. const result = await api.connect.crmOptions( c.ref ); setOwn( result.checked ? { tone: 'success', text: __( 'The connection works: the tool accepted the access data.', 'funnelforms-pro' ) } : { tone: 'info', text: __( 'This tool cannot be checked from here. Send a test entry to try the connection.', 'funnelforms-pro' ) } ); return; } if ( voice ) { await api.testConnection( c.ref, {} ); setOwn( { tone: 'success', text: __( 'The connection works. Agents are set up under Funnelforms → AI Phone Agent.', 'funnelforms-pro' ) } ); return; } await api.testConnection( c.ref, number ? ( 'whatsapp' === c.type ? { to: to.trim(), template: 'hello_world', language: 'en_US' } : { to: to.trim() } ) : {} ); setOwn( { tone: 'success', text: __( 'The test message was sent. Check that it arrived.', 'funnelforms-pro' ) } ); } catch ( e ) { setOwn( { tone: 'danger', text: message( e ) } ); } finally { setTesting( false ); } }; const remove = async (): Promise => { setOwn( null ); try { if ( crm ) { await api.connect.deleteCrmConnection( c.ref ); } else { await api.deleteConnection( c.ref ); } await onChanged( sprintf( __( '%s was removed.', 'funnelforms-pro' ), c.label ) ); } catch ( e ) { setRemoving( false ); setOwn( { tone: 'danger', text: message( e ) } ); } }; const saveSecret = async (): Promise => { setOwn( null ); try { await api.updateConnection( c.ref, { webhookSecret: secret.trim() } ); setSecret( '' ); await onChanged( sprintf( __( '%s was saved.', 'funnelforms-pro' ), c.label ) ); } catch ( e ) { setOwn( { tone: 'danger', text: message( e ) } ); } }; const copy = async (): Promise => { try { await navigator.clipboard.writeText( c.webhookUrl ?? '' ); setCopied( true ); } catch { setCopied( false ); } }; const shown = own ?? result ?? null; return (
  • { c.label } { c.testMode ? { __( 'Test mode', 'funnelforms-pro' ) } : null } { c.attention ? { __( 'Needs attention', 'funnelforms-pro' ) } : { __( 'Connected', 'funnelforms-pro' ) } } { legacy ? { __( 'From Funnelforms 3', 'funnelforms-pro' ) } : null }

    { c.formCount ? ( <> { __( 'Used in:', 'funnelforms-pro' ) }{ ' ' } { c.forms.map( ( f, i ) => ( { i ? ', ' : '' } { formUrl( f.id ) ? { f.title || '#' + f.id } : f.title || '#' + f.id } ) ) } { c.formCount > c.forms.length ? ' …' : '' } ) : ( __( 'Not used in any form yet.', 'funnelforms-pro' ) ) }

    { shown ? { shown.text } : null } { 'webhook_missing' === c.attention && c.webhookUrl ? (

    { __( 'Payments are confirmed through the webhook, also when visitors close the page. It is not set up yet.', 'funnelforms-pro' ) }

    { __( 'Set it up by hand', 'funnelforms-pro' ) }

    { __( 'In Stripe, add this address as webhook endpoint for the events checkout.session.*, customer.subscription.*, charge.refunded and charge.dispute.created, then enter its signing secret here, so payments, subscriptions and refunds are confirmed even when visitors close the page.', 'funnelforms-pro' ) }

    { c.webhookUrl }
    ) : null } { number && ! removing ? (
    ) : null } { removing ? (
    { sprintf( __( 'Delete “%s”?', 'funnelforms-pro' ), c.label ) } { c.formCount ? { sprintf( __( 'These stop working: %s. Choose another connection for them afterwards.', 'funnelforms-pro' ), c.forms.map( ( f ) => f.title || '#' + f.id ).join( ', ' ) ) } : null }

    { __( 'The connection is deleted for the whole site: other forms that use it stop sending through it too. The stored access keys are removed; this cannot be undone.', 'funnelforms-pro' ) }

    ) : (
    { payment ? ( ) : null } { direct || number ? ( ) : null } { crm || voice ? ( ) : null } { deletable( c.ref ) ? ( ) : null }
    ) } { legacy ?

    { __( 'This connection came from Funnelforms 3 and is still used there. Change its access data instead.', 'funnelforms-pro' ) }

    : null } { [ 'meta', 'ga4', 'tiktok' ].includes( c.type ) ?

    { __( 'Try it with a test entry: payments with the test keys of the provider, conversions with the test event code of the platform.', 'funnelforms-pro' ) }

    : null }
  • ); } /** Connects a service, or with a connection given renames it and replaces the keys typed in. */ function ConnectForm( { type, connection, defaultLabel = '', api, onCancel, onSaved }: { type: string; connection?: HubConnection; defaultLabel?: string; api: HubScreenApi; onCancel?: () => void; onSaved: ( c: { ref: string; type: string; label: string } ) => void } ) { const [ label, setLabel ] = useState( connection?.label ?? defaultLabel ); const [ values, setValues ] = useState>( {} ); const [ sandbox, setSandbox ] = useState( false ); const [ busy, setBusy ] = useState( false ); const [ error, setError ] = useState( null ); const fields = credentials( type ); const complete = '' !== label.trim() && ( connection ? true : fields.every( ( [ key, , , optional ] ) => optional || '' !== ( values[ key ] ?? '' ).trim() ) ); const save = async (): Promise => { setBusy( true ); setError( null ); try { const given = Object.fromEntries( Object.entries( values ).map( ( [ k, v ] ) => [ k, v.trim() ] ).filter( ( [ , v ] ) => '' !== v ) ); if ( connection ) { const saved = await api.updateConnection( connection.ref, { ...given, label: label.trim() } ); onSaved( { ref: connection.ref, type, label: saved.label ?? label.trim() } ); } else { onSaved( await api.createConnection( type, label.trim(), 'paypal' === type && sandbox ? { ...given, sandbox: true } : given ) ); } } catch ( e ) { setError( message( e ) ); setBusy( false ); } }; return (
    { e.preventDefault(); if ( complete && ! busy ) { void save(); } } } > { error ? { error } : null } { fields.map( ( [ key, name, secret, optional ] ) => ( setValues( ( x ) => ( { ...x, [ key ]: v } ) ) } /> ) ) } { 'paypal' === type && ! connection ? : null }

    { connection ? __( 'Fill in only what changes; empty fields keep the stored values. Access keys are stored encrypted and never shown again.', 'funnelforms-pro' ) : __( 'Access keys are stored encrypted and never shown again.', 'funnelforms-pro' ) }

    { onCancel ? ( ) : null }
    ); }