Skip to content

Pass

Raxos\Wallet\Apple\Component\Pass is the readonly value object that models the full pass.json document. It carries the pass metadata, colors, barcodes, relevance hints and exactly one style container.

php
final readonly class Pass implements ComponentInterface

Implements Raxos\Contract\Wallet\ComponentInterface (see raxos/contract).

Constructor

The constructor requires description, organizationName and serialNumber. Every other parameter is optional and named, mirroring Apple's PassKit schema. The most commonly used ones:

ParameterTypeDescription
descriptionstringHuman readable description of the pass.
organizationNamestringThe organization that issued the pass.
serialNumberstringUnique serial, also used for the .pkpass file name.
backgroundColor, foregroundColor, labelColor, footerBackgroundColorColor|nullColors, serialized as rgb() strings.
barcodesBarcode[]|nullBarcodes shown on the pass.
beaconsBeacon[]|nulliBeacon proximity triggers.
locationsLocation[]|nullGeofence triggers.
nfcNFC|nullNFC payload.
generic, storeCard, coupon, eventTicket, boardingPasscontainer|nullThe style container; set exactly one.
logoTextstring|nullText shown next to the logo.
relevantDatestring|nullSingle date for relevance.
relevantDatesRelevantDate[]|nullDate ranges for relevance.
expirationDatestring|nullWhen the pass expires.
voidedbool|nullMarks the pass as void.
webServiceURL, authenticationTokenstring|nullWeb service for pass updates.
userInfoarray|nullArbitrary app specific data.
formatVersionintSchema version, defaults to 1.

The constructor also accepts the full set of PassKit URL and venue fields (accessibilityURL, addOnURL, appLaunchURL, bagPolicyURL, contactVenueEmail, directionsInformationURL, merchandiseURL, orderFoodURL, parkingInformationURL, sellURL, transferURL, transitInformationURL and more), the store identifier arrays (associatedStoreIdentifiers, auxiliaryStoreIdentifiers), groupingIdentifier, maxDistance, preferredStyleSchemes, semanticTags, sharingProhibited, suppressStripShine, suppressHeaderDarkening and useAutomaticColors.

Methods

jsonSerialize(): array

Returns the array used to build pass.json, running every field through an "is not empty" filter so nulls and empty arrays are dropped. Colors are emitted as rgb() strings. The passTypeIdentifier and teamIdentifier are added later by PKPass from the Identity.

Example

php
<?php
declare(strict_types=1);

use Raxos\Wallet\Apple\Component\{Barcode, EventTicket, Pass, PrimaryField};
use Raxos\Wallet\Apple\Enum\BarcodeFormat;
use Raxos\Wallet\Component\Color;

$pass = new Pass(
    description: 'Concert ticket',
    organizationName: 'Example Venue',
    serialNumber: 'TCK-00042',
    backgroundColor: Color::fromHex('#1c1c1e'),
    barcodes: [
        new Barcode(format: BarcodeFormat::QR, message: 'TCK-00042')
    ],
    eventTicket: new EventTicket(
        primaryFields: [
            new PrimaryField(key: 'event', value: 'Summer Nights', label: 'Event')
        ]
    )
);

See also