gpt4 book ai didi

java - 无法购买商品,错误响应 : 7:Item Already Owned

转载 作者:太空宇宙 更新时间:2023-11-04 12:52:31 26 4
gpt4 key购买 nike

当我尝试再次购买商品时,出现以下错误。请不要将其作为重复项关闭。我知道堆栈溢出中有很多这样的问题,但似乎没有一个有帮助。请引用我的代码。

 public class BtnListener implements View.OnClickListener
{
// On-click event handler for all the buttons
@Override
public void onClick(View view)
{
switch (view.getId())
{

case R.id.TwoSeconds:
mHelper.launchPurchaseFlow(TimeBoosterActivity.this, ITEM_SKU, 10001,
mPurchaseFinishedListener, "2");
break;
}
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data)
{
if (!mHelper.handleActivityResult(requestCode,
resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result,
Purchase purchase)
{
if (result.isFailure()) {
// Handle error
return;
}
else if (purchase.getSku().equals(ITEM_SKU)) {
consumeItem();
//buyButton.setEnabled(false);

}

}
};

public void consumeItem() {
mHelper.queryInventoryAsync(mReceivedInventoryListener);
}

IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {

if (result.isFailure()) {
Toast.makeText(getApplicationContext(), "Failed to consume item",
Toast.LENGTH_SHORT).show();
} else {
mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
mConsumeFinishedListener);
}
}
};

IabHelper.OnConsumeFinishedListener mConsumeFinishedListener =
new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase,
IabResult result) {

if (result.isSuccess()) {
String getSeconds=purchase.getDeveloperPayload();
SharedPreferences saveTwoSeconds=getSharedPreferences(getSeconds, Context.MODE_PRIVATE);
//clickButton.setEnabled(true);
} else {
// handle error
Toast.makeText(getApplicationContext(), "Failed to consume item",
Toast.LENGTH_SHORT).show();
}
}
};

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

最佳答案

我认为由于 onActivityResult 中的代码,您的消费购买未被调用。

尝试使用下面的代码

  @Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == <Code you sent during launching purchase flow> || requestCode == <Code you sent during launching consume flow> )
mHelper.handleActivityResult(requestCode,resultCode, data))
}
}

关于java - 无法购买商品,错误响应 : 7:Item Already Owned,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35680576/

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