Client-side Authentication & Payments
For game clients which handles purchases/authentication locally without server verification.
These methods are not recommended by Pley. Use them at your own risk.
Verifying purchases, consuming payment entitlements, and authenticating sessions should be done server-side.
These methods must be enabled through the Game Manager.
Requires Pley SDK 5.8.0 or newer
Not all games have servers that can execute HTTP cURL requests, or are otherwise limited. For games with only a database and some server functions, the game logic is very local. For these games, Pley provides a simple way of determining which user is playing the game. However, this method is much less secure and is not recommended.
Before a game can call these methods, they have to be enabled.
- Go the the Game Manager at manage.pley.com .
- Capabilities > Dangerous SDK Methods
- Enable "Allow dangerous methods".
Consuming Payment Entitlements Client-side
C# SDK Method: public static async Task<(PleyResult, PleyResult[])> DangerouslyConsumeEntitlements(string[] entitlementIds)
1) Request a purchase in the game code (How to: Implementing Payments)
2) After the purchase is completed, consume the entitlement to validate the purchase by calling DangerouslyConsumeEntitlements()
.
3) Grant the item to the player.
// Call DangerouslyConsumeEntitlements with an array of entitlement IDs.
var (result, entitlements) = await Pley.PaymentsKit.DangerouslyConsumeEntitlements(entitlementIds);
// First, check that there was not an unexpected error.
if (result.IsOk())
{
foreach (var entitlement in entitlements)
{
// Grant items to the player.
}
}
else
{
Debug.LogError($"Consume Error: {result}");
}
Authenticating Game Users Client-side
C# SDK Method: public static string DangerouslyGetGameUserID()
1) Call Pley.DangerouslyGetGameUserID();
, getting a Pley Game User ID in return.
2) Use the Pley Game User ID to authenticate the user.
3) Start the game with the correct progress.
The Pley Game User ID should be saved to the player database. If no user has the ID, create a new user. Often, this Pley Game User ID can be treated as a device ID.
Updated about 2 hours ago