也许我做错了什么但如果是这样我就搞不清楚了。我正在尝试购买产品,无论出于何种原因,购买过程都工作不正常。当我点击购买商品时,它会为我提供结算流程。然后付款后我必须再次点击它才能收到我购买的芯片。任何帮助都会很棒,谢谢!如果您不熟悉该工具,可以使用以下链接https://github.com/anjlab/android-inapp-billing-v3,如果您需要更多详细信息,请与我们联系。
bp = new BillingProcessor(this, base64EncodedPublicKey,
new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(String productId,
TransactionDetails details) {
Log.v("chip", productId + " purchased");
if (bp.consumePurchase(productId)){
if(productId=="itemOne" || productId=="one_chip")
ChipUpdate.updateChipCount(2500);
if(productId=="itemTwo"|| productId=="five_chip")
ChipUpdate.updateChipCount(15000);
if(productId=="itemThree"|| productId=="ten_chip")
ChipUpdate.updateChipCount(35000);
if(productId=="itemFour"|| productId=="fifty_chip")
ChipUpdate.updateChipCount(200000);
}
}
@Override
public void onBillingError(int errorCode, Throwable error) {
Log.v("chip", "Error code: " + errorCode);
Log.v("chip", "Error: " + error);
}
@Override
public void onBillingInitialized() {
Log.v("chip", "billing initialized");
readyToPurchase = true;
}
@Override
public void onPurchaseHistoryRestored() {
for (String sku : bp.listOwnedProducts())
Log.v("chip", "Owned Managed Product: " + sku);
for (String sku : bp.listOwnedSubscriptions())
Log.v("chip", "Owned Subscription: " + sku);
}
});
public void oneChip(String noVal) {
Log.v("oneChip", "Calling launch purchase flow");
bp.purchase(this, itemOne);
Log.v("oneChip", "made it through launch purchase flow");
}
public void fiveChip(String noVal) {
Log.v("fiveChip", "Calling launch purchase flow");
bp.purchase(this, itemTwo);
Log.v("fiveChip", "made it through launch purchase flow");
}
public void tenChip(String noVal) {
Log.v("tenChip", "Calling launch purchase flow");
bp.purchase(this, itemThree);
Log.v("tenChip", "made it through launch purchase flow");
}
public void fiftyChip(String noVal) {
Log.v("fiftyChip", "Calling launch purchase flow");
bp.purchase(this, itemFour);
Log.v("fiftyChip", "made it through launch purchase flow");
}
答案 0 :(得分:0)
我想你不应该在consumePurchase
onProductPurchased