我有一个关于开发人员有效负载的问题,我一直在阅读文档,但仍然发现自己很难理解我仍然不了解的 verifydeveloperpayload:
boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();
/*
* TODO: verify that the developer payload of the purchase is correct. It will be
* the same one that you sent when initiating the purchase.
*
* WARNING: Locally generating a random string when starting a purchase and
* verifying it here might seem like a good approach, but this will fail in the
* case where the user purchases an item on one device and then uses your app on
* a different device, because on the other device you will not have access to the
* random string you originally generated.
*
* So a good developer payload has these characteristics:
*
* 1. If two different users purchase an item, the payload is different between them,
* so that one user's purchase can't be replayed to another user.
*
* 2. The payload must be such that you can verify it even when the app wasn't the
* one who initiated the purchase flow (so that items purchased by the user on
* one device work on other devices owned by the user).
*
* Using your own server to store and verify developer payloads across app
* installations is recommended.
*/
return true;
}
如果我的代码是
public void onClick(View v) {
String item1;
// TODO Auto-generated method stub
switch(v.getId()) {
case R.id.button1: {
/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
item1 = "item1";
String payload = email+item1;
mHelper.launchPurchaseFlow(this, SKU_2006, RC_REQUEST,
mPurchaseFinishedListener, payload);
break;
}
}
}
布尔 verifyDeveloperPayload 中的字符串有效负载是否等于我的 onClick 方法中的字符串有效负载?
我如何以及在哪里比较有效载荷?