django_program.registration.services.payment

Payment service for processing order payments.

Handles Stripe payment initiation, complimentary order fulfillment, and manual staff-entered payments. All methods are stateless and operate on model instances directly.

Classes

PaymentService

Stateless service for payment operations.

class django_program.registration.services.payment.PaymentService[source]

Bases: object

Stateless service for payment operations.

Orchestrates Stripe payment flows, complimentary order fulfillment, and manual staff payments against registration orders.

static initiate_payment(order)[source]

Initiate a Stripe payment flow for the given order.

Creates a Stripe customer (if needed), a PaymentIntent, and a pending Payment record. Returns the client_secret for the frontend to confirm via Stripe.js.

Parameters:

order (Order) – The order to collect payment for.

Return type:

str

Returns:

The Stripe client_secret string for frontend confirmation.

Raises:
  • ValidationError – If the order is not in PENDING status.

  • ValueError – If the conference has no Stripe key configured, or if the client_secret format is unexpected.

static record_comp(order)[source]

Record a complimentary payment for a zero-total order.

Used for speaker comps, 100% voucher discounts, or any other scenario where the order total is zero.

Parameters:

order (Order) – The order to fulfill as complimentary.

Return type:

Payment

Returns:

The created Payment record with SUCCEEDED status.

Raises:

ValidationError – If the order is not PENDING or has a non-zero total.

static record_manual(order, *, amount, reference='', note='', staff_user=None)[source]

Record a manual payment entered by staff.

Used for at-the-door cash payments, wire transfers, or other off-platform payment methods. If the cumulative succeeded payments meet or exceed the order total, the order is transitioned to PAID.

Parameters:
  • order (Order) – The order to record payment against.

  • amount (Decimal) – The payment amount (must be positive).

  • reference (str) – An optional external reference (e.g. receipt number).

  • note (str) – An optional staff note about the payment.

  • staff_user (AbstractBaseUser | None) – The staff member recording the payment.

Return type:

Payment

Returns:

The created Payment record with SUCCEEDED status.

Raises:

ValidationError – If the order is not PENDING or the amount is not positive.