forked from hyochan/react-native-iap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js.flow
97 lines (84 loc) · 2.56 KB
/
index.js.flow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// @flow
declare type Common = {
title: string,
description: string,
price: string,
currency: string,
localizedPrice: string,
}
declare type ID = string
export type Product<ID> = Common & {
type: "inapp" | "iap",
productId: ID,
}
export type Subscription<ID> = Common & {
type: "subs" | "sub",
productId: ID,
introductoryPrice?: string,
introductoryPricePaymentModeIOS?: string,
introductoryPriceNumberOfPeriods?: number,
introductoryPriceSubscriptionPeriod: {},
subscriptionPeriodNumberIOS?: string,
subscriptionPeriodUnitIOS?: number,
introductoryPriceCyclesAndroid?: number,
introductoryPricePeriodAndroid?: string,
subscriptionPeriodAndroid?: string,
freeTrialPeriodAndroid: string,
}
export type ProductPurchase = {|
productId: string,
transactionId: string,
transactionDate: string,
transactionReceipt: string,
signatureAndroid?: string,
dataAndroid?: string,
purchaseToken?: string,
|}
export type SubscriptionPurchase = ProductPurchase & {
autoRenewingAndroid: boolean,
originalTransactionDateIOS: string,
originalTransactionIdentifierIOS: string,
}
export type Purchase = ProductPurchase | SubscriptionPurchase
declare module.exports: {
getProducts: (string[]) => Promise<Product<string>[]>,
getSubscriptions(string[]): Promise<Subscription<string>[]>,
initConnection(): Promise<string>,
buyProduct: string => Promise<ProductPurchase>,
endConnection: () => Promise<void>,
consumeAllItems(): Promise<void>,
getPurchaseHistory(): Promise<Purchase[]>,
getAvailablePurchases(): Promise<Purchase[]>,
buySubscription(
sku: string,
oldSku?: string,
prorationMode?: number,
): Promise<SubscriptionPurchase>,
buyProductWithQuantityIOS(
sku: string,
quantity: number,
): Promise<ProductPurchase>,
buyProductWithoutFinishTransaction(sku: string): Promise<ProductPurchase>,
clearTransaction(): void,
clearProducts(): void,
finishTransaction(): void,
consumePurchase(token: string): Promise<void>,
validateReceiptIos(
receiptBody: AppleReceiptValidationRequest,
isTest: boolean,
): Promise<AppleReceiptValidationResponse | false>,
validateReceiptAndroid(
packageName: string,
productId: string,
productToken: string,
accessToken: string,
isSub: boolean,
): Promise<{} | false>,
addAdditionalSuccessPurchaseListenerIOS(
fn: (any) => any,
): EmitterSubscription,
}
// TODO: the following definitions should be more specific
export type AppleReceiptValidationResponse = any
export type AppleReceiptValidationRequest = any
export type EmitterSubscription = any