revert enums and change Arra<t> to T[]

This commit is contained in:
Ben Stevens
2018-02-12 21:39:34 +00:00
parent 4359c578e7
commit 6be1874774
2 changed files with 11 additions and 17 deletions
+4 -10
View File
@@ -173,9 +173,6 @@ declare namespace stripe {
type checkType = 'pass' | 'fail' | 'unavailable' | 'unchecked';
type fundingType = 'credit' | 'debit' | 'prepaid' | 'unknown';
type tokenizationType = 'apple_pay' | 'android_pay';
enum ThreeDSecureSupport {
Required = 'required', Recommended = 'recommended', Optional = 'optional', NotSupported = 'not_supported'
}
interface Card {
id: string;
object: string;
@@ -200,7 +197,7 @@ declare namespace stripe {
metadata: any;
name?: string;
tokenization_method?: tokenizationType;
three_d_secure?: ThreeDSecureSupport;
three_d_secure?: 'required' | 'recommended' | 'optional' | 'not_supported';
}
interface RetrieveSourceOptions {
@@ -219,7 +216,7 @@ declare namespace stripe {
interface StripePaymentRequestUpdateOptions {
currency: string;
total: DisplayItem;
displayItems?: Array<DisplayItem>;
displayItems?: DisplayItem[];
shippingOptions?: ShippingOption[];
}
@@ -231,13 +228,10 @@ declare namespace stripe {
requestShipping?: boolean;
}
enum UpdateDetailsStatus {
Success = 'success', Fail = 'fail', InvalidShippingAddress = 'invalid_shipping_address'
}
interface UpdateDetails {
status: UpdateDetailsStatus;
status: 'success' | 'fail' | 'invalid_shipping_address';
total?: DisplayItem;
displayItems?: Array<DisplayItem>;
displayItems?: DisplayItem[];
shippingOptions?: ShippingOption[];
}
+7 -7
View File
@@ -5,8 +5,8 @@ declare function it(desc: string, fn: () => void): void;
describe("Stripe", () => {
it("should excercise all Stripe API", () => {
const stripeInstance = Stripe('public-key');
const elements = stripeInstance.elements();
const stripe = Stripe('public-key');
const elements = stripe.elements();
const style = {
base: {
color: '#32325d',
@@ -31,7 +31,7 @@ describe("Stripe", () => {
card.on('change', (resp: stripe.elements.ElementChangeResponse) => {
console.log(resp.brand);
});
stripeInstance.createToken(card, {
stripe.createToken(card, {
name: 'Jimmy',
address_city: 'Toronto',
address_country: 'Canada'
@@ -51,7 +51,7 @@ describe("Stripe", () => {
postal_code: 'XYZ'
}
};
stripeInstance.createSource(card, { owner: ownerInfo }).then(result => {
stripe.createSource(card, { owner: ownerInfo }).then(result => {
if (result.error) {
// handle error
return Promise.resolve(null);
@@ -60,11 +60,11 @@ describe("Stripe", () => {
// handle error
return Promise.resolve(null);
}
if (!result.source.card || result.source.card.three_d_secure === stripe.ThreeDSecureSupport.NotSupported) {
if (!result.source.card || result.source.card.three_d_secure === 'not_supported') {
// make regular payment...
return Promise.resolve(null);
}
return stripeInstance.createSource({
return stripe.createSource({
type: 'three_d_secure',
amount: 100,
currency: 'usd',
@@ -101,7 +101,7 @@ describe("Stripe", () => {
});
card.destroy();
// test payment request
const paymentRequest = stripeInstance.paymentRequest({
const paymentRequest = stripe.paymentRequest({
country: 'US',
currency: 'usd',
total: {