-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathtypes.d.ts
62 lines (51 loc) · 1.89 KB
/
types.d.ts
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
declare module "extpay" {
interface Plan {
unitAmountCents: number
currency: string
nickname: String | null,
interval: "month" | "year" | "once"
intervalCount: number | null
}
interface User {
/** user.paid is meant to be a simple way to tell if the user should have paid features activated.
* For subscription payments, paid is only true if subscriptionStatus is active. */
paid: boolean
/** date that the user first paid or null. */
paidAt: Date | null
/** The user's email if there is one or `null`. */
email: string | null
/** date the user installed the extension. */
installedAt: Date
/** date the user confirmed their free trial. */
trialStartedAt: Date | null
plan: Plan | null
/** active means the user's subscription is paid-for.
* past_due means the user's most recent subscription payment has failed (expired card, insufficient funds, etc).
* canceled means that the user has canceled their subscription and the end of their last paid period has passed. */
subscriptionStatus?: "active" | "past_due" | "canceled"
/** date that the user's subscription is set to cancel or did cancel at. */
subscriptionCancelAt?: Date | null
}
interface Plan {
unitAmountCents: number;
currency: string;
nickname: string | null;
interval: 'month' | 'year' | 'once';
intervalCount: number | null;
}
interface ExtPay {
getUser: () => Promise<User>
getPlans: () => Promise<Plan[]>
onPaid: {
addListener: (cb: (user: User) => void) => void
}
openPaymentPage: (planNickname?: string) => Promise<void>
openLoginPage: () => Promise<void>
openTrialPage: (displayText?: string) => Promise<void>
onTrialStarted: {
addListener: (cb: (user: User) => void) => void
}
startBackground: () => void
}
export default function ExtPay(extensionId: string): ExtPay
}