Skip to main content
All CollectionsDevelopSoftware Developer Kits
How to use the PassKit PHP SDK
How to use the PassKit PHP SDK

Guide to PassKit PHP SDK setup with templates for memberships, coupons, flights, and event tickets.

Claudia avatar
Written by Claudia
Updated over 10 months ago

Prerequisites

You will need the following:

Getting Started

  1. 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 PHP.

  2. Now we need to decrypt your key.pem. At your project root directory, run cd ./certs openssl ec -in key.pem -out key.pem. Your key.pem file should look like below. If you are in your root directory the terminal should show PASSKIT-PHP-GRPC-QUICKSTART to the left of the cursor and then after running the command certs.

    ScreenShot

    If you do not see Proc-Type: 4,ENCEYPTED on line 2, you have successfully decrypted key.pem.

  3. Install & Enable the gRPC PHP extension by running sudo pecl install grpc

    After installing the gRPC extension, make sure the extension is enabled in your php.ini file by typing php --ini in your terminal. If you have done it correctly you should see something similiar to below:

    ScreenShot

    Make sure that the 'php.ini' file has extension="grpc.so" and add the line if it doesn't.

    For detailed steps visit the gRPC PHP quickstart.

  4. Add bindings to composer To install the bindings via Composer, add the following to composer.json:

    {

    "repositories": [

    {

    "type": "git",

    "url": "https://github.com/passkit/passkit-php-grpc-sdk.git"

    }

    ],

    "require": {

    "passkit/passkit-php-grpc-sdk": "1.1.70"

    }

    }

    Then run composer install.

    For manual installation clone the repo and include autoload.php:

    require_once('/path/to/passkit-php-grpc-sdk/vendor/autoload.php');

Once you have set up the certificates and any other variables from the above steps you can then pick one of the pre-made templates to start getting up and running with the PassKit SDK.

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.php - takes a new program name and creates a new program

  • create-tier.php - 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.php - 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

  • GetSingleMember() - takes memberId and returns the record of that member

  • list-members.php - takes search conditions as pagination object and returns list of member records which match with the conditions

  • update-member.php - takes memberId and memberDetails, and updates existing member record

  • earn-points.php - takes a programId of an existing program and memberId of existing member to add points to chosen member

  • burn-points.php - takes a programId of an existing program and memberId of existing member to use points from a chosen member

  • set-points.php - takes a programId of an existing program and memberId of existing member to set the points of a chosen member

  • delete-member.php - 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.php - takes a new campaign name and creates a new campaign

  • create-offer.php - 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.php - 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

  • get-single-coupon.php - takes couponId and returns the record of that coupon

  • list-coupons.php - takes search conditions as pagination object and returns list of coupon records which match with the conditions

  • count-coupons.php - takes search conditions as pagination object and returns the number of coupons who match with the condition

  • update-coupon.php - takes a campaignId of an existing campaign and couponId of existing coupon to update that coupon

  • redeem-coupon.php - takes a campaignId of an existing campaign and couponId of existing coupon to redeem that coupon

  • void-coupon.php - takes the couponId, offerId and campaignId to void an existing coupon

  • delete-campaign.php - takes the campaignId to delete an existing campaign

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.php - creates the pass template for flights and boarding passes

  • create-carrier.php - takes a new carrier code and creates a new carrier

  • create-airport.php - takes a new airport code and creates a new airport.

  • create-flight.php - 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.php - creates flight designator using flight code

  • create-boarding-pass.php - 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.php - takes an existing flight number as well as other details and deletes the flight associated with it

  • delete-flight-designator.php - takes an existing flight designation and deletes the flight designator associated with it

  • delete-airports.php - takes an existing airport code and deletes the airport associated with it

  • delete-carrier.php - takes an existing carrier code and deletes the carrier associated with it

Event Tickets Templates

These templates can be found as individual files in the 'event-tickets' folder and contain the basic fields for each of the actions. Additional fields or templates can be made based on the calls found here.

  • createTemplate() - creates the pass template for event tickets

  • createVenue() - creates a venue for the event

  • createProduction() - takes a new production name and creates a new production

  • createTicketType() - takes templateId , from previous method, to use as base template and the productionId, created from previous method, and creates a new ticketType

  • createEvent() - takes productionId and venueId ,from previous method, and creates a new Event

  • issueEventTicket() - takes ticketTypeId and eventId, from previous method, and customer details creates a event ticket, and sends a welcome email to deliver event ticket url

  • validateTicket() - takes an existing ticket number as well as other details and validates it

  • redeemTicket() - takes an existing ticket number and redeems the event ticket associate 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. php enrol-member.php 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 PHP SDK, configure credentials, and explore a variety of pre-made templates to streamline your PassKit integration.

Did this answer your question?