mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
stripe-node updated typings for webhook verification (#20382)
* Added stripe-node typings for webhook verification - See example on the stripe-node github for webhook signing here: https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing * Updated stripe-node types version
This commit is contained in:
committed by
Wesley Wigham
parent
972e5154d8
commit
2cdb812a31
30
types/stripe-node/index.d.ts
vendored
30
types/stripe-node/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for stripe-node 4.6.0
|
||||
// Type definitions for stripe-node 4.7.0
|
||||
// Project: https://github.com/stripe/stripe-node/
|
||||
// Definitions by: William Johnston <https://github.com/wjohnsto>, Peter Harris <https://github.com/codeanimal>
|
||||
// Definitions by: William Johnston <https://github.com/wjohnsto>, Peter Harris <https://github.com/codeanimal>, Sampson Oliver <https://github.com/sampsonjoliver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -71,7 +71,8 @@ declare namespace StripeNode {
|
||||
orders: resources.Orders;
|
||||
products: resources.Products;
|
||||
skus: resources.SKUs;
|
||||
|
||||
webhooks: resources.WebHooks;
|
||||
|
||||
setHost(host: string): void;
|
||||
setHost(host: string, port: string|number): void;
|
||||
setHost(host: string, port: string|number, protocol: string): void;
|
||||
@@ -3128,6 +3129,25 @@ declare namespace StripeNode {
|
||||
interface ISkuAttributes {}
|
||||
}
|
||||
|
||||
namespace webhooks {
|
||||
interface StripeWebhookEvent<T> {
|
||||
id: string;
|
||||
object: string;
|
||||
api_version: string;
|
||||
created: Date;
|
||||
data: {
|
||||
object: T;
|
||||
};
|
||||
livemode: boolean;
|
||||
pending_webhooks: number;
|
||||
/**
|
||||
* One of https://stripe.com/docs/api#event_types
|
||||
* E.g. account.updated
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
}
|
||||
|
||||
namespace tokens {
|
||||
interface IToken extends ICardToken, IBankAccountToken { }
|
||||
|
||||
@@ -6273,6 +6293,10 @@ declare namespace StripeNode {
|
||||
del(skuId: string, options: HeaderOptions, response?: IResponseFn<IDeleteConfirmation>): Promise<IDeleteConfirmation>;
|
||||
del(skuId: string, response?: IResponseFn<IDeleteConfirmation>): Promise<IDeleteConfirmation>;
|
||||
}
|
||||
|
||||
class WebHooks {
|
||||
constructEvent<T>(requestBody: any, signature: string | string[], endpointSecret: string): webhooks.StripeWebhookEvent<T>;
|
||||
}
|
||||
}
|
||||
|
||||
interface IObject {
|
||||
|
||||
@@ -701,6 +701,23 @@ stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkL
|
||||
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region WebHooks tests
|
||||
// ##################################################################################
|
||||
|
||||
const webhookRequest = {
|
||||
rawBody: '',
|
||||
headers: { 'stripe-signature': '' }
|
||||
};
|
||||
const webhookSecret = '';
|
||||
|
||||
const event = stripe.webhooks.constructEvent<StripeNode.subscriptions.ISubscription>(
|
||||
webhookRequest.rawBody,
|
||||
webhookRequest.headers['stripe-signature'],
|
||||
webhookSecret
|
||||
);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Coupons tests
|
||||
|
||||
Reference in New Issue
Block a user