From 6d591e5096e74d1d1546fee9028813c916c496f1 Mon Sep 17 00:00:00 2001 From: Amaury Liet Date: Mon, 14 Sep 2020 16:05:26 +0200 Subject: [PATCH] Fix/avoid blindly consuming success purchases (#1085) If the purchase is really pending, nothing will happen (error). Otherwise, the Play Store cache will be force updated * fix: When possible, properly check that module is defined (instead of throwing non-catchable promise * fix: Avoid consuming all purchase blindly, but only pending ones --- IapExample/App.js | 2 +- README.md | 79 +++++++++-------- .../java/com/dooboolab/RNIap/RNIapModule.java | 85 ++++++++++++++----- index.ts | 78 ++++++++++------- 4 files changed, 159 insertions(+), 85 deletions(-) diff --git a/IapExample/App.js b/IapExample/App.js index 52d03e305..284848809 100644 --- a/IapExample/App.js +++ b/IapExample/App.js @@ -116,7 +116,7 @@ class Page extends Component { async componentDidMount(): void { try { const result = await RNIap.initConnection(); - await RNIap.consumeAllItemsAndroid(); + await RNIap.flushFailedPurchasesCachedAsPendingAndroid(); console.log('result', result); } catch (err) { console.warn(err.code, err.message); diff --git a/README.md b/README.md index 0471cfdf8..9e9a2a5ea 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,8 @@ _*deprecated_
~~`buySubscription(sku: string)`~~