如何验证已取消的应用内订阅?
How do I verify canceled in-app subscription?
我正在使用:bp.isSubscribed(ID) 来验证我的订阅。但是当我取消订阅时,方法 bp.isSubscribed(ID) 仍然 returning 为真。我该怎么办?
transDetails.purchaseInfo.purchaseData.purchaseState.toString()
在我从 Play 商店管理订阅手动取消后总是 return 购买成功。
public void checkSubscriptionDetails(){
bp = new BillingProcessor(this, LICENSE_KEY, new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details) {
Common.printLog("InApp", ":onProductPurchased :" + productId);
}
@Override
public void onPurchaseHistoryRestored() {
}
@Override
public void onBillingError(int errorCode, @Nullable Throwable error) {
}
@Override
public void onBillingInitialized() {
}
});
boolean purchaseResult = bp.loadOwnedPurchasesFromGoogle();
// ## purchaseResult is always return FALSE
if (bp.isSubscribed(planID)) {
TransactionDetails transDetails = bp.getSubscriptionTransactionDetails(planID);
String strDetailsSubsMonth = "OrderID:" + transDetails.orderId +
"\nproductId: " + transDetails.productId +
"\npurchaseToken: " + transDetails.purchaseToken +
"\npurchaseTime: " + transDetails.purchaseTime +
"\npurchaseInfo.signature: " + transDetails.purchaseInfo.signature +
"\npurchaseInfo.responseData: " + transDetails.purchaseInfo.responseData +
"\npurchaseData.purchaseToken: " + transDetails.purchaseInfo.purchaseData.purchaseToken +
"\npurchaseData.autoRenewing: " + transDetails.purchaseInfo.purchaseData.autoRenewing +
"\npurchaseData.developerPayload: " + transDetails.purchaseInfo.purchaseData.developerPayload +
"\npurchaseData.purchaseState: " + transDetails.purchaseInfo.purchaseData.purchaseState.toString();
String strPurchaseState = transDetails.purchaseInfo.purchaseData.purchaseState.toString();
Common.printLog("InApp", "Details: " + planID + " >> " + strDetailsSubsMonth + " \n" + "Purchase State :" + strPurchaseState);
}
}
package com.anjlab.android.iab.v3;
public enum PurchaseState
{
PurchasedSuccessfully,
Canceled,
Refunded,
SubscriptionExpired
}
取消订阅后我需要return"Canceled"。
在onCreate()
中启动bp
变量,然后调用loadOwnedPurchasesFromGoogle()
。
In my case!
不知道为什么要多次调用loadOwnedPurchasesFromGoogle()
。当我在 onCreate()
中调用 loadOwnedPurchasesFromGoogle()
时,我总是得到 false。但是当我调用 onPause()
和 onDestory()
时,我得到了 true 并且我的所有值都得到了更新。
得到loadOwnedPurchasesFromGoogle()
真后,我得到更新订阅值!
服务器端的最佳解决方案获取订阅的实际信息,或者您可以通过 Node.js 配置进行交叉验证。
https://caster.io/lessons/verify-android-app-subscription-status-from-nodejs
我正在使用:bp.isSubscribed(ID) 来验证我的订阅。但是当我取消订阅时,方法 bp.isSubscribed(ID) 仍然 returning 为真。我该怎么办?
transDetails.purchaseInfo.purchaseData.purchaseState.toString() 在我从 Play 商店管理订阅手动取消后总是 return 购买成功。
public void checkSubscriptionDetails(){
bp = new BillingProcessor(this, LICENSE_KEY, new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details) {
Common.printLog("InApp", ":onProductPurchased :" + productId);
}
@Override
public void onPurchaseHistoryRestored() {
}
@Override
public void onBillingError(int errorCode, @Nullable Throwable error) {
}
@Override
public void onBillingInitialized() {
}
});
boolean purchaseResult = bp.loadOwnedPurchasesFromGoogle();
// ## purchaseResult is always return FALSE
if (bp.isSubscribed(planID)) {
TransactionDetails transDetails = bp.getSubscriptionTransactionDetails(planID);
String strDetailsSubsMonth = "OrderID:" + transDetails.orderId +
"\nproductId: " + transDetails.productId +
"\npurchaseToken: " + transDetails.purchaseToken +
"\npurchaseTime: " + transDetails.purchaseTime +
"\npurchaseInfo.signature: " + transDetails.purchaseInfo.signature +
"\npurchaseInfo.responseData: " + transDetails.purchaseInfo.responseData +
"\npurchaseData.purchaseToken: " + transDetails.purchaseInfo.purchaseData.purchaseToken +
"\npurchaseData.autoRenewing: " + transDetails.purchaseInfo.purchaseData.autoRenewing +
"\npurchaseData.developerPayload: " + transDetails.purchaseInfo.purchaseData.developerPayload +
"\npurchaseData.purchaseState: " + transDetails.purchaseInfo.purchaseData.purchaseState.toString();
String strPurchaseState = transDetails.purchaseInfo.purchaseData.purchaseState.toString();
Common.printLog("InApp", "Details: " + planID + " >> " + strDetailsSubsMonth + " \n" + "Purchase State :" + strPurchaseState);
}
}
package com.anjlab.android.iab.v3;
public enum PurchaseState
{
PurchasedSuccessfully,
Canceled,
Refunded,
SubscriptionExpired
}
取消订阅后我需要return"Canceled"。
在onCreate()
中启动bp
变量,然后调用loadOwnedPurchasesFromGoogle()
。
In my case!
不知道为什么要多次调用loadOwnedPurchasesFromGoogle()
。当我在 onCreate()
中调用 loadOwnedPurchasesFromGoogle()
时,我总是得到 false。但是当我调用 onPause()
和 onDestory()
时,我得到了 true 并且我的所有值都得到了更新。
得到loadOwnedPurchasesFromGoogle()
真后,我得到更新订阅值!
服务器端的最佳解决方案获取订阅的实际信息,或者您可以通过 Node.js 配置进行交叉验证。
https://caster.io/lessons/verify-android-app-subscription-status-from-nodejs