为 Android 实施 React Native In App Billing?

Implementing React Native In App Billing for Android?

我正在尝试使用 react-native-billing 为 Play 商店添加应用内购买,但不知道该怎么做。

Google 似乎找不到任何关于 In App Billing 的教程

我看过example,长这样

InAppBilling.open()
        .then(() => InAppBilling.purchase('android.test.purchased'))
        .then((details) => {
            this.setState({
                purchaseText: details.productId
            });
            return InAppBilling.getProductDetails('android.test.purchased');
        })
        .then((productDetails) => {
            this.setState({
                productDetailsText: productDetails.title
            });
            return InAppBilling.close();
        })
        .catch((error) => {
            this.setState({
                error: error
            });
        });

这很简单。但是我不明白的是android.test.purchased

也许这是因为我对 Android

上的应用内购买缺乏了解

我也不明白什么是 details & productDetails 以及在哪里实施它们

如何实现?

android.test.purchased 是一种出于调试目的测试应用内购买的方法(更多资源:https://developer.android.com/google/play/billing/billing_testing.html)。

我没有阅读 In App Products 下拉菜单中的内容。原来写的To add in-app products, you need to add the BILLING permission to your APK.现在可以实现了