最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Google Wallet: How to create generic pass object - Stack Overflow

programmeradmin1浏览0评论

I'm using library chiiya/passes to generate membership cards for my project. The github page has an example to create a generic object but, maybe I'm wrong, some information is missing.

$object = new GenericObject(
    cardTitle: LocalizedString::make('en', '::cardTitle::'),
    header: LocalizedString::make('en', '::header::'),
    subheader: LocalizedString::make('en', '::subheader::'),
    logo: Image::make('.png'),
    hexBackgroundColor: '#333',
    notifications: new Notifications(
        upcomingNotification: new UpcomingNotification(
            enableNotification: true
        ),
    ),
    classId: '1234567890123456789.generic-object',
    id: '1234567890123456789.'.Str::uuid()->toString(),
    heroImage: Image::make('.png'),
    state: State::ACTIVE,
    barcode: new Barcode(
        type: BarcodeType::QR_CODE,
        value: '1464194291627',
        renderEncoding: BarcodeRenderEncoding::UTF_8,
    ),
    validTimeInterval: new TimeInterval(
        start: new DateTime(date: now()),
        end: new DateTime(date: now()->addMonth())
    ),
    textModulesData: [
        new TextModuleData(
            header: 'label-1',
            body: 'value-1',
            id: 'key-1',
        ),
        new TextModuleData(
            header: 'label-2',
            body: 'value-2',
            id: 'key-2',
        )
    ],
    groupingInfo: new GroupingInfo(
        groupingId: 'group1'
    )
);

$jwt = (new JWT(
    iss: $credentials->client_email,
    key: $credentials->private_key,
    origins: [''],
))->addGenericObject($object)->sign();

Once the object has been created and signed using the credentials, how is it sent to Google so the pass is created and how do I offer the user the "Add to Google Wallet" button. I've seen somewhere that I need an id of the object but I haven't been able to find how to do that.

I've already created the generic class in the Google Wallet website.

Is there someone who has used this library, or similars, able to give me a hint?

Thanks

发布评论

评论列表(0)

  1. 暂无评论