Skip to content

Instantly share code, notes, and snippets.

@danielgomezrico
Created September 19, 2014 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielgomezrico/ec95c991cf25911d4ec3 to your computer and use it in GitHub Desktop.
Save danielgomezrico/ec95c991cf25911d4ec3 to your computer and use it in GitHub Desktop.
Replace the verifyPurchase method on "util/Security.java" for android In-App purchases in tests in order to make it pass the invalid sign verification. src=http://stackoverflow.com/a/19539213/273119
public class AppConfig {
public static final boolean DEBUG = true;
}
public static boolean verifyPurchase(String base64PublicKey,
String signedData, String signature) {
if (signedData == null) {
Log.e(TAG, "data is null");
return false;
}
if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey)
|| TextUtils.isEmpty(signature)) {
Log.e(TAG, "Purchase verification failed: missing data.");
if (BuildConfig.DEBUG) {
Log.d("DeBUG", ">>>"+BuildConfig.DEBUG);
return true;
}
return false;
}
PublicKey key = Security.generatePublicKey(base64PublicKey);
return Security.verify(key, signedData, signature);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment