mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
[braintree] Move webhook notifications to their own types (#41922)
* Adds account updater webhook fields * Create WebhookNotification subclasses * Use x as T syntax
This commit is contained in:
@@ -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;
|
||||
})();
|
||||
|
||||
Vendored
+26
-5
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user