laulamanapps/google-wallet-symfony

Google Wallet integration for your Symfony application

Maintainers

Package info

github.com/LauLamanApps/google-wallet-symfony

pkg:composer/laulamanapps/google-wallet-symfony

Transparency log

Statistics

Installs: 102

Dependents: 1

Suggesters: 1

Stars: 0

Open Issues: 0

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

This package is auto-updated.

Last update: 2026-07-08 22:17:14 UTC


README

This package provides Symfony integration for the LauLamanApps Google Wallet Package.

Requirements

  • PHP 8.1+
  • Symfony 6.4, 7.x, or 8.x

Installation

composer require laulamanapps/google-wallet-symfony

Register the bundle (skipped automatically when using Symfony Flex):

// config/bundles.php

return [
    // ...
    LauLamanApps\GoogleWalletBundle\GoogleWalletBundle::class => ['all' => true],
];

Get a Service Account

Head over to the Google Wallet Console and create a service account with access to the Google Wallet API. Download the JSON key file for that service account.

Configure Bundle

# config/packages/laulamanapps_google_wallet.yaml

laulamanapps_google_wallet:
    service_account: '%env(GOOGLE_WALLET_SERVICE_ACCOUNT)%'
    origins:
        - 'https://example.com'

Add the ENV variable to the .env file:

###> laulamanapps/google-wallet-symfony ###
GOOGLE_WALLET_SERVICE_ACCOUNT=config/secrets/google-wallet-service-account.json
###< laulamanapps/google-wallet-symfony ###

Security note: always reference the service-account key file path through %env(...)% as shown above. A literal value in the bundle configuration would be written into Symfony's compiled container in var/cache.

Configuration reference

Key Required Default Description
service_account yes Path to the Google service-account JSON key file
origins no [] Allowed origins for the Save to Google Wallet button
callback.enabled no false Enable the save/delete callback (webhook) endpoint
callback.issuer_id when enabled null Your Google Wallet issuer id, used to verify callback signatures
callback.environment no 'production' Google root signing keys to verify against: production / test

Usage

Inject the SaveUrlFactory to create "Save to Google Wallet" links:

namespace App\Controller;

use LauLamanApps\GoogleWallet\PassPayload;
use LauLamanApps\GoogleWallet\SaveUrlFactory;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;

class WalletController
{
    public function __construct(
        private readonly SaveUrlFactory $saveUrlFactory,
    ) {
    }

    public function save(): Response
    {
        $payload = new PassPayload();
        // ... build your pass, see the laulamanapps/google-wallet README

        return new RedirectResponse($this->saveUrlFactory->create($payload));
    }
}

See the laulamanapps/google-wallet README for details on building pass objects and classes.

Save/delete callbacks

Google can notify your application whenever a user saves or deletes a pass. The bundle ships a ready-made webhook endpoint that verifies each callback (Google's ECv2SigningOnly signature scheme) and turns it into a Symfony event. Verification is enforced server-side: unverifiable requests are rejected with a 400 response and no event is dispatched, so your listeners only ever see messages that provably came from Google.

1. Enable the callback endpoint

# config/packages/laulamanapps_google_wallet.yaml

laulamanapps_google_wallet:
    service_account: '%env(GOOGLE_WALLET_SERVICE_ACCOUNT)%'
    callback:
        enabled: true
        issuer_id: '3388000000012345678' # required when enabled
        environment: production          # or 'test' to verify against Google's test keys

2. Import the routes

// config/routes/google_wallet.php

use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes): void {
    $routes->import('@GoogleWalletBundle/Resources/config/callback_routes.php');
};

or in yaml:

# config/routes/google_wallet.yaml
googlewallet:
    resource: '@GoogleWalletBundle/Resources/config/callback_routes.php'

This exposes a single route, googlewallet_callback: POST /google-wallet/callback.

3. Register the callback url on your pass classes

Google only sends callbacks for passes whose class declares a callback url. Set your public HTTPS URL (Google requires https://) on the pass classes you create:

$class = new GenericClass('3388000000012345678.membership');
$class->setCallbackUrl('https://example.com/google-wallet/callback');

4. Listen to the events

The endpoint dispatches LauLamanApps\GoogleWalletBundle\Event\PassSavedEvent when a user saves a pass and LauLamanApps\GoogleWalletBundle\Event\PassDeletedEvent when a user deletes one:

namespace App\EventListener;

use LauLamanApps\GoogleWalletBundle\Event\PassDeletedEvent;
use LauLamanApps\GoogleWalletBundle\Event\PassSavedEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

final class WalletPassListener
{
    #[AsEventListener]
    public function onPassSaved(PassSavedEvent $event): void
    {
        $event->getObjectId(); // '3388000000012345678.member-0001'
        $event->getClassId();  // '3388000000012345678.membership'
    }

    #[AsEventListener]
    public function onPassDeleted(PassDeletedEvent $event): void
    {
        // e.g. mark the pass as removed in your database
    }
}

Both events expose the verified message via getCallbackEvent(), which returns the core lib's CallbackEvent (event type, expiration and nonce). Callbacks are delivered at least once, so use getCallbackEvent()->getNonce() to deduplicate.

Credits

This package has been developed by LauLaman.