Skip to content

Commit 79bdd9c

Browse files
committed
Add Stripe Checkout definitions
Fixes DefinitelyTyped#4366.
1 parent 70737c2 commit 79bdd9c

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// <reference path="stripe-checkout.d.ts" />
2+
3+
// Test the minimum amount of configuration required.
4+
var handler = StripeCheckout.configure({
5+
key: "my-secret-key",
6+
token: function(token: StripeTokenResponse) {
7+
console.log(token.id);
8+
}
9+
});
10+
11+
handler.open();
12+
13+
handler.close();
14+
15+
// Test all configuration options.
16+
var options = {
17+
key: "my-secret-key",
18+
token: function(token: StripeTokenResponse) {
19+
console.log(token.id);
20+
},
21+
image: "http://placehold.it/128x128",
22+
name: "Definitely Typed",
23+
description: "A DefinitelyTyped test for Stripe Checkout",
24+
amount: Number.MAX_VALUE,
25+
currency: "USD",
26+
panelLabel: "Pay Definitely Typed {{amount}}",
27+
label: "Pay Definitely Typed",
28+
zipCode: false,
29+
30+
allowRememberMe: false,
31+
bitcoin: false,
32+
opened: function() {},
33+
closed: function() {}
34+
}
35+
36+
handler = StripeCheckout.configure(options);
37+
38+
handler.open(options);

stripe-checkout/stripe-checkout.d.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Type definitions for Stripe Checkout
2+
// Project: https://stripe.com/checkout
3+
// Definitions by: Chris Wrench <https://github.com/cgwrench>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../stripe/stripe.d.ts"/>
7+
8+
interface StripeCheckoutStatic {
9+
configure(options: StripeCheckoutOptions): StripeCheckoutHandler;
10+
}
11+
12+
interface StripeCheckoutHandler {
13+
open(options?: StripeCheckoutOptions): void;
14+
close(): void;
15+
}
16+
17+
interface StripeCheckoutOptions {
18+
key: string;
19+
token: (token: StripeTokenResponse) => void;
20+
image?: string;
21+
name?: string;
22+
description?: string;
23+
amount?: number;
24+
currency?: string;
25+
panelLabel?: string;
26+
zipCode?: boolean;
27+
email?: string;
28+
label?: string;
29+
allowRememberMe?: boolean;
30+
bitcoin?: boolean;
31+
opened?: () => void;
32+
closed?: () => void;
33+
}
34+
35+
declare var StripeCheckout: StripeCheckoutStatic;

0 commit comments

Comments
 (0)