android - Xamarin Forms(Android) - 升级和降级订阅

标签 android xamarin.forms google-play in-app-purchase subscription

我已经为此苦苦挣扎了几天。我正在制作一个需要支持应用内订阅购买的应用。

我尝试过以下软件包:

-Xamarin.InAppBilling(组件)

-Plugin.InAppBilling(Nuget - 测试版)

-Android 发布商服务 (Nuget)

但都不支持升级/降级订阅。

是否有完全支持订阅的软件包?

最佳答案

我们也遇到过类似的问题。这些包仅支持 getBuyIntent。 getBuyIntent 不支持升级和降级订阅。 getBuyIntentExtraParams 方法确实支持这一点。通过此方法,您可以使用 skusToReplace 参数指定用户要升级或降级哪些以前的订阅。

有关详细信息,请参阅 Google 文档:https://developer.android.com/google/play/billing/billing_reference.html

getBuyIntentExtraParams 方法在这些包中不可用,但您可以在插件的aidl 文件中添加该方法。

Xamarin.InAppBilling包的aidl文件:https://github.com/hauptmedia/xamarin-inappbilling/blob/master/Droid/aidl/IInAppBillingService.aidl

您可以下载aidl文件并将getBuyIntentExtraParams方法附加到aidl文件中。将aidl 文件添加到您的android 项目中并使用它来代替插件。

方法定义:

/**
     * Returns a pending intent to launch the purchase flow for an in-app item. This method is
     * a variant of the {@link #getBuyIntent} method and takes an additional {@code extraParams}
     * parameter. This parameter is a Bundle of optional keys and values that affect the
     * operation of the method.
     * @param apiVersion billing API version that the app is using, must be 6 or later
     * @param packageName package name of the calling app
     * @param sku the SKU of the in-app item as published in the developer console
     * @param type of the in-app item being purchased ("inapp" for one-time purchases
     *        and "subs" for subscriptions)
     * @param developerPayload optional argument to be sent back with the purchase information
     * @extraParams a Bundle with the following optional keys:
     *        "skusToReplace" - List<String> - an optional list of SKUs that the user is
     *                          upgrading or downgrading from.
     *                          Pass this field if the purchase is upgrading or downgrading
     *                          existing subscriptions.
     *                          The specified SKUs are replaced with the SKUs that the user is
     *                          purchasing. Google Play replaces the specified SKUs at the start of
     *                          the next billing cycle.
     * "replaceSkusProration" - Boolean - whether the user should be credited for any unused
     *                          subscription time on the SKUs they are upgrading or downgrading.
     *                          If you set this field to true, Google Play swaps out the old SKUs
     *                          and credits the user with the unused value of their subscription
     *                          time on a pro-rated basis.
     *                          Google Play applies this credit to the new subscription, and does
     *                          not begin billing the user for the new subscription until after
     *                          the credit is used up.
     *                          If you set this field to false, the user does not receive credit for
     *                          any unused subscription time and the recurrence date does not
     *                          change.
     *                          Default value is true. Ignored if you do not pass skusToReplace.
     *            "accountId" - String - an optional obfuscated string that is uniquely
     *                          associated with the user's account in your app.
     *                          If you pass this value, Google Play can use it to detect irregular
     *                          activity, such as many devices making purchases on the same
     *                          account in a short period of time.
     *                          Do not use the developer ID or the user's Google ID for this field.
     *                          In addition, this field should not contain the user's ID in
     *                          cleartext.
     *                          We recommend that you use a one-way hash to generate a string from
     *                          the user's ID, and store the hashed string in this field.
     *                   "vr" - Boolean - an optional flag indicating whether the returned intent
     *                          should start a VR purchase flow. The apiVersion must also be 7 or
     *                          later to use this flag.
     */
    Bundle getBuyIntentExtraParams(int apiVersion, String packageName, String sku,
        String type, String developerPayload, in Bundle extraParams);

关于android - Xamarin Forms(Android) - 升级和降级订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43497934/

相关文章:

xamarin - 删除 Xamarin.Forms 网格单元之间的间距

xamarin - 在 Xamarin Forms Android 中处理通知

android - 您创建的应用数量

xcode - Xamarin Forms 显示缓存的签名身份

java - 无法正确存储 sqlite

android - 无法修复网格布局中的 4 个按钮

android - 如何从 ListView onClickAdapter 的数据库中删除一行?

android - Google Play商店上的名称可用性

xamarin - Xamarin Android 产品版本号的奇怪行为

c# - 调用 WCF 引用类型变量