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

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

Claudia avatar
Written by Claudia
Updated over a year ago

Prerequisites

You will need the following:

Getting started

  1. Download or clone this quickstart repository, in the certs folder 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 Golang.

  2. Install PassKit Golang SDK in the terminal with go install github.com/PassKit/passkit-golang-grpc-sdk

  3. Now we need to decrypt your key.pem. At your project root directory in the terminal, run cd ./certs openssl ec -in key.pem -out key.pem. If you are in your root directory the terminal should show PASSKIT-GOLANG-GRPC-QUICKSTART to the left of the cursor and then after running the command certs, as shown below. For the password use the one-time password that you used for generating the SDK credentials.

    ScreenShot

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

  4. Replace YOUR_EMAIL_ADDRESS@EMAIL.COM in main.go on line 29 with your email address in order to receive the welcome email with card url which your member will also receive.

  5. Go back to root directory with cd ../. Then run go mod tidy to finish setting up the SDK.

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 after clicking examples 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

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

  • ListMembers() - takes search conditions as pagination object and returns list of member records which match with the conditions

  • CountMembers() - takes search conditions as pagination object and returns the number of members who match with the condition

  • SendWelcomeEmail() - takes memberId and sends a welcome email (contains membership card url) to the member

  • UpdateMember_EmailAddress() - takes memberId and memberDetails, and updates existing member record

  • AddPoints() - takes a programId of an existing program and memberId of existing member to add points to chosen member

  • UsePoints() - takes a programId of an existing program and memberId of existing member to use points from a chosen member

  • DeleteMembers() - 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 after clicking examples 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() - takes couponId and returns the record of that coupon

  • ListCoupons() - takes search conditions as pagination object and returns list of coupon records which match with the conditions

  • CountCoupons() - takes search conditions as pagination object and returns the number of coupons who match with the condition

  • UpdateCoupon() - takes a campaignId of an existing campaign and couponId of existing coupon to update that coupon

  • RedeemCoupon() - takes a campaignId of an existing campaign and couponId of existing coupon to redeem that coupon

  • VoidCoupon() - takes the couponId, offerId and campaignId to void an existing coupon

  • DeleteCouponOffer() - takes the offerId to delete an existing offer

Flights Templates

These templates can be found as individual files in the 'flights' folder after clicking examples 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

  • CreateAirport() - 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

  • DeleteFlight() - takes an existing flight number as well as other details and deletes the flight associated with it

  • DeleteFlightDesignator() - takes an existing flight designation and deletes the flight designator associated with it

  • DeleteAirports() - takes an existing airport code and deletes the airport associated with it

  • DeleteCarrier() - 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 after clicking examples 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

  • RedeeemTicket() - takes an existing ticket number and redeems the event ticket associate with it

For implementing in your own projects, use connect_passkit_sdk file in the 'shared' folder class to manage connection to the PassKit gRPC endpoints.

Testing Templates

To test the template you are using edit the main file in the main folder to include only the quickstart templates you are using and then run go run main.go 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 Golang SDK, configure credentials, and explore a variety of pre-made templates to streamline your PassKit integration.

Did this answer your question?