Prerequisites
You will need the following:
A PassKit account
Your PassKit SDK Credentials
Apple wallet certificate id (for flights only)
Python 3.7 or above( Installation guide)
Getting Started
Download or clone this quickstart repository, create a folder
certs
in the home folder of the repository and add the following three PassKit SDK credential files :certificate.pem
ca-chain.pem
key.pem
You can disregard the key-java.pem credentials file as it is not compatible with Python.
Now we need to decrypt your
key.pem
. At your project root directory, runcd ./certs
openssl ec -in key.pem -out key.pem
. Yourkey.pem
file should look like below. If you are in your root directory the terminal should showPASSKIT-PYTHON-GRPC-QUICKSTART
to the left of the cursor and then after running the commandcerts
.If you do not see
Proc-Type: 4,ENCEYPTED
on line 2, you have successfully decryptedkey.pem
.Use
pip install passkit-python-grpc-sdk
to download the latest sdk from python.
Membership/Loyalty Templates
These templates can be found as individual files in the 'membership' folder and contain the basic fields for each of the actions. Additional fields or templates can be made based on the calls found here.
create-program.py - takes a new program name and creates a new program
create-tier.py - takes the programId of the program just created in the above program, creates a new template (based of default template), creates a tier, and links this tier to the program
enrol-member.py - takes programId and tierId created by the above methods, and memberDetails, creates a new member record, and sends a welcome email to deliver membership card url
update-member.py - takes memberId and memberDetails, and updates existing member record
check-in-member.py - takes memberId and location details and checks in the selected member
check-out-member.py - takes memberId and location details and checks out the selected member
earn-points.py - takes a programId of an existing program and memberId of existing member to add points to chosen member
burn-points.py - takes a programId of an existing program and memberId of existing member to use points from a chosen member
delete-member.py - takes programId, tierId, memberId and memberDetails, deletes an existing member record
Coupons Templates
These templates can be found as individual files in the 'coupons' folder and contain the basic fields for each of the actions. Additional fields or templates can be made based on the calls found here.
create-campaign.py - takes a new campaign name and creates a new campaign
create-offer.py - takes a campaignId of the campaign you just created and creates a new template (based of default template), creates an offer, and links this offer to the campaign
create-coupon.py - takes campaignId and offerId created by the above methods, and couponDetails, creates a new coupon record, and sends a welcome email to deliver coupon card url
list-coupons.py - takes campaignId and returns list of coupon records under that campaign
update-coupon.py - takes a campaignId of an existing campaign and couponId of existing coupon to update that coupon
redeem-coupon.py - takes a campaignId of an existing campaign and couponId of existing coupon to redeem that coupon
void-coupon.py - takes the couponId, offerId and campaignId to void an existing coupon
Flights Templates
These templates can be found as individual files in the 'flights' folder and contain the basic fields for each of the actions. Additional fields or templates can be made based on the calls found here.
create-template.py - creates the pass template for flights and boarding passes
create-carrier.py - takes a new carrier code and creates a new carrier
create-airport.py - takes a new airport code and creates a new airport.
create-flight.py - takes templateId , from previous method, to use as base template and uses a carrier code, created from previous method, and creates a new flight
create-flight-designator.py - creates flight designator using flight code
create-boarding-pass.py - takes templateId, from previous method, and customer details creates a new boarding pass, and sends a welcome email to deliver boarding pass url
delete-flight.py - takes an existing flight number as well as other details and deletes the flight associated with it
delete-flight-designator.py - takes an existing flight designation and deletes the flight designator associated with it
delete-airports.py - takes an existing airport code and deletes the airport associated with it
delete-carrier.py - takes an existing carrier code and deletes the carrier associated with it
Testing Templates
To run each method go into the directory, for members cd membership
, for coupons cd coupons
, for flights cd flights
, for event tickets cd event-tickets
. Then run php plus the name of the method e.g. python enrol-member.py
to run that method.
Note: If you don't plan to use certain templates, consider deleting them from the quickstart files to avoid unintended actions.
This comprehensive guide will help you set up the PassKit Python SDK, configure credentials, and explore a variety of pre-made templates to streamline your PassKit integration.