Skip to content

Commit

Permalink
fix: add proration to transaction preview line items (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
danbillson authored Dec 16, 2024
1 parent 0bdda08 commit 9e64617
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a

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.

## 2.2.1 - 2024-12-16

### Fixed

- Added `proration` to transaction line items

## 2.2.0 - 2024-12-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paddle/paddle-node-sdk",
"version": "2.2.0",
"version": "2.2.1",
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
"main": "dist/cjs/index.cjs.node.js",
"module": "dist/esm/index.esm.node.js",
Expand Down
14 changes: 14 additions & 0 deletions src/__tests__/mocks/resources/transactions.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ export const TransactionMock: ITransactionResponse = {
import_meta: { external_id: '9b95b0b8-e10f-441a-862e-1936a6d818ab', imported_from: 'billing_platform' },
updated_at: '2024-10-12T07:20:50.52Z',
},
proration: {
rate: '1',
billing_period: {
starts_at: '2024-02-08T11:02:03.946454Z',
ends_at: '2024-03-08T11:02:03.946454Z',
},
},
},
],
},
Expand Down Expand Up @@ -399,6 +406,13 @@ export const TransactionPreviewMock: ITransactionPreviewResponse = {
updated_at: '2024-10-12T07:20:50.52Z',
import_meta: { external_id: '9b95b0b8-e10f-441a-862e-1936a6d818ab', imported_from: 'billing_platform' },
},
proration: {
rate: '1',
billing_period: {
starts_at: '2024-02-08T11:02:03.946454Z',
ends_at: '2024-03-08T11:02:03.946454Z',
},
},
},
],
},
Expand Down
3 changes: 3 additions & 0 deletions src/entities/subscription/transaction-line-item-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { Totals, UnitTotals } from '../shared/index.js';
import { Product } from '../product/index.js';
import { type ITransactionLineItemPreviewResponse } from '../../types/index.js';
import { Proration } from '../transaction/proration.js';

export class TransactionLineItemPreview {
public readonly priceId: string;
Expand All @@ -15,6 +16,7 @@ export class TransactionLineItemPreview {
public readonly unitTotals: UnitTotals;
public readonly totals: Totals;
public readonly product: Product;
public readonly proration: Proration | null;

constructor(transactionLineItemPreview: ITransactionLineItemPreviewResponse) {
this.priceId = transactionLineItemPreview.price_id;
Expand All @@ -23,5 +25,6 @@ export class TransactionLineItemPreview {
this.unitTotals = new UnitTotals(transactionLineItemPreview.unit_totals);
this.totals = new Totals(transactionLineItemPreview.totals);
this.product = new Product(transactionLineItemPreview.product);
this.proration = transactionLineItemPreview.proration ? new Proration(transactionLineItemPreview.proration) : null;
}
}
2 changes: 2 additions & 0 deletions src/types/shared/transaction-line-item-preview-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { type IUnitTotals } from './unit-totals.js';
import { type ITotals } from './totals.js';
import { type IProductResponse } from '../product/index.js';
import { type IProrationResponse } from '../index.js';

export interface ITransactionLineItemPreviewResponse {
price_id: string;
Expand All @@ -15,4 +16,5 @@ export interface ITransactionLineItemPreviewResponse {
unit_totals: IUnitTotals;
totals: ITotals;
product: IProductResponse;
proration?: IProrationResponse | null;
}

0 comments on commit 9e64617

Please sign in to comment.