Skip to content

Commit e0943ff

Browse files
Handled missing unitPriceOverrides in the subscriptions.getPaymentMethodChangeTransaction operation. (#19)
1 parent a8e934e commit e0943ff

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ 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+
## 1.2.1 - 2024-03-20
16+
17+
### Fixed
18+
19+
- Handled missing `unitPriceOverrides` in the `subscriptions.getPaymentMethodChangeTransaction` operation.
20+
21+
---
22+
1523
## 1.2.0 - 2024-03-19
1624

1725
### 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": "1.2.0",
3+
"version": "1.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/index.js",
66
"types": "./dist/index.d.ts",

src/entities/price/price.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ export class Price {
3737
this.trialPeriod = price.trial_period ? new TimePeriod(price.trial_period) : null;
3838
this.taxMode = price.tax_mode;
3939
this.unitPrice = new Money(price.unit_price);
40-
this.unitPriceOverrides = price.unit_price_overrides.map(
41-
(unit_price_override) => new UnitPriceOverride(unit_price_override),
42-
);
40+
this.unitPriceOverrides =
41+
price.unit_price_overrides?.map((unit_price_override) => new UnitPriceOverride(unit_price_override)) ?? [];
4342
this.quantity = new PriceQuantity(price.quantity);
4443
this.status = price.status;
4544
this.createdAt = price.created_at;

src/notifications/entities/price/price-notification.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ export class PriceNotification {
4343
this.trialPeriod = price.trial_period ? new TimePeriodNotification(price.trial_period) : null;
4444
this.taxMode = price.tax_mode;
4545
this.unitPrice = new MoneyNotification(price.unit_price);
46-
this.unitPriceOverrides = price.unit_price_overrides.map(
47-
(unit_price_override) => new UnitPriceOverrideNotification(unit_price_override),
48-
);
46+
this.unitPriceOverrides =
47+
price.unit_price_overrides?.map(
48+
(unit_price_override) => new UnitPriceOverrideNotification(unit_price_override),
49+
) ?? [];
4950
this.quantity = new PriceQuantityNotification(price.quantity);
5051
this.status = price.status;
5152
this.createdAt = price.created_at ?? null;

src/notifications/types/price/price-notification-response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface IPriceNotificationResponse {
2525
trial_period?: ITimePeriodNotification | null;
2626
tax_mode: TaxMode;
2727
unit_price: IMoneyNotificationResponse;
28-
unit_price_overrides: IUnitPriceOverrideNotificationResponse[];
28+
unit_price_overrides: IUnitPriceOverrideNotificationResponse[] | null;
2929
quantity: IPriceQuantityNotification;
3030
status: Status;
3131
created_at?: string | null;

src/types/price/price-response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface IPriceResponse {
2525
trial_period?: ITimePeriod | null;
2626
tax_mode: TaxMode;
2727
unit_price: IMoneyResponse;
28-
unit_price_overrides: IUnitPriceOverrideResponse[];
28+
unit_price_overrides: IUnitPriceOverrideResponse[] | null;
2929
quantity: IPriceQuantity;
3030
status: Status;
3131
created_at: string;

0 commit comments

Comments
 (0)