Stripe operations¶
The operation facade is included in 0.3.0. Existing 0.2.0 connector exports remain compatible. Facades, models, connectors and gateway protocols work with the base installation. SDK gateway classes and webhook parsing require the optional Stripe integration.
StripeActions ¶
StripeActions(*, host: RefundHost | None = None, policy: RefundPolicy | None = None, settings: StripeRefundSettings | None = None, store: ActionStore, authority_evaluator: AuthorityEvaluatorPort, commitment_provider: CommitmentProviderPort, protection_codec: ProtectionCodecPort, retention_store: RetentionStore | None = None, clock: Clock | None = None, identifiers: IdentifierProvider | None = None, event_sink: EventSink | None = None, runtime_revision: str | None = None, client: StripeClient | None = None, gateway: StripeRefundGateway | None = None, subscriptions: SubscriptionCancellationConfig | None = None, credit_notes: CreditNoteConfig | None = None)
Compose Stripe operations once per host scope; SDK ownership stays with the caller.
Source code in src/threvo_actions/integrations/stripe/actions.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
from_services
classmethod
¶
from_services(services: StripeServices, *, refunds: RefundConfig | None = None, subscriptions: SubscriptionCancellationConfig | None = None, credit_notes: CreditNoteConfig | None = None) -> StripeActions
Compose through the progressive typed service/configuration layer.
Source code in src/threvo_actions/integrations/stripe/actions.py
StripeRefunds ¶
StripeRefunds(*, definition: ActionDefinition[RefundRequest, RefundSnapshot, RefundPreview, RefundOutcome], runtime: ActionRuntime, workflow: _RefundWorkflow)
Governed refunds. Identity arguments must come from authenticated host context.
Expose definition through ActionToolBinding for agents; never expose these server-side methods or authority arguments as raw model tools.
Source code in src/threvo_actions/integrations/stripe/actions.py
prepare
async
¶
prepare(request: RefundRequest, *, tenant_reference: str, requesting_principal: RequestingPrincipal, proposing_agent: ProposingAgent | None = None) -> ActionOperationResult
Source code in src/threvo_actions/integrations/stripe/actions.py
record_authority
async
¶
record_authority(evidence: AuthorityEvidence, *, authenticated_authority: ConfirmingAuthority) -> ActionOperationResult
Source code in src/threvo_actions/integrations/stripe/actions.py
execute
async
¶
execute(*, tenant_reference: str, proposal_reference: str) -> ActionOperationResult
Source code in src/threvo_actions/integrations/stripe/actions.py
reconcile
async
¶
reconcile(*, tenant_reference: str, proposal_reference: str) -> ActionOperationResult
Source code in src/threvo_actions/integrations/stripe/actions.py
expire_due
async
¶
expire_due(*, tenant_reference: str, proposal_reference: str) -> ActionOperationResult
Source code in src/threvo_actions/integrations/stripe/actions.py
read
async
¶
read(proposal_reference: str, *, context: ReadContext) -> ProposalView
read_recovery
async
¶
read_recovery(proposal_reference: str, *, context: ReadContext) -> ActionRecoveryView
Source code in src/threvo_actions/integrations/stripe/actions.py
export_evidence
async
¶
export_evidence(proposal_reference: str, *, context: ReadContext) -> ActionEvidenceBundle
Source code in src/threvo_actions/integrations/stripe/actions.py
observe_effect
async
¶
observe_effect(proposal_reference: str, *, context: ReadContext) -> StripeEffectObservation
Source code in src/threvo_actions/integrations/stripe/actions.py
RefundPolicy ¶
Bases: ExperimentalModel
Explicit per-currency ceilings; hosts separately authorize every operation.
model_config
class-attribute
instance-attribute
¶
unique_positive_limits ¶
unique_positive_limits() -> RefundPolicy
Source code in src/threvo_actions/integrations/stripe/models.py
RefundRequest ¶
Bases: ExperimentalModel
Model-visible intent. Resolve payment_reference through the authenticated host.
intent_reference
class-attribute
instance-attribute
¶
intent_reference: SafeReference = Field(description='Stable reference for this business intent.')
payment_reference
class-attribute
instance-attribute
¶
payment_reference: SafeReference = Field(description='Host payment reference, not a Stripe ID.')
RefundPayment ¶
Bases: ExperimentalModel
Canonical host payment; version changes whenever its refund binding changes.
model_config
class-attribute
instance-attribute
¶
RefundSnapshot ¶
Bases: ExperimentalModel
RefundPreview ¶
Bases: ExperimentalModel
StripeRefundSettings ¶
Bases: ExperimentalModel
Host authority identity is explicit; execution always uses the existing runtime.
action_type
class-attribute
instance-attribute
¶
action_type: ActionType = ActionType(namespace='stripe.refunds', name='create', version=1)
authority_channel_assurance
class-attribute
instance-attribute
¶
authority_channel_assurance: SafeReference = 'authenticated_host_session'
proposal_ttl
class-attribute
instance-attribute
¶
verification_delay
class-attribute
instance-attribute
¶
verification_lease_duration
class-attribute
instance-attribute
¶
max_verification_attempts
class-attribute
instance-attribute
¶
RefundHost
dataclass
¶
RefundHost(repository: RefundRepository, authorization: AuthorizationPort[RefundRequest, RefundSnapshot])
RefundRepository ¶
Bases: Protocol
payment
async
¶
payment(tenant_reference: str, payment_reference: str) -> RefundPayment
Source code in src/threvo_actions/integrations/stripe/ports.py
remember
async
¶
remember(snapshot: RefundSnapshot, requester: str) -> None
Durably bind intent + requester; refuse different parameters for an existing intent.
load
async
¶
load(tenant_reference: str, effect_reference: str) -> RefundSnapshot
Source code in src/threvo_actions/integrations/stripe/ports.py
reserve
async
¶
reserve(snapshot: RefundSnapshot, *, not_after: datetime) -> RefundReservationStatus
Atomically compare payment/intent, deadline and unresolved attempts before claiming.
Coordinate with all payment writers. ALREADY_SUBMITTED never permits resend. An uncertain reservation acknowledgement must raise and retain the durable claim.
Source code in src/threvo_actions/integrations/stripe/ports.py
record_no_submission
async
¶
Mark this intent resolved without submission; never erase/reopen its identity.
record_outcome
async
¶
Persist a terminal provider observation without rewriting runtime receipts.
Billing operations¶
See the billing guide for composition, supported scope and host obligations. Both groups expose the same prepare, record_authority, execute, reconcile and read methods as refunds.
StripeSubscriptions ¶
StripeSubscriptions(*, definition: ActionDefinition[CommandT, SnapshotT, PreviewT, ResultT], runtime: ActionRuntime, workflow: _Workflow[CommandT, SnapshotT, PreviewT, ResultT])
Bases: _StripeOperation[SubscriptionCancellationRequest, SubscriptionCancellationSnapshot, SubscriptionCancellationPreview, SubscriptionCancellationOutcome]
Prepare schedule/withdrawal proposals; host authority and verification remain required.
Source code in src/threvo_actions/integrations/stripe/_operation.py
observe_effect
async
¶
observe_effect(proposal_reference: str, *, context: ReadContext) -> StripeEffectObservation
Source code in src/threvo_actions/integrations/stripe/subscriptions.py
SubscriptionCancellationConfig
dataclass
¶
SubscriptionCancellationConfig(host: SubscriptionCancellationHost, policy: SubscriptionCancellationPolicy, settings: StripeActionSettings, gateway: StripeSubscriptionGateway | None = None)
SubscriptionCancellationRequest ¶
Bases: ExperimentalModel
intent_reference
class-attribute
instance-attribute
¶
intent_reference: SafeReference = Field(description='Stable business intent; never reuse for a different operation.')
subscription_reference
class-attribute
instance-attribute
¶
subscription_reference: SafeReference = Field(description='Host subscription reference, not a Stripe ID.')
operation
class-attribute
instance-attribute
¶
operation: SubscriptionOperation = Field(description='Schedule cancellation at current period end, or withdraw that schedule. Does not end service immediately.')
SubscriptionCancellationPolicy ¶
Bases: ExperimentalModel
permits ¶
SubscriptionCancellationRepository ¶
Bases: StripeActionRepository[SubscriptionCancellationSnapshot, SubscriptionCancellationOutcome], Protocol
subscription
async
¶
subscription(tenant_reference: str, subscription_reference: str) -> SubscriptionBinding
SubscriptionBinding ¶
Bases: ExperimentalModel
SubscriptionCancellationOutcome ¶
Bases: ExperimentalModel
StripeCreditNotes ¶
StripeCreditNotes(*, definition: ActionDefinition[CommandT, SnapshotT, PreviewT, ResultT], runtime: ActionRuntime, workflow: _Workflow[CommandT, SnapshotT, PreviewT, ResultT])
Bases: _StripeOperation[CreditNoteRequest, CreditNoteSnapshot, CreditNotePreview, CreditNoteOutcome]
Issue a line-bound credit; cash refunds and mixed allocation are unsupported.
Source code in src/threvo_actions/integrations/stripe/_operation.py
observe_effect
async
¶
observe_effect(proposal_reference: str, *, context: ReadContext) -> StripeEffectObservation
Source code in src/threvo_actions/integrations/stripe/credit_notes.py
CreditNoteConfig
dataclass
¶
CreditNoteConfig(host: CreditNoteHost, policy: CreditNotePolicy, settings: StripeActionSettings, gateway: StripeCreditNoteGateway | None = None)
CreditNoteRequest ¶
Bases: ExperimentalModel
lines
instance-attribute
¶
expected_total
class-attribute
instance-attribute
¶
expected_total: Money = Field(description='Exact expected final credit including Stripe-computed tax and discounts. A different preview total is refused.')
disposition
class-attribute
instance-attribute
¶
disposition: CreditDisposition = Field(description="Reduce an open invoice or credit a paid invoice customer's future balance. Neither returns cash.")
consistent_lines ¶
consistent_lines() -> CreditNoteRequest
Source code in src/threvo_actions/integrations/stripe/credit_notes.py
CreditNotePolicy ¶
Bases: ExperimentalModel
unique_positive_limits ¶
unique_positive_limits() -> CreditNotePolicy
Source code in src/threvo_actions/integrations/stripe/credit_notes.py
permits ¶
permits(request: CreditNoteRequest, *, livemode: bool) -> bool
Source code in src/threvo_actions/integrations/stripe/credit_notes.py
CreditNoteRepository ¶
Bases: StripeActionRepository[CreditNoteSnapshot, CreditNoteOutcome], Protocol
invoice
async
¶
invoice(tenant_reference: str, invoice_reference: str) -> CreditNoteInvoice
Source code in src/threvo_actions/integrations/stripe/credit_notes.py
CreditNoteInvoice ¶
Bases: ExperimentalModel
model_config
class-attribute
instance-attribute
¶
unique_lines ¶
unique_lines() -> CreditNoteInvoice
Source code in src/threvo_actions/integrations/stripe/credit_notes.py
CreditNoteOutcome ¶
Bases: ExperimentalModel
StripeActionSettings ¶
Bases: ExperimentalModel
authority_channel_assurance
class-attribute
instance-attribute
¶
authority_channel_assurance: SafeReference = 'authenticated_host_session'
proposal_ttl
class-attribute
instance-attribute
¶
verification_delay
class-attribute
instance-attribute
¶
verification_lease_duration
class-attribute
instance-attribute
¶
max_verification_attempts
class-attribute
instance-attribute
¶
StripeActionRepository ¶
Bases: Protocol[SnapshotT, ResultContraT]
remember
async
¶
Durably bind tenant + intent + requester; reject any different rebinding.
load
async
¶
Source code in src/threvo_actions/integrations/stripe/_operation.py
reserve
async
¶
Atomically compare binding/version/deadline and serialize all resource writers.
Exclude unresolved operations across intents and action groups. Preserve the claim if acknowledgement is uncertain; raise rather than claiming refusal. ALREADY_SUBMITTED never permits dispatch. Never reopen a consumed intent.
Source code in src/threvo_actions/integrations/stripe/_operation.py
record_no_submission
async
¶
Close a known no-dispatch attempt without reopening its intent identity.
record_outcome
async
¶
Record the independently verified outcome and release the resource claim.