Skip to content

janirefdez/google-wallet-web

 
 

Repository files navigation

Google Wallet Codelab

This project contains sample code used for the Google Wallet Codelab

Requirements

Create service account

The Google Wallet APIs use service accounts for authentication.

You will first need to create a service account and download its service account key file. You can do that with the gcloud command-line tool, so make sure to install it, if you haven't before.

  • Open up your terminal, and define a PROJECT_ID variable. For example if your project ID was my-cloud-project

    export PROJECT_ID=my-cloud-project

  • Run the following command to create a service account:

    gcloud iam service-accounts create wallet-codelab --project=$PROJECT_ID

  • Run the following command, which will create and download a service account key file:

    gcloud iam service-accounts keys create ./key.json --iam-account=wallet-codelab@$PROJECT_ID.iam.gserviceaccount.com --project=$PROJECT_ID

  • Note the path to the key.json file in the current directory. You will need to include it here (the following command will display it)

    echo $(pwd)/key.json

  • Enable the Wallet API using the following command:

    gcloud services enable walletobjects.googleapis.com --project=$PROJECT_ID

Create a temporary issuer account

To create passes for your user, you first need to create an issuer account, enable the Wallet API, and then create a class, all of which can be done via the Google Pay Business Console. However, access to this is only granted once the approval process is complete. But you can create a temporary issuer account, and a pass class for you.

NOTE: The email address that you use to generate the temporary issuer account, has to be the same as the one that is created for the service account. In the codelab, that is wallet-codelab@$PROJECT_ID.iam.gserviceaccount.com.

Click Create a temporary issuer account and a sample class. Take note of the issuer ID and class ID.

Run this project

Install project dependencies

This sample app consists of a simple Node.js app. Install the dependencies with the following command:

npm install .

Run Node.js

You should now be able to run the Node.js app with the following command:

node app.js

Open http://localhost:3000/ in your browser. You should be able to see something like this: image

Test App

First make sure you have included the correct key location in code. Then in the browser you should include the email, issuer ID and class ID obtained when creating the temporary issuer account.

In case you are not using a temporary account you can take those details from Google Wallet API Dashboard image

Demo

Screen.Recording.2022-06-23.at.23.00.36.mov

About

Sample code used for Google Wallet.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 42.8%
  • JavaScript 42.2%
  • CSS 15.0%