createPaymentSession method
Create a new payment session.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter expiryTimeInMinutes :
The session expiry time in minutes. Must be between 15 and 480 minutes.
Parameter paymentManagerArn :
The ARN of the payment manager that owns this session.
Parameter agentName :
The agent name associated with this request, used for observability.
Parameter clientToken :
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request.
Parameter limits :
The spending limits for this payment session.
Parameter userId :
The user ID associated with this payment session.
Implementation
Future<CreatePaymentSessionResponse> createPaymentSession({
required int expiryTimeInMinutes,
required String paymentManagerArn,
String? agentName,
String? clientToken,
SessionLimits? limits,
String? userId,
}) async {
final headers = <String, String>{
if (agentName != null)
'X-Amzn-Bedrock-AgentCore-Payments-Agent-Name': agentName.toString(),
if (userId != null)
'X-Amzn-Bedrock-AgentCore-Payments-User-Id': userId.toString(),
};
final $payload = <String, dynamic>{
'expiryTimeInMinutes': expiryTimeInMinutes,
'paymentManagerArn': paymentManagerArn,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (limits != null) 'limits': limits,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/payments/createPaymentSession',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return CreatePaymentSessionResponse.fromJson(response);
}