Skip to content

Interface: X402RequestState<TRequirements, TPayload> ​

Defined in: packages/x402-express/src/options.ts:243

What a verified payment leaves on the request.

Type-parameterised so a route gated on another scheme can say what its requirements and payload are; the Express global below pins the default scheme's shapes, which is what req.x402 is typed as.

Type Parameters ​

TRequirements ​

TRequirements = CantonPaymentRequirements

TPayload ​

TPayload = CantonPaymentPayload

Properties ​

payer ​

ts
payer: string;

Defined in: packages/x402-express/src/options.ts:247


payload ​

ts
payload: TPayload;

Defined in: packages/x402-express/src/options.ts:249


requirements ​

ts
requirements: TRequirements;

Defined in: packages/x402-express/src/options.ts:248


settle? ​

ts
settle?: 
  | {
  amount?: string;
  extensions?: {
   [key: string]: unknown;
  };
  network: string;
  payer?: string;
  success: true;
  transaction: string;
}
  | {
  errorMessage?: string;
  errorReason:   | "invalid_exact_canton_missing_proof"
     | "invalid_exact_canton_malformed_payload"
     | "invalid_exact_canton_signature_invalid"
     | "invalid_exact_canton_amount_mismatch"
     | "invalid_exact_canton_merchant_mismatch"
     | "invalid_exact_canton_instrument_id_mismatch"
     | "invalid_exact_canton_preapproval_missing"
     | "invalid_exact_canton_fee_payer_mismatch"
     | "invalid_exact_canton_expired"
     | "invalid_exact_canton_execute_before_too_far"
     | "invalid_exact_canton_insufficient_inputs"
     | "invalid_exact_canton_memo_mismatch"
     | "invalid_exact_canton_merchant_not_registered"
     | "invalid_exact_canton_self_payment"
     | "invalid_exact_canton_execute_failed"
     | "unexpected_canton_ledger_error"
     | "settlement_pending"
     | "invalid_network"
     | "unsupported_scheme"
     | "insufficient_funds"
     | "invalid_payload"
     | "invalid_payment_requirements"
     | "invalid_scheme"
     | "invalid_x402_version"
     | "invalid_transaction_state"
     | "unexpected_verify_error"
     | "unexpected_settle_error"
     | "invalid_exact_canton_synchronizer_mismatch";
  extensions?: {
   [key: string]: unknown;
  };
  network: string;
  payer?: string;
  success: false;
  transaction: string;
};

Defined in: packages/x402-express/src/options.ts:251

Union Members ​

Type Literal ​
ts
{
  amount?: string;
  extensions?: {
   [key: string]: unknown;
  };
  network: string;
  payer?: string;
  success: true;
  transaction: string;
}
amount? ​
ts
amount?: string;

The amount settled, in atomic units, as the requirements' amount is.

extensions? ​
ts
extensions?: object;
Index Signature ​
ts
[key: string]: unknown
network ​
ts
network: string;
payer? ​
ts
payer?: string;

Optional in x402 v2, so a facilitator may leave it out.

success ​
ts
success: true;
transaction ​
ts
transaction: string;

Canton updateId of the executed transaction.


Type Literal ​
ts
{
  errorMessage?: string;
  errorReason:   | "invalid_exact_canton_missing_proof"
     | "invalid_exact_canton_malformed_payload"
     | "invalid_exact_canton_signature_invalid"
     | "invalid_exact_canton_amount_mismatch"
     | "invalid_exact_canton_merchant_mismatch"
     | "invalid_exact_canton_instrument_id_mismatch"
     | "invalid_exact_canton_preapproval_missing"
     | "invalid_exact_canton_fee_payer_mismatch"
     | "invalid_exact_canton_expired"
     | "invalid_exact_canton_execute_before_too_far"
     | "invalid_exact_canton_insufficient_inputs"
     | "invalid_exact_canton_memo_mismatch"
     | "invalid_exact_canton_merchant_not_registered"
     | "invalid_exact_canton_self_payment"
     | "invalid_exact_canton_execute_failed"
     | "unexpected_canton_ledger_error"
     | "settlement_pending"
     | "invalid_network"
     | "unsupported_scheme"
     | "insufficient_funds"
     | "invalid_payload"
     | "invalid_payment_requirements"
     | "invalid_scheme"
     | "invalid_x402_version"
     | "invalid_transaction_state"
     | "unexpected_verify_error"
     | "unexpected_settle_error"
     | "invalid_exact_canton_synchronizer_mismatch";
  extensions?: {
   [key: string]: unknown;
  };
  network: string;
  payer?: string;
  success: false;
  transaction: string;
}
errorMessage? ​
ts
errorMessage?: string;

Human-readable text for errorReason. Free text that can change between facilitators, so match on the code, never on this (x402 v2 §9). Which of a code's causes it was goes in extensions.detail, as on verify.

errorReason ​
ts
errorReason: 
  | "invalid_exact_canton_missing_proof"
  | "invalid_exact_canton_malformed_payload"
  | "invalid_exact_canton_signature_invalid"
  | "invalid_exact_canton_amount_mismatch"
  | "invalid_exact_canton_merchant_mismatch"
  | "invalid_exact_canton_instrument_id_mismatch"
  | "invalid_exact_canton_preapproval_missing"
  | "invalid_exact_canton_fee_payer_mismatch"
  | "invalid_exact_canton_expired"
  | "invalid_exact_canton_execute_before_too_far"
  | "invalid_exact_canton_insufficient_inputs"
  | "invalid_exact_canton_memo_mismatch"
  | "invalid_exact_canton_merchant_not_registered"
  | "invalid_exact_canton_self_payment"
  | "invalid_exact_canton_execute_failed"
  | "unexpected_canton_ledger_error"
  | "settlement_pending"
  | "invalid_network"
  | "unsupported_scheme"
  | "insufficient_funds"
  | "invalid_payload"
  | "invalid_payment_requirements"
  | "invalid_scheme"
  | "invalid_x402_version"
  | "invalid_transaction_state"
  | "unexpected_verify_error"
  | "unexpected_settle_error"
  | "invalid_exact_canton_synchronizer_mismatch" = SettleErrorReasonSchema;
extensions? ​
ts
extensions?: object;
Index Signature ​
ts
[key: string]: unknown
network ​
ts
network: string;
payer? ​
ts
payer?: string;
success ​
ts
success: false;
transaction ​
ts
transaction: string;

The transaction the answer is about. Empty when nothing was relayed. On settlement_pending it is the payment's preparedTxHash: the relay went out and its outcome is not known yet.


verify ​

ts
verify: 
  | {
  extensions?: {
   [key: string]: unknown;
  };
  extra?: {
   [key: string]: unknown;
  };
  isValid: true;
  payer?: string;
}
  | {
  extensions?: {
   [key: string]: unknown;
  };
  extra?: {
   [key: string]: unknown;
  };
  invalidMessage?: string;
  invalidReason:   | "invalid_exact_canton_missing_proof"
     | "invalid_exact_canton_malformed_payload"
     | "invalid_exact_canton_signature_invalid"
     | "invalid_exact_canton_amount_mismatch"
     | "invalid_exact_canton_merchant_mismatch"
     | "invalid_exact_canton_instrument_id_mismatch"
     | "invalid_exact_canton_preapproval_missing"
     | "invalid_exact_canton_fee_payer_mismatch"
     | "invalid_exact_canton_expired"
     | "invalid_exact_canton_execute_before_too_far"
     | "invalid_exact_canton_insufficient_inputs"
     | "invalid_exact_canton_memo_mismatch"
     | "invalid_exact_canton_merchant_not_registered"
     | "invalid_exact_canton_self_payment"
     | "invalid_exact_canton_execute_failed"
     | "unexpected_canton_ledger_error"
     | "settlement_pending"
     | "invalid_network"
     | "unsupported_scheme"
     | "insufficient_funds"
     | "invalid_payload"
     | "invalid_payment_requirements"
     | "invalid_scheme"
     | "invalid_x402_version"
     | "invalid_transaction_state"
     | "unexpected_verify_error"
     | "unexpected_settle_error"
     | "invalid_exact_canton_synchronizer_mismatch";
  isValid: false;
  payer?: string;
};

Defined in: packages/x402-express/src/options.ts:250

Union Members ​

Type Literal ​
ts
{
  extensions?: {
   [key: string]: unknown;
  };
  extra?: {
   [key: string]: unknown;
  };
  isValid: true;
  payer?: string;
}
extensions? ​
ts
extensions?: object;
Index Signature ​
ts
[key: string]: unknown
extra? ​
ts
extra?: object;

Scheme-specific data, as x402 v2 §5.4.2 gives a verify answer.

Index Signature ​
ts
[key: string]: unknown
isValid ​
ts
isValid: true;
payer? ​
ts
payer?: string;

Type Literal ​
ts
{
  extensions?: {
   [key: string]: unknown;
  };
  extra?: {
   [key: string]: unknown;
  };
  invalidMessage?: string;
  invalidReason:   | "invalid_exact_canton_missing_proof"
     | "invalid_exact_canton_malformed_payload"
     | "invalid_exact_canton_signature_invalid"
     | "invalid_exact_canton_amount_mismatch"
     | "invalid_exact_canton_merchant_mismatch"
     | "invalid_exact_canton_instrument_id_mismatch"
     | "invalid_exact_canton_preapproval_missing"
     | "invalid_exact_canton_fee_payer_mismatch"
     | "invalid_exact_canton_expired"
     | "invalid_exact_canton_execute_before_too_far"
     | "invalid_exact_canton_insufficient_inputs"
     | "invalid_exact_canton_memo_mismatch"
     | "invalid_exact_canton_merchant_not_registered"
     | "invalid_exact_canton_self_payment"
     | "invalid_exact_canton_execute_failed"
     | "unexpected_canton_ledger_error"
     | "settlement_pending"
     | "invalid_network"
     | "unsupported_scheme"
     | "insufficient_funds"
     | "invalid_payload"
     | "invalid_payment_requirements"
     | "invalid_scheme"
     | "invalid_x402_version"
     | "invalid_transaction_state"
     | "unexpected_verify_error"
     | "unexpected_settle_error"
     | "invalid_exact_canton_synchronizer_mismatch";
  isValid: false;
  payer?: string;
}
extensions? ​
ts
extensions?: object;
Index Signature ​
ts
[key: string]: unknown
extra? ​
ts
extra?: object;

Scheme-specific data, as x402 v2 §5.4.2 gives a verify answer.

Index Signature ​
ts
[key: string]: unknown
invalidMessage? ​
ts
invalidMessage?: string;

Human-readable text for invalidReason. Free text that can change between facilitators, so match on the code, never on this (x402 v2 §9).

invalidReason ​
ts
invalidReason: 
  | "invalid_exact_canton_missing_proof"
  | "invalid_exact_canton_malformed_payload"
  | "invalid_exact_canton_signature_invalid"
  | "invalid_exact_canton_amount_mismatch"
  | "invalid_exact_canton_merchant_mismatch"
  | "invalid_exact_canton_instrument_id_mismatch"
  | "invalid_exact_canton_preapproval_missing"
  | "invalid_exact_canton_fee_payer_mismatch"
  | "invalid_exact_canton_expired"
  | "invalid_exact_canton_execute_before_too_far"
  | "invalid_exact_canton_insufficient_inputs"
  | "invalid_exact_canton_memo_mismatch"
  | "invalid_exact_canton_merchant_not_registered"
  | "invalid_exact_canton_self_payment"
  | "invalid_exact_canton_execute_failed"
  | "unexpected_canton_ledger_error"
  | "settlement_pending"
  | "invalid_network"
  | "unsupported_scheme"
  | "insufficient_funds"
  | "invalid_payload"
  | "invalid_payment_requirements"
  | "invalid_scheme"
  | "invalid_x402_version"
  | "invalid_transaction_state"
  | "unexpected_verify_error"
  | "unexpected_settle_error"
  | "invalid_exact_canton_synchronizer_mismatch" = VerifyInvalidReasonSchema;
isValid ​
ts
isValid: false;
payer? ​
ts
payer?: string;