From 73cd9e7a9e7fdf3daae41133f727345ba6924ad2 Mon Sep 17 00:00:00 2001 From: Christian Brevik Date: Mon, 11 Jun 2018 10:00:53 +0200 Subject: [PATCH] Add the transactionDetails autoRenewing flag Apparently used for checking if subscription is cancelled --- README.md | 9 +++++++++ .../main/java/com/idehub/Billing/InAppBillingBridge.java | 2 +- types/index.d.ts | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a70761a..e55c217 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,10 @@ Testing with static responses is limited, because you are only able to test the **Important**: You can only test on a physical Android device, not from an emulator. +## Handle Canceled Subscriptions + +Call `InAppBilling.getSubscriptionTransactionDetails(productId)` and check the `details.autoRenewing` flag. It will be set to `false` once subscription gets cancelled. Also notice, that you will need to call periodically `InAppBilling.loadOwnedPurchasesFromGoogle()` method in order to update purchase/subscription information from the Google-servers. + ## Javascript API All methods returns a `Promise`. @@ -224,6 +228,7 @@ InAppBilling.open() - **purchaseState:** String ("PurchasedSuccessfully", "Canceled", "Refunded", "SubscriptionExpired") - **receiptSignature:** String - **receiptData:** String + - **autoRenewing** Boolean - **developerPayload:** String ```javascript @@ -263,6 +268,7 @@ InAppBilling.consumePurchase('your.inapp.productid').then(...); - **purchaseState:** String ("PurchasedSuccessfully", "Canceled", "Refunded", "SubscriptionExpired") - **receiptSignature:** String - **receiptData:** String + - **autoRenewing** Boolean - **developerPayload:** String ```javascript @@ -303,6 +309,7 @@ InAppBilling.isSubscribed('your.inapp.productid').then(...); - **purchaseState:** String ("PurchasedSuccessfully", "Canceled", "Refunded", "SubscriptionExpired") - **receiptSignature:** String - **receiptData:** String + - **autoRenewing** Boolean - **developerPayload:** String ```javascript @@ -467,6 +474,7 @@ InAppBilling.getSubscriptionDetailsArray(['your.inapp.productid', 'your.inapp.pr - **purchaseState:** String ("PurchasedSuccessfully", "Canceled", "Refunded", "SubscriptionExpired") - **receiptSignature:** String - **receiptData:** String + - **autoRenewing** Boolean - **developerPayload:** String ```javascript @@ -493,6 +501,7 @@ InAppBilling.getPurchaseTransactionDetails("your.inapp.productid").then( - **purchaseState:** String ("PurchasedSuccessfully", "Canceled", "Refunded", "SubscriptionExpired") - **receiptSignature:** String - **receiptData:** String + - **autoRenewing** Boolean - **developerPayload:** String ```javascript diff --git a/android/src/main/java/com/idehub/Billing/InAppBillingBridge.java b/android/src/main/java/com/idehub/Billing/InAppBillingBridge.java index f9a2ddf..82da06e 100644 --- a/android/src/main/java/com/idehub/Billing/InAppBillingBridge.java +++ b/android/src/main/java/com/idehub/Billing/InAppBillingBridge.java @@ -414,7 +414,7 @@ private WritableMap mapTransactionDetails(TransactionDetails details) { ? "" : purchaseData.purchaseTime.toString()); map.putString("purchaseState", purchaseData.purchaseState == null ? "" : purchaseData.purchaseState.toString()); - + map.putBoolean("autoRenewing", purchaseData.autoRenewing); if (purchaseData.developerPayload != null) map.putString("developerPayload", purchaseData.developerPayload); diff --git a/types/index.d.ts b/types/index.d.ts index ba71df7..db9065d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -15,6 +15,7 @@ export interface ITransactionDetails { purchaseState: PurchaseState; receiptSignature: string; receiptData: string; + autoRenewing: boolean; developerPayload: string; }