首页 > 解决方案 > 我应该如何退出应用内购买测试模式

问题描述

所以我决定实现in-app-purchasesusing expo-in-app-purchases,一切都很好。

现在我已经完成了我的工作,并希望它进入生产模式。

当我尝试在我的应用程序中购买东西时,它会显示test Card。我应该如何退出这个?

我现在已经在 Google Play 控制台上发布了我的应用程序,并且正在审核中。我应该等到 Review 部分完成然后它自动存在测试模式吗?

这是我目前拥有的支付类。

import * as InAppPurchases from 'expo-in-app-purchases';
export default class payment {
    private static finishTransactionCallback?: (purchase: any) => Promise<void>;
    constructor() {

    }

    public static connectAsync = async () => {
        await InAppPurchases.connectAsync();
        InAppPurchases.setPurchaseListener(async ({ responseCode, results, errorCode }) => {
            // Purchase was successful
            if (responseCode === InAppPurchases.IAPResponseCode.OK) {
                results.forEach(purchase => {
                    if (!purchase.acknowledged) {
                        console.log(`Successfully purchased ${purchase.productId}`);
                        // Process transaction here and unlock content...
                        // Then when you're done
                        payment.finishTransactionAsync(undefined, purchase);
                    }
                });
            } else
                if (responseCode === InAppPurchases.IAPResponseCode.USER_CANCELED) {
                    console.log('User canceled the transaction');
                } else if (responseCode === InAppPurchases.IAPResponseCode.DEFERRED) {
                    console.log('User does not have permissions to buy but requested parental approval (iOS only)');
                } else {
                    console.warn(`Something went wrong with the purchase. Received errorCode ${errorCode}`);
                }
        });
    }

    public static async disconnectAsync() {
        await InAppPurchases.disconnectAsync();
    }

    public static getPurchaseHistoryAsync = async () => {
        var item = await InAppPurchases.getPurchaseHistoryAsync();
        if (item && item.results && item.results.length > 0)
            return item.results;
        else return [] as (InAppPurchases.InAppPurchase | InAppPurchases.IAPItemDetails)[];
    }

    public static getProducts = async (itemList: string[]) => {
        var item = await InAppPurchases.getProductsAsync(itemList);
        if (item && item.results && item.results.length > 0)
            return item.results;
        else return [] as (InAppPurchases.InAppPurchase | InAppPurchases.IAPItemDetails)[];
    }

    public static finishTransactionAsync = async (callBack?: (purchase: any) => Promise<void>, purchase?: any) => {
        try {
            if (callBack)
                payment.finishTransactionCallback = callBack;
            else {
                await InAppPurchases.finishTransactionAsync(purchase, false);
                purchase.acknowledged = true;
                if (payment.finishTransactionCallback)
                    await payment.finishTransactionCallback(purchase);

            }
        } catch (error) {
            console.log(error);
        }
    }

    public static async requestPayment(productId: string) {
        try {
            await InAppPurchases.purchaseItemAsync(productId);
            return true;
        }
        catch (error) {
            console.log("Something went wrong. with purchase:" + productId);
            console.log(error);
        }

        return false;
    }
}

更新

该应用程序现已发布到生产环境,并且仍处于测试模式。

我的应用名称是NovelManager

标签: typescriptreact-nativeexpogoogle-play-consolegoogle-play-developer-api

解决方案


推荐阅读