From 33e633eea530638824c2efd3786e29c2e7a50dab Mon Sep 17 00:00:00 2001 From: Andres Aguilar Date: Fri, 9 Sep 2022 13:02:03 -0700 Subject: [PATCH] test two methods (#1943) Co-authored-by: Andres Aguilar --- .../api-reference/interfaces/_category_.json | 3 -- docs/docs/api-reference/interfaces/product.md | 7 ---- .../api-reference/interfaces/subscription.md | 7 ---- .../api-reference/methods/end-connection.md | 31 --------------- src/iap.ts | 38 ++++++++++++++++--- src/types/index.ts | 7 +++- 6 files changed, 39 insertions(+), 54 deletions(-) delete mode 100644 docs/docs/api-reference/interfaces/_category_.json delete mode 100644 docs/docs/api-reference/interfaces/product.md delete mode 100644 docs/docs/api-reference/interfaces/subscription.md delete mode 100644 docs/docs/api-reference/methods/end-connection.md diff --git a/docs/docs/api-reference/interfaces/_category_.json b/docs/docs/api-reference/interfaces/_category_.json deleted file mode 100644 index 4962ce514..000000000 --- a/docs/docs/api-reference/interfaces/_category_.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "label": "Interfaces" -} diff --git a/docs/docs/api-reference/interfaces/product.md b/docs/docs/api-reference/interfaces/product.md deleted file mode 100644 index 764e073ac..000000000 --- a/docs/docs/api-reference/interfaces/product.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Product - -A product can either be a consumable or a non-consumable product. diff --git a/docs/docs/api-reference/interfaces/subscription.md b/docs/docs/api-reference/interfaces/subscription.md deleted file mode 100644 index b2606538a..000000000 --- a/docs/docs/api-reference/interfaces/subscription.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Subscription - -A subscription is a product that can be renew multiple times. diff --git a/docs/docs/api-reference/methods/end-connection.md b/docs/docs/api-reference/methods/end-connection.md deleted file mode 100644 index 2df08beac..000000000 --- a/docs/docs/api-reference/methods/end-connection.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -sidebar_position: 2 ---- - -# `endConnection` - -End the In-App Purchases module connection. - -## Signature - -```ts -endConnection(): Promise; -``` - -## Usage - -```tsx -import React, {useEffect} from 'react'; -import {View} from 'react-native'; -import {endConnection} from 'react-native-iap'; - -const App = () => { - useEffect(() => { - return () => { - void endConnection(); - }; - }, []); - - return ; -}; -``` diff --git a/src/iap.ts b/src/iap.ts index 10a08b3c6..281dd7530 100644 --- a/src/iap.ts +++ b/src/iap.ts @@ -87,7 +87,23 @@ export const initConnection = (): Promise => getNativeModule().initConnection(); /** - * End module for purchase flow. + * Disconnects from native SDK + * Usage + * ```tsx +import React, {useEffect} from 'react'; +import {View} from 'react-native'; +import {endConnection} from 'react-native-iap'; + +const App = () => { + useEffect(() => { + return () => { + void endConnection(); + }; + }, []); + + return ; +}; +``` * @returns {Promise} */ export const endConnection = (): Promise => @@ -405,10 +421,22 @@ export const requestPurchaseWithQuantityIOS = ({ * Call this after you have persisted the purchased state to your server or local data in your app. * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.** * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables. - * @param {object} purchase The purchase that you would like to finish. - * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`. - * @param {string} developerPayloadAndroid Android developerPayload. - * @returns {Promise } + * +```tsx +import React from 'react'; +import {Button} from 'react-native'; +import {finishTransaction} from 'react-native-iap'; + +const App = () => { + const handlePurchase = async () => { + // ... handle the purchase request + + const result = finishTransaction(purchase); + }; + + return