Skip to content

Commit 9e64617

Browse files
authored
fix: add proration to transaction preview line items (#89)
1 parent 0bdda08 commit 9e64617

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a
1212

1313
This means when upgrading minor versions of the SDK, you may notice type errors. You can safely ignore these or fix by adding additional type guards.
1414

15+
## 2.2.1 - 2024-12-16
16+
17+
### Fixed
18+
19+
- Added `proration` to transaction line items
20+
1521
## 2.2.0 - 2024-12-12
1622

1723
### Added

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": "2.2.0",
3+
"version": "2.2.1",
44
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
55
"main": "dist/cjs/index.cjs.node.js",
66
"module": "dist/esm/index.esm.node.js",

src/__tests__/mocks/resources/transactions.mock.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ export const TransactionMock: ITransactionResponse = {
233233
import_meta: { external_id: '9b95b0b8-e10f-441a-862e-1936a6d818ab', imported_from: 'billing_platform' },
234234
updated_at: '2024-10-12T07:20:50.52Z',
235235
},
236+
proration: {
237+
rate: '1',
238+
billing_period: {
239+
starts_at: '2024-02-08T11:02:03.946454Z',
240+
ends_at: '2024-03-08T11:02:03.946454Z',
241+
},
242+
},
236243
},
237244
],
238245
},
@@ -399,6 +406,13 @@ export const TransactionPreviewMock: ITransactionPreviewResponse = {
399406
updated_at: '2024-10-12T07:20:50.52Z',
400407
import_meta: { external_id: '9b95b0b8-e10f-441a-862e-1936a6d818ab', imported_from: 'billing_platform' },
401408
},
409+
proration: {
410+
rate: '1',
411+
billing_period: {
412+
starts_at: '2024-02-08T11:02:03.946454Z',
413+
ends_at: '2024-03-08T11:02:03.946454Z',
414+
},
415+
},
402416
},
403417
],
404418
},

src/entities/subscription/transaction-line-item-preview.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { Totals, UnitTotals } from '../shared/index.js';
88
import { Product } from '../product/index.js';
99
import { type ITransactionLineItemPreviewResponse } from '../../types/index.js';
10+
import { Proration } from '../transaction/proration.js';
1011

1112
export class TransactionLineItemPreview {
1213
public readonly priceId: string;
@@ -15,6 +16,7 @@ export class TransactionLineItemPreview {
1516
public readonly unitTotals: UnitTotals;
1617
public readonly totals: Totals;
1718
public readonly product: Product;
19+
public readonly proration: Proration | null;
1820

1921
constructor(transactionLineItemPreview: ITransactionLineItemPreviewResponse) {
2022
this.priceId = transactionLineItemPreview.price_id;
@@ -23,5 +25,6 @@ export class TransactionLineItemPreview {
2325
this.unitTotals = new UnitTotals(transactionLineItemPreview.unit_totals);
2426
this.totals = new Totals(transactionLineItemPreview.totals);
2527
this.product = new Product(transactionLineItemPreview.product);
28+
this.proration = transactionLineItemPreview.proration ? new Proration(transactionLineItemPreview.proration) : null;
2629
}
2730
}

src/types/shared/transaction-line-item-preview-response.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { type IUnitTotals } from './unit-totals.js';
88
import { type ITotals } from './totals.js';
99
import { type IProductResponse } from '../product/index.js';
10+
import { type IProrationResponse } from '../index.js';
1011

1112
export interface ITransactionLineItemPreviewResponse {
1213
price_id: string;
@@ -15,4 +16,5 @@ export interface ITransactionLineItemPreviewResponse {
1516
unit_totals: IUnitTotals;
1617
totals: ITotals;
1718
product: IProductResponse;
19+
proration?: IProrationResponse | null;
1820
}

0 commit comments

Comments
 (0)