[英]How to get email id or order id to database when user purchases my app from play store
I want to get order id or email id of user when he purchases my app from play store. 我想从Play商店购买我的应用程序时获得用户的订单ID或电子邮件ID。
I want that when ever user purchases my app, the order id gets stored in my sql database. 我希望当用户购买我的应用程序时,订单ID存储在我的sql数据库中。 Next when user signup from my app and enters order id, that order id can be validated with stored order id. 接下来,当用户从我的应用程序注册并输入订单ID时,可以使用存储的订单ID验证该订单ID。
Or if I can get email id used for that purchase then I can store that purchase with that email id. 或者,如果我可以获得用于该购买的电子邮件ID,那么我可以使用该电子邮件ID存储该购买。
Thanks 谢谢
It cannot be done. 它无法完成。
You cannot get the order IDs of customer purchases. 您无法获取客户购买的订单ID。
When the application open then in your first activity you can have this method for checking purchase done or not? 当应用程序在您的第一个活动中打开时,您可以使用此方法检查购买是否已完成?
This is basic code to understand how to get inapp details, You may need to add security in this by using native or encryption. 这是了解如何获取inapp详细信息的基本代码,您可能需要使用本机或加密来增加安全性。
public class HomeActivity extends Activity{
private IabHelper mIabHelper;
private void checkPurchase(){
String base64EncodedPublickey = "Your BASE 64 key";
if (mIabHelper == null) {
mIabHelper = new IabHelper(getActivity(), base64EncodedPublickey);
mIabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult result) {
try {
if (result.isSuccess()) {
mIabHelper.queryInventoryAsync(mQueryFinishedListener);
}
} catch (IabHelper.IabAsyncInProgressException e) {
}
}
});
}
}
IabHelper.QueryInventoryFinishedListener
mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(final IabResult result, final Inventory inventory) {
Gson gson = new Gson();
try {
if (result.isFailure()) {
return;
}
if (inventory.hasPurchase("Package name")) {
Purchase purchase = inventory.getPurchase("Inapp Package name");
if (purchase != null) {
String puchaseDetails = gson.toJson(purchase);
Log.e(TAG, "Purchase Data : "+puchaseDetails);
}
}
} catch (Exception e) {
localData = null;
}
}
};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.