我正在研究如何将应用内购买添加到Android应用中。
根据官方Android文档,一切都由Google处理。我找不到如何通知我的后端服务器成功付款?这有可能吗?
答案 0 :(得分:0)
是 您可以在付款成功后通知您的后端服务器。 如果您已按照官方Android文档进行应用内购买。 您可以看到不同的覆盖方法:
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (mHelper == null) return;
if (result.isFailure()) {
return;
}
Log.d(TAG, "Purchase successful.");
if (ITEM_SKU.equals(ITEM_SKU)) {
mHelper.consumeAsync(purchase, mConsumeFinishedListener);
}
}
};
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase, IabResult result) {
Log.d(TAG, "Consumption finished. Purchase: " + purchase + ", result: " + result);
if (mHelper == null) return;
if (result.isSuccess()) {
Log.d(TAG, "Consumption successful.");
//After consumption successful you can notify backend from here.
} else {
//show error
}
}
};