Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions types/braintree/braintree-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ const gateway: BraintreeGateway = new braintree.BraintreeGateway({
escrowStatus === Transaction.EscrowStatus.Refunded;

// Assert overlap between source and static field
"Api" === Transaction.Source.Api;
"Recurring" === Transaction.Source.Recurring;
"ControlPanel" === Transaction.Source.ControlPanel;
"api" === Transaction.Source.Api;
"recurring" === Transaction.Source.Recurring;
"control_panel" === Transaction.Source.ControlPanel;

// Assert overlap between created using and static field
"token" === Transaction.CreatedUsing.Token;
Expand Down Expand Up @@ -262,13 +262,17 @@ const gateway: BraintreeGateway = new braintree.BraintreeGateway({

// $ExpectType string
subscription.nextBillingDate;
subscription.firstBillingDate;

// Assert overlap between subscription status and static field
subscription.status === braintree.Subscription.Status.Active;
subscription.status === braintree.Subscription.Status.Canceled;
subscription.status === braintree.Subscription.Status.Expired;
subscription.status === braintree.Subscription.Status.PastDue;
subscription.status === braintree.Subscription.Status.Pending;

// $ExpectType ValidatedResponse<Subscription>
const cancelResult = await gateway.subscription.cancel("subscriptionId");
})();

// $ExpectType () => string[]
Expand Down
49 changes: 25 additions & 24 deletions types/braintree/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ declare namespace braintree {
}

interface SubscriptionGateway {
cancel(subscriptionId: string): Promise<Subscription>;
cancel(subscriptionId: string): Promise<ValidatedResponse<Subscription>>;
create(request: SubscriptionCreateRequest): Promise<ValidatedResponse<Subscription>>;
find(subscriptionId: string): Promise<Subscription>;
retryCharge(
Expand Down Expand Up @@ -793,9 +793,9 @@ declare namespace braintree {
reason: string;
reasonCode: string;
reasonDescription: string;
receivedDate: Date;
receivedDate: string;
referenceNumber: string;
replyByDate: Date;
replyByDate: string;
status: DisputeStatus;
statusHistory: DisputeStatusHistory[];
transaction: {
Expand All @@ -812,17 +812,17 @@ declare namespace braintree {
export type DisputeStatus = "Accepted" | "Disputed" | "Expired" | "Open" | "Lost" | "Won";

export interface DisputeStatusHistory {
disbursementDate: Date;
effectiveDate: Date;
disbursementDate: string;
effectiveDate: string;
status: DisputeStatus;
timestamp: Date;
timestamp: string;
}

export interface Evidence {
comment?: string | undefined;
createdAt: string;
id: string;
sendToProcessorAt: Date;
sendToProcessorAt: string;
url?: string | undefined;
}

Expand All @@ -838,7 +838,7 @@ declare namespace braintree {

id: string;
amount: string;
disbursementDate: Date;
disbursementDate: string;
disbursementType: DisbursementType;
transactionIds: string[];
merchantAccount: DisbursementMerchantAccount;
Expand Down Expand Up @@ -1127,7 +1127,7 @@ declare namespace braintree {
* Account Updater
*/
export class AccountUpdaterDailyReport {
reportDate: Date;
reportDate: string;
reportUrl: string;
}

Expand All @@ -1142,7 +1142,7 @@ declare namespace braintree {

export interface BaseWebhookNotification {
kind: WebhookNotificationKind;
timestamp: Date;
timestamp: string;
}

export interface TransactionNotification extends BaseWebhookNotification {
Expand Down Expand Up @@ -1218,7 +1218,8 @@ declare namespace braintree {
| "subscription_expired"
| "subscription_trial_ended"
| "subscription_went_active"
| "subscription_went_past_due";
| "subscription_went_past_due"
| "subscription_billing_skipped";

export type SubMerchantAccountApprovedNotificationKind = "sub_merchant_account_approved";

Expand Down Expand Up @@ -1339,15 +1340,15 @@ declare namespace braintree {
descriptor?: Descriptor | undefined;
discounts?: Discount[] | undefined;
failureCount?: number | undefined;
firstBillingDate?: Date | undefined;
firstBillingDate?: string | undefined;
id: string;
merchantAccountId: string;
neverExpires?: boolean | undefined;
nextBillAmount: string;
nextBillingDate: string;
nextBillingPeriodAmount: string;
numberOfBillingCycles?: number | undefined;
paidThroughDate?: Date | undefined;
paidThroughDate?: string | undefined;
paymentMethodToken: string;
planId: string;
price?: string | undefined;
Expand Down Expand Up @@ -1451,9 +1452,9 @@ declare namespace braintree {
};

static Source: {
Api: "Api";
ControlPanel: "ControlPanel";
Recurring: "Recurring";
Api: "api";
ControlPanel: "control_panel";
Recurring: "recurring";
};

static CreatedUsing: {
Expand Down Expand Up @@ -1540,7 +1541,7 @@ declare namespace braintree {
}
| undefined;
authorizationAdjustments?: AuthorizationAdjustment[] | undefined;
authorizationExpiresAt?: Date | undefined;
authorizationExpiresAt?: string | undefined;
avsErrorResponseCode: string;
avsPostalCodeResponseCode: string;
avsStreetAddressResponseCode: string;
Expand Down Expand Up @@ -1726,8 +1727,8 @@ declare namespace braintree {
statusHistory?: TransactionStatusHistory[] | undefined;
subscription?:
| {
billingPeriodEndDate: Date;
billingPeriodStartDate: Date;
billingPeriodEndDate: string;
billingPeriodStartDate: string;
}
| undefined;
subscriptionId?: string | undefined;
Expand Down Expand Up @@ -1913,7 +1914,7 @@ declare namespace braintree {
export interface AuthorizationAdjustment {
amount: string;
success: boolean;
timestamp: Date;
timestamp: string;
processorResponseType: string;
processorResponseCode: string;
processorResponseText: string;
Expand All @@ -1926,7 +1927,7 @@ declare namespace braintree {
}

export interface DisbursementDetails {
disbursementDate: Date;
disbursementDate: string;
fundsHeld: boolean;
settlementAmount: string;
settlementCurrencyExchangeRate: string;
Expand Down Expand Up @@ -1998,12 +1999,12 @@ declare namespace braintree {
export interface TransactionStatusHistory {
amount: string;
status: TransactionStatus;
timestamp: Date;
transactionsource: TransactionSource;
timestamp: string;
transactionSource: TransactionSource;
user: string;
}

export type TransactionSource = "Api" | "ControlPanel" | "Recurring";
export type TransactionSource = "api" | "control_panel" | "recurring";

export interface TransactionThreeDSecureInfo {
enrolled: string;
Expand Down