laulamanapps / google-wallet-symfony
Google Wallet integration for your Symfony application
Package info
github.com/LauLamanApps/google-wallet-symfony
pkg:composer/laulamanapps/google-wallet-symfony
Requires
- php: ^8.1
- laulamanapps/google-wallet: ^1.0
- symfony/framework-bundle: ^6.4|^7.0|^8.0
Requires (Dev)
- matthiasnoback/symfony-config-test: ^4.3|^5.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.0|^11.0
- symfony/yaml: ^6.4|^7.0|^8.0
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 invar/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 |
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.
Credits
This package has been developed by LauLaman.