Skip to content

Commit 1c3f816

Browse files
authored
Merge pull request #1 from PassKit/develop
Added flights, members and coupons to php quickstart
2 parents 96287c7 + 488cb0c commit 1c3f816

Some content is hidden

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

41 files changed

+1670
-4
lines changed

.gitattributes

-2
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pem
2+
vendor/

README.md

+134-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,134 @@
1-
# passkit-php-quickstart
2-
Quickstart coming soon
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+
[![Latest Stable Version](https://poser.pugx.org/passkit/passkit-php-grpc-sdk/v)](https://packagist.org/packages/passkit/passkit-php-grpc-sdk)
5+
### Overview
6+
7+
This quickstart aims to help get PHP developers up and running with the PassKit SDK as quickly as possible.
8+
9+
### Prerequisites
10+
11+
You will need the following:
12+
- PHP 7.0 or higher [Installation Guide](https://grpc.io/docs/languages/php/quickstart/)
13+
- PEAR [Installation Guide](https://pear.php.net/manual/en/installation.php)
14+
- PECL [Mac Installation Guide](https://blackdeerdev.com/install-pecl-pear-on-mac-osx/), [Windows Installation Guide](https://wiki.php.net/internals/windows/stepbystepbuild#building_pecl_extensions)
15+
- Composer [Download Here](https://getcomposer.org/) ([Installation Guide](https://getcomposer.org/download/) )
16+
- A PassKit account (signup for free at [PassKit](https://app.passkit.com))
17+
- Your PassKit SDK Credentials (available from the [Developer Tools Page](https://app.passkit.com/app/account/developer-tools))
18+
- Apple wallet certificate id (for flights only, available from the [certificate page](https://app.passkit.com/app/account/certificates))
19+
![ScreenShot](images/certificate.png)
20+
21+
22+
### Configuration
23+
24+
1. Install & Enable the gRPC PHP extension
25+
![ScreenShot](images/pecl.png)
26+
27+
After installing the gRPC extension, make sure the extension is enabled in your `php.ini` file by typing `php --ini`
28+
![ScreenShot](images/ini.png)
29+
30+
Make sure that the file has `extension="grpc.so"` and add the line if it doesn't so it matches the screenshot below:
31+
![ScreenShot](images/grpc.png)
32+
33+
For detailed steps visit the [gRPC PHP quickstart](https://grpc.io/docs/languages/php/quickstart/).
34+
35+
2. Add bindings to composer
36+
To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`:
37+
38+
```json
39+
{
40+
"repositories": [
41+
{
42+
"type": "git",
43+
"url": "https://github.com/passkit/passkit-php-grpc-sdk.git"
44+
}
45+
],
46+
"require": {
47+
"passkit/passkit-php-grpc-sdk": "1.1.70"
48+
}
49+
}
50+
```
51+
52+
Then run `composer install`
53+
54+
Manual Installation
55+
Clone the repo and include `autoload.php`:
56+
57+
```php
58+
require_once('/path/to/passkit-php-grpc-sdk/vendor/autoload.php');
59+
```
60+
61+
3. In the certs folder of the repository add the following three PassKit credential files:
62+
- certificate.pem
63+
- ca-chain.pem
64+
- key.pem
65+
66+
You can disregard the key-java.pem credentials file as it is not compatible with PHP.
67+
68+
4. Now we need to decrypt your `key.pem`. At your project root directory, run `cd ./certs` `openssl ec -in key.pem -out key.pem`.
69+
![ScreenShot](images/decrypt-key.png)
70+
For the password use the one-time password that you used for generating the SDK credentials.
71+
72+
Your `key.pem` file should look like below.
73+
![ScreenShot](images/decrypted-key.png)
74+
If you do not see `Proc-Type: 4,ENCEYPTED` on line 2, you have successfully decrypted `key.pem`.
75+
76+
5. 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.
77+
![ScreenShot](images/variables.png)
78+
79+
6. 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.
80+
81+
## Examples
82+
### Membership Cards
83+
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
84+
In the membership folder the methods there are:
85+
- create-program.php - takes a new program name and creates a new program
86+
- 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
87+
- 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
88+
- GetSingleMember() - takes memberId and returns the record of that member
89+
- list-members.php - takes search conditions as pagination object and returns list of member records which match with the conditions
90+
- update-member.php - takes memberId and memberDetails, and updates existing member record
91+
- earn-points.php - takes a programId of an existing program and memberId of existing member to add points to chosen member
92+
- burn-points.php - takes a programId of an existing program and memberId of existing member to use points from a chosen member
93+
- set-points.php - takes a programId of an existing program and memberId of existing member to set the points of a chosen member
94+
- delete-member.php - takes programId, tierId, memberId and memberDetails, deletes an existing member record
95+
96+
97+
### Coupons
98+
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
99+
In the coupons folder the methods are:
100+
- create-campaign.php - takes a new campaign name and creates a new campaign
101+
- 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
102+
- 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
103+
- get-single-coupon.php - takes couponId and returns the record of that coupon
104+
- list-coupons.php - takes search conditions as pagination object and returns list of coupon records which match with the conditions
105+
- count-coupons.php - takes search conditions as pagination object and returns the number of coupons who match with the condition
106+
- update-coupon.php - takes a campaignId of an existing campaign and couponId of existing coupon to update that coupon
107+
- redeem-coupon.php - takes a campaignId of an existing campaign and couponId of existing coupon to redeem that coupon
108+
- void-coupon.php - takes the couponId, offerId and campaignId to void an existing coupon
109+
- delete-campaign.php - takes the campaignId to delete an existing campaign
110+
111+
112+
### Boarding Passes
113+
#### Issue A Boarding Pass.
114+
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
115+
In the flights folder the methods are:
116+
- create-template.php - creates the pass template for flights and boarding passes
117+
- create-carrier.php - takes a new carrier code and creates a new carrier
118+
- create-airport.php - takes a new airport code and creates a new airport.
119+
- 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
120+
- create-flight-designator.php - creates flight designator using flight code
121+
- 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
122+
- delete-flight.php - takes an existing flight number as well as other details and deletes the flight associated with it
123+
- delete-flight-designator.php - takes an existing flight designation and deletes the flight designator associated with it
124+
- delete-airports.php - takes an existing airport code and deletes the airport associated with it
125+
- delete-carrier.php - takes an existing carrier code and deletes the carrier associated with it
126+
127+
## Documentation
128+
* [PassKit Membership Official Documentation](https://docs.passkit.io/protocols/member)
129+
* [PassKit Coupons Official Documentation](https://docs.passkit.io/protocols/coupon)
130+
* [PassKit Boarding Passes Official Documentation](https://docs.passkit.io/protocols/boarding)
131+
132+
133+
## Getting Help
134+
* [Online chat support](https://passkit.com/)

composer.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
"require": {
27+
"grpc/grpc": "^v1.42.0",
28+
"google/protobuf": "^v3.21.7",
29+
"passkit/passkit-php-grpc-sdk": "1.1.72"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"Analytics\\": "lib/Analytics",
34+
"Cabin_codes\\": "lib/Cabin_codes",
35+
"Ct\\": "lib/Ct",
36+
"Event_tickets\\": "lib/Event_tickets",
37+
"Flights\\": "lib/Flights",
38+
"Io\\": "lib/Io",
39+
"Members\\": "lib/Members",
40+
"Raw\\": "lib/Raw",
41+
"Scheduler\\": "lib/Scheduler",
42+
"Single_use_coupons\\": "lib/Single_use_coupons",
43+
"GPBMetadata\\Io\\": "lib/GPBMetadata/Io",
44+
"GPBMetadata\\Ct\\": "lib/GPBMetadata/Ct",
45+
"GPBMetadata\\Google\\": "lib/extra/GPBMetadata/Google",
46+
"Google\\Api\\": "lib/extra/google/api"
47+
}
48+
}
49+
}

composer.lock

+160
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)