android - Google In-App Billing returning invalid signature for test purchases -
i having trouble license testing in-app products. have app published google play beta channel, , have relevant google account listed license tester in dev console. (meaning can make "purchases" without paying item(s).)
when visit in-app store first time, works fine. however, upon "purchasing" item, receive signature verification error in purchase flow response. point forward, receive same signature error when querying store inventory.
i need part. have seen posts stating method verifypurchase within security.java blame. other posts state issue android.test.purchased returning empty string signature. i'm seeing different. call passes isempty(signature) test, rejected later in code. why google in-app billing returning signature invalid? have included relevant code below.
public class security { // ... // method part of trace // iabhelper.queryinventory , iabhelper.onactivityresult public static boolean verifypurchase(string base64publickey, string signeddata, string signature) { if (textutils.isempty(signeddata) || textutils.isempty(base64publickey) || textutils.isempty(signature)) { // problem here log.e(tag, "purchase verification failed: missing data."); return false; } publickey key = security.generatepublickey(base64publickey); return security.verify(key, signeddata, signature); // code gets here, but... } public static boolean verify(publickey publickey, string signeddata, string signature) { signature sig; try { sig = signature.getinstance(signature_algorithm); sig = initverify(publickey); sig.update(signeddata.getbytes()); if (!sig.verify(base64.decode(signature))) { // ...verify fails; return false log.e(tag, "signature verification failed."); return false; } return true; } catch (nosuchalgorithmexception e) { log.e(tag, "nosuchalgorithmexception."); } catch (invalidkeyexception e) { log.e(tag, "invalid key specification."); } catch (signatureexception e) { log.e(tag, "signature exception."); } catch (base64decoderexception e) { log.e(tag, "base64 decoding failed."); } return false; } } update: mentioned in comment, running signed apk, debuggable flag set true. have tried making actual purchase, real credit card; saw exact same results. though google play purchase flow completed expected, did not receive product. upon returning store, google play did not return in-app inventory.
my problem had nothing google play in-app billing java code. reading wrong license key app. project has several different flavors. when particular flavor added, file contains license key copied different flavor , never changed. have corrected key, working intended.
tl;dr: verify google play license key correct.
Comments
Post a Comment