Learn how to sell digital and physical goods in your Google Actions by using Google Transactions.
- Digital Goods
- Physical Goods
Official Google Docs: Transactions
Transactions for Google Actions allow you to sell both digital and physical goods in your app. The Jovo implementation of Google Transactions can be accessed like this:
The two types (digital and physical goods) differ in functionality and configuration, this is why they are addressed as distinct features in this document.
Learn more below:
Official Google Docs: Build digital transactions
Digital transactions allow you to sell in-app product in the Google Play store.
Learn more about configurations in the official Google Docs.
Here are some of the steps that need to be taken:
- Create a Google Developer account
- Create an app project
- Download Android Studio
<uses-permission android:name="com.android.vending.BILLING" />to the
- Generate Signed APK from the
- Upload APK into Google Playstore
To use transactions for digital goods, you need to install the
googleapis npm package:
To implement the transaction of digital goods in your Jovo project, there are few things you need to do (in line with the transaction flow described in the Google docs):
There are two types of digital goods that can be sold (take a look at the official Google docs for more information):
SKU_TYPE_IN_APP: One-time in-app purchases
SKU_TYPE_SUBSCRIPTION: Auomatically charge users on a recurring schedule
Depending on which type you want to use, you can use the following methods to query the Play store with a list of product IDs (SKUs):
This part of the flow prompts the user to select an item. Learn in the official docs by Google how to create a rich response that describes the available items to the user.
You can use the following method to complete the purchase:
The next request will then go into the
COMPLETE_PURCHASE() inside the
ON_TRANSACTION object in your handler:
COMPLETE_PURCHASE() handler, you can check the purchase status:
The following can be returned:
Physical transactions allow you to sell physical items (e.g. books, clothes) in your Google Action. You can either choose to do the transaction with Google Pay, or do merchant-managed payments (e.g. by using Stripe).
- Build Physical Transactions with Google Pay
- Build Physical Transactions with Merchant-Managed Payments
- Physical Goods Implementation
Learn more about configurations for Google Pay in the official Google Docs.
Learn more about configurations for merchant-managed payments in the official Google Docs.
There are several steps that need to be taken to create an order with your physical goods transaction:
- Check Requirements
- Order Update
paymentOptions either need to include
To handle transaction events, add the
ON_TRANSACTION element to your handler:
ON_TRANSACTION needs to include the following three elements:
checkRequirements, the next request will go into the
There are two helper methods that you can use to query for the requirements in the
true, you can ask for the delivery address:
The next request will go into the
After the user accepted the delivery address (
this.$googleAction.$transaction.isDeliveryAddressAccepted()), you can as them to make a transaction decision:
The next request will go into the
If the order is accepted by the user (
this.$googleAction.$transaction.isOrderAccepted()), you can create the order:
You can also update orders, which is not related to the Jovo Framework, but mostly happens somewhere else outside your Google Action.
The example file shows how this could look like, and uses the
googleapis, which you need to install like this: