diff --git a/stripe-checkout/stripe-checkout-tests.ts b/stripe-checkout/stripe-checkout-tests.ts new file mode 100644 index 0000000000..c054b2365d --- /dev/null +++ b/stripe-checkout/stripe-checkout-tests.ts @@ -0,0 +1,38 @@ +/// + +// Test the minimum amount of configuration required. +var handler = StripeCheckout.configure({ + key: "my-secret-key", + token: function(token: StripeTokenResponse) { + console.log(token.id); + } +}); + +handler.open(); + +handler.close(); + +// Test all configuration options. +var options = { + key: "my-secret-key", + token: function(token: StripeTokenResponse) { + console.log(token.id); + }, + image: "http://placehold.it/128x128", + name: "Definitely Typed", + description: "A DefinitelyTyped test for Stripe Checkout", + amount: Number.MAX_VALUE, + currency: "USD", + panelLabel: "Pay Definitely Typed {{amount}}", + label: "Pay Definitely Typed", + zipCode: false, + email: "test@example.com", + allowRememberMe: false, + bitcoin: false, + opened: function() {}, + closed: function() {} +} + +handler = StripeCheckout.configure(options); + +handler.open(options); \ No newline at end of file diff --git a/stripe-checkout/stripe-checkout.d.ts b/stripe-checkout/stripe-checkout.d.ts new file mode 100644 index 0000000000..f648a1bb31 --- /dev/null +++ b/stripe-checkout/stripe-checkout.d.ts @@ -0,0 +1,35 @@ +// Type definitions for Stripe Checkout +// Project: https://stripe.com/checkout +// Definitions by: Chris Wrench +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface StripeCheckoutStatic { + configure(options: StripeCheckoutOptions): StripeCheckoutHandler; +} + +interface StripeCheckoutHandler { + open(options?: StripeCheckoutOptions): void; + close(): void; +} + +interface StripeCheckoutOptions { + key: string; + token: (token: StripeTokenResponse) => void; + image?: string; + name?: string; + description?: string; + amount?: number; + currency?: string; + panelLabel?: string; + zipCode?: boolean; + email?: string; + label?: string; + allowRememberMe?: boolean; + bitcoin?: boolean; + opened?: () => void; + closed?: () => void; +} + +declare var StripeCheckout: StripeCheckoutStatic; \ No newline at end of file