Skip to content

Commit 401d57c

Browse files
Adding latest API changes (#2)
1 parent ebc1c17 commit 401d57c

24 files changed

+79
-16
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
99
Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-node-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.
1010

11+
## 0.4.0 - 2024-02-14
12+
13+
### Added
14+
15+
- Added `availablePaymentMethods` as an `include` Parameter to all transaction operations.
16+
- Added `importMeta` to Subscription webhooks.
17+
18+
### Changed
19+
20+
- Filter customers by email address in `customers.list()` operation, see [related changelog](https://developer.paddle.com/changelog/2024/filter-customers-email?utm_source=dx&utm_medium=paddle-node-sdk).
21+
- New payment method ID field for transaction payments, see [related changelog](https://developer.paddle.com/changelog/2024/payment-method-paddle-id?utm_source=dx&utm_medium=paddle-node-sdk).
22+
23+
### Fixed
24+
25+
- Fixed `effective_from` enum in Resume subscription operations.
26+
27+
### Deprecated
28+
29+
- Deprecated `storedPaymentMethodId` from transaction payments in favour of `paymentMethodId` field.
30+
31+
---
32+
1133
## 0.3.0 - 2024-01-11
1234

1335
### Changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paddle/paddle-node-sdk",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/__tests__/mocks/notifications/subscription-activated.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const SubscriptionActivatedMockExpectation = {
9494
startsAt: '2023-08-11T08:07:35.449123Z',
9595
},
9696
customData: null,
97+
importMeta: null,
9798
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
9899
discount: null,
99100
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/mocks/notifications/subscription-canceled.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const SubscriptionCanceledMockExpectation = {
109109
currencyCode: 'USD',
110110
currentBillingPeriod: null,
111111
customData: null,
112+
importMeta: null,
112113
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
113114
discount: null,
114115
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/mocks/notifications/subscription-created.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const SubscriptionCreatedMockExpectation = {
9494
startsAt: '2023-08-11T08:07:35.449123Z',
9595
},
9696
customData: null,
97+
importMeta: null,
9798
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
9899
discount: null,
99100
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/mocks/notifications/subscription-imported.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const SubscriptionImportedMockExpectation = {
109109
startsAt: '2023-04-13T09:07:04.730931Z',
110110
},
111111
customData: null,
112+
importMeta: null,
112113
customerId: 'ctm_01gxwxe6vzgz6hcsbwjs6zrszr',
113114
discount: null,
114115
firstBilledAt: '2023-04-13T09:07:04.730931Z',

src/__tests__/mocks/notifications/subscription-past-due.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const SubscriptionPastDueMockExpectation = {
9494
startsAt: '2023-10-11T08:07:35.449123Z',
9595
},
9696
customData: null,
97+
importMeta: null,
9798
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
9899
discount: null,
99100
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/mocks/notifications/subscription-paused.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const SubscriptionPausedMockExpectation = {
9191
currencyCode: 'USD',
9292
currentBillingPeriod: null,
9393
customData: null,
94+
importMeta: null,
9495
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
9596
discount: null,
9697
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/mocks/notifications/subscription-resumed.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const SubscriptionResumedMockExpectation = {
9494
startsAt: '2023-11-11T08:33:04.443903Z',
9595
},
9696
customData: null,
97+
importMeta: null,
9798
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
9899
discount: null,
99100
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/mocks/notifications/subscription-trialing.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const SubscriptionTrialingMockExpectation = {
7575
startsAt: '2023-08-18T13:15:46.864158Z',
7676
},
7777
customData: null,
78+
importMeta: null,
7879
customerId: 'ctm_01h84cjfwmdph1k8kgsyjt3k7g',
7980
discount: null,
8081
firstBilledAt: null,

src/__tests__/mocks/notifications/subscription-updated.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const SubscriptionUpdatedMockExpectation = {
9494
startsAt: '2023-09-11T08:07:35.449123Z',
9595
},
9696
customData: null,
97+
importMeta: null,
9798
customerId: 'ctm_01h7hswb86rtps5ggbq7ybydcw',
9899
discount: null,
99100
firstBilledAt: '2023-08-11T08:07:35.449123Z',

src/__tests__/resources/transactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('TransactionsResource', () => {
113113
const transactionsResource = new TransactionsResource(paddleInstance);
114114
const updatedTransaction = await transactionsResource.update(transactionId, transactionToBeUpdated);
115115

116-
expect(paddleInstance.patch).toBeCalledWith(`/transactions/${transactionId}`, transactionToBeUpdated);
116+
expect(paddleInstance.patch).toBeCalledWith(`/transactions/${transactionId}?`, transactionToBeUpdated);
117117
expect(updatedTransaction).toBeDefined();
118118
expect(convertToSnakeCase(UpdateTransactionMock)).toEqual(UpdateTransactionExpectation);
119119
});

src/entities/shared/transaction-payment-attempt.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { type PaymentAttemptStatus, type ErrorCode } from '../../enums';
1010

1111
export class TransactionPaymentAttempt {
1212
public readonly paymentAttemptId: string;
13+
public readonly paymentMethodId: string;
14+
/**
15+
* @deprecated use paymentMethodId instead
16+
*/
1317
public readonly storedPaymentMethodId: string;
1418
public readonly amount: string;
1519
public readonly status: PaymentAttemptStatus;
@@ -20,6 +24,7 @@ export class TransactionPaymentAttempt {
2024

2125
constructor(transactionPaymentAttempt: ITransactionPaymentAttemptResponse) {
2226
this.paymentAttemptId = transactionPaymentAttempt.payment_attempt_id;
27+
this.paymentMethodId = transactionPaymentAttempt.payment_method_id;
2328
this.storedPaymentMethodId = transactionPaymentAttempt.stored_payment_method_id;
2429
this.amount = transactionPaymentAttempt.amount;
2530
this.status = transactionPaymentAttempt.status;

src/entities/subscription/subscription-notification.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import {
88
BillingDetails,
99
type CustomData,
10+
ImportMeta,
1011
SubscriptionDiscount,
1112
SubscriptionItem,
1213
SubscriptionScheduledChange,
@@ -39,6 +40,7 @@ export class SubscriptionNotification {
3940
public readonly scheduledChange: SubscriptionScheduledChange | null;
4041
public readonly items: SubscriptionItem[];
4142
public readonly customData: CustomData | null;
43+
public readonly importMeta: ImportMeta | null;
4244

4345
constructor(subscription: ISubscriptionNotificationResponse) {
4446
this.id = subscription.id;
@@ -67,5 +69,6 @@ export class SubscriptionNotification {
6769
: null;
6870
this.items = subscription.items.map((item) => new SubscriptionItem(item));
6971
this.customData = subscription.custom_data ? subscription.custom_data : null;
72+
this.importMeta = subscription.import_meta ? new ImportMeta(subscription.import_meta) : null;
7073
}
7174
}

src/entities/transaction/transaction-includes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
TransactionsTimePeriod,
2222
} from '../index';
2323
import { type CollectionMode, type CurrencyCode, type TransactionStatus, type TransactionOrigin } from '../../enums';
24+
import { type AvailablePaymentMethod } from '../../enums/shared/available-payment-methods';
2425

2526
export class TransactionIncludes {
2627
public readonly id: string;
@@ -51,6 +52,7 @@ export class TransactionIncludes {
5152
public readonly business: Business | null;
5253
public readonly customer: Customer | null;
5354
public readonly discount: Discount | null;
55+
public readonly availablePaymentMethods: AvailablePaymentMethod[] | null;
5456

5557
constructor(transaction: ITransactionResponse) {
5658
this.id = transaction.id;
@@ -85,5 +87,6 @@ export class TransactionIncludes {
8587
this.business = transaction.business ? new Business(transaction.business) : null;
8688
this.customer = transaction.customer ? new Customer(transaction.customer) : null;
8789
this.discount = transaction.discount ? new Discount(transaction.discount) : null;
90+
this.availablePaymentMethods = transaction.available_payment_methods ? transaction.available_payment_methods : null;
8891
}
8992
}

src/resources/customers/operations/list-customer-query-parameters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export interface ListCustomerQueryParameters {
1212
perPage?: number;
1313
search?: string;
1414
status?: Status[];
15+
email?: string[];
1516
}

src/resources/subscriptions/operations/resume-subscription-request-object.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* Changes may be overwritten as part of auto-generation.
55
*/
66

7-
import { type SubscriptionEffectiveFrom } from '../../../enums';
8-
97
export interface ResumeSubscription {
10-
effectiveFrom: SubscriptionEffectiveFrom | string;
8+
effectiveFrom: 'immediately' | string;
119
}

src/resources/transactions/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
* Changes may be overwritten as part of auto-generation.
55
*/
66

7-
import {
8-
Transaction,
9-
TransactionCollection,
10-
TransactionIncludes,
11-
TransactionInvoicePDF,
12-
TransactionPreview,
13-
} from '../../entities';
7+
import { TransactionCollection, TransactionIncludes, TransactionInvoicePDF, TransactionPreview } from '../../entities';
148
import { type ErrorResponse, type Response } from '../../internal';
159
import { BaseResource, PathParameters, QueryParameters } from '../../internal/base';
1610
import {
@@ -20,6 +14,7 @@ import {
2014
type ListTransactionQueryParameters,
2115
type UpdateTransactionRequestBody,
2216
type TransactionPreviewRequestBody,
17+
type UpdateTransactionQueryParameters,
2318
} from './operations';
2419
import { type ITransactionResponse, type ITransactionInvoicePDF, type ITransactionPreviewResponse } from '../../types';
2520

@@ -55,19 +50,24 @@ export class TransactionsResource extends BaseResource {
5550
return new TransactionIncludes(data);
5651
}
5752

58-
public async update(transactionId: string, updateTransaction: UpdateTransactionRequestBody): Promise<Transaction> {
53+
public async update(
54+
transactionId: string,
55+
updateTransaction: UpdateTransactionRequestBody,
56+
queryParams?: UpdateTransactionQueryParameters,
57+
): Promise<TransactionIncludes> {
58+
const queryParameters = new QueryParameters(queryParams);
5959
const urlWithPathParams = new PathParameters(TransactionPaths.update, {
6060
transaction_id: transactionId,
6161
}).deriveUrl();
6262

6363
const response = await this.client.patch<
6464
UpdateTransactionRequestBody,
6565
Response<ITransactionResponse> | ErrorResponse
66-
>(urlWithPathParams, updateTransaction);
66+
>(urlWithPathParams + queryParameters.toQueryString(), updateTransaction);
6767

6868
const data = this.handleResponse<ITransactionResponse>(response);
6969

70-
return new Transaction(data);
70+
return new TransactionIncludes(data);
7171
}
7272

7373
public async get(transactionId: string, queryParams?: GetTransactionQueryParameters): Promise<TransactionIncludes> {

src/resources/transactions/operations/create-transaction-query-parameters.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
*/
66

77
export interface CreateTransactionQueryParameters {
8-
include?: Array<'address' | 'adjustment' | 'adjustments_totals' | 'business' | 'customer' | 'discount'>;
8+
include?: Array<
9+
'address' | 'adjustment' | 'adjustments_totals' | 'available_payment_methods' | 'business' | 'customer' | 'discount'
10+
>;
911
}

src/resources/transactions/operations/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
export * from './list-transaction-query-parameters';
88
export * from './create-transaction-query-parameters';
9+
export * from './update-transaction-query-parameters';
910
export * from './create-transaction-request-body';
1011
export * from './get-transaction-query-parameters';
1112
export * from './update-transaction-request-body';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
export interface UpdateTransactionQueryParameters {
8+
include?: Array<
9+
'address' | 'adjustment' | 'adjustments_totals' | 'available_payment_methods' | 'business' | 'customer' | 'discount'
10+
>;
11+
}

src/types/shared/transaction-payment-attempt-response.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import { type PaymentAttemptStatus, type ErrorCode } from '../../enums';
99

1010
export interface ITransactionPaymentAttemptResponse {
1111
payment_attempt_id: string;
12+
/**
13+
* @deprecated use payment_method_id instead
14+
*/
1215
stored_payment_method_id: string;
16+
payment_method_id: string;
1317
amount: string;
1418
status: PaymentAttemptStatus;
1519
error_code?: ErrorCode | null;

src/types/subscription/subscription-notification-response.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import {
88
type IBillingDetailsResponse,
99
type ICustomData,
10+
type IImportMetaResponse,
1011
type INextTransactionResponse,
1112
type ISubscriptionDiscountResponse,
1213
type ISubscriptionItemResponse,
@@ -40,6 +41,7 @@ export interface ISubscriptionNotificationResponse {
4041
scheduled_change?: ISubscriptionScheduledChangeResponse | null;
4142
items: ISubscriptionItemResponse[];
4243
custom_data?: ICustomData | null;
44+
import_meta?: IImportMetaResponse | null;
4345
next_transaction?: INextTransactionResponse | null;
4446
recurring_transaction_details?: ITransactionDetailsPreviewResponse | null;
4547
}

src/types/transaction/transaction-response.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
type IDiscountResponse,
2121
} from '../index';
2222
import { type TransactionStatus, type CurrencyCode, type TransactionOrigin, type CollectionMode } from '../../enums';
23+
import { type AvailablePaymentMethod } from '../../enums/shared/available-payment-methods';
2324

2425
export interface ITransactionResponse {
2526
id: string;
@@ -50,4 +51,5 @@ export interface ITransactionResponse {
5051
business?: IBusinessResponse | null;
5152
customer?: ICustomerResponse | null;
5253
discount?: IDiscountResponse | null;
54+
available_payment_methods?: AvailablePaymentMethod[] | null;
5355
}

0 commit comments

Comments
 (0)