django_program.registration.stripe_client¶
Stripe client wrapper for per-conference Stripe API operations.
Each conference has its own Stripe account keys, so the client is initialized
with a Conference instance and uses the modern stripe.StripeClient pattern
(v1 namespace) for all API calls.
Classes
Per-conference Stripe API client. |
- class django_program.registration.stripe_client.StripeClient[source]¶
Bases:
objectPer-conference Stripe API client.
Wraps
stripe.StripeClient(v1 namespace) and binds every call to the conference’s secret key and the globally configured API version.- Parameters:
conference (
Conference) – The conference whose Stripe keys will be used.- Raises:
ValueError – If the conference has no Stripe secret key configured.
- __init__(conference)[source]¶
Initialize the client with per-conference Stripe credentials.
- Parameters:
conference (
Conference) – A Conference instance withstripe_secret_keyset.- Raises:
ValueError – If the conference has no Stripe secret key.
- get_or_create_customer(user)[source]¶
Return an existing StripeCustomer or create one via the Stripe API.
Looks up the local
StripeCustomerrecord for this user and conference. If none exists, creates a Stripe customer in the conference’s Stripe account and persists the mapping locally.- Parameters:
user (
AbstractBaseUser) – The Django user to map to a Stripe customer.- Return type:
- Returns:
The
StripeCustomerrecord linking the user to a Stripe customer ID.
- create_payment_intent(order, customer_id)[source]¶
Create a Stripe PaymentIntent for the given order.
Converts the order total to the smallest currency unit and passes the order reference as an idempotency key so retried requests are safe.
- capture_payment_intent(intent_id)[source]¶
Capture a previously authorized PaymentIntent.
- Parameters:
intent_id (
str) – The Stripe PaymentIntent ID to capture.- Return type:
PaymentIntent- Returns:
The captured
stripe.PaymentIntentobject.