• Stars
    star
    908
  • Rank 50,132 (Top 1.0 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 12 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ’ณ PHP class for creating passes for Wallet on iOS.

PHP library to create passes for iOS Wallet

Packagist Version Packagist Downloads Packagist License

This class provides the functionality to create passes for Wallet in Apple's iOS. It creates, signs and packages the pass as a .pkpass file according to Apple's documentation.

Requirements

  • PHP 7.0 or higher (may also work with older versions)
  • PHP ZIP extension (often installed by default)
  • Access to filesystem to write temporary cache files

Installation

Simply run the following command in your project's root directory to install via Composer:

composer require pkpass/pkpass

Or add to your composer.json: "pkpass/pkpass": "^2.0.0"

Usage

Please take a look at the examples/example.php file for example usage. For more info on the JSON for the pass and how to style it, take a look at the docs at developers.apple.com.

Included demos

Functions to add files

  • addFile : add a file without locale like icon.png
  • addRemoteFile : add a file from a url without locale like https://xyz.io/icon.png
  • addLocaleFile : add a localized file like strip.png
  • addLocaleRemoteFile : add a localized file from a url like https://xyz.io/strip.png

Requesting the Pass Certificate

  1. Go to the iOS Provisioning portal.
  2. Create a new Pass Type ID, and write down the Pass ID you choose, you'll need it later.
  3. Click the edit button under your newly created Pass Type ID and generate a certificate according to the instructions shown on the page. Make sure not to choose a name for the Certificate but keep it empty instead.
  4. Download the .cer file and drag it into Keychain Access.
  5. Find the certificate you just imported and click the triangle on the left to reveal the private key.
  6. Select both the certificate and the private key it, then right-click the certificate in Keychain Access and choose Export 2 itemsโ€ฆ.
  7. Choose a password and export the file to a folder.

Exporting P12 file

Getting the example.php sample to work

  1. Request the Pass certificate (.p12) as described above and upload it to your server.
  2. Set the correct path and password on line 22.
  3. Change the passTypeIdentifier and teamIndentifier to the correct values on lines 29 and 31 (teamIndentifier can be found on the Developer Portal).

After completing these steps, you should be ready to go. Upload all the files to your server and navigate to the address of the examples/example.php file on your iPhone.

Debugging passes

If you aren't able to open your pass on an iPhone, plug the iPhone into a Mac and open the 'Console' application. On the left, you can select your iPhone. You will then be able to inspect any errors that occur while adding the pass:

Console with Passkit error

  • Trust evaluate failure: [leaf TemporalValidity]: If you see this error, your pass was signed with an outdated certificate.
  • Trust evaluate failure: [leaf LeafMarkerOid]: You did not leave the name of the certificate empty while creating it in the developer portal.

Changelog

Version 2.1.0 - April 2023

  • Add alternative method for extracting P12 contents to circumvent issues in recent versions of OpenSSL.

Version 2.0.2 - October 2022

  • Switch to ZipArchive::OVERWRITE method of opening ZIP due to PHP 8 deprecation (#120).

Version 2.0.1 - October 2022

  • Update WWDR certificate to v6 (#118).

Version 2.0.0 - September 2022

  • Changed signature of constructor to take out third $json parameter.
  • Remove deprecated setJSON() method.
  • Removed checkError() and getError() methods in favor of exceptions.

Support & documentation

Please read the instructions above and consult the Wallet Documentation before submitting tickets or requesting support. It might also be worth to check Stackoverflow, which contains quite a few questions about this library.




Get professional support for this package โ†’
Custom consulting sessions availabe for implementation support and feature development.

More Repositories

1

react-native-map-link

๐Ÿ—บ Open the map app of the user's choice.
TypeScript
651
star
2

react-native-email-link

๐Ÿ“ญ Open an email client from React Native (for 'magic link' type functionality).
JavaScript
390
star
3

react-native-check-version

๐Ÿฅ• Get the latest version of your app.
JavaScript
188
star
4

db.php

๐ŸŽ Simple PHP class for doing standard MySQL actions, such as select, insert, update and delete rows.
PHP
103
star
5

lambda-sample-events

โšก๏ธ A library of example event payloads for AWS Lambda.
JavaScript
48
star
6

react-native-keycode

๐Ÿ”ข Show the user a input form for a fixed-length code or password.
JavaScript
43
star
7

macaw

๐Ÿฆœ Scalable email templates for Node.js applications.
JavaScript
26
star
8

mapkit-jwt

๐Ÿ—บ Simple class to create MapKit and MusicKit JWT tokens.
PHP
18
star
9

react-native-confetti-view

JavaScript
9
star
10

things-stats

๐Ÿ“Š Stats tool for Things.
JavaScript
6
star
11

csv-hero

๐Ÿฆธโ€ The easiest tool to merge, filter and mangle CSV and JSON files.
JavaScript
5
star
12

jsnotebook

๐Ÿ“˜ Play around with Javascript in your browser and share notebooks.
JavaScript
5
star
13

todo-chrome-extensions

๐Ÿ“ฉ Chrome extension to quickly add Gmail conversations as tasks in Things & OmniFocus.
JavaScript
5
star
14

tschoffelen

๐ŸŒŽ My personal website.
HTML
4
star
15

react-update-popup

๐Ÿ”„ Ask users to refresh when there is a new version of the app available.
TypeScript
4
star
16

things-gmail

๐Ÿ“ฉ A Chrome extension to quickly add Gmail conversations as a task in Things.
JavaScript
3
star
17

serverless-starter

Starter boilerplate for a serverless API.
JavaScript
2
star
18

breakout-team

๐Ÿ“น Video breakout rooms made easy.
JavaScript
1
star
19

mirri

๐ŸŒฟ A little file sharing app.
JavaScript
1
star
20

gatsby-remark-fountain

Plugin to render Fountain screenwriting syntax in `gatsby-transformer-remark`.
JavaScript
1
star
21

advent-2020

๐ŸŽ… My Advent of Code solutions.
JavaScript
1
star
22

alfred-schof.link

Alfred workflow to copy clipboard to schof.link.
JavaScript
1
star