Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flights, members and coupons to php quickstart #1

Merged
merged 7 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pem
vendor/
136 changes: 134 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,134 @@
# passkit-php-quickstart
Quickstart coming soon
PassKit PHP Quickstart
=======================
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/PassKit/passkit-php-grpc-sdk/main/LICENSE)
[![Latest Stable Version](https://poser.pugx.org/passkit/passkit-php-grpc-sdk/v)](https://packagist.org/packages/passkit/passkit-php-grpc-sdk)
### Overview

This quickstart aims to help get PHP developers up and running with the PassKit SDK as quickly as possible.

### Prerequisites

You will need the following:
- PHP 7.0 or higher [Installation Guide](https://grpc.io/docs/languages/php/quickstart/)
- PEAR [Installation Guide](https://pear.php.net/manual/en/installation.php)
- 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)
- Composer [Download Here](https://getcomposer.org/) ([Installation Guide](https://getcomposer.org/download/) )
- A PassKit account (signup for free at [PassKit](https://app.passkit.com))
- Your PassKit SDK Credentials (available from the [Developer Tools Page](https://app.passkit.com/app/account/developer-tools))
- Apple wallet certificate id (for flights only, available from the [certificate page](https://app.passkit.com/app/account/certificates))
![ScreenShot](images/certificate.png)


### Configuration

1. Install & Enable the gRPC PHP extension
![ScreenShot](images/pecl.png)

After installing the gRPC extension, make sure the extension is enabled in your `php.ini` file by typing `php --ini`
![ScreenShot](images/ini.png)

Make sure that the file has `extension="grpc.so"` and add the line if it doesn't so it matches the screenshot below:
![ScreenShot](images/grpc.png)

For detailed steps visit the [gRPC PHP quickstart](https://grpc.io/docs/languages/php/quickstart/).

2. Add bindings to composer
To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`:

```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`

Manual Installation
Clone the repo and include `autoload.php`:

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

3. In the certs folder of the repository add the following three PassKit 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.

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`.
![ScreenShot](images/decrypt-key.png)
For the password use the one-time password that you used for generating the SDK credentials.

Your `key.pem` file should look like below.
![ScreenShot](images/decrypted-key.png)
If you do not see `Proc-Type: 4,ENCEYPTED` on line 2, you have successfully decrypted `key.pem`.

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.
![ScreenShot](images/variables.png)

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.

## Examples
### Membership Cards
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
In the membership folder the methods there are:
- 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
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
In the coupons folder the methods are:
- 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


### Boarding Passes
#### Issue A Boarding Pass.
Follow the steps of the [Quickstart](#quickstart) to get the quickstart up and running.
In the flights folder the methods are:
- 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

## Documentation
* [PassKit Membership Official Documentation](https://docs.passkit.io/protocols/member)
* [PassKit Coupons Official Documentation](https://docs.passkit.io/protocols/coupon)
* [PassKit Boarding Passes Official Documentation](https://docs.passkit.io/protocols/boarding)


## Getting Help
* [Online chat support](https://passkit.com/)
49 changes: 49 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "passkit/passkit-php-quickstart",
"description": "PHP gRPC SDK for Apple Wallet and Google Pay Membership / Loyalty / Access Cards, Coupons, Flights & Event-Tickets.",
"keywords": [
"passkit",
"php",
"sdk",
"api",
"grpc"
],
"version": "1.0.0",
"homepage": "http://passkit.com",
"license": "MIT",
"authors": [
{
"name": "PassKit Inc.",
"homepage": "https://passkit.com"
}
],
"repositories": [
{
"type": "git",
"url": "https://github.com/passkit/passkit-php-grpc-sdk.git"
}
],
"require": {
"grpc/grpc": "^v1.42.0",
"google/protobuf": "^v3.21.7",
"passkit/passkit-php-grpc-sdk": "1.1.72"
},
"autoload": {
"psr-4": {
"Analytics\\": "lib/Analytics",
"Cabin_codes\\": "lib/Cabin_codes",
"Ct\\": "lib/Ct",
"Event_tickets\\": "lib/Event_tickets",
"Flights\\": "lib/Flights",
"Io\\": "lib/Io",
"Members\\": "lib/Members",
"Raw\\": "lib/Raw",
"Scheduler\\": "lib/Scheduler",
"Single_use_coupons\\": "lib/Single_use_coupons",
"GPBMetadata\\Io\\": "lib/GPBMetadata/Io",
"GPBMetadata\\Ct\\": "lib/GPBMetadata/Ct",
"GPBMetadata\\Google\\": "lib/extra/GPBMetadata/Google",
"Google\\Api\\": "lib/extra/google/api"
}
}
}
160 changes: 160 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading