If your Google Play Games on PC Native games directly call the Play Billing APIs, you must migrate your game to use the PC SDK.
Depending on the game engine you are using, you can integrate the C++ SDK
or the C# SDK.
Refer to the sample
projects that demonstrate examples that can be used to migrate
your Native game to SDK.
Setup and preparation
This section describes the migration steps from an API-based solution to the Google Play Games on PC Native SDK.
Command-line arguments
Google Play Games on PC Native SDK relies on some command-line arguments passed in during your game process startup to authenticate users. These arguments need to be passed in to the process that calls Initialize SDK. If your game startup involves multiple processes, you have to verify that all the arguments are passed to the process that ultimately uses the SDK. Checkout the Supporting multi game-processes step of the setup.
API mapping
To complete the migration, you will need to remove all the direct API calls to the Play servers. There are corresponding function calls in the SDK to achieve the same functionality. This section lists out the mapping for each functionality.
Google Sign-In
Google Sign-In, also known as Sign in with Google, is an OAuth authentication method that provides a one-click authentication option for users with their Google Account. In API-based projects, you associate a player's account with their purchases. SDK-based solutions don't require this association.
SDK-based solutions use the Google Play Games client's Google Account that is already associated with the player's Gamer Profile and entitlements. This provides a more seamless experience for players and a more secure environment for developers because the SDK can communicate securely with the Google Play Games client through IPC.
Instead of Google Sign-In, call Initialize SDK as early as possible. Act on the error code accordingly to provide a secure environment for your game's runtime.
Get product list
In the API solution, your backend server retrieves the product list using the
Play Developer API inappproduct.gets endpoint.
In the SDK, retrieve the in-app product list directly on the client using the
QueryProductDetails function.
Get purchases
In the API solution, your backend server retrieves user purchases using the Play
Developer API purchases.products.get endpoint.
In the SDK, use the QueryPurchases function directly from your game
client.
Launch purchase flow
In the API solution, launching the purchase flow requires calling multiple endpoints for setup and acquiring the necessary tokens.
In the SDK, launch the process by calling the BillingClient's
LaunchPurchaseFlow function. The SDK handles all necessary work.
Process the purchase
Processing the user's purchase involves acknowledging and consuming the purchase after successfully validating that it is legitimate. Both API-solution and SDK-solution recommends the steps to be completed from your backend for security purposes.
The process is similar for both API-solution and SDK-solution:
After retrieving the purchaseToken from the purchase, such as ProductPurchase.purchaseToken in the API solution or ProductPurchaseDetails's purchase_token in the SDK solution, send it to your backend for verification.
Once it is verified, your backend can securely acknowledge or consume the purchase after granting the entitlement.
Submit for testing
To submit your game for testing, follow these steps.
Package for submission
Games using the SDK must be packaged in Windows App Bundle format and uploaded through Play Console. Refer to the documentation to package your game in Windows App Bundle for:
- Self managed publishing: Installer publishing
- Play managed publishing: Play managed publishing