定制 laulamanapps/google-wallet-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laulamanapps/google-wallet-laravel

Composer 安装命令:

composer require laulamanapps/google-wallet-laravel

包简介

Google Wallet integration for your Laravel application

README 文档

README

This package provides Laravel integration for the LauLamanApps Google Wallet Package: generate "Add to Google Wallet" save links (RS256-signed JWTs) from your Laravel application.

Requirements

  • PHP 8.1+
  • Laravel 11.x, 12.x or 13.x

Installation

composer require laulamanapps/google-wallet-laravel

The service provider (LauLamanApps\GoogleWalletLaravel\GoogleWalletServiceProvider) is registered automatically via Laravel package auto-discovery.

Run Tests

composer install
./bin/phpunit

Configuration

Publish the config file:

php artisan vendor:publish --tag=google-wallet-config

This creates config/google-wallet.php:

Key Default Description
service_account env('GOOGLE_WALLET_SERVICE_ACCOUNT') Path to the Google Cloud service account JSON key file used to sign the JWTs
origins [] Origins allowed to render the save urls; leave empty to allow opening from anywhere

Add the ENV variable to your .env file:

###> laulamanapps/google-wallet-laravel ###
GOOGLE_WALLET_SERVICE_ACCOUNT=storage/keys/google-wallet.json
###< laulamanapps/google-wallet-laravel ###

Get a service account

  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.

Creating a save link

The package registers LauLamanApps\GoogleWallet\SaveUrlFactory as a singleton, configured with your service account and origins. Inject it anywhere:

namespace App\Http\Controllers;

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

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

    public function save()
    {
        // Ids are '<issuerId>.<identifier>'
        $object = new GenericObject('3388000000012345678.member-0001', '3388000000012345678.membership');
        $object->setCardTitle('ACME Membership');
        $object->setHeader('John Doe');
        $object->setBarcode(new Barcode(BarcodeType::QrCode, 'member-0001'));

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

        return redirect()->away($this->saveUrlFactory->create($payload));
    }
}

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

See the core package documentation for all pass types (generic, event ticket, offer, loyalty, transit), fields, images and colors. The service provider also registers LauLamanApps\GoogleWallet\ServiceAccount and LauLamanApps\GoogleWallet\JwtSigner as singletons in case you want to sign a JWT yourself.

Credits

This package has been developed by LauLaman.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固