|
5 | 5 |
|
6 | 6 | Use the PassKit PHP gRPC SDK to issue and manage Apple Wallet and Google Pay Passes from your PHP application. |
7 | 7 |
|
8 | | -For more information, please visit [the documentation](https://docs.passkit.io). |
9 | | - |
10 | | -## Table Of Contents |
11 | | -- [Requirements](#requirements) |
12 | | -- [Installation](#installation) |
13 | | -- [Getting Started](#getting-started) |
14 | | -- [PassKit Portal](#passkit-portal) |
15 | | -- [Known Issues & Unsupported Endpoints](#known-issues--unsupported-endpoints) |
16 | | -- [Getting Help](#getting-help) |
17 | | -- [Contributing](#contributing) |
18 | | -- [Author & License](#author--license) |
19 | | - |
20 | | -## Requirements |
21 | | -1. PHP 7.0 or higher. |
22 | | -2. PECL. |
23 | | -3. Composer. |
24 | | -4. A PassKit account; sign up for free at [https://app.passkit.com](https://app.passkit.com/signup). |
25 | | -5. Your [SDK API credentials](https://app.passkit.com/app/account/developer-tools) (Home >> Account >> Developer Tools >> Generate New SDK Credentials). |
26 | | - |
27 | | -## Installation |
28 | | - |
29 | | -### Instal & Enable the gRPC PHP extension |
30 | | -```bash |
31 | | -sudo pecl install grpc-1.42.0 |
32 | | -``` |
33 | | - |
34 | | -After installing the gRPC extension, make sure the extension is enabled in your `php.ini` file, (e.g. `/etc/php5/cli/php.ini`, `/etc/php5/apache2/php.ini`, or `/usr/local/etc/php/7.2/php.ini`), depending on where your PHP installation is. |
35 | | -```bash |
36 | | -extension=grpc.so |
37 | | -``` |
38 | | - |
39 | | -For detailed steps visit the [gRPC PHP quickstart](https://grpc.io/docs/languages/php/quickstart/). |
40 | | - |
41 | | -### Add bindings to composer |
42 | | -To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: |
43 | | - |
44 | | -```json |
45 | | -{ |
46 | | - "repositories": [ |
47 | | - { |
48 | | - "type": "git", |
49 | | - "url": "https://github.com/passkit/passkit-php-grpc-sdk.git" |
50 | | - } |
51 | | - ], |
52 | | - "require": { |
53 | | - "passkit/passkit-php-grpc-sdk": "1.1.70" |
54 | | - } |
55 | | -} |
56 | | -``` |
57 | | - |
58 | | -Then run `composer install` |
59 | | - |
60 | | -### Manual Installation |
61 | | -Clone the repo and include `autoload.php`: |
62 | | - |
63 | | -```php |
64 | | -require_once('/path/to/passkit-php-grpc-sdk/vendor/autoload.php'); |
65 | | -``` |
66 | | - |
67 | | -## Getting Started |
68 | | -Follow the [installation procedure](#installation), and see general usage format & examples below. |
69 | | - |
70 | | -### Authorization |
71 | | -Simply request your SDK credentials from the [PassKit Portal](https://app.passkit.com/app/account/developer-tools). You will receive an email with your credentials on your registered email address. |
72 | | -Follow the instructions in the email to decrypt `key.pem`, and then copy the `.pem` files into your project (in this project & for the examples to work they should be in the `certs` directory). |
73 | | - |
74 | | -You will need the credentials when you setup the SSL connection to the server. |
75 | | - |
76 | | -Your credentials consist of 3 files: |
77 | | -- `ca-chain.pem`: the PassKit CA chain. |
78 | | -- `certificate.pem`: the certificate for your account. |
79 | | -- `key.pem`: the key that belongs to your certificate. |
80 | | - |
81 | | -Setting up the connection: |
82 | | -```php |
83 | | -putenv("GRPC_SSL_CIPHER_SUITES=HIGH+ECDSA"); |
84 | | - |
85 | | -$ca_filename = "ca-chain.pem"; |
86 | | -$key_filename = "key.pem"; |
87 | | -$cert_filename = "certificate.pem"; |
88 | | -$path = "../certs/"; |
89 | | - |
90 | | -$credentials = Grpc\ChannelCredentials::createSsl( |
91 | | - file_get_contents($path . $ca_filename), |
92 | | - file_get_contents($path . $key_filename), |
93 | | - file_get_contents($path . $cert_filename) |
94 | | -); |
95 | | - |
96 | | -$client = new Members\MembersClient('grpc.pub1.passkit.io:443', [ |
97 | | - 'credentials' => $credentials |
98 | | -]); |
99 | | -``` |
100 | | - |
101 | | -### General Instructions |
102 | | -The general format is shown below. Each API has its own client that you will need to initialise. Clients can re-use the credentials object. |
103 | | - |
104 | | -General format: |
105 | | - |
106 | | -```php |
107 | | -<?php |
108 | | -require_once "../vendor/autoload.php"; |
109 | | - |
110 | | -putenv("GRPC_SSL_CIPHER_SUITES=HIGH+ECDSA"); |
111 | | - |
112 | | -try { |
113 | | - $ca_filename = "ca-chain.pem"; |
114 | | - $key_filename = "key.pem"; |
115 | | - $cert_filename = "certificate.pem"; |
116 | | - $path = "../certs/"; |
117 | | - |
118 | | - $credentials = Grpc\ChannelCredentials::createSsl( |
119 | | - file_get_contents($path . $ca_filename), |
120 | | - file_get_contents($path . $key_filename), |
121 | | - file_get_contents($path . $cert_filename) |
122 | | - ); |
123 | | - |
124 | | - $client = new Members\MembersClient('grpc.pub1.passkit.io:443', [ |
125 | | - 'credentials' => $credentials |
126 | | - ]); |
127 | | - |
128 | | - // Set the Member body |
129 | | - $member = new Members\Member(); |
130 | | - $member->setProgramId("5fbCcr7f4NuBg9lvjJayvV"); |
131 | | - $member->setTierId("bronze"); |
132 | | - |
133 | | - $person = new Io\Person(); |
134 | | - $person->setDisplayName("Patrick Kosterman"); |
135 | | - $dateOfBirth = new Io\Date(); |
136 | | - $dateOfBirth->setDay(22); |
137 | | - $dateOfBirth->setMonth(6); |
138 | | - $dateOfBirth->setYear(2020); |
139 | | - $person->setDateOfBirth($dateOfBirth); |
140 | | - $person->setEmailAddress(" [email protected]"); |
141 | | - $member->setPerson($person); |
142 | | - |
143 | | - list($id, $status) = $client->enrolMember($member)->wait(); |
144 | | - if ($status->code !== 0) { |
145 | | - throw new Exception(sprintf('Status Code: %s, Details: %s, Meta: %s', $status->code, $status->details, var_dump($status->metadata))); |
146 | | - } |
147 | | - |
148 | | - echo "https://pub1.pskt.io/" . $id->getId(); |
149 | | -} catch (Exception $e) { |
150 | | - echo $e; |
151 | | -} |
152 | | -?> |
153 | | -``` |
154 | | - |
155 | | -### Examples |
156 | | -The [examples](/examples) folder contains working samples for using the SDK. |
157 | | - |
158 | | -To successfully run the program: |
159 | | -- ensure your gPRC certificates are in the `certs` folder in this repo (you will need `ca-chain.pem`, `certificate.pem` & `key.pem`). |
160 | | -- modify the variables with the values for your programs & campaigns. |
161 | | -- run `cd examples && php enrol-member.php`. |
162 | | - |
163 | | -## PassKit Portal |
164 | | -The [https://app.passkit.com](https://app.passkit.com) allows you to easily design loyalty cards, membership cards and coupons for both Apple Wallet and Google Pay. |
165 | | - |
166 | | -Additionally, the PassKit portal facilitates management, distribution and simple analysis of your Mobile Wallet projects. |
167 | | - |
168 | | -Best Practices: |
169 | | -- Use the web portal for initial account and project setup. |
170 | | -- Then use the SDKs / APIs to issue, update and delete your individual passes. |
171 | | - |
172 | | -## Known Issues & Unsupported Endpoints |
173 | | -The following methods are currently not implemented: |
174 | | - |
175 | | -__Members__: |
176 | | -- Update Members by Segment: can be done by updating individual members and looping on client side |
177 | | -- Delete Members by Segment: can be done by deleting individual members and looping on client side |
178 | | -- Check In / Out Member |
179 | | - |
180 | | -__Coupons__: |
181 | | -- GetAnalytics |
| 8 | +For more information, see our [PHP quick start](https://github.com/PassKit/passkit-php-quickstart). |
182 | 9 |
|
183 | 10 | ## Getting Help |
184 | 11 | - [Official documentation](https://docs.passkit.io/) |
|
0 commit comments