diff --git a/types/braintree/braintree-tests.ts b/types/braintree/braintree-tests.ts index 2de2377a94..939c59cbbb 100644 --- a/types/braintree/braintree-tests.ts +++ b/types/braintree/braintree-tests.ts @@ -14,9 +14,8 @@ import { PaymentMethod, PaymentMethodNonce, Transaction, - SampleNotification, - WebhookNotification, WebhookNotificationKind, + SubscriptionNotification, } from 'braintree'; /** @@ -109,5 +108,6 @@ const gateway: BraintreeGateway = new braintree.BraintreeGateway({ const notificationResponse = await gateway.webhookNotification.parse(sampleResponse.bt_signature, sampleResponse.bt_payload).catch(console.error); if (!notificationResponse) return; - const notification: WebhookNotification = notificationResponse; + const notification: SubscriptionNotification = notificationResponse as SubscriptionNotification; + const subscription = notification.subscription; })(); diff --git a/types/braintree/index.d.ts b/types/braintree/index.d.ts index 456c2856ba..d4b682fc4b 100644 --- a/types/braintree/index.d.ts +++ b/types/braintree/index.d.ts @@ -836,13 +836,34 @@ declare namespace braintree { bt_payload: string; } - export class WebhookNotification { + export abstract class WebhookNotification { kind: WebhookNotificationKind; timestamp: Date; - subscription?: Subscription; - merchantAccount?: MerchantAccount; - transaction?: Transaction; - dispute?: Dispute; + } + + export class TransactionNotification extends WebhookNotification { + transaction: Transaction; + } + + export class SubMerchantAccountApprovedNotification extends WebhookNotification { + merchantAccount: MerchantAccount; + } + + export class SubMerchantAccountDeclinedNotification extends WebhookNotification { + merchantAccount: MerchantAccount; + } + + export class SubscriptionNotification extends WebhookNotification { + subscription: Subscription; + } + + export class DisputeNotification extends WebhookNotification { + dispute: Dispute; + } + + export class AccountUpdaterNotification extends WebhookNotification { + reportDate: Date; + reportUrl: string; } export type WebhookNotificationKind =