Skip to content

Commit

Permalink
test two methods (#1943)
Browse files Browse the repository at this point in the history
Co-authored-by: Andres Aguilar <andres.aguilar@nfl.com>
  • Loading branch information
andresesfm and Andres Aguilar authored Sep 9, 2022
1 parent 3396c2f commit 33e633e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 54 deletions.
3 changes: 0 additions & 3 deletions docs/docs/api-reference/interfaces/_category_.json

This file was deleted.

7 changes: 0 additions & 7 deletions docs/docs/api-reference/interfaces/product.md

This file was deleted.

7 changes: 0 additions & 7 deletions docs/docs/api-reference/interfaces/subscription.md

This file was deleted.

31 changes: 0 additions & 31 deletions docs/docs/api-reference/methods/end-connection.md

This file was deleted.

38 changes: 33 additions & 5 deletions src/iap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,23 @@ export const initConnection = (): Promise<boolean> =>
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 <View />;
};
```
* @returns {Promise<void>}
*/
export const endConnection = (): Promise<boolean> =>
Expand Down Expand Up @@ -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<string | void> }
*
```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 <Button title="Buy product" onPress={handlePurchase} />;
};
```
*/
export const finishTransaction = ({
purchase,
Expand Down
7 changes: 6 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export interface Discount {
paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';
subscriptionPeriod: string;
}

/**
* A product can either be a consumable or a non-consumable product.
*/
export interface Product extends ProductCommon {
type: 'inapp' | 'iap';
// Android V5
Expand Down Expand Up @@ -166,6 +168,9 @@ export interface SubscriptionIOS extends ProductCommon {
subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';
}

/**
* A subscription is a product that can be renewed multiple times.
*/
export type Subscription = SubscriptionAndroid & SubscriptionIOS;

/**
Expand Down

0 comments on commit 33e633e

Please sign in to comment.