mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[@types/stripe] Added missing webhook endpoints (#40337)
* add webhook endpoints resource to stripe * add stripe webhook endpoints comments, tests * remove myself from defs * address pr comments
This commit is contained in:
committed by
Pranav Senthilnathan
parent
70267282de
commit
412f9a452a
322
types/stripe/index.d.ts
vendored
322
types/stripe/index.d.ts
vendored
@@ -122,6 +122,7 @@ declare class Stripe {
|
||||
setupIntents: Stripe.resources.SetupIntents;
|
||||
skus: Stripe.resources.SKUs;
|
||||
webhooks: Stripe.resources.WebHooks;
|
||||
webhookEndpoints: Stripe.resources.WebhookEndpoints;
|
||||
ephemeralKeys: Stripe.resources.EphemeralKeys;
|
||||
usageRecords: Stripe.resources.UsageRecords;
|
||||
usageRecordSummaries: Stripe.resources.UsageRecordSummaries;
|
||||
@@ -3677,6 +3678,157 @@ declare namespace Stripe {
|
||||
}
|
||||
|
||||
namespace events {
|
||||
type EventType =
|
||||
| "*"
|
||||
| "account.updated"
|
||||
| "account.application.authorized"
|
||||
| "account.application.deauthorized"
|
||||
| "account.external_account.created"
|
||||
| "account.external_account.deleted"
|
||||
| "account.external_account.updated"
|
||||
| "application_fee.created"
|
||||
| "application_fee.refunded"
|
||||
| "application_fee.refund.updated"
|
||||
| "balance.available"
|
||||
| "capability.updated"
|
||||
| "charge.captured"
|
||||
| "charge.expired"
|
||||
| "charge.failed"
|
||||
| "charge.pending"
|
||||
| "charge.refunded"
|
||||
| "charge.succeeded"
|
||||
| "charge.updated"
|
||||
| "charge.dispute.closed"
|
||||
| "charge.dispute.created"
|
||||
| "charge.dispute.funds_reinstated"
|
||||
| "charge.dispute.funds_withdrawn"
|
||||
| "charge.dispute.updated"
|
||||
| "charge.refund.updated"
|
||||
| "checkout.session.completed"
|
||||
| "coupon.created"
|
||||
| "coupon.deleted"
|
||||
| "coupon.updated"
|
||||
| "credit_note.created"
|
||||
| "credit_note.updated"
|
||||
| "credit_note.voided"
|
||||
| "customer.created"
|
||||
| "customer.deleted"
|
||||
| "customer.updated"
|
||||
| "customer.discount.created"
|
||||
| "customer.discount.deleted"
|
||||
| "customer.discount.updated"
|
||||
| "customer.source.created"
|
||||
| "customer.source.deleted"
|
||||
| "customer.source.expiring"
|
||||
| "customer.source.updated"
|
||||
| "customer.subscription.created"
|
||||
| "customer.subscription.deleted"
|
||||
| "customer.subscription.trial_will_end"
|
||||
| "customer.subscription.updated"
|
||||
| "customer.tax_id.created"
|
||||
| "customer.tax_id.deleted"
|
||||
| "customer.tax_id.updated"
|
||||
| "file.created"
|
||||
| "invoice.created"
|
||||
| "invoice.deleted"
|
||||
| "invoice.finalized"
|
||||
| "invoice.marked_uncollectible"
|
||||
| "invoice.payment_action_required"
|
||||
| "invoice.payment_failed"
|
||||
| "invoice.payment_succeeded"
|
||||
| "invoice.sent"
|
||||
| "invoice.upcoming"
|
||||
| "invoice.updated"
|
||||
| "invoice.voided"
|
||||
| "invoiceitem.created"
|
||||
| "invoiceitem.deleted"
|
||||
| "invoiceitem.updated"
|
||||
| "issuing_authorization.created"
|
||||
| "issuing_authorization.request"
|
||||
| "issuing_authorization.updated"
|
||||
| "issuing_card.created"
|
||||
| "issuing_card.updated"
|
||||
| "issuing_cardholder.created"
|
||||
| "issuing_cardholder.updated"
|
||||
| "issuing_dispute.created"
|
||||
| "issuing_dispute.updated"
|
||||
| "issuing_settlement.created"
|
||||
| "issuing_settlement.updated"
|
||||
| "issuing_transaction.created"
|
||||
| "issuing_transaction.updated"
|
||||
| "mandate.updated"
|
||||
| "order.created"
|
||||
| "order.payment_failed"
|
||||
| "order.payment_succeeded"
|
||||
| "order.updated"
|
||||
| "order_return.created"
|
||||
| "payment_intent.amount_capturable_updated"
|
||||
| "payment_intent.canceled"
|
||||
| "payment_intent.created"
|
||||
| "payment_intent.payment_failed"
|
||||
| "payment_intent.succeeded"
|
||||
| "payment_method.attached"
|
||||
| "payment_method.card_automatically_updated"
|
||||
| "payment_method.detached"
|
||||
| "payment_method.updated"
|
||||
| "payout.canceled"
|
||||
| "payout.created"
|
||||
| "payout.failed"
|
||||
| "payout.paid"
|
||||
| "payout.updated"
|
||||
| "person.created"
|
||||
| "person.deleted"
|
||||
| "person.updated"
|
||||
| "plan.created"
|
||||
| "plan.deleted"
|
||||
| "plan.updated"
|
||||
| "product.created"
|
||||
| "product.deleted"
|
||||
| "product.updated"
|
||||
| "radar.early_fraud_warning.created"
|
||||
| "radar.early_fraud_warning.updated"
|
||||
| "recipient.created"
|
||||
| "recipient.deleted"
|
||||
| "recipient.updated"
|
||||
| "reporting.report_run.failed"
|
||||
| "reporting.report_run.succeeded"
|
||||
| "reporting.report_type.updated"
|
||||
| "review.closed"
|
||||
| "review.opened"
|
||||
| "setup_intent.canceled"
|
||||
| "setup_intent.created"
|
||||
| "setup_intent.setup_failed"
|
||||
| "setup_intent.succeeded"
|
||||
| "sigma.scheduled_query_run.created"
|
||||
| "sku.created"
|
||||
| "sku.deleted"
|
||||
| "sku.updated"
|
||||
| "source.canceled"
|
||||
| "source.chargeable"
|
||||
| "source.failed"
|
||||
| "source.mandate_notification"
|
||||
| "source.refund_attributes_required"
|
||||
| "source.transaction.created"
|
||||
| "source.transaction.updated"
|
||||
| "subscription_schedule.aborted"
|
||||
| "subscription_schedule.canceled"
|
||||
| "subscription_schedule.completed"
|
||||
| "subscription_schedule.created"
|
||||
| "subscription_schedule.expiring"
|
||||
| "subscription_schedule.released"
|
||||
| "subscription_schedule.updated"
|
||||
| "tax_rate.created"
|
||||
| "tax_rate.updated"
|
||||
| "topup.created"
|
||||
| "topup.failed"
|
||||
| "topup.reversed"
|
||||
| "topup.succeeded"
|
||||
| "transfer.created"
|
||||
| "transfer.failed"
|
||||
| "transfer.paid"
|
||||
| "transfer.reversed"
|
||||
| "transfer.updated";
|
||||
|
||||
interface IEvent extends IResourceObject {
|
||||
/**
|
||||
* Value is "event"
|
||||
@@ -9484,6 +9636,114 @@ declare namespace Stripe {
|
||||
}
|
||||
}
|
||||
|
||||
namespace webhookEndpoints {
|
||||
interface IWebhookCreateOptions {
|
||||
/**
|
||||
* The URL of the webhook endpoint
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* The list of enabled events for this webhook endpoint.
|
||||
* Use '*' to enable all events, except those that require explicit selection.
|
||||
*/
|
||||
enabled_events: events.EventType[];
|
||||
|
||||
/**
|
||||
* Events sent to this endpoint will be generated with this Stripe Version instead of your
|
||||
* account’s default Stripe Version.
|
||||
*/
|
||||
api_version?: string;
|
||||
|
||||
/**
|
||||
* If true, this endpoint will receive events from connected accounts instead of just your account.
|
||||
*/
|
||||
connect?: boolean;
|
||||
}
|
||||
|
||||
interface IWebhookEndpoint extends IObject {
|
||||
/**
|
||||
* Value is 'webhook_endpoint'
|
||||
*/
|
||||
object: "webhook_endpoint";
|
||||
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Stripe API version used to render data.
|
||||
*/
|
||||
api_version: string;
|
||||
|
||||
/**
|
||||
* ID of the Application.
|
||||
*/
|
||||
application: string | null;
|
||||
|
||||
/**
|
||||
* Time at which the object was created. Measured in seconds since the Unix epoch.
|
||||
*/
|
||||
created: number;
|
||||
|
||||
/**
|
||||
* The list of enabled events for this webhook endpoint.
|
||||
* Use '*' to enable all events, except those that require explicit selection.
|
||||
*/
|
||||
enabled_events: events.EventType[];
|
||||
|
||||
/**
|
||||
* Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
*/
|
||||
livemode: boolean;
|
||||
|
||||
/**
|
||||
* The status of the webhook.
|
||||
*/
|
||||
status: "enabled" | "disabled";
|
||||
|
||||
/**
|
||||
* The URL of the webhook endpoint.
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* The endpoint’s secret, used to generate webhook signatures. Only returned at creation.
|
||||
*/
|
||||
secret?: string;
|
||||
|
||||
/**
|
||||
* Set of key-value pairs that you can attach to an object.
|
||||
* This can be useful for storing additional information about
|
||||
* the object in a structured format.
|
||||
*/
|
||||
metadata?: IMetadata;
|
||||
}
|
||||
|
||||
interface IWebhookUpdateOptions {
|
||||
/**
|
||||
* If true, it disables the webhookendpoint.
|
||||
*/
|
||||
disabled?: boolean;
|
||||
|
||||
/**
|
||||
* The list of enabled events for this webhook endpoint.
|
||||
* Use '*' to enable all events, except those that require explicit selection.
|
||||
*/
|
||||
enabled_events?: events.EventType[];
|
||||
|
||||
/**
|
||||
* The URL of the webhook endpoint.
|
||||
*/
|
||||
url?: string;
|
||||
|
||||
/**
|
||||
* Set of key-value pairs that you can attach to an object.
|
||||
* This can be useful for storing additional information about
|
||||
* the object in a structured format.
|
||||
*/
|
||||
metadata?: IMetadata;
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-unnecessary-class
|
||||
class StripeResource {
|
||||
constructor(stripe: Stripe, urlData: any);
|
||||
@@ -13910,6 +14170,68 @@ declare namespace Stripe {
|
||||
generateTestHeaderString(options: IWebHookGenerateTestHeaderStringOptions): string;
|
||||
}
|
||||
|
||||
class WebhookEndpoints {
|
||||
/**
|
||||
* Creates a new Webhook Endpoint
|
||||
*/
|
||||
create(
|
||||
data: webhookEndpoints.IWebhookCreateOptions,
|
||||
options: HeaderOptions,
|
||||
response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>,
|
||||
): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
create(data: webhookEndpoints.IWebhookCreateOptions, response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
|
||||
/**
|
||||
* Retrieves the details of an existing webhook
|
||||
*/
|
||||
retrieve(
|
||||
webhookId: string,
|
||||
data: IDataOptions,
|
||||
options: HeaderOptions,
|
||||
response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>,
|
||||
): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
retrieve(webhookId: string, data: IDataOptions, response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
retrieve(webhookId: string, options: HeaderOptions, response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
retrieve(webhookId: string, response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
|
||||
/**
|
||||
* Updates the specific webhook endpoint by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
|
||||
*
|
||||
* The parameters that can be edited are the url, the list of enabled_events, and the status of your endpoint
|
||||
*/
|
||||
update(
|
||||
webhookId: string,
|
||||
data: webhookEndpoints.IWebhookUpdateOptions,
|
||||
options: HeaderOptions,
|
||||
response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>,
|
||||
): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
update(webhookId: string, data: webhookEndpoints.IWebhookUpdateOptions, response?: IResponseFn<webhookEndpoints.IWebhookEndpoint>): Promise<webhookEndpoints.IWebhookEndpoint>;
|
||||
|
||||
/**
|
||||
* Returns a list of your webhook endpoints
|
||||
*/
|
||||
list(
|
||||
data: IListOptions,
|
||||
options: HeaderOptions,
|
||||
response?: IResponseFn<IList<webhookEndpoints.IWebhookEndpoint>>,
|
||||
): IListPromise<webhookEndpoints.IWebhookEndpoint>;
|
||||
list(data: IListOptions, response?: IResponseFn<IList<webhookEndpoints.IWebhookEndpoint>>): IListPromise<webhookEndpoints.IWebhookEndpoint>;
|
||||
list(options: HeaderOptions, response?: IResponseFn<IList<webhookEndpoints.IWebhookEndpoint>>): IListPromise<webhookEndpoints.IWebhookEndpoint>;
|
||||
list(response?: IResponseFn<IList<webhookEndpoints.IWebhookEndpoint>>): IListPromise<webhookEndpoints.IWebhookEndpoint>;
|
||||
|
||||
/**
|
||||
* Deletes a webhook endpoint.
|
||||
*
|
||||
* Webhook endpoints can also be deleted from the Stripe dashboard
|
||||
*/
|
||||
del(
|
||||
webhookId: string,
|
||||
options: HeaderOptions,
|
||||
response?: IResponseFn<IDeleteConfirmation>,
|
||||
): Promise<IDeleteConfirmation>;
|
||||
del(webhookId: string, response?: IResponseFn<IDeleteConfirmation>): Promise<IDeleteConfirmation>;
|
||||
}
|
||||
|
||||
interface IWebHookGenerateTestHeaderStringOptions {
|
||||
/**
|
||||
* Timestamp of the header. Defaults to Date.now()
|
||||
|
||||
@@ -1495,6 +1495,63 @@ const header: string = stripe.webhooks.generateTestHeaderString({
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region WebHook Endpoints tests
|
||||
// ##################################################################################
|
||||
|
||||
stripe.webhookEndpoints.create(
|
||||
{
|
||||
url: "https://example.com/success",
|
||||
enabled_events: ["plan.updated"],
|
||||
},
|
||||
(err, webhookEndpoint) => {
|
||||
// asynchronously called
|
||||
},
|
||||
);
|
||||
stripe.webhookEndpoints
|
||||
.create({
|
||||
url: "https://example.com/success",
|
||||
enabled_events: ["plan.updated"],
|
||||
})
|
||||
.then(webhookEndpoint => {
|
||||
// asynchronously called
|
||||
});
|
||||
|
||||
stripe.webhookEndpoints.retrieve('we_1FdwxEJmFhanyRvFIL756jiC', (err, webhookEndpoint) => {
|
||||
// asynchronously called
|
||||
});
|
||||
stripe.webhookEndpoints.retrieve('we_1FdwxEJmFhanyRvFIL756jiC').then(webhookEndpoint => {
|
||||
// asynchronously called
|
||||
});
|
||||
|
||||
stripe.webhookEndpoints.update(
|
||||
'we_1FdwxEJmFhanyRvFIL756jiC',
|
||||
{
|
||||
metadata: { key: 'value' },
|
||||
},
|
||||
(err: Stripe.IStripeError, webhook: Stripe.webhookEndpoints.IWebhookEndpoint) => {
|
||||
// asynchronously called
|
||||
},
|
||||
);
|
||||
stripe.webhookEndpoints
|
||||
.update('we_1FdwxEJmFhanyRvFIL756jiC', {
|
||||
metadata: { key: 'value' },
|
||||
})
|
||||
.then(coupon => {
|
||||
// asynchronously called
|
||||
});
|
||||
|
||||
stripe.webhookEndpoints.del('we_1FdwxEJmFhanyRvFIL756jiC', (err, confirmation) => {});
|
||||
stripe.webhookEndpoints.del('we_1FdwxEJmFhanyRvFIL756jiC').then(confirmation => {});
|
||||
|
||||
stripe.webhookEndpoints.list({ limit: 3 }, (err, coupons) => {
|
||||
// asynchronously called
|
||||
});
|
||||
stripe.webhookEndpoints.list({ limit: 3 }).then(coupons => {
|
||||
// asynchronously called
|
||||
});
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Coupons tests
|
||||
// ##################################################################################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user