简体   繁体   English

当用户从Play商店购买我的应用程序时,如何将电子邮件ID或订单ID发送到数据库

[英]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.

相关问题 如何在 Flutter 中从 Play 商店获取用户购买 - How to get user purchases from Play Store in Flutter 在哪里可以找到我的Play商店App用户的电子邮件ID或电话号码 - Where to find my Play store App user's Email ID or Phone Number 如何获得在Play商店上写反馈的客户的电子邮件ID - How to get email id of customer who write feedback on play store Google Play 商店:如何从多个设备访问应用内购买? - Google Play Store: How to access in app purchases from multiple devices? 如何知道谁从Google Play下载了该应用程序的电子邮件ID - how to know email id of whom downloaded the app from Google Play 从Facebook检索用户名和电子邮件ID到我的Android应用程序 - Retrieving the user name and email id from Facebook into my android app 如何从 Firebase 电子邮件身份验证中获取电子邮件的用户 ID - How to get the user id of a email from firebase email authentication 如何在Android中从Facebook获取用户电子邮件ID和用户名 - How to get user email id , user name from Facebook in android 如何知道哪个Google帐户(电子邮件ID)用户在我的应用中购买了产品? - How can I know from which Google account (Email id) user purchased a product in my app? 从Google Play服务获取用户ID? - Get a user ID from Google Play Services?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM