U-net Docs
Example

Checkout-bound verification

Verify a restricted checkout for the same holder who logged in.

@union-networks/verification@union-networks/server

Scenario

A restricted basket contains alcohol and must be verified without reusable age flags.

Steps

  1. Verify login assertion.
  2. Create checkout verification.
  3. Render proof QR if required.
  4. Poll checkout status and remove restricted items on failure.

Code

tsCheckout
import {
  createCheckoutVerification,
  pollCheckoutVerification,
} from '@union-networks/verification';

const checkout = await createCheckoutVerification(
  {
    serviceId: 'example-shop',
    assertionJws,
    requiredChecks: ['age_over_18'],
    restrictedResourceIds: ['wine-001'],
    ttlSeconds: 120,
  },
  { issuerBaseUrl: 'https://issuer.egress.live' },
);

if (checkout.requiresVerification && checkout.verification) {
  renderQr(checkout.verification.qrPayload);
  const finalCheckout = await pollCheckoutVerification(
    {
      checkoutId: checkout.checkout.checkoutId,
      serviceId: 'example-shop',
      assertionJws,
    },
    { issuerBaseUrl: 'https://issuer.egress.live' },
  );

  if (finalCheckout.checkout.status !== 'completed') {
    removeRestrictedItems(finalCheckout.checkout.failureReason);
  }
}