Added stripe.webhooks.generateTestHeaderString (#40292)

This commit is contained in:
Wilco Waaijer
2019-11-11 21:29:39 +01:00
committed by Pranav Senthilnathan
parent 087ed675db
commit cd9b92d298
2 changed files with 37 additions and 0 deletions

View File

@@ -13888,6 +13888,38 @@ declare namespace Stripe {
endpointSecret: string,
tolerance?: number,
): events.IEvent;
/**
* Generates a header to be used for webhook mocking
*/
generateTestHeaderString(options: IWebHookGenerateTestHeaderStringOptions): string;
}
interface IWebHookGenerateTestHeaderStringOptions {
/**
* Timestamp of the header. Defaults to Date.now()
*/
timestamp?: number;
/**
* JSON stringified payload object, containing the 'id' and 'object' parameters
*/
payload?: string;
/**
* Stripe webhook secret 'whsec_...'
*/
secret?: string;
/**
* Version of API to hit. Defaults to 'v1'.
*/
scheme?: string;
/**
* Computed webhook signature
*/
signature?: string;
}
class EphemeralKeys {

View File

@@ -1488,6 +1488,11 @@ const event: Stripe.events.IEvent = stripe.webhooks.constructEvent(
webhookSecret,
);
const header: string = stripe.webhooks.generateTestHeaderString({
payload: JSON.stringify(event),
secret: webhookSecret,
});
//#endregion
//#region Coupons tests