如何实现亚马逊应用内购买 API?

时间:2021-07-30 10:19:40

标签: java android

嗨,抱歉标题含糊不清。我有一个关于 Amazon IAP API 的特定问题,您将在帖子底部看到。

我以最简单的方式实现了 API,即我刚刚导入了他们的示例 IAP 应用程序并将其全部粘贴到我的应用程序中。我认为示例应用中唯一需要更改的是 SKU 和市场。

这是示例应用中名为 MySku.java 的类:

package com.amazon.sample.iap.entitlement;

/**
 * 
 * MySku enum contains all In App Purchase products definition that the sample
 * app will use. The product definition includes two properties: "SKU" and
 * "Available Marketplace".
 * 
 */
public enum MySku {

    // The only entitlement product used in this sample app
    LEVEL2("com.amazon.sample.iap.entitlement.level2", "US");

    private final String sku;
    private final String availableMarkpetplace;

    /**
     * Returns the MySku object from the specified Sku and marketplace value.
     * 
     * @param sku
     * @param marketplace
     * @return
     */
    public static MySku fromSku(final String sku, final String marketplace) {
        if (LEVEL2.getSku().equals(sku) && (marketplace == null || LEVEL2.getAvailableMarketplace().equalsIgnoreCase(marketplace))) {
            return LEVEL2;
        }
        return null;
    }

    /**
     * Returns the Sku string of the MySku object
     * 
     * @return
     */
    public String getSku() {
        return this.sku;
    }

    /**
     * Returns the Available Marketplace of the MySku object
     * 
     * @return
     */
    public String getAvailableMarketplace() {
        return this.availableMarkpetplace;
    }

    private MySku(final String sku, final String availableMarkpetplace) {
        this.sku = sku;
        this.availableMarkpetplace = availableMarkpetplace;
    }

}

所以我必须更改 skuavailableMarketplace。我知道我的应用内产品的 sku,所以我设置了它,但是我应该如何将 availableMarketPlace 更改为我的应用允许所有市场而不是美国市场?

0 个答案:

没有答案