Passtiche is a website plugin that brings Passbook to your website or mobile app with just a couple lines of code.
- Passtiche auto-generates badges for listings or links to existing Passbook files
- Visitors can download your passes via SMS or email and share them with friends
- Listings passes are automatically enhanced with extra info from Yelp & Foursquare
- Schedule personalized alerts & reminders to be sent as Passbook notifications
See the Passtiche Documentations for details.
Passtiche runs on Tornado.
The Passtiche stack includes:
- A javascript library that can be included on a website with
<script src="http://passtiche.appspot.com/js>
- A Passbook server that creates, updates, signs, and delivers pass files.
- A website with dashboard for managing passes and account settings.
Passtiche uses the following object-oriented MVC framework:
-
All request handlers inherit from
BaseHandler
inviews.base
-
Website request handlers inherit from ViewHandler
in
views.website.index` -
API request handlers inherit from
AjaxHandler
inviews.api.index
-
Ajax request handlers inherit from
AjaxHandler
inviews.ajax.index
-
Resource request handlers (for images and other media) are in
views.resource
module -
Authentication handlers are in
views.website.auth
, with some helper methods inBaseHandler
-
Models are in
model
directory and inherit fromBaseModel
inpostal code
. -
A datastore viewier is available at
/_ah/admin
on the local server and from the productin dashboard. -
Classes and functions for the backend "heavy lifting" are in the
backend
directory. -
Templates for the website are in the
templates/website
directory. -
Javascript and CSS are in the
static
directory, with some portions included via thetemplates
directory.
There are more components for emails, third-party API access, utilities, tests, etc. If you get lost, start with app.yaml
and main.py
.
The initial script loaded via <script src="http://passtiche.appspot.com/js>
is located at static/js/badge/badge.js
.
This script contains a PassticheBadger
class. When initiated, this class finds all links that either link to a pkpass file or contain supported data attributes.
From the PassticheBadger.addBadge
method, supported links on the page are injected with markup containing an Add to Passbook badge image.
The initial PassticheBadger
class also calls a PassticheBadger.loadResources
method when initiated, and this method adds HTML tags to the page that retrieve CSS and JS for the badge dialog.
dialog.js
and dialog.css
are in the templates.resources
directory, and are loaded via resource.StaticResourceHandler
.
dialog.js
contains a PassticheDialog
class. When initiated, this class calls PassticheBadger.findBadges
method, which makes an ajax call to the pass.find
API endpoint.
This API (described below) gets data for each of the passes, creating a new pass and looking up location data when necessary. The ajax call also returns HTML for the badge dialog, which is added to the DOM.
When a badge is clicked, PassticheBadger.badgeClick
is triggered, which then calls PassticheDialog.openPassDialog
.
The dialog class also contains methods for sending passes and other actions within the dialog.
The passbook server consists of components on GAE, as well as a Heroku server that handles the security certificate signing (which requires a C-based library).
When a pass link in the format /p/$short_code
is visited, the badge dialog is loaded.
From the request handler in views.website.index
, the user agent is checked. If the UA supports passbook, the browser is redirected to /pd/$short_code
.
The views.website.index.PassDirectDownload
request handler redirects to a pkpass file if the pass is remotely located.
Otherwise, it calls backend.passes.passfile.PassFile
. This class creates the pass.json
for the pass and sends the JSON and a few other fields to the Heroku server, located in repo/heroku
.
The heroku server then zips a pkpass file and sends it back to GAE, which writes it along with the correct MIMETYPE.
Download the Google AppEngine Python development environment at http://code.google.com/appengine/downloads.html.
Run with extra flags (Info menu from GAE launcher): --datastore_path=PATH
Go to /console
(admin login required) for a python console that makes it easy to call functions in the codebase and run queries.
201 => Created
400 => Bad Request
Path | HTTP Methods | Description |
---|---|---|
/users | GET POST | List of users |
/users/authentication | GET | Authenticate a user |
/users/:id | GET PUT | A specific user |
/users/:id/verification | POST | Verify a user to receive payments |
/users/:id/campaigns | GET | All campaigns the user is involved with |
/users/:id/paid_campaigns | GET | Campaigns this user paid for |
/users/:id/cards | GET POST | User credit cards |
/users/:id/cards/:id | GET PUT DELETE | A specific credit card |
/users/:id/banks | GET POST | User bank accounts |
/users/:id/banks/:id | GET PUT DELETE | A specific bank account |
/users/:id/payments | GET | A list of Users payments |
The verification data is as follows:
name
- should be the real name of the userdob
- the date of birth of the user in the format YYYY-MMphone_number
- the user's phone numberstreet_address
- the user's street addresspostal code
- the user's postal code