Hi, I implemented inapp billing V3 to subscribe for a year for an item using android-inapp-billing-v3 . I want to show the remaining days in my application. I call getSubscriptionTransactionDetailsto get transaction information for the product, but always returns null. here is my code.
private BillingProcessor startInappCheck(){
bp = new BillingProcessor(mContext, BASE64ENCODEDPUBLICKEY, new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
LogUtils.e(TAG, "onProductPurchased :" +productId);
}
@Override
public void onBillingError(int errorCode, Throwable error) {
LogUtils.e(TAG, "onBillingError :" +errorCode);
}
@Override
public void onBillingInitialized() {
readyToPurchase = true;
try{
SkuDetails subs = bp.getSubscriptionListingDetails(SUBSCRIPTION_ID);
LogUtils.d(TAG, "Owned Subscription: " + subs.toString());
TransactionDetails tr = bp.getSubscriptionTransactionDetails(SUBSCRIPTION_ID);
LogUtils.d(TAG, "Owned Subscription: " + tr.toString());
}catch (Exception e) {
}
}
@Override
public void onPurchaseHistoryRestored() {
for(String sku : bp.listOwnedSubscriptions()){
LogUtils.d(TAG, "Owned Subscription: " + sku);
}
}
});
return bp;
}
I called this method from onCreate.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!bp.handleActivityResult(requestCode, resultCode, data))
super.onActivityResult(requestCode, resultCode, data);
}
My subscription item button is implemented in fragment. Another problem, I found that after a successful subscription is onProductPurchasednot called, but I implemented the logic in onResumeto update the interface if it bp.isSubscribed(SUBSCRIPTION_ID)returns true. Please tell me how to get the start date of the subscription and the expiration date.