Skip to content

Commit 0bdda08

Browse files
authored
Adjustment type and VND currency (#87)
* feat: add VND currency support * feat: add adjustment type * chore: bump version * chore: rename adjustment type * chore: rename adjustment.type to be AdjustmentActionType * chore: rename adjustment type filenames
1 parent 9d441c5 commit 0bdda08

File tree

13 files changed

+66
-8
lines changed

13 files changed

+66
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ 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.0 - 2024-12-12
16+
17+
### Added
18+
19+
- `VND` (Vietnamese dong) as new currency
20+
- Added `adjustment.type` which is either `partial` which should include `items` or `full` where `items` are not required
21+
1522
## 2.1.3 - 2024-11-29
1623

1724
### 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": "2.1.3",
3+
"version": "2.2.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/cjs/index.cjs.node.js",
66
"module": "dist/esm/index.esm.node.js",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const AdjustmentCreatedMock: IEventsResponse<IAdjustmentResponse> = {
2424
},
2525
],
2626
action: 'refund',
27+
type: 'partial',
2728
reason: 'error',
2829
status: 'pending_approval',
2930
totals: { fee: '5', tax: '8', total: '100', earnings: '87', subtotal: '92', currency_code: 'USD' },
@@ -41,6 +42,7 @@ export const AdjustmentCreatedMock: IEventsResponse<IAdjustmentResponse> = {
4142
export const AdjustmentCreatedMockExpectation = {
4243
data: {
4344
action: 'refund',
45+
type: 'partial',
4446
createdAt: '2023-08-21T14:08:43.297512Z',
4547
creditAppliedToBalance: true,
4648
currencyCode: 'USD',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const AdjustmentUpdatedMock: IEventsResponse<IAdjustmentResponse> = {
2424
},
2525
],
2626
action: 'refund',
27+
type: 'partial',
2728
reason: 'error',
2829
status: 'approved',
2930
totals: { fee: '5', tax: '8', total: '100', earnings: '87', subtotal: '92', currency_code: 'USD' },
@@ -41,6 +42,7 @@ export const AdjustmentUpdatedMock: IEventsResponse<IAdjustmentResponse> = {
4142
export const AdjustmentUpdatedMockExpectation = {
4243
data: {
4344
action: 'refund',
45+
type: 'partial',
4446
createdAt: '2023-08-21T14:08:43.297512Z',
4547
creditAppliedToBalance: true,
4648
currencyCode: 'USD',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const CreateAdjustmentExpectation = {
3636

3737
export const AdjustmentMock: IAdjustmentResponse = {
3838
action: 'credit',
39+
type: 'partial',
3940
items: [
4041
{
4142
amount: '1000',

src/entities/adjustment/adjustment.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
* Changes may be overwritten as part of auto-generation.
55
*/
66

7-
import { type AdjustmentAction, type AdjustmentStatus, type CurrencyCode } from '../../enums/index.js';
7+
import {
8+
type AdjustmentActionType,
9+
type AdjustmentAction,
10+
type AdjustmentStatus,
11+
type CurrencyCode,
12+
} from '../../enums/index.js';
813
import { AdjustmentItem } from './adjustment-item.js';
914
import { PayoutTotalsAdjustment, TotalAdjustments } from '../shared/index.js';
1015
import { type IAdjustmentResponse } from '../../types/index.js';
1116

1217
export class Adjustment {
1318
public readonly id: string;
1419
public readonly action: AdjustmentAction;
20+
public readonly type: AdjustmentActionType;
1521
public readonly transactionId: string;
1622
public readonly subscriptionId: string | null;
1723
public readonly customerId: string;
@@ -28,6 +34,7 @@ export class Adjustment {
2834
constructor(adjustment: IAdjustmentResponse) {
2935
this.id = adjustment.id;
3036
this.action = adjustment.action;
37+
this.type = adjustment.type;
3138
this.transactionId = adjustment.transaction_id;
3239
this.subscriptionId = adjustment.subscription_id ? adjustment.subscription_id : null;
3340
this.customerId = adjustment.customer_id;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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 type AdjustmentActionType = 'full' | 'partial';

src/enums/adjustment/index.ts

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

7-
export * from './adjustment-type.js';
8-
export * from './adjustment-currency-code.js';
7+
export * from './adjustment-action-type.js';
98
export * from './adjustment-action.js';
9+
export * from './adjustment-currency-code.js';
1010
export * from './adjustment-status.js';
11+
export * from './adjustment-type.js';

src/enums/shared/currency-code.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Do not make changes to this file.
44
* Changes may be overwritten as part of auto-generation.
55
*/
6+
67
export type CurrencyCode =
78
| 'USD'
89
| 'EUR'
@@ -33,4 +34,5 @@ export type CurrencyCode =
3334
| 'TRY'
3435
| 'TWD'
3536
| 'UAH'
37+
| 'VND'
3638
| 'ZAR';

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
* Changes may be overwritten as part of auto-generation.
55
*/
66

7-
import { type AdjustmentAction, type AdjustmentStatus, type CurrencyCode } from '../../../enums/index.js';
7+
import {
8+
type AdjustmentActionType,
9+
type AdjustmentAction,
10+
type AdjustmentStatus,
11+
type CurrencyCode,
12+
} from '../../../enums/index.js';
813
import { AdjustmentItemNotification } from './adjustment-item-notification.js';
914
import { PayoutTotalsAdjustmentNotification, TotalAdjustmentsNotification } from '../shared/index.js';
1015
import { type IAdjustmentNotificationResponse } from '../../types/index.js';
1116

1217
export class AdjustmentNotification {
1318
public readonly id: string;
1419
public readonly action: AdjustmentAction;
20+
public readonly type: AdjustmentActionType;
1521
public readonly transactionId: string;
1622
public readonly subscriptionId: string | null;
1723
public readonly customerId: string;
@@ -28,6 +34,7 @@ export class AdjustmentNotification {
2834
constructor(adjustment: IAdjustmentNotificationResponse) {
2935
this.id = adjustment.id;
3036
this.action = adjustment.action;
37+
this.type = adjustment.type;
3138
this.transactionId = adjustment.transaction_id;
3239
this.subscriptionId = adjustment.subscription_id ? adjustment.subscription_id : null;
3340
this.customerId = adjustment.customer_id;

0 commit comments

Comments
 (0)