Prerequisites
You will need the following:
A PassKit account
Your PassKit SDK Credentials
Apple wallet certificate id (for flights only)
Recommended Code Editor: Visual Studio Code see here for guide on installing the necessary extensions
.NET v6.0 Guide to Installation (please note: should you be installing this in Mac if may come up as malicious software despite being from Microsoft. The way to fix this is shown in the configuration)
Note: should you be installing this in Mac if may come up as malicious software despite being from Microsoft, please see getting started section on how to fix this.
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 C#.
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-C-SHARP-GRPC-QUICKSTART
to the left of the cursor and then after running the commandcerts
, as shown below.If you do not see
Proc-Type: 4,ENCEYPTED
on line 2, you have successfully decryptedkey.pem
.If you wish to receive enrollment emails for loyalty or coupon cards edit
baseEmail
andvipEmail
on lines 29 and 30 in QuickstartLoyalty for loyalty and lines 30 and 31 in QuickstartCoupons for coupons.Mac users only
After configuring the quickstart should you encounter the error, navigate to system preferences and select security and privacy
Then navigate to general
In general, underneath App Store and identified developers the file that is being flagged as malicious will be shown. Allow it to run and the quickstart should run smoothly, you may need to repeat the process a couple of times for the other files involved in .Net.
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 in the QuickstartLoyalty file in 'Quickstarts' folder and contain the basic fields for each of the actions. Additional fields or templates can be made based on the calls found here.
createProgram() - takes a new program name and creates a new program
createTier() - 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
enrolMember() - 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
checkInMember() - an optional method that checks in a member at an event
checkOutMember() - an optional method that checks out a member at an event
addPoints() - an optional method that takes the memberId of existing member to add points to chosen member
burnPoints() - an optional method that burns the selected number of points of a chosen member
deleteProgram() - an optional method that deletes a program and any tiers or members associated with it.
Coupons Templates
These templates can be found in the QuickstartCoupons file in 'Quickstarts' folder and contain the basic fields for each of the actions. Additional fields or templates can be made based on the calls found here.
createCampaign() - takes a new campaign name and creates a new campaign
createOffer() - 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
createCoupon() - 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
getSingleCoupon() - an optional method that takes couponId and returns the record of that coupon
redeemCoupon() - an optional method that redeems a coupon that has been made
voidCoupon() - an optional method that voids a coupon that has been made
deleteCampaign() - an optional method that deletes a campaign and any associated offers or coupons
Flights Templates
These templates can be found in the QuickstartFlights file in 'Quickstarts' 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 flights and boarding passes
createCarrier() - takes a new carrier code and creates a new carrier
createAirports() - takes a new airport code and creates a new airport
createFlight() - takes templateId , from previous method, to use as base template and uses a carrier code, created from previous method, and creates a new flight
createFlightDesignator() - creates flight designator using flight code
createBoardingPass() - takes templateId, from previous method, and customer details creates a new boarding pass, and sends a welcome email to deliver boarding pass url
deleteFlightAssets() - an optional method that deletes the flight objects recently created
Event Tickets Templates
These templates can be found in the QuickstartEventTickets file in 'Quickstarts' 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
For implementing in your own projects, use the GrpcConnection class to manage connection to the PassKit gRPC endpoints.
Use the GrpcConnection's ManagedChannel object to create the stubs you require in your implementation.
Testing Templates
To test the template you are using edit the Program file in the main folder to include only the quickstart file you are using and then run dotnet run
in the terminal.
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 C# SDK, configure credentials, and explore a variety of pre-made templates to streamline your PassKit integration.