Technical Reference
This document provides technical details and implementation patterns for specific Billy features and integrations.Payment Status Integration
Overview
Billy implements bidirectional payment status synchronization between Pennylane and various integration sources. This allows payment updates to flow in both directions, ensuring data consistency across systems.Architecture
Dest to Source (Pennylane → Integration)
When Pennylane updates payment status, Billy syncs this information to the source integration: Requirements:- PennylaneIntegration must implement
UpdatePaymentStatusIntegration
- Source integration must implement
PushPaymentStatusIntegration
- Ensure
getAllowedSourcesForInvoiceSynchronization
works for your integration - Update
getDestToSourceSyncableSourceIntegrations
to include your integration - Implement the required interfaces
Source to Dest (Integration → Pennylane)
When source systems update payment status, Billy syncs to Pennylane: Requirements:- Update
getAllowedSourcesForInvoiceSynchronization
- Specifically update
getSourceToDestSyncableSourceIntegrations
- This prevents querying non-existing fields
- Check
filterDestSyncableInvoices
function - Review
getSyncablePennylaneGateways
for gateway restrictions - Consider implementing
refresh_unpaid_client_invoices
orrefresh_unpaid_supplier_invoices
Implementation Patterns
UpdatePaymentStatusIntegration
Render this field in your integration component:PushPaymentStatusIntegration
Render this field in your integration component:Development Workflow
Cron Jobs
Payment synchronization is managed by Vercel cron jobs:- Pennylane-only sync:
/api/invoices/cron/synchronize_payments_with_pennylane_dest_invoices
- Integration sync (200 at a time):
/api/integrations/internal/[source]/cron/synchronize_payments_with_pennylane_dest_invoices
- Individual integration sync:
/api/integrations/internal/[source]/[id]/synchronize_payments_with_pennylane_dest_invoices
Database Development
PostgreSQL Constraints
List constraints on a specific table:Database Migrations
Integration Development
Webhook Development
Local Testing with Tunnels
For local webhook development, use Cloudflare tunnels:Permanent Tunnel Setup
.cloudflared/your-name.yml
:
OAuth Development
Spendesk OAuth
Spendesk doesn’t allow ports in redirect URIs:HubSpot Development
- Go to HubSpot Developer Account
- Create application with redirect URI:
https://localhost:3000/oauth/hubspot/redirect_uri
- Add credentials to
.env.local
:
Pipedrive Development
- Go to Pipedrive Developer Hub
- Create OAuth application with redirect URI:
https://localhost:3000/oauth/pipedrive/redirect_uri
- Add credentials to
.env.local
:
Pipedrive Extensions
Custom Modals
Add these modals to your Pipedrive application:Name | Iframe URL |
---|---|
Créer une facture Pennylane | <Tunnel URL>/iframes/pipedrive/pennylane/deals |
Créer un devis Pennylane | <Tunnel URL>/iframes/pipedrive/pennylane/quotes |
Associer une facture | <Tunnel URL>/iframes/pipedrive/pennylane/associate_invoices |
Associer un devis | <Tunnel URL>/iframes/pipedrive/pennylane/associate_quotes |
Créer un client | <Tunnel URL>/iframes/pipedrive/pennylane/organization/create_client |
Configuration | <Tunnel URL>/iframes/pipedrive/pennylane/configuration_fields |
Custom Panels
Add these panels to your Pipedrive application:Name | API Endpoint | Panel Locations | Main Action |
---|---|---|---|
Pennylane (Your Name [Dev]) | <Tunnel URL>/iframes/pipedrive/pennylane/invoice_panel | deals | Default |
Pennylane (Your Name [Dev]) | <Tunnel URL>/iframes/pipedrive/pennylane/organization_panel | organizations | Default |
PIPEDRIVE_PENNYLANE_CLIENT_SECRET
if required.
Development Tools
Cloudflare Workers
Hookdeck
GraphQL Development
Gotenberg (PDF Generation)
Gotenberg is accessible at: http://localhost:3045/healthEnvironment Management
Pennylane Sandbox
- Go to Pennylane Sandbox
- Create your own sandbox
- Get API key from developer settings
- Add to
.env.local
:
- Reset SQL schema and run
pnpm populate