如何修复android应用程序的应用程序内购买?

w41d8nur  于 2021-09-13  发布在  Java
关注(0)|答案(1)|浏览(450)

我在google play store中有一个应用程序,在添加计费3v以处理订阅时遇到一些问题。任何新的订阅者在付款和付款完成并出现在谷歌控制台后都无法访问我的应用程序。
我希望在我的应用程序中帮助我处理应用程序内购买,代码如下:
public static void isuserhassubscription(上下文上下文,oncheck-oncheck){billingclient-billingclient=billingclient.newbuilder(上下文).enablependingpurchases().setlistener(新purchasesupdatedlistener(){@override public void-onpurchasesupdated(@nonnull-billingresult-billingresult,@null-list-list){

}
    }).build();

    billingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(BillingResult billingResult) {
            Purchase.PurchasesResult purchasesResult=billingClient.queryPurchases(BillingClient.SkuType.SUBS);

            billingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.SUBS,(billingResult1, list) -> {

                Log.d("billingprocess","purchasesResult.getPurchasesList():"+purchasesResult.getPurchasesList());

                //                        //here you can pass the user to use the app because he has an active subscription
                //                        Intent myIntent=new Intent(context,MainActivity.class);
                //                        startActivity(myIntent);
                boolean isPrshees = billingResult1.getResponseCode() == BillingClient.BillingResponseCode.OK && !Objects.requireNonNull(purchasesResult.getPurchasesList()).isEmpty();

                onCheck.onCheck(isPrshees,isPrshees?getOrderId(purchasesResult.getPurchasesList().get(0).getOriginalJson()):"");

            });
        }
        @Override
        public void onBillingServiceDisconnected() {
            onCheck.onCheck(false,"") ;
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
            Log.d("billingprocess","onBillingServiceDisconnected");
        }
    });
}
klh5stk1

klh5stk11#

我用了图书馆下面的那个,它很好用。请尝试一下,希望它能帮助你。https://github.com/anjlab/android-inapp-billing-v3 非常感谢。

相关问题