Created
April 3, 2022 19:35
-
-
Save javielico/260ca276069bad91da9e2c69c6e65c71 to your computer and use it in GitHub Desktop.
Wallet pass example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use PKPass\PKPass; | |
require('../vendor/autoload.php'); | |
// Replace the parameters below with the path to your .p12 certificate and the certificate password! | |
$pass = new PKPass('../Certificates.p12', 'password'); | |
// Pass content | |
$data = [ | |
'description' => 'Demo pass', | |
'formatVersion' => 1, | |
'organizationName' => 'SH Demo', | |
'passTypeIdentifier' => 'pass.com.sh.test', // Change this! | |
'serialNumber' => '12345678', | |
'teamIdentifier' => 'KN44X8ZLNC', // Change this! | |
'boardingPass' => [ | |
'primaryFields' => [ | |
[ | |
'key' => 'origin', | |
'label' => 'San Francisco', | |
'value' => 'SFO', | |
], | |
[ | |
'key' => 'destination', | |
'label' => 'London', | |
'value' => 'LHR', | |
], | |
], | |
'secondaryFields' => [ | |
[ | |
'key' => 'gate', | |
'label' => 'Gate', | |
'value' => 'F12', | |
], | |
[ | |
'key' => 'date', | |
'label' => 'Departure date', | |
'value' => '07/11/2012 10:22', | |
], | |
], | |
'backFields' => [ | |
[ | |
'key' => 'passenger-name', | |
'label' => 'Passenger', | |
'value' => 'John Appleseed', | |
], | |
], | |
'transitType' => 'PKTransitTypeAir', | |
], | |
'barcode' => [ | |
'format' => 'PKBarcodeFormatQR', | |
'message' => 'Flight-GateF12-ID6643679AH7B', | |
'messageEncoding' => 'iso-8859-1', | |
], | |
'backgroundColor' => 'rgb(32,110,247)', | |
'logoText' => 'Flight info', | |
'relevantDate' => date('Y-m-d\TH:i:sP') | |
]; | |
$pass->setData($data); | |
// Add files to the pass package | |
$pass->addFile('images/icon.png'); | |
$pass->addFile('images/[email protected]'); | |
$pass->addFile('images/logo.png'); | |
// Create and output the pass | |
if(!$pass->create(true)) { | |
echo 'Error: ' . $pass->getError(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment