forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stripe.d.ts
105 lines (96 loc) · 2.83 KB
/
stripe.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
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
98
99
100
101
102
103
104
105
// Type definitions for stripe
// Project: https://stripe.com/
// Definitions by: Andy Hawkins <https://github.com/a904guy/,http://a904guy.com>, Eric J. Smith <https://github.com/ejsmith/>, Amrit Kahlon <https://github.com/amritk/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface StripeStatic {
setPublishableKey(key: string): void;
validateCardNumber(cardNumber: string): boolean;
validateExpiry(month: string, year: string): boolean;
validateCVC(cardCVC: string): boolean;
cardType(cardNumber: string): string;
getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void): void;
card: StripeCardData;
createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void;
bankAccount: StripeBankAccount;
}
interface StripeTokenData {
number: string;
exp_month: number;
exp_year: number;
cvc?: string;
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
}
interface StripeTokenResponse {
id: string;
card: StripeCardData;
created: number;
currency: string;
livemode: boolean;
object: string;
used: boolean;
error: StripeError;
}
interface StripeError {
type: string;
code: string;
message: string;
param?: string;
}
interface StripeCardData {
object: string;
last4: string;
type: string;
exp_month: number;
exp_year: number;
fingerprint: string;
country?: string;
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void;
}
interface StripeBankAccount
{
createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void;
validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean;
validateAccountNumber(accountNumber: number | string, countryCode: string): boolean;
}
interface StripeBankTokenParams
{
country: string;
currency: string;
account_number: number | string;
routing_number?: number | string;
}
interface StripeBankTokenResponse
{
id: string;
bank_account: {
id: string;
country: string;
bank_name: string;
last4: number;
validated: boolean;
object: string;
};
created: number;
livemode: boolean;
type: string;
object: string;
used: boolean;
error: StripeError;
}
declare var Stripe: StripeStatic;
declare module "Stripe" {
export = StripeStatic;
}