gpt4 book ai didi

android - 您请求的商品无法购买 - 应用内结算

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:03:07 25 4
gpt4 key购买 nike

我在测试 android 计费时遇到了麻烦!谁来帮帮我!我举个例子:

主 Activity

public class MainActivity extends Activity {
IabHelper mHelper;

IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory){
if (result.isFailure()) {
// handle error
Toast.makeText(getApplicationContext(), "debug: Query occur error!", Toast.LENGTH_SHORT).show();
return;
}

if (result.isSuccess()) {
Toast.makeText(getApplicationContext(), "debug: Query successfully!", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "debug: " + inventory.getSkuDetails("product_1").getTitle(), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "debug: " + inventory.getSkuDetails("product_2").getTitle(), Toast.LENGTH_SHORT).show();
return;
}
}
};

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Toast.makeText(getApplicationContext(), "debug: purcharge failed", Toast.LENGTH_SHORT).show();
Log.d("Purchrge", "Error purchasing: " + result);
return;
}
switch (purchase.getSku()){
case "product_1":
Toast.makeText(getApplicationContext(), "debug: purcharge product 1", Toast.LENGTH_SHORT).show();
break;
case "product_2":
Toast.makeText(getApplicationContext(), "debug: purcharge product 2", Toast.LENGTH_SHORT).show();
break;
}
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn9zEWzKIvk/hScbZyrZ6HE4y679DUIQPsxfz0mQJmnv3RYCdd7Zcy+peOtnvRyZzmbrAcYmW1FOsH/3dJwuAmdO+Wd9HyDre+vJwAAQ/QI2WA4lbWSl4jVEr7AX9p3J8pBIy3UKRmhjk/PFN8N1jYDUnnPbZJnSkd6eRpiET+MMUsNHIoCxXzmqXvy3bFh/L61gtqUW/acOkWuXnLkn6rVVBzHUL9YLeVRdnN86DnejJySe8DniiAH0sfMP7wxU2y4GoKPjXDeZFNZr4ii22re7ogpIjEfUEb3+FxtxfbjPFz6hONsy/NofkEDznci5fPk8FtulhVbkJ82Rpiq6BXQIDAQAB";
mHelper = new IabHelper(this, base64EncodedPublicKey);

}

public void query(View view){
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d("Billing error: ", "Problem setting up In-app Billing: " + result);
Toast.makeText(getApplicationContext(), "debug: IAB is not set up!", Toast.LENGTH_SHORT).show();
}
// Hooray, IAB is fully set up!
Toast.makeText(getApplicationContext(), "debug: Hooray, IAB is fully set up!", Toast.LENGTH_SHORT).show();
List additionalSkuList = new ArrayList();
additionalSkuList.add("product_1");
additionalSkuList.add("product_2");
mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
}
});
}

public void pay(View view){
mHelper.launchPurchaseFlow(this, "product_1", 10001, mPurchaseFinishedListener, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
}

@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
}

activity_main

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Query"
android:onClick="query"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pay"
android:onClick="pay"/>
</LinearLayout>

部署应用程序时,我有两个按钮(查询、支付)。我在点击支付按钮之前点击查询按钮。

然后我得到表单:

The item you requested is not available for purchase

我在 Release模式下签署了 APK。该应用程序已发布且产品处于 Activity 状态。有人帮我找到我们的问题吗?

最佳答案

确保您正在测试的 AndroidManifest.xml 文件中的 android:versionCode.apk 中的版本号相同您在 Developer Console 中上传为当前 Activity 的 alpha 版本。

这至少是我的问题,因为我遇到了同样的错误。

关于android - 您请求的商品无法购买 - 应用内结算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32366721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com