Skip to content

Instantly share code, notes, and snippets.

@Justin-Credible
Created June 28, 2017 17:03
Show Gist options
  • Save Justin-Credible/15c1efdce0945337a5a864b291c9bdbd to your computer and use it in GitHub Desktop.
Save Justin-Credible/15c1efdce0945337a5a864b291c9bdbd to your computer and use it in GitHub Desktop.
TypeScript definitions for the Braintree Web SDK (version 2.22.2)
/**
* Types for Braintree's Client SDK for Web.
*
* https://github.com/braintree/braintree-web
*/
declare namespace BraintreeClientWeb {
interface BraintreeClientWebStatic {
api: API;
}
interface API {
Client: Client;
}
interface Client {
new (options: ClientOptions);
tokenizeCard(cardOptions: CardOptions, callback: (error: any, nonce: string, result: TokenizeCardResult) => void);
addCreditCard(cardOptions: CardOptions, callback: (error: any, nonce: string) => void);
getCreditCards(callback: (error: any, nonce: string) => void);
}
interface ClientOptions {
clientToken: string;
}
interface CardOptions {
number: string;
cardholderName: string;
/**
* Year and month: "10/16"
*/
expirationDate?: string;
/**
* Month number: "10"
*/
expirationMonth?: string;
/**
* Year: "2016"
*/
expirationYear?: string;
cvv?: string;
/**
* Address to validate if validation is enabled.
*/
billingAddress?: {
firstName?: string;
lastName?: string;
streetAddress?: string;
postalCode?: string;
};
}
interface TokenizeCardResult {
type: string;
details: {
lastTwo: string;
cardType: string;
};
}
}
declare var braintree: BraintreeClientWeb.BraintreeClientWebStatic;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment