Skip to content

Latest commit

 

History

History

README.md

Deprecation Notice

API way of accessing will be replaced by SDK way of accessing, refer to sdk-client for the sample of similar functionality accessed through SDK.

Teapot Sample

This project demonstrates Windows and Android sharing C++ code. (Work in progress, please report bugs and suggestions)

Windows Setup

In order to build run this sample on Windows you will need libraries 'freeglut' and 'glew'.

One way to get these is to use vcpkg:

./vcpkg install freeglut:x64-windows
./vcpkg install glew:x64-windows
./vcpkg install freeglut:x86-windows
./vcpkg install glew:x86-windows

Play Console Setup

You will need to setup billing from your Play Console Application and Create in-app products for purchase in this sample.

Also, to sign-in using Google Identity API, you will need to retrieve your Google API client-id and secret

Building the application

  • Open Teapot-Sdk.sln file using any recent version of Microsoft Visual Studio

  • Open app.config and replace the client_id and client_secret with your Google API client-id and secret.

  • Open AppConfig.json and replace the same client_id and client_secret with your Google API client-id and secret.

  • Press F5 to build and run your application

Running the application

  • Once the application is running correctly, you will be greeted by an OpenGL scene with a teapot and "Billing APIs" button

Teapot Scene

  • Click on the "Billing APIs" button and a debug panel will pop up. Using this panel, you will be able to see a list of the operations you can perform, the API and parameters that will be sent to the server as well as the result once you execute the API request.

Debug Panel

  • In the Select the operation menu, click on the first menu item "Google Login". The URLs and parameters will automatically change to reflect the backend APIs that will be invoked when you click on the Execute button.

Google Login

  • Click on the Execute button and follow the login process, make sure that you give the permissions requested during the OAuth steps that follows

Oauth Steps

Oauth Steps

  • Upon returning, you will get the appropriate user access token that can be used to invoke purchase and other subsequent APIs

User Access Token

  • With the user access token loaded, proceed to Get SKUs API which will allow you to get a list of all available IAP items and launch the purchase flow on a hardcoded item

Get SKUs API

  • The application will launch the purchase flow using your default browser

Purchase Flow

Purchase Completed

Get Purchased Items

Purchase Token

Validate Purchase

Validate Purchase Result

Acknowledge Purchase

Acknowledge Purchase Result

Consume Purchase

Consume Purchase Result

  • Invoke get all purchased items using the Get Purchase API and you will see that the API now returns no item as it has been consumed

Get Purchased Items Result

Note that some of the API may return empty string upon success, this is intended and you can modify it in the API Server