Design

The following template contains all of the basic fields for an offer.
Google Pay API for Passes Offers template
  1. class.titleImage
  2. class.issuerName
  3. class.title
  4. class.heroImage
  5. object.barcode.type

    object.barcode.value

  6. object.barcode.value / object.barcode.alternateText

  7. class.hexBackgroundColor
  8. object.validTimeInterval.end
  9. class.provider
  10. *.imageModulesData.mainImage
  11. class.details
  12. class.finePrint
  13. *.messages[0].header
  14. *.messages[0].body
  15. *.textModulesData.header
  16. *.textModulesData.body
  17. *.infoModuleData.labelValueRows[0].columns[0].label
  18. *.infoModuleData.labelValueRows[0].columns[0].value
  19. *.linksModuleData.uris[2]
  20. *.linksModuleData.uris[0]
  21. *.linksModuleData.uris[1]
  22. class.helpUri

Priority of fields and values shown on Pass header

There are fields and values that can change the design of an offer Pass depending on what values are set.

Field 6 rendering logic: value under barcode image

If the object.barcode.alternateText field isn't set, then object.barcode.value is used.

Mapping template data to an Offer Class

The following tabs identify the contents of a JSON Offer resource and provide code examples in different languages to populate that resource.

Resource

{
  "kind": "walletobjects#offerClass",
  "id": "#{issuerId}.#{classId}",
  "issuerName": "Baconrista Coffee",
  "issuerData": {
  "kind": "walletobjects#typedValue"
  },
  "title": "20% off on one bacon fat latte",
  "redemptionChannel": "both",
  "provider": "Baconrista Deals",
  "titleImage": {
    "kind": "walletobjects#image",
    "sourceUri": {
      "kind": "walletobjects#uri",
      "uri": "https://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg"
    }
  },
  "locations": [{
    "kind": "walletobjects#latLongPoint",
    "latitude": 37.424015499999996,
    "longitude": -122.09259560000001
    },{
    "kind": "walletobjects#latLongPoint",
    "latitude": 37.424354,
    "longitude": -122.09508869999999
    },{
    "kind": "walletobjects#latLongPoint",
    "latitude": 37.7901435,
    "longitude": -122.39026709999997
    },{
    "kind": "walletobjects#latLongPoint",
    "latitude": 40.7406578,
    "longitude": -74.00208940000002
  }],
  "reviewStatus": "underReview",
  "review": {
    "comments": "Real auto approval by system"
  },
  "textModulesData": [
    {
      "header": "Details",
      "body": "20% off one cup of coffee at all Baconrista Coffee locations. " +
                "Only one can be used per visit."
    },
    {
      "header": "About Baconrista",
      "body": "Since 2013, Baconrista Coffee has been committed to making high " +
                "quality bacon coffee. Visit us in our stores or online at www.baconrista.com"
    }
  ],
  "linksModuleData": {
    "uris": [
      {
        "kind": "walletobjects#uri",
        "uri": "https://maps.google.com/map?q=google",
        "description": "Nearby Locations"
      },
      {
        "kind": "walletobjects#uri",
        "uri": "tel:6505555555",
        "description": "Call Customer Service"
      }
    ]
  },
  "imageModulesData": [
    {
      "mainImage": {
        "kind": "walletobjects#image",
        "sourceUri": {
          "kind": "walletobjects#uri",
          "uri": "https://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg",
          "description": "Coffee beans"
        }
      }
    }
  ],
  "hexBackgroundColor": "#ffffff",
  "heroImage": {
   "kind": "walletobjects#image",
   "sourceUri": {
     "kind": "walletobjects#uri",
     "uri": "https://farm8.staticflickr.com/7302/11177240353_115daa5729_o.jpg"
    }
  }
}

Java

// Define the Image Module Data
List<ImageModuleData> imageModuleData = new ArrayList<ImageModuleData>();

ImageModuleData image = new ImageModuleData().setMainImage(
    new Image().setSourceUri(
        new Uri().setUri("http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg")));

imageModuleData.add(image);

// Define Links Module Data
List<Uri> uris = new ArrayList<Uri>();
Uri uri1 = new Uri().setDescription("Nearby Locations").setUri("http://maps.google.com/?q=google");
Uri uri2 = new Uri().setDescription("Call Customer Service").setUri("tel:6505555555");

uris.add(uri1);
uris.add(uri2);

LinksModuleData linksModuleData = new LinksModuleData().setUris(uris);

// Define Text Areas
List<TextModuleData> textModulesData = new ArrayList<TextModuleData>();

TextModuleData details = new TextModuleData().setHeader("Details").setBody(
    "20% off one cup of coffee at all Baconrista Coffee locations.  Only one can be used per visit.");
TextModuleData finePrint = new TextModuleData().setHeader("About Baconrista").setBody(
    "Since 2013, Baconrista Coffee has been committed to making high quality bacon coffee. Visit us in our stores or online at www.baconrista.com");

textModulesData.add(details);
textModulesData.add(finePrint);

// Define Geofence locations
List<LatLongPoint> locations = new ArrayList<LatLongPoint>();
locations.add(new LatLongPoint().setLatitude(37.422601).setLongitude(
    -122.085286));
locations.add(new LatLongPoint().setLatitude(37.424354).setLongitude(
    -122.09508869999999));
locations.add(new LatLongPoint().setLatitude(40.7406578).setLongitude(
    -74.00208940000002));

OfferClass wobClass = new OfferClass()
    .setId('2945482443380251551.ExampleOfferClass1')
    .setIssuerName("Baconrista Coffee")
    .setTitle("20% off one bacon fat latte")
    .setProvider("Baconrista Deals")
    .setTitleImage(
        new Image().setSourceUri(new Uri()
            .setUri("http://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg")))
    .setRedemptionChannel("both")
    .setReviewStatus("underReview")
    .setLinksModuleData(linksModuleData)
    .setImageModulesData(imageModuleData)
    .setTextModulesData(textModulesData)
    .setLocations(locations).setMultipleDevicesAndHoldersAllowedStatus("multipleHolders");

OfferClass response = client.offerclass().insert(wobClass).execute();

PHP

// A list of locations at which the Wallet Class can be used.
$locations = array(
    array(
        'kind' => 'walletobjects#latLongPoint',
        'latitude' => 37.424015499999996,
        'longitude' => -122.09259560000001
    ),
    array(
        'kind' => 'walletobjects#latLongPoint',
        'latitude' => 37.424354,
        'longitude' => -122.09508869999999
    ),
    array(
        'kind' => 'walletobjects#latLongPoint',
        'latitude' => 37.7901435,
        'longitude' => -122.39026709999997
    ),
    array(
        'kind' => 'walletobjects#latLongPoint',
        'latitude' => 40.7406578,
        'longitude' => -74.00208940000002
    )
);
// Source uri of title image.
$uriTitleImageInstance = new Google_Service_Walletobjects_Uri();
$imageTitleImageInstance = new Google_Service_Walletobjects_Image();
$uriTitleImageInstance->setUri(
    'http://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg'
);
$imageTitleImageInstance->setSourceUri($uriTitleImageInstance);
// Define text module data.
$textModulesData = array(
    array(
        'header' => 'Details',
        'body' => '20% off one cup of coffee at all Baconrista Coffee locations. ' .
            'Only one can be used per visit.'
    ),
    array(
        'header' => 'About Baconrista',
        'body' => 'Since 2013, Baconrista Coffee has been committed to making high ' .
            'quality bacon coffee. Visit us in our stores or online at www.baconrista.com'
    )
);
// Define links module data.
$linksModuleData = new Google_Service_Walletobjects_LinksModuleData();
$uris = array (
    array(
        'uri' => 'http://maps.google.com/map?q=google',
        'kind' => 'walletobjecs#uri',
        'description' => 'Nearby Locations'
    ),
    array(
        'uri' => 'tel:6505555555',
        'kind' => 'walletobjecs#uri',
        'description' => 'Call Customer Service'
    )
);
$linksModuleData->setUris($uris);

$uriModuleImageInstance = new Google_Service_Walletobjects_Uri();
$uriModuleImageInstance->setUri(
    'http://farm8.staticflickr.com/7401/11177116434_d8e600bba6_o.jpg'
);
$uriModuleImageInstance->setDescription('Coffee beans');
$imageModuleImageInstance = new Google_Service_Walletobjects_Image();
$imageModuleImageInstance->setSourceUri($uriModuleImageInstance);
$imagesModuleData = new Google_Service_Walletobjects_ImageModuleData();
$imagesModuleData->setMainImage($imageModuleImageInstance);
$imagesModuleDataArr = array ($imagesModuleData);

// Create wallet class.
$wobClass = new Google_Service_Walletobjects_OfferClass();
$offerClass->setId('2945482443380251551.OfferClass');
$wobClass->setIssuerName('Baconrista Coffee');
$wobClass->setTitle('20% off on one bacon fat latte');
$wobClass->setProvider('Baconrista Deals');
$wobClass->setTitleImage($imageTitleImageInstance);
$wobClass->setLinksModuleData($linksModuleData);
$wobClass->setTextModulesData($textModulesData);
$wobClass->setImageModulesData($imagesModuleDataArr);
$wobClass->setRedemptionChannel('both');
$wobClass->setReviewStatus('underReview');
$wobClass->setLocations($locations);
$wobClass->setMultipleDevicesAndHoldersAllowedStatus('multipleHolders');

$service->offerclass->insert($wobClass);

Python

api_object = generate_offer_class(
      '1234567', 'ExampleOfferClass')
api_request = service.offerclass().insert(body=api_object)
api_response = api_request.execute()

def generate_offer_class(issuer_id, class_id):
  offer_class = {
      'kind': 'walletobjects#offerClass',
      'id': '%s.%s' % (issuer_id, class_id),
      'issuerName': 'Baconrista Coffee',
      'issuerData': {
          'kind': 'walletobjects#typedValue'
      },
      'title': '20% off one bacon fat latte',
      'redemptionChannel': 'both',
      'provider': 'Baconrista Deals',
      'titleImage': {
          'kind': 'walletobjects#image',
          'sourceUri': {
              'kind': 'walletobjects#uri',
              'uri': 'http://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg'
          }
      },
      'multipleDevicesAndHoldersAllowedStatus': 'multipleHolders',
      'locations': [{
          'kind': 'walletobjects#latLongPoint',
          'latitude': 37.424015499999996,
          'longitude': -122.09259560000001
          },{
          'kind': 'walletobjects#latLongPoint',
          'latitude': 37.424354,
          'longitude': -122.09508869999999
          },{
          'kind': 'walletobjects#latLongPoint',
          'latitude': 37.7901435,
          'longitude': -122.39026709999997
          },{
          'kind': 'walletobjects#latLongPoint',
          'latitude': 40.7406578,
          'longitude': -74.00208940000002
      }],
      'reviewStatus': 'underReview',
      'review': {
          'comments': 'Real auto approval by system'
      },
      'textModulesData': [{
        'header': 'Details',
        'body': '20% off one cup of coffee at all Baconrista Coffee locations. ' +
                'Only one can be used per visit.'
       },{
        'header': 'About Baconrista',
        'body': 'Since 2013, Baconrista Coffee has been committed to making high ' +
                'quality bacon coffee. Visit us in our stores or online at www.baconrista.com'
      }],
      'linksModuleData': {
        'uris': [
          {
            'kind': 'walletobjects#uri',
            'uri': 'http://maps.google.com/map?q=google',
            'description': 'Nearby Locations'
          },{
            'kind': 'walletobjects#uri',
            'uri': 'tel:6505555555',
            'description': 'Call Customer Service'
          }]
      },
      'imageModulesData': [
        {
          'mainImage': {
            'kind': 'walletobjects#image',
            'sourceUri': {
              'kind': 'walletobjects#uri',
              'uri':  'http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg',
              'description': 'Coffee beans'
            }
          }
        }
      ],
    }
  return offer_class

Mapping template data to an Offer Object

The following tabs identify the contents of a JSON Offerobject resource and provide code examples in different languages to populate that resource.

Resource

{
  "kind": "walletobjects#offerObject",
  "classId": "2945482443380251551.OfferClass",
  "id": "2945482443380251551.OfferObject",
  "state": "active",
  "issuerData": {
    "kind": "walletobjects#typedValue"
  },
  "barcode": {
    "kind": "walletobjects#barcode",
    "type": "upcA",
    "value": "123456789012",
    "alternateText": "12345"
  },
  "validTimeInterval": {
    "kind": "walletobjects#timeInterval",
    "start": {
      "date": "2013-06-12T23:20:50.52Z"
      },
    "end": {
      "date": "2013-12-12T23:20:50.52Z"
      }
  }
}

Java

// Define Barcode
Barcode barcode = new Barcode().setType("upcA").setValue("123456789012")
    .setAlternateText("12345");

// Define Wallet Object
OfferObject object = new OfferObject()
	.setClassId('2945482443380251551.ExampleOfferClass1')
    .setId('2945482443380251551.ExampleOfferObject1')
    .setBarcode(barcode)
    .setValidTimeInterval(new TimeInterval().setEnd(new DateTime().setDate(new com.google.api.client.util.DateTime(
            new Date().getTime() + 263000000000L))))
    .setState("active");

PHP

$barcode = new Google_Service_Walletobjects_Barcode();
$barcode->setType('upcA');
$barcode->setValue('123456789012');
$barcode->setAlternateText('12345');

$validTimeInterval = new Google_TimeInterval();
$startDateTime = new Google_DateTime();
$startDateTime->setDate('2013-06-12T23:20:50.52Z');
$validTimeInterval->setStart($startDateTime);
$endDateTime = new Google_DateTime();
$endDateTime->setDate('2013-12-12T23:20:50.52Z');
$validTimeInterval->setEnd($endDateTime);

// Create wallet object.
$offerObject = new Google_Service_Walletobjects_OfferObject();
$offerObject->setClassId('2945482443380251551.OfferClass');
$offerObject->setId('2945482443380251551.OfferObject');
$offerObject->setBarcode($barcode);
$offerObject->setValidTimeInterval($validTimeInterval);
$offerObject->setState('active');

Python

offer_object = {
      'kind': 'walletobjects#offerObject',
      'classId': '1234567.ExampleOfferClass',
      'id': '1234567.ExampleOfferObject',
      'state': 'active',
      'issuerData': {
          'kind': 'walletobjects#typedValue'
      },
      'barcode': {
          'kind': 'walletobjects#barcode',
          'type': 'upcA',
          'value': '123456789012',
          'alternateText': '12345'
      }
  }

Send feedback about...

Google Pay for Passes