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

Remove Walletobjects.php manual dependency #110

Merged
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
45 changes: 18 additions & 27 deletions php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ creating a pass class, updating issuer permissions, and more.

## Prerequisites

* PHP 8.x
* PHP 7.4
* Composer 2.x
* Follow the steps outlined in the
[Google Wallet prerequisites](https://developers.google.com/wallet/generic/web/prerequisites)
to create the Google Wallet issuer account and Google Cloud service account
* Download the PHP
[Google Wallet API Client library](https://developers.google.com/wallet/generic/resources/libraries#php)

## Environment variables

Expand All @@ -45,59 +43,52 @@ for each class file.
composer install
```

2. Copy the path to the Google Wallet API Client library (`Walletobjects.php`
file) you downloaded. If needed, update the path in the demo class PHP file
(line 22).

```php
// Download the PHP client library from the following URL
// https://developers.google.com/wallet/generic/resources/libraries
require __DIR__ . '/lib/Walletobjects.php';
```

3. In your PHP code, import a demo class and call its method(s). An example
2. In your PHP code, import a demo class and call its method(s). An example
can be found below

```php
// Import the demo class
require __DIR__ . 'demo_eventticket.php';
require __DIR__ . '/demo_eventticket.php';

// Your Issuer account ID (@see Prerequisites)
$issuerId = '3388000000000000000';

// Create a demo class instance
$demo = new DemoEventTicket();

// Create a pass class
$demo->createClass('issuer_id', 'class_suffix');
$demo->createClass($issuerId, 'class_suffix');

// Update a pass class
$demo->updateClass('issuer_id', 'class_suffix');
$demo->updateClass($issuerId, 'class_suffix');

// Patch a pass class
$demo->patchClass('issuer_id', 'class_suffix');
$demo->patchClass($issuerId, 'class_suffix');

// Add a message to a pass class
$demo->addClassMessage('issuer_id', 'class_suffix', 'header', 'body');
$demo->addClassMessage($issuerId, 'class_suffix', 'header', 'body');

// Create a pass object
$demo->createObject('issuer_id', 'class_suffix', 'object_suffix');
$demo->createObject($issuerId, 'class_suffix', 'object_suffix');

// Update a pass object
$demo->updateObject('issuer_id', 'object_suffix');
$demo->updateObject($issuerId, 'object_suffix');

// Patch a pass object
$demo->patchObject('issuer_id', 'object_suffix');
$demo->patchObject($issuerId, 'object_suffix');

// Add a message to a pass object
$demo->addObjectMessage('issuer_id', 'object_suffix', 'header', 'body');
$demo->addObjectMessage($issuerId, 'object_suffix', 'header', 'body');

// Expire a pass object
$demo->expireObject('issuer_id', 'object_suffix');
$demo->expireObject($issuerId, 'object_suffix');

// Generate an Add to Google Wallet link that creates a new pass class and object
$demo->createJWTNewObjects('issuer_id', 'class_suffix', 'object_suffix');
$demo->createJWTNewObjects($issuerId, 'class_suffix', 'object_suffix');

// Generate an Add to Google Wallet link that references existing pass object(s)
$demo->createJWTExistingObjects('issuer_id');
$demo->createJWTExistingObjects($issuerId);

// Create pass objects in batch
$demo->batchCreateObjects('issuer_id', 'class_suffix');
$demo->batchCreateObjects($issuerId, 'class_suffix');
```
11 changes: 10 additions & 1 deletion php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
"require": {
"google/auth": "^1.18",
"guzzlehttp/guzzle": "*",
"google/apiclient": "^2.12"
"google/apiclient": "^2.15",
"google/apiclient-services": "~0.300"
},
"scripts": {
"pre-autoload-dump": "Google\\Task\\Composer::cleanup"
},
"extra": {
"google/apiclient-services": [
"Walletobjects"
]
}
}
Loading