pub struct AuthenticatedPaymentRequest {
pub user_id: String,
pub session_id: Option<String>,
pub tenant_id: Option<String>,
pub scopes: Vec<String>,
pub metadata: Map<String, Value>,
}payments only.Expand description
Authenticated request identity carried into payment tools or endpoints.
This type intentionally keeps request identity separate from the durable session identity stored on a transaction and from the protocol actor roles recorded in commerce payloads.
§Example
use adk_payments::auth::{AuthenticatedPaymentRequest, PaymentOperation};
let request = AuthenticatedPaymentRequest::new("alice")
.with_tenant_id("tenant-1")
.with_scopes(["payments:checkout:update"]);
request
.check_operation_scopes(PaymentOperation::UpdateCheckout)
.unwrap();Fields§
§user_id: String§session_id: Option<String>§tenant_id: Option<String>§scopes: Vec<String>§metadata: Map<String, Value>Implementations§
Source§impl AuthenticatedPaymentRequest
impl AuthenticatedPaymentRequest
Sourcepub fn new(user_id: impl Into<String>) -> AuthenticatedPaymentRequest
pub fn new(user_id: impl Into<String>) -> AuthenticatedPaymentRequest
Creates a new authenticated payment request capsule.
Sourcepub fn with_session_id(
self,
session_id: impl Into<String>,
) -> AuthenticatedPaymentRequest
pub fn with_session_id( self, session_id: impl Into<String>, ) -> AuthenticatedPaymentRequest
Attaches the caller’s session identifier.
Sourcepub fn with_tenant_id(
self,
tenant_id: impl Into<String>,
) -> AuthenticatedPaymentRequest
pub fn with_tenant_id( self, tenant_id: impl Into<String>, ) -> AuthenticatedPaymentRequest
Attaches the caller’s tenant identifier.
Sourcepub fn with_scopes<I, S>(self, scopes: I) -> AuthenticatedPaymentRequest
pub fn with_scopes<I, S>(self, scopes: I) -> AuthenticatedPaymentRequest
Replaces the granted scope list.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: Value,
) -> AuthenticatedPaymentRequest
pub fn with_metadata( self, key: impl Into<String>, value: Value, ) -> AuthenticatedPaymentRequest
Adds one metadata field preserved alongside the authenticated request.
Sourcepub fn check_operation_scopes(
&self,
operation: PaymentOperation,
) -> Result<(), PaymentsAuthError>
pub fn check_operation_scopes( &self, operation: PaymentOperation, ) -> Result<(), PaymentsAuthError>
Checks that the request scopes authorize one payment operation.
§Errors
Returns PaymentsAuthError::MissingScopes when the request is missing
one or more required scopes.
Sourcepub fn assert_transaction_binding(
&self,
record: &TransactionRecord,
) -> Result<(), PaymentsAuthError>
pub fn assert_transaction_binding( &self, record: &TransactionRecord, ) -> Result<(), PaymentsAuthError>
Rejects attempts to access a transaction with conflicting identity or tenant bindings.
§Errors
Returns PaymentsAuthError::IdentityConflict when the authenticated
request tries to rebind the durable session or tenant association of an
existing transaction.
Trait Implementations§
Source§impl Clone for AuthenticatedPaymentRequest
impl Clone for AuthenticatedPaymentRequest
Source§fn clone(&self) -> AuthenticatedPaymentRequest
fn clone(&self) -> AuthenticatedPaymentRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthenticatedPaymentRequest
impl Debug for AuthenticatedPaymentRequest
Source§impl<'de> Deserialize<'de> for AuthenticatedPaymentRequest
impl<'de> Deserialize<'de> for AuthenticatedPaymentRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AuthenticatedPaymentRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AuthenticatedPaymentRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for AuthenticatedPaymentRequest
impl Serialize for AuthenticatedPaymentRequest
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for AuthenticatedPaymentRequest
Auto Trait Implementations§
impl Freeze for AuthenticatedPaymentRequest
impl RefUnwindSafe for AuthenticatedPaymentRequest
impl Send for AuthenticatedPaymentRequest
impl Sync for AuthenticatedPaymentRequest
impl Unpin for AuthenticatedPaymentRequest
impl UnsafeUnpin for AuthenticatedPaymentRequest
impl UnwindSafe for AuthenticatedPaymentRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request