laulamanapps/google-wallet

Generate Google Wallet passes from PHP

Maintainers

Package info

github.com/LauLamanApps/google-wallet

pkg:composer/laulamanapps/google-wallet

Transparency log

Statistics

Installs: 0

Dependents: 5

Suggesters: 3

Stars: 0

Open Issues: 0

v1.0.0 2026-07-08 08:00 UTC

This package is auto-updated.

Last update: 2026-07-08 08:03:10 UTC


README

Generate Google Wallet passes from PHP. The Google counterpart of laulamanapps/apple-passbook.

Passes are distributed via "Add to Google Wallet" links: an RS256-signed JWT whose payload embeds the pass classes and objects (a so-called "fat JWT"). Because the classes and objects travel inside the JWT, no Google Wallet REST API call is needed — the only dependency is ext-openssl for signing.

Installation

composer require laulamanapps/google-wallet

Or use one of the framework integrations, which wire the service account and save-URL factory from configuration:

Service account setup

  1. Sign up for a Google Wallet issuer account in the Google Pay & Wallet Console and note your issuer id.
  2. Create a Google Cloud service account with the Wallet Object Issuer role and download its JSON key file.
  3. Link the service account to your issuer account in the console.

Quickstart

use LauLamanApps\GoogleWallet\Object\Barcode;
use LauLamanApps\GoogleWallet\Object\BarcodeType;
use LauLamanApps\GoogleWallet\Object\GenericClass;
use LauLamanApps\GoogleWallet\Object\GenericObject;
use LauLamanApps\GoogleWallet\Object\Image;
use LauLamanApps\GoogleWallet\Object\TextModule;
use LauLamanApps\GoogleWallet\PassPayload;
use LauLamanApps\GoogleWallet\SaveUrlFactory;
use LauLamanApps\GoogleWallet\ServiceAccount;

$serviceAccount = ServiceAccount::fromJsonFile('/path/to/service-account.json');

// Ids are '<issuerId>.<identifier>'
$object = new GenericObject('3388000000012345678.member-0001', '3388000000012345678.membership');
$object->setCardTitle('ACME Membership');
$object->setHeader('John Doe');
$object->setSubheader('Gold member');
$object->setHexBackgroundColor('#4285f4');
$object->setLogo(Image::fromUri('https://example.com/logo.png', 'ACME logo'));
$object->setBarcode(new Barcode(BarcodeType::QrCode, 'member-0001'));
$object->addTextModule(new TextModule('Member since', '2020'));

$payload = new PassPayload();
$payload->addGenericClass(new GenericClass('3388000000012345678.membership'));
$payload->addGenericObject($object);

$factory = new SaveUrlFactory($serviceAccount, ['https://example.com']);
$saveUrl = $factory->create($payload);
// https://pay.google.com/gp/v/save/eyJhbGciOiJSUzI1NiIs...

Render the url as an Add to Google Wallet button and you are done.

Pass types

Next to GenericClass/GenericObject the same pattern is available for:

  • EventTicketClass / EventTicketObject
  • OfferClass / OfferObject
  • LoyaltyClass / LoyaltyObject
  • TransitClass / TransitObject

Add them to the PassPayload with the matching add*Class()/add*Object() methods.

Signing a JWT yourself

SaveUrlFactory covers the common case. If you need the raw JWT, use JwtSigner directly:

use LauLamanApps\GoogleWallet\JwtSigner;

$signer = new JwtSigner($serviceAccount);
$jwt = $signer->sign([
    'iss' => $serviceAccount->getClientEmail(),
    'aud' => 'google',
    'typ' => 'savetowallet',
    'iat' => time(),
    'origins' => ['https://example.com'],
    'payload' => $payload->toArray(),
]);

Credits

License

The MIT License (MIT). Please see License File for more information.