<?php require 'PKPass.php'; $pass = new PKPass(); $pass->setCertificate('../Certificate.p12'); // Set the path to your Pass Certificate (.p12 file) $pass->setCertificatePassword('test123'); // Set password for certificate $pass->setJSON('{ "passTypeIdentifier": "pass.com.apple.test", "formatVersion": 1, "organizationName": "Flight Express", "serialNumber": "123456", "teamIdentifier": "AGK5BZEN3E", "backgroundColor": "rgb(107,156,196)", "logoText": "Flight info", "boardingPass": { "primaryFields": [ { "key" : "origin", "label" : "San Francisco", "value" : "SFO" }, { "key" : "destination", "label" : "London", "value" : "LHR" } ], "secondaryFields": [ {
<?php if (isset($_POST['name'])) { // User has filled in the card info, so create the pass now setlocale(LC_MONETARY, 'en_US'); require '../PKPass.php'; // Variables $id = rand(100000, 999999) . '-' . rand(100, 999) . '-' . rand(100, 999); // Every card should have a unique serialNumber $balance = '$' . rand(0, 30) . '.' . rand(10, 99); // Create random balance $name = stripslashes($_POST['name']); // Create pass $pass = new PKPass(); $pass->setCertificate('../../Certificate.p12'); // Set the path to your Pass Certificate (.p12 file) $pass->setCertificatePassword('test123'); // Set password for certificate $pass->setWWDRcertPath('../AppleWWDR.pem'); $pass->setJSON('{ "passTypeIdentifier": "pass.com.apple.test", "formatVersion": 1, "organizationName": "Starbucks", "teamIdentifier": "AGK5BZEN3E", "serialNumber": "' . $id . '", "backgroundColor": "rgb(240,240,240)", "logoText": "Starbucks", "description": "Demo pass", "storeCard": { "secondaryFields": [ {
// Predefined data $labels = array('SFO' => 'San Francisco', 'LAX' => 'Los Angeles', 'LHR' => 'London'); $gates = array('F12', 'G43', 'A2', 'C5', 'K9'); // User-set vars $passenger = addslashes($_POST['passenger']); $origin = $_POST['origin']; $origin_label = $labels[$origin]; $destination = $_POST['destination']; $destination_label = $labels[$destination]; $gate = $gates[array_rand($gates)]; // Yup, pick a random gate $date = date('m/d/Y H:i', $_POST['date']); // Convert date to string // Create pass //Set certifivate and path in the constructor $pass = new PKPass('../../Certificate.p12', 'test123'); //Check if an error occured within the constructor if ($pass->checkError($error) == true) { exit('An error occured: ' . $error); } //Or do it manually outside of the constructor /* // Set the path to your Pass Certificate (.p12 file) if($pass->setCertificate('../../Certificate.p12') == false) { echo 'An error occured'; if($pass->checkError($error) == true) { echo ': '.$error; } exit('.'); } // Set password for certificate
<?php if(isset($_POST['name'])){ // User has filled in the card info, so create the pass now setlocale(LC_MONETARY, 'en_US'); require('../PKPass.php'); // Variables $id = rand(100000,999999) . '-' . rand(100,999) . '-' . rand(100,999); // Every card should have a unique serialNumber $balance = '$'.rand(0,30).'.'.rand(10,99); // Create random balance $name = $_POST['name']; // Create pass $pass = new PKPass(); $pass->setCertificate('../../Certificate.p12'); // Set the path to your Pass Certificate (.p12 file) $pass->setCertificatePassword('test123'); // Set password for certificate $pass->setJSON('{ "passTypeIdentifier": "pass.com.apple.test", "formatVersion": 1, "organizationName": "Starbucks", "teamIdentifier": "AGK5BZEN3E", "serialNumber": "'.$id.'", "backgroundColor": "rgb(240,240,240)", "logoText": "Starbucks", "description": "Demo pass", "storeCard": { "secondaryFields": [ {