django_program.registration.services.stripe_invoicing

Stripe Invoicing integration for purchase orders.

Creates, sends, and syncs Stripe Invoices for corporate POs. Uses the per-conference StripeClient pattern so each conference’s Stripe account handles its own invoices. Supports card and ACH payments via Stripe’s hosted invoice page.

Functions

create_stripe_invoice(purchase_order)

Create and send a Stripe Invoice for a purchase order.

handle_invoice_paid_webhook(stripe_event_payload)

Process an invoice.paid webhook event from Stripe.

sync_stripe_invoice_status(purchase_order)

Fetch the Stripe invoice and sync payment status to the PO.

django_program.registration.services.stripe_invoicing.create_stripe_invoice(purchase_order)[source]

Create and send a Stripe Invoice for a purchase order.

Builds a Stripe Invoice with line items matching the PO, finalizes it, and stores the invoice ID and hosted URL on the PO record.

Parameters:

purchase_order (PurchaseOrder) – The purchase order to invoice.

Return type:

str

Returns:

The Stripe-hosted invoice URL where the customer can pay.

Raises:
  • ValueError – If the conference has no Stripe key, or if the PO already has a Stripe invoice attached.

  • stripe.StripeError – On any Stripe API failure.

django_program.registration.services.stripe_invoicing.sync_stripe_invoice_status(purchase_order)[source]

Fetch the Stripe invoice and sync payment status to the PO.

If Stripe reports the invoice as fully paid, records a payment via record_payment() with method stripe. Handles partial payments when amount_paid < amount_due.

Parameters:

purchase_order (PurchaseOrder) – The PO with a stripe_invoice_id to sync.

Raises:
  • ValueError – If the PO has no Stripe invoice ID.

  • stripe.StripeError – On any Stripe API failure.

Return type:

None

django_program.registration.services.stripe_invoicing.handle_invoice_paid_webhook(stripe_event_payload)[source]

Process an invoice.paid webhook event from Stripe.

Looks up the PO by the Stripe invoice ID embedded in the event data. If found, records the payment amount and updates the PO status.

Parameters:

stripe_event_payload (dict[str, object]) – The full Stripe event payload dict. Expected to contain data.object with invoice fields.

Return type:

None