Giter Club home page Giter Club logo

php-pkpass's Introduction

PHP library to create passes for iOS wallet app

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

Requirements

  • PHP 5.4 or higher
  • PHP ZIP Support (may be installed by default)
  • Access to filesystem (script must be able to create temporary folders)

Installation

Composer

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": "^1.2.0"

Manually

Include the PKPass.php file in your PHP project:

require('src/PKPass.php');

Usage

Please take a look at the 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.

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.
  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 under 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.

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.

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

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:

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.

Email me at thomas [at] scholica.com or tweet me @tschoffelen.

php-pkpass's People

Contributors

tschoffelen avatar mikealmond avatar dododedodonl avatar ebetancourt avatar ptz0n avatar gcalmels avatar jacksonj04 avatar artyfarty avatar chao avatar dator avatar fbrinker avatar antonioreyna avatar getreup avatar mac-cain13 avatar ondrejmirtes avatar philippec avatar piamancini avatar aeoris avatar fedegiust avatar

Watchers

Ben Haim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.