diff --git a/library/AndroidManifest.xml b/library/AndroidManifest.xml index 29c1a922..23c02dc3 100644 --- a/library/AndroidManifest.xml +++ b/library/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="1.0.12"> - + diff --git a/library/src/com/anjlab/android/iab/v3/BillingProcessor.java b/library/src/com/anjlab/android/iab/v3/BillingProcessor.java index 0f765ffe..16118b66 100644 --- a/library/src/com/anjlab/android/iab/v3/BillingProcessor.java +++ b/library/src/com/anjlab/android/iab/v3/BillingProcessor.java @@ -54,10 +54,10 @@ public static interface IBillingHandler { private static final String RESTORE_KEY = ".products.restored" + SETTINGS_VERSION; private static final String MANAGED_PRODUCTS_CACHE_KEY = ".products.cache" + SETTINGS_VERSION; private static final String SUBSCRIPTIONS_CACHE_KEY = ".subscriptions.cache" + SETTINGS_VERSION; + private static final String PURCHASE_PAYLOAD_CACHE_KEY = ".purchase.last" + SETTINGS_VERSION; private IInAppBillingService billingService; private String contextPackageName; - private String purchasePayload; private String signatureBase64; private BillingCache cachedProducts; private BillingCache cachedSubscriptions; @@ -148,7 +148,8 @@ private boolean loadPurchasesByType(String type, BillingCache cacheStorage) { for (int i=0; i i ? signatureList.get(i) : null; + cacheStorage.put(purchase.getString(Constants.RESPONSE_PRODUCT_ID), jsonData, signature); } } return true; @@ -179,7 +180,8 @@ private boolean purchase(String productId, String purchaseType) { if (!isInitialized() || TextUtils.isEmpty(productId) || TextUtils.isEmpty(purchaseType)) return false; try { - purchasePayload = purchaseType + ":" + UUID.randomUUID().toString(); + String purchasePayload = purchaseType + ":" + UUID.randomUUID().toString(); + savePurchasePayload(purchasePayload); Bundle bundle = billingService.getBuyIntent(Constants.GOOGLE_API_VERSION, contextPackageName, productId, purchaseType, purchasePayload); if (bundle != null) { int response = bundle.getInt(Constants.RESPONSE_CODE); @@ -297,8 +299,10 @@ public TransactionDetails getSubscriptionTransactionDetails(String productId) { public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != PURCHASE_FLOW_REQUEST_CODE) return false; - int responseCode = data.getIntExtra(Constants.RESPONSE_CODE, Constants.BILLING_RESPONSE_RESULT_OK); - if (resultCode == Activity.RESULT_OK && responseCode == Constants.BILLING_RESPONSE_RESULT_OK) { + int responseCode = data.getIntExtra(Constants.RESPONSE_CODE, Constants.BILLING_RESPONSE_RESULT_OK); + Log.d(LOG_TAG, String.format("resultCode = %d, responseCode = %d", resultCode, responseCode)); + String purchasePayload = getPurchasePayload(); + if (resultCode == Activity.RESULT_OK && responseCode == Constants.BILLING_RESPONSE_RESULT_OK && !TextUtils.isEmpty(purchasePayload)) { String purchaseData = data.getStringExtra(Constants.INAPP_PURCHASE_DATA); String dataSignature = data.getStringExtra(Constants.RESPONSE_INAPP_SIGNATURE); try { @@ -360,4 +364,12 @@ public void setPurchaseHistoryRestored() { saveBoolean(getPreferencesBaseKey() + RESTORE_KEY, true); } + private void savePurchasePayload(String value) { + saveString(getPreferencesBaseKey() + PURCHASE_PAYLOAD_CACHE_KEY, value); + } + + private String getPurchasePayload() { + return loadString(getPreferencesBaseKey() + PURCHASE_PAYLOAD_CACHE_KEY, null); + } + } diff --git a/sample/libs/anjlab-iabv3-current.jar b/sample/libs/anjlab-iabv3-current.jar index c347cf62..70c8a90d 100644 Binary files a/sample/libs/anjlab-iabv3-current.jar and b/sample/libs/anjlab-iabv3-current.jar differ