Skip to content

Commit c43939d

Browse files
committed
Added flights, members and coupons to php quickstart
1 parent 1947174 commit c43939d

File tree

1,043 files changed

+116912
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,043 files changed

+116912
-2
lines changed

README.md

+107-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,107 @@
1-
# passkit-php-quickstart
2-
1+
PassKit PHP Quickstart
2+
=======================
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/PassKit/passkit-php-grpc-sdk/main/LICENSE)
4+
### Overview
5+
6+
This quickstart aims to help get PHP developers up and running with the PassKit SDK as quickly as possible.
7+
8+
### Prerequisites
9+
10+
You will need the following:
11+
- PHP 7.0 or higher [Installation Guide](https://grpc.io/docs/languages/php/quickstart/)
12+
- PECL
13+
- Composer [Download Here](https://getcomposer.org/) ([Installation Guide](https://getcomposer.org/download/) )
14+
- A PassKit account (signup for free at [PassKit](https://app.passkit.com))
15+
- Your PassKit SDK Credentials (available from the [Developer Tools Page](https://app.passkit.com/app/account/developer-tools))
16+
- Apple wallet certificate id (for flights only, available from the [certificate page](https://app.passkit.com/app/account/certificates))
17+
![ScreenShot](images/certificate.png)
18+
19+
20+
### Configuration
21+
22+
1. Install & Enable the gRPC PHP extension
23+
![ScreenShot](images/pecl.png)
24+
25+
After installing the gRPC extension, make sure the extension is enabled in your `php.ini` file by typing `php --ini`
26+
![ScreenShot](images/ini.png)
27+
28+
Make sure that the file has `extension="grpc.so"` and add the line if it doesn't so it matches the screenshot below:
29+
![ScreenShot](images/grpc.png)
30+
31+
For detailed steps visit the [gRPC PHP quickstart](https://grpc.io/docs/languages/php/quickstart/).
32+
33+
2. In the certs folder of the repository add the following three PassKit credential files:
34+
- certificate.pem
35+
- ca-chain.pem
36+
- key.pem
37+
38+
You can disregard the key-java.pem credentials file as it is not compatible with PHP.
39+
40+
3. Now we need to decrypt your `key.pem`. At your project root directory, run `cd ./certs` `openssl ec -in key.pem -out key.pem`.
41+
![ScreenShot](images/decrypt-key.png)
42+
For the password use the one-time password that you used for generating the SDK credentials.
43+
44+
Your `key.pem` file should look like below.
45+
![ScreenShot](images/decrypted-key.png)
46+
If you do not see `Proc-Type: 4,ENCEYPTED` on line 2, you have successfully decrypted `key.pem`.
47+
48+
4. Modify the variables with the values for your programs or campaigns in each of the membership, coupons and flights methods. The variables to modify will be at the top of each method.
49+
![ScreenShot](images/variables.png)
50+
51+
5. To run each method go into the directory, for members `cd membership`, for coupons `cd coupons` and for flights `cd flights`. Then run php plus the name of the method e.g. `php enrol-member.php` to run that method.
52+
53+
## Examples
54+
### Membership Cards
55+
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
56+
In the membership folder the methods there are:
57+
- create-program.php - takes a new program name and creates a new program
58+
- 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
59+
- 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
60+
- GetSingleMember() - takes memberId and returns the record of that member
61+
- list-members.php - takes search conditions as pagination object and returns list of member records which match with the conditions
62+
- update-member.php - takes memberId and memberDetails, and updates existing member record
63+
- earn-points.php - takes a programId of an existing program and memberId of existing member to add points to chosen member
64+
- burn-points.php - takes a programId of an existing program and memberId of existing member to use points from a chosen member
65+
- set-points.php - takes a programId of an existing program and memberId of existing member to set the points of a chosen member
66+
- delete-member.php - takes programId, tierId, memberId and memberDetails, deletes an existing member record
67+
68+
69+
### Coupons
70+
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
71+
In the coupons folder the methods are:
72+
- create-campaign.php - takes a new campaign name and creates a new campaign
73+
- 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
74+
- 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
75+
- get-single-coupon.php - takes couponId and returns the record of that coupon
76+
- list-coupons.php - takes search conditions as pagination object and returns list of coupon records which match with the conditions
77+
- count-coupons.php - takes search conditions as pagination object and returns the number of coupons who match with the condition
78+
- update-coupon.php - takes a campaignId of an existing campaign and couponId of existing coupon to update that coupon
79+
- redeem-coupon.php - takes a campaignId of an existing campaign and couponId of existing coupon to redeem that coupon
80+
- void-coupon.php - takes the couponId, offerId and campaignId to void an existing coupon
81+
- delete-campaign.php - takes the campaignId to delete an existing campaign
82+
83+
84+
### Boarding Passes
85+
#### Issue A Boarding Pass.
86+
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
87+
In the flights folder the methods are:
88+
- create-template.php - creates the pass template for flights and boarding passes
89+
- create-carrier.php - takes a new carrier code and creates a new carrier
90+
- create-airport.php - takes a new airport code and creates a new airport.
91+
- 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
92+
- create-flight-designator.php - creates flight designator using flight code
93+
- 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
94+
- delete-flight.php - takes an existing flight number as well as other details and deletes the flight associated with it
95+
- delete-flight-designator.php - takes an existing flight designation and deletes the flight designator associated with it
96+
- delete-airports.php - takes an existing airport code and deletes the airport associated with it
97+
- delete-carrier.php - takes an existing carrier code and deletes the carrier associated with it
98+
99+
## Documentation
100+
* [PassKit Membership Official Documentation](https://docs.passkit.io/protocols/member)
101+
* [PassKit Coupons Official Documentation](https://docs.passkit.io/protocols/coupon)
102+
* [PassKit Boarding Passes Official Documentation](https://docs.passkit.io/protocols/boarding)
103+
104+
105+
## Getting Help
106+
* [Online chat support](https://passkit.com/)
107+

composer.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "passkit/passkit-php-quickstart",
3+
"description": "PHP gRPC SDK for Apple Wallet and Google Pay Membership / Loyalty / Access Cards, Coupons, Flights & Event-Tickets.",
4+
"keywords": [
5+
"passkit",
6+
"php",
7+
"sdk",
8+
"api",
9+
"grpc"
10+
],
11+
"version": "1.0.0",
12+
"homepage": "http://passkit.com",
13+
"license": "MIT",
14+
"authors": [
15+
{
16+
"name": "PassKit Inc.",
17+
"homepage": "https://passkit.com"
18+
}
19+
],
20+
"repositories": [
21+
{
22+
"type": "git",
23+
"url": "https://github.com/passkit/passkit-php-grpc-sdk.git"
24+
},
25+
{
26+
"type": "vcs",
27+
"url": "https://github.com/stanley-cheung/Protobuf-PHP"
28+
}
29+
],
30+
"require": {
31+
"grpc/grpc": "^v1.42.0",
32+
"google/protobuf": "^v3.13.0",
33+
"passkit/passkit-php-grpc-sdk": "1.0.0",
34+
"zircote/swagger-php": "^4.4",
35+
"protobuf-php/protobuf": "^0.1.3"
36+
},
37+
"autoload": {
38+
"psr-4": {
39+
"Analytics\\": "lib/Analytics",
40+
"Cabin_codes\\": "lib/Cabin_codes",
41+
"Event_tickets\\": "lib/Event_tickets",
42+
"Flights\\": "lib/Flights",
43+
"Io\\": "lib/Io",
44+
"Members\\": "lib/Members",
45+
"Single_use_coupons\\": "lib/Single_use_coupons",
46+
"GPBMetadata\\Io\\": "lib/GPBMetadata/Io",
47+
"GPBMetadata\\Google\\": "lib/extra/GPBMetadata/Google",
48+
"Google\\Api\\": "lib/extra/google/api"
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)