getPaymentInstrumentBalance method
Get the balance of a payment instrument.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter chain :
The specific blockchain chain to query balance on. Required because
balances are chain-specific.
Parameter paymentConnectorId :
The ID of the payment connector associated with this instrument.
Parameter paymentInstrumentId :
The ID of the payment instrument to query balance for.
Parameter paymentManagerArn :
The ARN of the payment manager that owns this payment instrument.
Parameter token :
The token to query balance for. Only tokens supported for X402 payments
are returned.
Parameter agentName :
The agent name associated with this request, used for observability.
Parameter userId :
The user ID associated with this payment instrument.
Implementation
Future<GetPaymentInstrumentBalanceResponse> getPaymentInstrumentBalance({
required BlockchainChainId chain,
required String paymentConnectorId,
required String paymentInstrumentId,
required String paymentManagerArn,
required InstrumentBalanceToken token,
String? agentName,
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>{
'chain': chain.value,
'paymentConnectorId': paymentConnectorId,
'paymentInstrumentId': paymentInstrumentId,
'paymentManagerArn': paymentManagerArn,
'token': token.value,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/payments/getPaymentInstrumentBalance',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return GetPaymentInstrumentBalanceResponse.fromJson(response);
}