Third parties can read any existing diamonds.whereditgo.bazaar.purchase.receipt records stored on the user's (buyer's) own PDS to drive special effects.

See example receipt

If a user has purchased a good that is published on your site, a valid receipt could be used to gate content, show support badges, and more.

Verifying a purchase

By default, the DID document of a bazzar instance is served at https://<domain>/.well-known/did.json.

  1. 1.

    Resolve storefrontDid to its DID document. Find the signing key in verificationMethod. If kid is present on the receipt, use the matching entry. If absent, try every non-revoked key.

  2. 2.

    Recompute grantedItemsDigest: SHA-256 of the grantedItems array with CIDs sorted lexicographically, base64url-encoded without padding.

  3. 3.

    Rebuild the payload string in this order, colon-delimited:

purchasedAt:payment.ref:purchasedGood.uri:listing.cid:buyerDid:licenseGrant.cid:grantedItemsDigest
  1. 4.

    Verify storefrontSig (base64url) against the UTF-8 payload bytes using the key's algorithm. Bazaar uses ES256K by default. A receipt that passes is genuine and unmodified — if any of the seven fields were changed after signing, the payload won't match and verification fails.

  2. 5.

    Fetch the catalog.listing record at listing.uri and confirm its CID matches listing.cid on the receipt. This proves the price and license terms were not swapped after checkout.

Evaluating licensing

  1. 1.

    Fetch the license.terms record at licenseGrant.uri and confirm its CID matches licenseGrant.cid. This is the exact text the buyer agreed to at checkout. If the merchant has edited the terms since, existing receipts are unaffected — the CID pins the version in force at the time of sale.

  2. 2.

    Fetch purchasedGood.uri. For a catalog.product, confirm the item being gated appears in grantedItems on the receipt. The product's current items list is irrelevant — grantedItems is frozen at checkout and is the only authoritative record of what the buyer owns.

Checking entitlement

After verification, check that the receipt covers the item or product you are evaluating:

  • For a single item: purchasedGood.uri matches the item's AT-URI, or the item appears in grantedItems.

  • For a product: purchasedGood.uri matches the product's AT-URI and the specific item the buyer is accessing appears in grantedItems.

Pin to CIDs when you need an exact version. Use URIs alone when any version of the record satisfies the check.

Key rotation

Storefronts may rotate keys. Old receipts remain valid under the key that signed them. When a key is revoked, the DID document marks it with revoked: true and a revokedAt timestamp. A receipt signed before revokedAt by a revoked key is still valid; one signed after is not.

Do not cache the DID document indefinitely. Re-resolve periodically or on verification failure.