I tried to implement Google Wallet API to create Generic Card Pass with PHP and I'm using the demo code described there: https://github.com/google-wallet/rest-samples/blob/main/php/demo_generic.php . When I create a class with only id as class definition (['id' => $issuerId . '.' . $classSuffix]) it works but if I use the class base below I get and Invalid Argument Error:
Google\Service\Exception {
#message: """
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
"""
#code: 400
#file: "../vendor/google/apiclient/src/Http/REST.php"
#errors: array:1 [
0 => array:3 [
"message" => "Request contains an invalid argument."
"domain" => "global"
"reason" => "badRequest"
]
]
}
My class base definition:
$classDef = [
'id' => $issuerId . '.' . self::CLASS_SUFFIX,
'classTemplateInfo' => [
'cardTemplateOverride' => [
'cardRowTemplateInfos' => [
[
'twoItems' => [
'startItem' => [
'firstValue' => [
'fields' => [
[
'fieldPath' => 'object.textModulesData["points"]'
]
]
]
],
'endItem' => [
'firstValue' => [
'fields' => [
[
'fieldPath' => 'object.textModulesData["contacts"]'
]
]
]
]
]
]
]
],
'detailsTemplateOverride' => [
'detailsItemInfos' => [
[
'item' => [
'firstValue' => [
'fields' => [
[
'fieldPath' => 'class.imageModulesData["event_banner"]'
]
]
]
]
],
[
'item' => [
'firstValue' => [
'fields' => [
[
'fieldPath' => 'class.textModulesData["game_overview"]'
]
]
]
]
],
[
'item' => [
'firstValue' => [
'fields' => [
[
'fieldPath' => 'class.linksModuleData.uris["official_site"]'
]
]
]
]
]
]
]
],
'imageModulesData' => [
[
'mainImage' => [
'sourceUri' => [
'uri' => 'https=>//storage.googleapis.com/wallet-lab-tools-codelab-artifacts-public/google-io-2021-card.png'
],
'contentDescription' => [
'defaultValue' => [
'language' => 'en-US',
'value' => 'Google I/O 2022 Banner'
]
]
],
'id' => 'event_banner'
]
],
'textModulesData' => [
[
'header' => 'Gather points meeting new people at Google I/O',
'body' => 'Join the game and accumulate points in this badge by meeting other attendees in the event.',
'id' => 'game_overview'
]
],
'linksModuleData' => [
'uris' => [
[
'uri' => 'https=>//io.google/2022/',
'description' => 'Official I/O \'22 Site',
'id' => 'official_site'
]
]
]
];
N.B: When I use the exemple with nodejs it works perfectly
I think I'm going to use createJwtNewObjects method because it works.