Skip to content

Commit

Permalink
Create type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
taxpon committed Aug 9, 2016
0 parents commit 829cc19
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
typings/
.idea
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Takuro Wada ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Typed Stripe

The type definition for [stripe](https://stripe.com/docs/api) api interface. This definition is based on the stipe's definition in
[DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped).

## License

MIT
119 changes: 119 additions & 0 deletions stripe.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Type definitions for stripe
// This type definition is based on the definition in DefinitelyTyped
// 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/>, Takuro Wada <https://takuro.ws>
// Definitions: https://github.com/DefinitelyTyped/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_city?: string;
address_country?: string;
address_line1?: string;
address_line2?: string;
address_state?: string;
address_zip?: string;
currency?: string;
}

interface StripeTokenResponse {
id: string;
object: string;
card: StripeCardData;
client_id: string;
created: number;
currency: string;
livemode: boolean;
type: string;
used: boolean;
error: StripeError;
}

interface StripeError {
type: string;
code: string;
message: string;
param?: string;
}

interface StripeCardData {
id: string;
object: string;
address_city?: string;
address_country?: string;
address_line1?: string;
address_line1_check: string;
address_line2?: string;
address_state?: string;
address_zip?: string;
address_zip_check?: string;
brand: string;
country?: string;
cvc_check?: string;
dynamic_last4?: string;
exp_month: number;
exp_year: number;
fingerprint?: string;
funding: string;
last4: string;
metadata?: any;
name?: string;
tokenization_method?: 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;
account_holder_name: string;
account_holder_type: 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;
}
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files": [
"stripe.d.ts"
]
}
5 changes: 5 additions & 0 deletions typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "stripe",
"main": "stripe.d.ts",
"browser": "stripe.d.ts"
}

0 comments on commit 829cc19

Please sign in to comment.