Stripe integration
Purpose
Section titled “Purpose”Create Stripe Payment Links, track status, and update Sales Invoice payment state via webhooks.
Scope in codebase
Section titled “Scope in codebase”leekimerp/leekimerp/api/stripe.py— payment link APIleekimerp/leekimerp/api/stripe_webhook.py— webhook handling, payment entry creation helpers
Flow (simplified)
Section titled “Flow (simplified)”sequenceDiagram participant U as User participant API as stripe.py participant S as Stripe participant WH as stripe_webhook.py U->>API: create_payment_link API->>S: Create link / session S->>WH: payment_intent.succeeded / checkout.session.completed WH->>WH: update_invoice_payment_statusWhitelisted API (stripe.py)
Section titled “Whitelisted API (stripe.py)”| Function | Role |
|---|---|
create_payment_link | Create link for a sales invoice |
get_payment_link_status | Poll status |
payment_completed | Mark completion from client callback |
cancel_payment_link | Cancel link |
Webhooks (stripe_webhook.py)
Section titled “Webhooks (stripe_webhook.py)”stripe_webhook is the main entry; guest access — must validate Stripe signatures (see implementation). Helper functions update invoice status and may create Payment Entry.
Dependencies
Section titled “Dependencies”- Stripe settings per Company (
get_stripe_settings,init_stripe_client)
Configuration
Section titled “Configuration”- API keys via site config or integration DocType (follow existing
get_stripe_settingspattern)
Operational notes
Section titled “Operational notes”- Test helpers:
test_webhook,debug_webhook_signature,stripe_webhook_test— disable or protect in production