
نوشته شده توسط
hoseinoo
سلام
دوستان عزیز وقتی بنده به بازار متصل میشوم و محصولی خرید میکنم، پس از اتمام خرید برنامه ی من بسته می شود و دوباره خودکار اجرا میشود.
هیچ اطلاعات برگشتی توسط برنامه دریافت نمی شود!!
مشکل از کجاست؟
تراکنش در پنل بازار به طور کامل ثبت شده اما بنده نمی توانم این محصول خریده شده را مصرف کنم.

لطفا راهنمایی کنید
با تشکر
برای مصرف خرید شما باید بعد از اتمام خرید به بازار بفهمانید که این خرید قابل مصرف است .
بریا این کار باید متد مصرف خرید را در برنامه قرار دهید و در تابع اتمام خرید (IabHelper.OnIabPurchaseFinishedListener) آن را صدا بزنید
به کدهای برنامه Trivial Drive دقت کنید :
// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
// if we were disposed of in the meantime, quit.
if (mHelper == null) return;
if (result.isFailure()) {
complain("Error purchasing: " + result);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
return;
}
Log.d(TAG, "Purchase successful.");
if (purchase.getToken().equals(token)) {
// bought 1/4 tank of gas. So consume it.
Log.d(TAG, "Purchase is gas. Starting gas consumption.");
mHelper.consumeAsync(purchase, mConsumeFinishedListener);
}
}
};
کد مصرف خرید :
// Called when consumption is complete
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase, IabResult result) {
Log.d(TAG, "Consumption finished. Purchase: " + purchase + ", result: " + result);
// if we were disposed of in the meantime, quit.
if (mHelper == null) return;
// We know this is the "gas" sku because it's the only one we consume,
// so we don't check which sku was consumed. If you have more than one
// sku, you probably should check...
if (result.isSuccess()) {
// successfully consumed, so we apply the effects of the item in our
// game world's logic, which in our case means filling the gas tank a bit
Log.d(TAG, "Consumption successful. Provisioning.");
updateUI();
}
else {
complain("Error while consuming: " + result);
Toast.makeText(getApplicationContext(), "Consome Not Ready", Toast.LENGTH_SHORT).show();
}
Log.d(TAG, "End consumption flow.");
}
};