raxos / wallet
A PHP library for generating Apple Wallet and Google Wallet passes.
Requires
- php: >=8.5
- ext-json: *
- ext-openssl: *
- ext-zip: *
- jetbrains/phpstorm-attributes: ^1.2
- raxos/contract: *
- raxos/foundation: *
- raxos/http: *
- raxos/router: *
Requires (Dev)
- pestphp/pest: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Raxos Wallet
Build, sign and package Apple Wallet passes and pass bundles.
Documentation | Packagist | Raxos
- Typed pass models for generic passes, store cards, coupons, tickets and boarding passes.
- Fields, barcodes, colors, locations, localization and semantic tags.
- Signed
.pkpassarchives,.pkpassesbundles and HTTP responses.
Installation
Requires PHP 8.5 or later. Enable the json, openssl, zip PHP extensions. Composer checks the remaining package and extension dependencies declared in composer.json.
composer require "raxos/wallet:^3.2"
Usage
<?php declare(strict_types=1); use Raxos\Wallet\Apple\Component\EventTicket; use Raxos\Wallet\Apple\Component\Pass; use Raxos\Wallet\Apple\Component\PrimaryField; use Raxos\Wallet\Apple\Identity; use Raxos\Wallet\Apple\PKPass; require __DIR__ . '/vendor/autoload.php'; $pass = new Pass( description: 'Admission ticket', organizationName: 'Example Venue', serialNumber: 'TICKET-0042', eventTicket: new EventTicket( primaryFields: [new PrimaryField(key: 'event', value: 'Summer Concert', label: 'Event')] ) ); function packagePass(Identity $identity, Pass $pass, string $iconPath): PKPass { $archive = new PKPass($identity, $pass); $archive->file('icon.png', $iconPath); $archive->sign(); $archive->close(); return $archive; }
Create an Identity from your Apple pass signing certificate, private key, key password, pass type identifier and team identifier, then call packagePass() with the required icon asset. The WWDR certificate is included in the package. Read the result with binary() or serve it with respond()->send(), then call delete() to remove the temporary archive. The current implementation supports Apple Wallet.
Documentation
Testing
Run this library's Pest suite from the Raxos workspace:
git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=wallet
See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.
License
MIT. Copyright (c) 2017 - present Bas Milius.