-- Example seed for one Stripe billing provider connection.
-- Replace placeholder values before running this in a real environment.

INSERT INTO billing.billing_provider_connections (
    owner_kind,
    owner_id,
    provider,
    mode,
    status,
    credential_kind,
    provider_account_id,
    provider_profile_id,
    scopes,
    config,
    metadata
)
VALUES (
    'org',
    'replace-me-org-id',
    'stripe',
    'test',
    'active',
    'secret_key',
    'acct_replace_me',
    'acct_replace_me',
    '[
      "read_only",
      "customers.read",
      "payment_intents.read",
      "checkout.sessions.read",
      "invoices.read",
      "subscriptions.read"
    ]'::jsonb,
    jsonb_build_object(
        'apiBaseUrl', 'https://api.stripe.com',
        'credentialKind', 'secret_key',
        'apiKey', 'replace-me-stripe-secret-key',
        'mode', 'test',
        'accountId', 'acct_replace_me',
        'webhookSigningSecrets', jsonb_build_array('whsec_replace_me')
    ),
    jsonb_build_object(
        'origin', 'sql.seed',
        'notes', 'Replace placeholder values before use.'
    )
)
ON CONFLICT (owner_kind, owner_id, provider, mode)
WHERE deleted_at IS NULL
DO UPDATE SET
    status = EXCLUDED.status,
    credential_kind = EXCLUDED.credential_kind,
    provider_account_id = EXCLUDED.provider_account_id,
    provider_profile_id = EXCLUDED.provider_profile_id,
    scopes = EXCLUDED.scopes,
    config = EXCLUDED.config,
    metadata = EXCLUDED.metadata,
    updated_at = now();
