@paddle/paddle-node-sdk 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +90 -106
- package/dist/entities/subscription/transaction-line-item-preview.d.ts +1 -1
- package/dist/entities/transaction/address-preview.d.ts +8 -0
- package/dist/entities/transaction/address-preview.js +16 -0
- package/dist/entities/transaction/index.d.ts +4 -0
- package/dist/entities/transaction/index.js +4 -0
- package/dist/entities/transaction/proration.d.ts +8 -0
- package/dist/entities/transaction/proration.js +17 -0
- package/dist/entities/transaction/transaction-item-preview.d.ts +10 -0
- package/dist/entities/transaction/transaction-item-preview.js +21 -0
- package/dist/entities/transaction/transaction-preview.d.ts +17 -0
- package/dist/entities/transaction/transaction-preview.js +33 -0
- package/dist/resources/transactions/index.d.ts +3 -2
- package/dist/resources/transactions/index.js +8 -0
- package/dist/resources/transactions/operations/index.d.ts +1 -0
- package/dist/resources/transactions/operations/index.js +1 -0
- package/dist/resources/transactions/operations/transaction-preview-request-body.d.ts +17 -0
- package/dist/resources/transactions/operations/transaction-preview-request-body.js +2 -0
- package/dist/types/shared/transaction-line-item-preview.d.ts +1 -1
- package/dist/types/transaction/index.d.ts +2 -0
- package/dist/types/transaction/index.js +2 -0
- package/dist/types/transaction/transaction-preview-item.d.ts +5 -0
- package/dist/types/transaction/transaction-preview-item.js +2 -0
- package/dist/types/transaction/transaction-preview.d.ts +27 -0
- package/dist/types/transaction/transaction-preview.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
|
|
7
|
+
> **Important:** While in early access(version 0.X.Y) we may introduce breaking changes. Where we can, we'll tag breaking changes in this changelog and communicate ahead of time.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## 0.1.8 - 2023-11-24
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Added `transactions.preview()` to [preview a transaction](https://developer.paddle.com/api-reference/transactions/preview-transaction?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 0.1.7 - 2023-11-23
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Added changelog.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 0.1.6 - 2023-11-22
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Fixed optional management URL object in subscription entities.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 0.1.5 - 2023-11-14
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- Added `transactions.getInvoicePDF()` for the [get a PDF invoice for a transaction](https://developer.paddle.com/api-reference/transactions/get-invoice-pdf?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
40
|
+
- Enabled request and response logging.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 0.1.4 - 2023-11-09
|
|
45
|
+
|
|
46
|
+
### Removed
|
|
47
|
+
|
|
48
|
+
- Removed unused dependency `lodash`.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 0.1.3 - 2023-11-08
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- Added missing query parameters for the [list transactions](https://developer.paddle.com/api-reference/transactions/list-transactions?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 0.1.2 - 2023-11-06
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
|
|
64
|
+
- Fixed incorrect update subscription request body TypeScript definition.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 0.1.1 - 2023-11-06
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- Added `customers.getCreditBalance()` for the [list credit balances for a customer](https://developer.paddle.com/api-reference/customers/list-credit-balances?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
73
|
+
- Added `subscriptions.previewUpdate()` for the [preview an update to a subscription](https://developer.paddle.com/api-reference/subscriptions/preview-subscription?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
74
|
+
- Added `subscriptions.activate()` for the [activate a trialing subscription](https://developer.paddle.com/api-reference/subscriptions/activate-subscription?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
75
|
+
- Added `subscriptions.pause()` for the [pause a subscription](https://developer.paddle.com/api-reference/subscriptions/pause-subscription?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
76
|
+
- Added `subscriptions.resume()` for the [resume a paused subscription](https://developer.paddle.com/api-reference/subscriptions/resume-subscription?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
77
|
+
- Added `subscriptions.cancel()` for the [cancel a subscription](https://developer.paddle.com/api-reference/subscriptions/cancel-subscription?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
78
|
+
- Added `subscriptions.createOneTimeCharge()` for the [create a one-time charge for a subscription](https://developer.paddle.com/api-reference/subscriptions/create-one-time-charge?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
79
|
+
- Added `subscriptions.previewOneTimeCharge()` for the [preview a one-time charge for a subscription](https://developer.paddle.com/api-reference/subscriptions/preview-subscription-charge?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
80
|
+
- Added `subscriptions.getPaymentMethodChangeTransaction()` for the [get a transaction to update payment method](https://developer.paddle.com/api-reference/subscriptions/update-payment-method?utm_source=dx&utm_medium=paddle-node-sdk) operation.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 0.1.0 - 2023-11-03
|
|
85
|
+
|
|
86
|
+
### Added
|
|
87
|
+
|
|
88
|
+
- Initial early access release. Added support for the most frequently used Paddle Billing entities and API operations. Check the [README](./README.md) for more information.
|
package/README.md
CHANGED
|
@@ -44,29 +44,16 @@ To authenticate, you'll need an API key. You can create and manage API keys in *
|
|
|
44
44
|
Pass your API key while initializing a new Paddle client.
|
|
45
45
|
|
|
46
46
|
``` typescript
|
|
47
|
-
import { Environment, Paddle } from '@paddle/paddle-node-sdk'
|
|
47
|
+
import { Environment, Paddle } from '@paddle/paddle-node-sdk'
|
|
48
48
|
|
|
49
|
-
...
|
|
50
49
|
const paddle = new Paddle('API_KEY')
|
|
51
|
-
...
|
|
52
|
-
|
|
53
|
-
async function getProducts() {
|
|
54
|
-
try {
|
|
55
|
-
const productCollection = await paddle.products.list()
|
|
56
|
-
return productCollection.next()
|
|
57
|
-
} catch (e) {
|
|
58
|
-
// Handle Network/API errors
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const products = await getProducts()
|
|
63
50
|
```
|
|
64
51
|
|
|
65
52
|
You can also pass an environment to work with the sandbox:
|
|
66
53
|
|
|
67
54
|
```typescript
|
|
68
55
|
const paddle = new Paddle('API_KEY', {
|
|
69
|
-
environment:
|
|
56
|
+
environment: Environment.production, // or Environment.sandbox for accessing sandbox API
|
|
70
57
|
})
|
|
71
58
|
```
|
|
72
59
|
|
|
@@ -83,28 +70,28 @@ This SDK comes with TypeScript definitions for the Paddle API. We recommend that
|
|
|
83
70
|
You can list supported entities with the `list` function in the resource. It returns an iterator to help when working with multiple pages.
|
|
84
71
|
|
|
85
72
|
``` typescript
|
|
86
|
-
import {
|
|
73
|
+
import { Paddle } from '@paddle/paddle-node-sdk'
|
|
87
74
|
|
|
88
|
-
...
|
|
89
75
|
const paddle = new Paddle('API_KEY')
|
|
90
|
-
...
|
|
91
76
|
|
|
92
77
|
async function getProducts() {
|
|
93
78
|
// creates an iterator instance
|
|
94
|
-
const productCollection = await paddle.products.list()
|
|
95
|
-
return productCollection
|
|
79
|
+
const productCollection = await paddle.products.list()
|
|
80
|
+
return productCollection
|
|
96
81
|
}
|
|
97
82
|
|
|
98
83
|
try {
|
|
99
84
|
// Creates an iterator to loop through paginated data.
|
|
100
85
|
// At this point, It does not hold any data.
|
|
101
|
-
const productCollection = await getProducts()
|
|
86
|
+
const productCollection = await getProducts()
|
|
102
87
|
|
|
103
88
|
// Call `next()` to retrieve first page of the dataset
|
|
104
89
|
const firstPage = await productCollection.next()
|
|
90
|
+
console.log("First page data", firstPage)
|
|
105
91
|
|
|
106
92
|
// Calling `next()` again will retrieve subsequent pages.
|
|
107
93
|
const secondPage = await productCollection.next()
|
|
94
|
+
console.log("Second page data", secondPage)
|
|
108
95
|
} catch (e) {
|
|
109
96
|
// Handle Network/API errors
|
|
110
97
|
}
|
|
@@ -115,11 +102,9 @@ try {
|
|
|
115
102
|
You can create a supported entity with the `create` function in the resource. It accepts the body to be created. The created entity is returned.
|
|
116
103
|
|
|
117
104
|
``` typescript
|
|
118
|
-
import {
|
|
105
|
+
import { Paddle, CreateProductRequestBody } from '@paddle/paddle-node-sdk'
|
|
119
106
|
|
|
120
|
-
...
|
|
121
107
|
const paddle = new Paddle('API_KEY')
|
|
122
|
-
...
|
|
123
108
|
|
|
124
109
|
async function createProduct(requestBody: CreateProductRequestBody) {
|
|
125
110
|
try {
|
|
@@ -132,7 +117,8 @@ async function createProduct(requestBody: CreateProductRequestBody) {
|
|
|
132
117
|
}
|
|
133
118
|
}
|
|
134
119
|
|
|
135
|
-
const product = await createProduct({
|
|
120
|
+
const product = await createProduct({ name: 'ChatApp Education', tax_category: 'standard' })
|
|
121
|
+
console.log("Product", product)
|
|
136
122
|
```
|
|
137
123
|
|
|
138
124
|
### Update an entity
|
|
@@ -140,11 +126,9 @@ const product = await createProduct({... object with required attributes})
|
|
|
140
126
|
You can update a supported entity with the `update` function in the resource. It accepts the `id` of the entity to update and an object with the attributes to be updated. The updated entity is returned.
|
|
141
127
|
|
|
142
128
|
``` typescript
|
|
143
|
-
import {
|
|
129
|
+
import { Paddle, UpdateProductRequestBody } from '@paddle/paddle-node-sdk'
|
|
144
130
|
|
|
145
|
-
...
|
|
146
131
|
const paddle = new Paddle('API_KEY')
|
|
147
|
-
...
|
|
148
132
|
|
|
149
133
|
async function updateProduct(productId: string, requestBody: UpdateProductRequestBody) {
|
|
150
134
|
try {
|
|
@@ -157,7 +141,8 @@ async function updateProduct(productId: string, requestBody: UpdateProductReques
|
|
|
157
141
|
}
|
|
158
142
|
}
|
|
159
143
|
|
|
160
|
-
const product = await updateProduct('id', {
|
|
144
|
+
const product = await updateProduct('id', { name: 'ChatApp for Schools' })
|
|
145
|
+
console.log('Updated product', product)
|
|
161
146
|
```
|
|
162
147
|
|
|
163
148
|
Where operations require more than one `id`, the `update` function accepts multiple arguments. For example, to update an address for a customer, pass the `customerId` and the `addressId`:
|
|
@@ -171,11 +156,9 @@ const address = await paddle.addresses.update(customerId, addressId, requestBody
|
|
|
171
156
|
You can get an entity with the `get` function in the resource. It accepts the `id` of the entity to get. The entity is returned.
|
|
172
157
|
|
|
173
158
|
``` typescript
|
|
174
|
-
import {
|
|
159
|
+
import { Paddle } from '@paddle/paddle-node-sdk'
|
|
175
160
|
|
|
176
|
-
...
|
|
177
161
|
const paddle = new Paddle('API_KEY')
|
|
178
|
-
...
|
|
179
162
|
|
|
180
163
|
async function getProduct(productId: string) {
|
|
181
164
|
try {
|
|
@@ -189,6 +172,7 @@ async function getProduct(productId: string) {
|
|
|
189
172
|
}
|
|
190
173
|
|
|
191
174
|
const product = await getProduct('id')
|
|
175
|
+
console.log('Product', product)
|
|
192
176
|
```
|
|
193
177
|
|
|
194
178
|
## Resources
|
|
@@ -198,7 +182,7 @@ const product = await getProduct('id')
|
|
|
198
182
|
The SDK includes a helper function to verify webhook signatures sent by Notifications from Paddle.
|
|
199
183
|
|
|
200
184
|
```typescript
|
|
201
|
-
import { NotificationsValidator } from '@paddle/paddle-node-sdk'
|
|
185
|
+
import { NotificationsValidator } from '@paddle/paddle-node-sdk'
|
|
202
186
|
|
|
203
187
|
|
|
204
188
|
const isValid = new NotificationsValidator().isValidSignature('RAW_UNFORMATTED_REQUEST_BODY', 'PRIVATE_KEY_FROM_DASHBOARD', 'SIGNATURE_FROM_RESPONSE_HEADER')
|
|
@@ -210,79 +194,79 @@ While in early access, not all operations in the Paddle API are available in our
|
|
|
210
194
|
|
|
211
195
|
This table shows which operations are available as of the latest release.
|
|
212
196
|
|
|
213
|
-
| Paddle API operation |
|
|
214
|
-
|
|
215
|
-
| **Products** |
|
|
216
|
-
| List products |
|
|
217
|
-
| Create a product |
|
|
218
|
-
| Get a product |
|
|
219
|
-
| Update a product |
|
|
220
|
-
| **Prices** |
|
|
221
|
-
| List prices |
|
|
222
|
-
| Create a price |
|
|
223
|
-
| Get a price |
|
|
224
|
-
| Update a price |
|
|
225
|
-
| **Discounts** |
|
|
226
|
-
| List discounts |
|
|
227
|
-
| Create a discount |
|
|
228
|
-
| Get a discount |
|
|
229
|
-
| Update a discount |
|
|
230
|
-
| **Customers** |
|
|
231
|
-
| List customers |
|
|
232
|
-
| Create a customer |
|
|
233
|
-
| Get a customer |
|
|
234
|
-
| Update a customer |
|
|
235
|
-
| List credit balances for a customer |
|
|
236
|
-
| **Addresses** |
|
|
237
|
-
| List addresses for a customer |
|
|
238
|
-
| Create an addresses for a customer |
|
|
239
|
-
| Get an address for a customer |
|
|
240
|
-
| Update an address for a customer |
|
|
241
|
-
| **Businesses** |
|
|
242
|
-
| List businesses for a customer |
|
|
243
|
-
| Create a business for a customer |
|
|
244
|
-
| Get a business for a customer |
|
|
245
|
-
| Update a business for a customer |
|
|
246
|
-
| **Transactions** | **
|
|
247
|
-
| List transactions |
|
|
248
|
-
| Create a transaction |
|
|
249
|
-
| Get a transaction |
|
|
250
|
-
| Update a transaction |
|
|
251
|
-
| Preview a transaction |
|
|
252
|
-
| Get a PDF invoice for a transaction |
|
|
253
|
-
| **Subscriptions** |
|
|
254
|
-
| List subscriptions |
|
|
255
|
-
| Get a subscription |
|
|
256
|
-
| Preview an update to a subscription |
|
|
257
|
-
| Update a subscription |
|
|
258
|
-
| Get a transaction to update payment method |
|
|
259
|
-
| Preview a one-time charge for a subscription |
|
|
260
|
-
| Create a one-time charge for a subscription |
|
|
261
|
-
| Activate a trialing subscription |
|
|
262
|
-
| Pause a subscription |
|
|
263
|
-
| Resume a paused subscription |
|
|
264
|
-
| Cancel a subscription |
|
|
265
|
-
| **Adjustments** |
|
|
266
|
-
| List adjustments |
|
|
267
|
-
| Create an adjustment |
|
|
268
|
-
| **Pricing preview** |
|
|
269
|
-
| Preview prices |
|
|
270
|
-
| **Event types** |
|
|
271
|
-
| List event types |
|
|
272
|
-
| **Events** |
|
|
273
|
-
| List events |
|
|
274
|
-
| **Notification settings** |
|
|
275
|
-
| List notification settings |
|
|
276
|
-
| Create a notification setting |
|
|
277
|
-
| Get a notification setting |
|
|
278
|
-
| Update a notification setting |
|
|
279
|
-
| Delete a notification setting |
|
|
280
|
-
| **Notifications** |
|
|
281
|
-
| List notifications |
|
|
282
|
-
| Get a notification |
|
|
283
|
-
| Replay a notification |
|
|
284
|
-
| **Notification logs** |
|
|
285
|
-
| List logs for a notification |
|
|
197
|
+
| Paddle API operation | Support |
|
|
198
|
+
|----------------------------------------------|:--------:|
|
|
199
|
+
| **Products** | **Full** |
|
|
200
|
+
| List products | ✅ |
|
|
201
|
+
| Create a product | ✅ |
|
|
202
|
+
| Get a product | ✅ |
|
|
203
|
+
| Update a product | ✅ |
|
|
204
|
+
| **Prices** | **Full** |
|
|
205
|
+
| List prices | ✅ |
|
|
206
|
+
| Create a price | ✅ |
|
|
207
|
+
| Get a price | ✅ |
|
|
208
|
+
| Update a price | ✅ |
|
|
209
|
+
| **Discounts** | **Full** |
|
|
210
|
+
| List discounts | ✅ |
|
|
211
|
+
| Create a discount | ✅ |
|
|
212
|
+
| Get a discount | ✅ |
|
|
213
|
+
| Update a discount | ✅ |
|
|
214
|
+
| **Customers** | **Full** |
|
|
215
|
+
| List customers | ✅ |
|
|
216
|
+
| Create a customer | ✅ |
|
|
217
|
+
| Get a customer | ✅ |
|
|
218
|
+
| Update a customer | ✅ |
|
|
219
|
+
| List credit balances for a customer | ✅ |
|
|
220
|
+
| **Addresses** | **Full** |
|
|
221
|
+
| List addresses for a customer | ✅ |
|
|
222
|
+
| Create an addresses for a customer | ✅ |
|
|
223
|
+
| Get an address for a customer | ✅ |
|
|
224
|
+
| Update an address for a customer | ✅ |
|
|
225
|
+
| **Businesses** | ✅ |
|
|
226
|
+
| List businesses for a customer | ✅ |
|
|
227
|
+
| Create a business for a customer | ✅ |
|
|
228
|
+
| Get a business for a customer | ✅ |
|
|
229
|
+
| Update a business for a customer | ✅ |
|
|
230
|
+
| **Transactions** | **Full** |
|
|
231
|
+
| List transactions | ✅ |
|
|
232
|
+
| Create a transaction | ✅ |
|
|
233
|
+
| Get a transaction | ✅ |
|
|
234
|
+
| Update a transaction | ✅ |
|
|
235
|
+
| Preview a transaction | ✅ |
|
|
236
|
+
| Get a PDF invoice for a transaction | ✅ |
|
|
237
|
+
| **Subscriptions** | **Full** |
|
|
238
|
+
| List subscriptions | ✅ |
|
|
239
|
+
| Get a subscription | ✅ |
|
|
240
|
+
| Preview an update to a subscription | ✅ |
|
|
241
|
+
| Update a subscription | ✅ |
|
|
242
|
+
| Get a transaction to update payment method | ✅ |
|
|
243
|
+
| Preview a one-time charge for a subscription | ✅ |
|
|
244
|
+
| Create a one-time charge for a subscription | ✅ |
|
|
245
|
+
| Activate a trialing subscription | ✅ |
|
|
246
|
+
| Pause a subscription | ✅ |
|
|
247
|
+
| Resume a paused subscription | ✅ |
|
|
248
|
+
| Cancel a subscription | ✅ |
|
|
249
|
+
| **Adjustments** | **Full** |
|
|
250
|
+
| List adjustments | ✅ |
|
|
251
|
+
| Create an adjustment | ✅ |
|
|
252
|
+
| **Pricing preview** | **None** |
|
|
253
|
+
| Preview prices | ❌ |
|
|
254
|
+
| **Event types** | **None** |
|
|
255
|
+
| List event types | ❌ |
|
|
256
|
+
| **Events** | **None** |
|
|
257
|
+
| List events | ❌ |
|
|
258
|
+
| **Notification settings** | **None** |
|
|
259
|
+
| List notification settings | ❌ |
|
|
260
|
+
| Create a notification setting | ❌ |
|
|
261
|
+
| Get a notification setting | ❌ |
|
|
262
|
+
| Update a notification setting | ❌ |
|
|
263
|
+
| Delete a notification setting | ❌ |
|
|
264
|
+
| **Notifications** | **None** |
|
|
265
|
+
| List notifications | ❌ |
|
|
266
|
+
| Get a notification | ❌ |
|
|
267
|
+
| Replay a notification | ❌ |
|
|
268
|
+
| **Notification logs** | **None** |
|
|
269
|
+
| List logs for a notification | ❌ |
|
|
286
270
|
|
|
287
271
|
## Learn more
|
|
288
272
|
|
|
@@ -2,7 +2,7 @@ import { type ITransactionLineItemPreview } from '../../types';
|
|
|
2
2
|
import { UnitTotals, Totals, Product } from '../index';
|
|
3
3
|
export declare class TransactionLineItemPreview {
|
|
4
4
|
readonly price_id: string;
|
|
5
|
-
readonly quantity:
|
|
5
|
+
readonly quantity: number;
|
|
6
6
|
readonly tax_rate: string;
|
|
7
7
|
readonly unit_totals: UnitTotals;
|
|
8
8
|
readonly totals: Totals;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CountryCode } from '../../enums';
|
|
2
|
+
import { type IAddressPreview } from '../../resources';
|
|
3
|
+
export declare class AddressPreview {
|
|
4
|
+
readonly postal_code?: string | null | undefined;
|
|
5
|
+
readonly country_code: CountryCode;
|
|
6
|
+
constructor(address: IAddressPreview);
|
|
7
|
+
toJson(): IAddressPreview;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddressPreview = void 0;
|
|
4
|
+
class AddressPreview {
|
|
5
|
+
constructor(address) {
|
|
6
|
+
this.postal_code = address.postal_code;
|
|
7
|
+
this.country_code = address.country_code;
|
|
8
|
+
}
|
|
9
|
+
toJson() {
|
|
10
|
+
return {
|
|
11
|
+
postal_code: this.postal_code,
|
|
12
|
+
country_code: this.country_code,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.AddressPreview = AddressPreview;
|
|
@@ -11,3 +11,7 @@ export * from './transaction-includes';
|
|
|
11
11
|
export * from './transaction';
|
|
12
12
|
export * from './transaction-collection';
|
|
13
13
|
export * from './transaction-invoice-pdf';
|
|
14
|
+
export * from './transaction-preview';
|
|
15
|
+
export * from './transaction-item-preview';
|
|
16
|
+
export * from './proration';
|
|
17
|
+
export * from './address-preview';
|
|
@@ -27,3 +27,7 @@ __exportStar(require("./transaction-includes"), exports);
|
|
|
27
27
|
__exportStar(require("./transaction"), exports);
|
|
28
28
|
__exportStar(require("./transaction-collection"), exports);
|
|
29
29
|
__exportStar(require("./transaction-invoice-pdf"), exports);
|
|
30
|
+
__exportStar(require("./transaction-preview"), exports);
|
|
31
|
+
__exportStar(require("./transaction-item-preview"), exports);
|
|
32
|
+
__exportStar(require("./proration"), exports);
|
|
33
|
+
__exportStar(require("./address-preview"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TransactionsTimePeriod } from '../index';
|
|
2
|
+
import { type IProration } from '../../types';
|
|
3
|
+
export declare class Proration {
|
|
4
|
+
readonly rate: string;
|
|
5
|
+
readonly billing_period: TransactionsTimePeriod;
|
|
6
|
+
constructor(prorationResponse: IProration);
|
|
7
|
+
toJson(): IProration;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Proration = void 0;
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
class Proration {
|
|
6
|
+
constructor(prorationResponse) {
|
|
7
|
+
this.rate = prorationResponse.rate;
|
|
8
|
+
this.billing_period = new index_1.TransactionsTimePeriod(prorationResponse.billing_period);
|
|
9
|
+
}
|
|
10
|
+
toJson() {
|
|
11
|
+
return {
|
|
12
|
+
rate: this.rate,
|
|
13
|
+
billing_period: this.billing_period,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Proration = Proration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PriceWithIncludes, Proration } from '../index';
|
|
2
|
+
import { type ITransactionItemPreviewResponse } from '../../types';
|
|
3
|
+
export declare class TransactionItemPreview {
|
|
4
|
+
readonly price?: PriceWithIncludes | null | undefined;
|
|
5
|
+
readonly quantity: number;
|
|
6
|
+
readonly include_in_totals?: boolean | null | undefined;
|
|
7
|
+
readonly proration?: Proration | null | undefined;
|
|
8
|
+
constructor(transactionItem: ITransactionItemPreviewResponse);
|
|
9
|
+
toJson(): ITransactionItemPreviewResponse;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionItemPreview = void 0;
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
class TransactionItemPreview {
|
|
6
|
+
constructor(transactionItem) {
|
|
7
|
+
this.price = transactionItem.price ? new index_1.PriceWithIncludes(transactionItem.price) : null;
|
|
8
|
+
this.quantity = transactionItem.quantity;
|
|
9
|
+
this.include_in_totals = transactionItem.include_in_totals;
|
|
10
|
+
this.proration = transactionItem.proration ? new index_1.Proration(transactionItem.proration) : null;
|
|
11
|
+
}
|
|
12
|
+
toJson() {
|
|
13
|
+
return {
|
|
14
|
+
price: this.price,
|
|
15
|
+
quantity: this.quantity,
|
|
16
|
+
include_in_totals: this.include_in_totals,
|
|
17
|
+
proration: this.proration,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.TransactionItemPreview = TransactionItemPreview;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ITransactionPreview } from '../../types';
|
|
2
|
+
import { AddressPreview, TransactionDetailsPreview, TransactionItemPreview } from '../index';
|
|
3
|
+
import { type CurrencyCode } from '../../enums';
|
|
4
|
+
export declare class TransactionPreview {
|
|
5
|
+
readonly customer_id?: string | null | undefined;
|
|
6
|
+
readonly address_id?: string | null | undefined;
|
|
7
|
+
readonly business_id?: string | null | undefined;
|
|
8
|
+
readonly currency_code: CurrencyCode;
|
|
9
|
+
readonly discount_id?: string | null | undefined;
|
|
10
|
+
readonly customer_ip_address?: string | null | undefined;
|
|
11
|
+
readonly address?: AddressPreview | null | undefined;
|
|
12
|
+
readonly ignore_trials?: boolean | null | undefined;
|
|
13
|
+
readonly items: TransactionItemPreview[];
|
|
14
|
+
readonly details: TransactionDetailsPreview;
|
|
15
|
+
constructor(transactionPreview: ITransactionPreview);
|
|
16
|
+
toJson(): ITransactionPreview;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionPreview = void 0;
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
class TransactionPreview {
|
|
6
|
+
constructor(transactionPreview) {
|
|
7
|
+
this.customer_id = transactionPreview.customer_id;
|
|
8
|
+
this.address_id = transactionPreview.address_id;
|
|
9
|
+
this.business_id = transactionPreview.business_id;
|
|
10
|
+
this.currency_code = transactionPreview.currency_code;
|
|
11
|
+
this.discount_id = transactionPreview.discount_id;
|
|
12
|
+
this.customer_ip_address = transactionPreview.customer_ip_address;
|
|
13
|
+
this.address = transactionPreview.address ? new index_1.AddressPreview(transactionPreview.address) : null;
|
|
14
|
+
this.ignore_trials = transactionPreview.ignore_trials;
|
|
15
|
+
this.items = transactionPreview.items.map((item) => new index_1.TransactionItemPreview(item));
|
|
16
|
+
this.details = new index_1.TransactionDetailsPreview(transactionPreview.details);
|
|
17
|
+
}
|
|
18
|
+
toJson() {
|
|
19
|
+
return {
|
|
20
|
+
customer_id: this.customer_id,
|
|
21
|
+
address_id: this.address_id,
|
|
22
|
+
business_id: this.business_id,
|
|
23
|
+
currency_code: this.currency_code,
|
|
24
|
+
discount_id: this.discount_id,
|
|
25
|
+
customer_ip_address: this.customer_ip_address,
|
|
26
|
+
address: this.address,
|
|
27
|
+
ignore_trials: this.ignore_trials,
|
|
28
|
+
items: this.items,
|
|
29
|
+
details: this.details,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.TransactionPreview = TransactionPreview;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Transaction, TransactionCollection, TransactionIncludes, TransactionInvoicePDF } from '../../entities';
|
|
1
|
+
import { Transaction, TransactionCollection, TransactionIncludes, TransactionInvoicePDF, TransactionPreview } from '../../entities';
|
|
2
2
|
import { BaseResource } from '../../internal/base';
|
|
3
|
-
import { type CreateTransactionQueryParameters, type CreateTransactionRequestBody, type GetTransactionQueryParameters, type ListTransactionQueryParameters, type UpdateTransactionRequestBody } from './operations';
|
|
3
|
+
import { type CreateTransactionQueryParameters, type CreateTransactionRequestBody, type GetTransactionQueryParameters, type ListTransactionQueryParameters, type UpdateTransactionRequestBody, type TransactionPreviewRequestBody } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class TransactionsResource extends BaseResource {
|
|
6
6
|
list(queryParams?: ListTransactionQueryParameters): Promise<TransactionCollection>;
|
|
@@ -8,4 +8,5 @@ export declare class TransactionsResource extends BaseResource {
|
|
|
8
8
|
update(transactionId: string, updateTransaction: UpdateTransactionRequestBody): Promise<Transaction>;
|
|
9
9
|
get(transactionId: string, queryParams?: GetTransactionQueryParameters): Promise<TransactionIncludes>;
|
|
10
10
|
getInvoicePDF(transactionId: string): Promise<TransactionInvoicePDF>;
|
|
11
|
+
preview(previewTransactionParameters: TransactionPreviewRequestBody): Promise<TransactionPreview>;
|
|
11
12
|
}
|
|
@@ -32,6 +32,7 @@ const TransactionPaths = {
|
|
|
32
32
|
get: '/transactions/{transaction_id}',
|
|
33
33
|
update: '/transactions/{transaction_id}',
|
|
34
34
|
getInvoicePDF: '/transactions/{transaction_id}/invoice',
|
|
35
|
+
preview: '/transactions/preview',
|
|
35
36
|
};
|
|
36
37
|
__exportStar(require("./operations"), exports);
|
|
37
38
|
class TransactionsResource extends base_1.BaseResource {
|
|
@@ -80,5 +81,12 @@ class TransactionsResource extends base_1.BaseResource {
|
|
|
80
81
|
return new entities_1.TransactionInvoicePDF(data);
|
|
81
82
|
});
|
|
82
83
|
}
|
|
84
|
+
preview(previewTransactionParameters) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const response = yield this.client.post(TransactionPaths.preview, previewTransactionParameters);
|
|
87
|
+
const data = this.handleResponse(response);
|
|
88
|
+
return new entities_1.TransactionPreview(data);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
83
91
|
}
|
|
84
92
|
exports.TransactionsResource = TransactionsResource;
|
|
@@ -21,3 +21,4 @@ __exportStar(require("./get-transaction-query-parameters"), exports);
|
|
|
21
21
|
__exportStar(require("./get-transaction-path-parameters"), exports);
|
|
22
22
|
__exportStar(require("./update-transaction-path-parameters"), exports);
|
|
23
23
|
__exportStar(require("./update-transaction-request-body"), exports);
|
|
24
|
+
__exportStar(require("./transaction-preview-request-body"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CountryCode, type CurrencyCode } from '../../../enums';
|
|
2
|
+
import { type ITransactionItemPreviewRequest } from '../../../types';
|
|
3
|
+
export interface IAddressPreview {
|
|
4
|
+
postal_code?: string | null | undefined;
|
|
5
|
+
country_code: CountryCode;
|
|
6
|
+
}
|
|
7
|
+
export interface TransactionPreviewRequestBody {
|
|
8
|
+
items: ITransactionItemPreviewRequest[];
|
|
9
|
+
customer_id?: string | null | undefined;
|
|
10
|
+
address_id?: string | null | undefined;
|
|
11
|
+
business_id?: string | null | undefined;
|
|
12
|
+
currency_code?: CurrencyCode | null | undefined;
|
|
13
|
+
discount_id?: string | null | undefined;
|
|
14
|
+
customer_ip_address?: string | null | undefined;
|
|
15
|
+
address?: IAddressPreview | null | undefined;
|
|
16
|
+
ignore_trials?: boolean | null | undefined;
|
|
17
|
+
}
|
|
@@ -25,3 +25,5 @@ __exportStar(require("./adjustment-totals-breakdown"), exports);
|
|
|
25
25
|
__exportStar(require("./adjustment-totals"), exports);
|
|
26
26
|
__exportStar(require("./transaction"), exports);
|
|
27
27
|
__exportStar(require("./transaction-invoice-pdf"), exports);
|
|
28
|
+
__exportStar(require("./transaction-preview-item"), exports);
|
|
29
|
+
__exportStar(require("./transaction-preview"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CurrencyCode } from '../../enums';
|
|
2
|
+
import { type IAddressPreview } from '../../resources';
|
|
3
|
+
import { type ITransactionDetailsPreview } from '../shared';
|
|
4
|
+
import { type IPrice } from '../price';
|
|
5
|
+
import { type ITransactionsTimePeriod } from './transactions-time-period';
|
|
6
|
+
export interface IProration {
|
|
7
|
+
rate: string;
|
|
8
|
+
billing_period: ITransactionsTimePeriod;
|
|
9
|
+
}
|
|
10
|
+
export interface ITransactionItemPreviewResponse {
|
|
11
|
+
price?: IPrice | null | undefined;
|
|
12
|
+
quantity: number;
|
|
13
|
+
include_in_totals?: boolean | null | undefined;
|
|
14
|
+
proration?: IProration | null | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface ITransactionPreview {
|
|
17
|
+
customer_id?: string | null | undefined;
|
|
18
|
+
address_id?: string | null | undefined;
|
|
19
|
+
business_id?: string | null | undefined;
|
|
20
|
+
currency_code: CurrencyCode;
|
|
21
|
+
discount_id?: string | null | undefined;
|
|
22
|
+
customer_ip_address?: string | null | undefined;
|
|
23
|
+
address?: IAddressPreview | null | undefined;
|
|
24
|
+
ignore_trials?: boolean | null | undefined;
|
|
25
|
+
items: ITransactionItemPreviewResponse[];
|
|
26
|
+
details: ITransactionDetailsPreview;
|
|
27
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.8";
|
package/dist/version.js
CHANGED