Add Stripe Checkout definitions

Fixes #4366.
This commit is contained in:
Chris Wrench 2015-05-27 15:20:33 +01:00
parent 70737c2a24
commit 79bdd9caf3
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,38 @@
/// <reference path="stripe-checkout.d.ts" />
// 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);

35
stripe-checkout/stripe-checkout.d.ts vendored Normal file
View File

@ -0,0 +1,35 @@
// Type definitions for Stripe Checkout
// Project: https://stripe.com/checkout
// Definitions by: Chris Wrench <https://github.com/cgwrench>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../stripe/stripe.d.ts"/>
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;