android结算代码,android – 实现应用内结算

我目前正在我的应用程序中购买应用程序,当它启动时我总是在我到达IabHelper.QueryInventoryFinishedListener方法时查询错误代码-1003查询所拥有的项目响应签名验证失败.

我目前使用谷歌“Trivial Drive”的示例版本,我想我的签名是正确的,因为当我使用android.app.purchassed时我会买很多…

关键似乎对我来说是正确的,因为当我点击喜欢购买一个产品,告诉我出版商不能购买本身正常的产品(如果我放任何东西,我有另一个错误,说产品不存在).对于缺点,当我把测试产品“android.test.purchasse”时,我有同样的错误,然后我应该能够测试它.

我在那里用android.test.purchasse购买了,如果你已经成功我无法重置我感兴趣.

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// load game data

loadData();

String base64EncodedPublicKey = "MY_KEY_BASE64";

PublicKey key = Security.generatePublicKey(base64EncodedPublicKey);

// Create the helper, passing it our context and the public key to verify signatures with

Log.d(TAG, "Creating IAB helper.");

mHelper = new IabHelper(this, base64EncodedPublicKey);

// enable debug logging (for a production application, you should set this to false).

mHelper.enableDebugLogging(true);

// Start setup. This is asynchronous and the specified listener

// will be called once setup completes.

Log.d(TAG, "Starting setup.");

mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

public void onIabSetupFinished(IabResult result) {

Log.d(TAG, "Setup finished.");

if (!result.isSuccess()) {

// Oh noes, there was a problem.

complain("Problem setting up in-app billing: " + result);

return;

}

// Have we been disposed of in the meantime? If so, quit.

if (mHelper == null) return;

// IAB is fully set up. Now, let's get an inventory of stuff we own.

Log.d(TAG, "Setup successful. Querying inventory.");

mHelper.queryInventoryAsync(mGotInventoryListener);

}

});

}

// Listener that's called when we finish querying the items and subscriptions we own

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {

public void onQueryInventoryFinished(IabResult result, Inventory inventory) {

Log.d(TAG, "Query inventory finished.");

// Have we been disposed of in the meantime? If so, quit.

if (mHelper == null) return;

// Is it a failure?

if (result.isFailure()) {

complain("Failed to query inventory: " + result);

return;

}

Log.d(TAG, "Query inventory was successful.");

/*

* Check for items we own. Notice that for each purchase, we check

* the developer payload to see if it's correct! See

* verifyDeveloperPayload().

*/

if(inventory.hasPurchase(SKU_GAS))

{

Toast.makeText(getApplicationContext(),"PREMIUM",Toast.LENGTH_SHORT).show();

}else{

Toast.makeText(getApplicationContext(),"NOT PREMIUM", Toast.LENGTH_SHORT).show();

}

// Do we have the premium upgrade?

Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);

mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));

Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));

// Do we have the infinite gas plan?

Purchase infiniteGasPurchase = inventory.getPurchase(SKU_INFINITE_GAS);

mSubscribedToInfiniteGas = (infiniteGasPurchase != null && verifyDeveloperPayload(infiniteGasPurchase));

Log.d(TAG, "User " + (mSubscribedToInfiniteGas ? "HAS" : "DOES NOT HAVE")

+ " infinite gas subscription.");

if (mSubscribedToInfiniteGas) mTank = TANK_MAX;

// Check for gas delivery -- if we own gas, we should fill up the tank immediately

Purchase gasPurchase = inventory.getPurchase(SKU_GAS);

if (gasPurchase != null && verifyDeveloperPayload(gasPurchase)) {

Log.d(TAG, "We have gas. Consuming it.");

mHelper.consumeAsync(inventory.getPurchase(SKU_GAS), mConsumeFinishedListener);

return;

}

updateUi();

setWaitScreen(false);

Log.d(TAG, "Initial inventory query finished; enabling main UI.");

}

};

你有没有担心过?我认为没有办法解决这个错误的帮助你将不胜感激.

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值