Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test two methods #1943

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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