我无法使用android.test.purchased产品ID。
下面是我处理采购的代码。
public void handlePurchase(Purchase purchase) {
try {
if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
consumeSKU(purchase.getPurchaseToken(), purchase.getDeveloperPayload());
}
} catch (Exception e) {
e.printStackTrace();
}
}
下面是我的consumeSKU方法:
public void consumeSKU(String purchase_token, String developer_payload) {
ConsumeParams consumeParams =
ConsumeParams.newBuilder()
.setPurchaseToken(purchase_token)
.setDeveloperPayload(developer_payload)
.build();
billingClient.consumeAsync(consumeParams, this);
}
和我的消费响应侦听器:
@Override
public void onConsumeResponse(BillingResult billingResult, String purchaseToken) {
Toast.makeText(context, "onConsumeResponse: " + billingResult.getResponseCode() + ", purchase token: " + purchaseToken, Toast.LENGTH_LONG).show();
}
每次调用consumerSKU方法时,我都会从Response Code: 6
获得billingResult
。
我要去哪里错了?