createPaymentInstrument method
Create a new payment instrument for a connector.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter paymentConnectorId :
The ID of the payment connector to use for this instrument.
Parameter paymentInstrumentDetails :
The details of the payment instrument.
Parameter paymentInstrumentType :
The type of payment instrument being created.
Parameter paymentManagerArn :
The ARN of the payment manager that owns this payment instrument.
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 userId :
The user ID associated with this payment instrument.
Implementation
Future<CreatePaymentInstrumentResponse> createPaymentInstrument({
required String paymentConnectorId,
required PaymentInstrumentDetails paymentInstrumentDetails,
required PaymentInstrumentType paymentInstrumentType,
required String paymentManagerArn,
String? agentName,
String? clientToken,
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>{
'paymentConnectorId': paymentConnectorId,
'paymentInstrumentDetails': paymentInstrumentDetails,
'paymentInstrumentType': paymentInstrumentType.value,
'paymentManagerArn': paymentManagerArn,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/payments/createPaymentInstrument',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return CreatePaymentInstrumentResponse.fromJson(response);
}