BedrockAgentCore / Client / process_payment
process_payment¶
- BedrockAgentCore.Client.process_payment(**kwargs)¶
Processes a payment using a payment instrument within a payment session.
See also: AWS API Documentation
Request Syntax
response = client.process_payment( userId='string', agentName='string', paymentManagerArn='string', paymentSessionId='string', paymentInstrumentId='string', paymentType='CRYPTO_X402'|'MPP', paymentInput={ 'cryptoX402': { 'version': 'string', 'payload': {...}|[...]|123|123.4|'string'|True|None, 'permit2AllowanceLimit': 'string' }, 'mpp': { 'version': 'string', 'wwwAuthenticateHeaders': [ 'string', ], 'buyerPaysGasFees': True|False } }, clientToken='string' )
- Parameters:
userId (string) – The user ID associated with this payment.
agentName (string) – The agent name associated with this request, used for observability.
paymentManagerArn (string) –
[REQUIRED]
The ARN of the payment manager.
paymentSessionId (string) –
[REQUIRED]
The ID of the payment session.
paymentInstrumentId (string) –
[REQUIRED]
The ID of the payment instrument to use.
paymentType (string) –
[REQUIRED]
The type of payment to process.
paymentInput (dict) –
[REQUIRED]
The payment input details specific to the payment type.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
cryptoX402,mpp.cryptoX402 (dict) –
Input for a crypto X402 payment.
version (string) – [REQUIRED]
The version of the X402 protocol.
payload (document) – [REQUIRED]
The X402 payment payload.
permit2AllowanceLimit (string) –
The maximum on-chain Permit2 allowance to grant before signing the payment authorization, in the asset’s smallest denomination. This field is valid only for the
upto(metered) scheme; supplying it for theexactscheme returns a validation error.When set, the service approves an ERC-20 allowance for this amount before processing the payment. The approval sets, rather than adds to, the wallet’s allowance. Set this field only when the wallet needs approving, for example on its first
uptopayment, to avoid a redundant on-chain transaction. Omit the field to skip allowance handling. This is the default, and the only behavior for theexactscheme.
mpp (dict) –
Contains the payment challenge from a 402 Payment Required response. Forward the raw
WWW-Authenticate: Paymentheader value verbatim. In response, you receive a payment credential that satisfies the challenge. Provide exactly one challenge per request.version (string) – [REQUIRED]
The MPP protocol version, for example “1” or “2”.
wwwAuthenticateHeaders (list) – [REQUIRED]
The raw
WWW-Authenticate: Paymentheader value from the 402 response, passed verbatim. Provide exactly one entry. The service uses this value to generate the payment credential.(string) –
A raw
WWW-Authenticate: Paymentheader value from a 402 response, containing RFC 9110 auth-params such asid,realm,method,intent, andrequest. Pass this value in the request body, not as an HTTP header.
buyerPaysGasFees (boolean) –
Authorizes the service to sign a payment whose blockchain network (gas) fees are charged to your wallet, on top of the payment amount.
The challenge indicates who sponsors the network fees. When the challenge does not sponsor them, the service signs the payment only if this field is
true. Otherwise it returns a validation error, so you can decide whether to pay the fees or obtain a challenge that sponsors them.Optional. When omitted or
false, you decline to pay network fees. This field has no effect on challenges that already sponsor the fees.
clientToken (string) –
A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
This field is autopopulated if not provided.
- Return type:
dict
- Returns:
Response Syntax
{ 'processPaymentId': 'string', 'paymentManagerArn': 'string', 'paymentSessionId': 'string', 'paymentInstrumentId': 'string', 'paymentType': 'CRYPTO_X402'|'MPP', 'status': 'PROOF_GENERATED', 'paymentOutput': { 'cryptoX402': { 'version': 'string', 'payload': {...}|[...]|123|123.4|'string'|True|None }, 'mpp': { 'version': 'string', 'selectedPaymentId': 'string', 'paymentCredential': 'string' } }, 'createdAt': datetime(2015, 1, 1), 'updatedAt': datetime(2015, 1, 1) }
Response Structure
(dict) –
Response structure for processing a payment.
processPaymentId (string) –
The unique identifier of the processed payment.
paymentManagerArn (string) –
The ARN of the payment manager.
paymentSessionId (string) –
The ID of the payment session used.
paymentInstrumentId (string) –
The ID of the payment instrument used.
paymentType (string) –
The type of payment processed.
status (string) –
The status of the payment.
paymentOutput (dict) –
The payment output details specific to the payment type.
Note
This is a Tagged Union structure. Only one of the following top level keys will be set:
cryptoX402,mpp. If a client receives an unknown member it will setSDK_UNKNOWN_MEMBERas the top level key, which maps to the name or tag of the unknown member. The structure ofSDK_UNKNOWN_MEMBERis as follows:'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
cryptoX402 (dict) –
Output from a crypto X402 payment.
version (string) –
The version of the X402 protocol.
payload (document) –
The X402 payment response payload.
mpp (dict) –
Contains the payment credential, ready to retry the request.
version (string) –
The MPP protocol version, for example “1” or “2”.
selectedPaymentId (string) –
The id of the challenge that was paid, echoed from the input challenge so you can correlate the result without decoding the credential.
paymentCredential (string) –
Ready-to-send value for the
Authorizationheader, in the form “Payment <base64url-token>”. Attach this header and retry the original request. To inspect the full credential, base64url-decode the token.
createdAt (datetime) –
The timestamp when the payment was created.
updatedAt (datetime) –
The timestamp when the payment was last updated.
Exceptions
BedrockAgentCore.Client.exceptions.ServiceQuotaExceededExceptionBedrockAgentCore.Client.exceptions.AccessDeniedExceptionBedrockAgentCore.Client.exceptions.ConflictExceptionBedrockAgentCore.Client.exceptions.ValidationExceptionBedrockAgentCore.Client.exceptions.ResourceNotFoundExceptionBedrockAgentCore.Client.exceptions.ThrottlingExceptionBedrockAgentCore.Client.exceptions.InternalServerExceptionBedrockAgentCore.Client.exceptions.SubscriptionRequiredException