Provide a way to pass an obfuscated user id when purchasing using GooglePlay. Google uses this as part of their anti-fraud efforts

[at]sam.zamani, [at]eric.newman, [at]rob.cannaday

#ROBOMERGE-OWNER: michael.kirzinger
#ROBOMERGE-AUTHOR: michael.kirzinger
#ROBOMERGE-SOURCE: CL 13032447 via CL 13033126 via CL 13033127 via CL 13033128 via CL 13033131
#ROBOMERGE-BOT: RELEASE (Release-Engine-Staging -> Main) (v683-13008971)

[CL 13033133 by michael kirzinger in Main branch]
This commit is contained in:
michael kirzinger
2020-04-24 10:10:53 -04:00
parent e4e6985b14
commit ba2dcd6317
8 changed files with 757 additions and 395 deletions

View File

@@ -67,6 +67,9 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import android.annotation.TargetApi;
@@ -4620,13 +4623,35 @@ public class GameActivity extends $${gameActivitySuperClass}$$ implements Surfac
}
}
public boolean AndroidThunkJava_IapBeginPurchase(String ProductId)
public boolean AndroidThunkJava_IapBeginPurchase(String ProductId, String AccountId)
{
Log.debug("[JAVA] - AndroidThunkJava_IapBeginPurchase");
boolean bTriggeredPurchase = false;
if( IapStoreHelper != null )
{
bTriggeredPurchase = IapStoreHelper.BeginPurchase(ProductId);
// sha-256 the accountId and get the hex string representation
String ObfuscatedAccountId = null;
if (AccountId != null)
{
try
{
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] sha256hash = md.digest(AccountId.getBytes("UTF-8"));
StringBuilder builder = new StringBuilder(sha256hash.length * 2);
for (byte b : sha256hash)
{
builder.append(String.format("%02x", b));
}
ObfuscatedAccountId = builder.toString();
}
catch (NoSuchAlgorithmException ae)
{
}
catch (UnsupportedEncodingException ee)
{
}
}
bTriggeredPurchase = IapStoreHelper.BeginPurchase(ProductId, ObfuscatedAccountId);
}
else
{

View File

@@ -8,10 +8,11 @@ import android.os.Bundle;
public interface StoreHelper
{
public boolean QueryInAppPurchases(String[] ProductIDs);
public boolean BeginPurchase(String ProductID);
public boolean BeginPurchase(String ProductID, String ObfuscatedAccountId);
public boolean IsAllowedToMakePurchases();
public void ConsumePurchase(String purchaseToken);
public boolean QueryExistingPurchases();
public boolean RestorePurchases(String[] InProductIDs, boolean[] bConsumable);
public void onDestroy();
public boolean onActivityResult(int requestCode, int resultCode, Intent data);
}