diff --git a/types/braintree/braintree-tests.ts b/types/braintree/braintree-tests.ts index cee198201d..1eb48cfa7c 100644 --- a/types/braintree/braintree-tests.ts +++ b/types/braintree/braintree-tests.ts @@ -123,9 +123,26 @@ const gateway: BraintreeGateway = new braintree.BraintreeGateway({ const notification = await gateway.webhookNotification.parse(sampleResponse.bt_signature, sampleResponse.bt_payload).catch(console.error); if (!notification) return; - // this should cause the type of `notification` to be narrowed to `SubscriptionNotification` + // this should cause the type of `notification` to be narrowed to `PaymentMethodNotification` if (notification.kind !== kind) return; const metadata = notification.revokedPaymentMethodMetadata; if (!metadata.revokedPaymentMethod) return; })(); + +(async () => { + const kind: WebhookNotificationKind = 'account_updater_daily_report'; + const subscriptionId = '123456'; + + const sampleResponse = await gateway.webhookTesting.sampleNotification(kind, subscriptionId).catch(console.error); + if (!sampleResponse) return; + + const notification = await gateway.webhookNotification.parse(sampleResponse.bt_signature, sampleResponse.bt_payload).catch(console.error); + if (!notification) return; + + // this should cause the type of `notification` to be narrowed to `AccountUpdaterNotification` + if (notification.kind !== kind) return; + + const reportUrl = notification.accountUpdaterDailyReport.reportUrl; + if (!reportUrl) return; +})(); diff --git a/types/braintree/index.d.ts b/types/braintree/index.d.ts index 97bc493871..cd43432c43 100644 --- a/types/braintree/index.d.ts +++ b/types/braintree/index.d.ts @@ -827,6 +827,14 @@ declare namespace braintree { | 'VisaCheckoutCard' | 'SamsungPayCard'; + /** + * Account Updater + */ + export class AccountUpdaterDailyReport { + reportDate: Date; + reportUrl: string; + } + /** * Webhooks */ @@ -868,8 +876,7 @@ declare namespace braintree { export interface AccountUpdaterNotification extends BaseWebhookNotification { kind: AccountUpdaterNotificationKind; - reportDate: Date; - reportUrl: string; + accountUpdaterDailyReport: AccountUpdaterDailyReport; } export interface PaymentMethodNotification extends BaseWebhookNotification {