Import
Signature
Encode a payment payload into a base64-encoded PAYMENT-SIGNATURE header. Constructs the standard x402 v2 payment response object containing accepted requirements, the base64-encoded transaction group (signed or unsigned), the paymentIndex, and any resource or extensions metadata copied from the original challenge.

Parameters

PaymentRequired
required
The original PaymentRequired challenge object.
PaymentRequirements
required
The selected and fulfilled PaymentRequirements item.
string[]
required
Array of base64-encoded transactions (signed bytes or unsigned fallback).
number
required
0-based index of the payment transaction within the group.

Returns

string
Base64-encoded string ready to pass in the PAYMENT-SIGNATURE HTTP header.

Example

Source: src/index.ts