@deliverart/sdk-js-subscription 2.13.5 → 2.13.7
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/README.md +124 -0
- package/dist/index.cjs +448 -94
- package/dist/index.d.cts +2658 -598
- package/dist/index.d.ts +2658 -598
- package/dist/index.js +409 -94
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ Subscription management package for the Deliverart JavaScript SDK.
|
|
|
13
13
|
- credit adjustments for consumption subscriptions
|
|
14
14
|
- renewal payment initialization for `stripe`, `bank_transfer`, `cash` and `credit_card`
|
|
15
15
|
- manual renewal payment resolution for offline payment methods
|
|
16
|
+
- purchase lifecycle actions: `cancel`, `retry_payment`, `refund`
|
|
17
|
+
- renewal lifecycle actions: `cancel`, `retry_payment`, `refund`
|
|
16
18
|
|
|
17
19
|
## Subscription Plan Catalog
|
|
18
20
|
|
|
@@ -24,6 +26,38 @@ const plans = await sdk.call(new GetSubscriptionPlanCatalog())
|
|
|
24
26
|
|
|
25
27
|
Each catalog item exposes the plan configuration plus `priceOptions`, already sorted by threshold.
|
|
26
28
|
|
|
29
|
+
Preview the self-service charge before creating a purchase:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { CalculateSubscriptionPlanPurchaseQuote } from '@deliverart/sdk-js-subscription'
|
|
33
|
+
|
|
34
|
+
const quote = await sdk.call(
|
|
35
|
+
new CalculateSubscriptionPlanPurchaseQuote('plan-id', {
|
|
36
|
+
pointOfSale: '/point_of_sales/pos-id',
|
|
37
|
+
startsAt: '2026-04-05',
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The response includes `threshold`, `unitPrice`, `amount`, `type`, `startsAt` and the effective `autoRenewal`.
|
|
43
|
+
|
|
44
|
+
## Admin Plan Assignment
|
|
45
|
+
|
|
46
|
+
Assign a plan directly to a point of sale without going through the public purchase flow:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { AssignSubscriptionPlan } from '@deliverart/sdk-js-subscription'
|
|
50
|
+
|
|
51
|
+
const subscription = await sdk.call(
|
|
52
|
+
new AssignSubscriptionPlan('plan-id', {
|
|
53
|
+
pointOfSale: '/point_of_sales/pos-id',
|
|
54
|
+
startsAt: '2026-04-01',
|
|
55
|
+
}),
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This operation is intended for admin/backoffice flows, including `adminOnly` and `infinite` plans.
|
|
60
|
+
|
|
27
61
|
## Subscription Purchase
|
|
28
62
|
|
|
29
63
|
Create a purchase from a public plan:
|
|
@@ -62,6 +96,40 @@ await sdk.call(
|
|
|
62
96
|
)
|
|
63
97
|
```
|
|
64
98
|
|
|
99
|
+
Cancel a non-completed purchase:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { CancelSubscriptionPurchase } from '@deliverart/sdk-js-subscription'
|
|
103
|
+
|
|
104
|
+
await sdk.call(
|
|
105
|
+
new CancelSubscriptionPurchase('purchase-id', {
|
|
106
|
+
response: 'customer cancelled before payment',
|
|
107
|
+
}),
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Retry a failed purchase payment:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { RetrySubscriptionPurchasePayment } from '@deliverart/sdk-js-subscription'
|
|
115
|
+
|
|
116
|
+
const payment = await sdk.call(
|
|
117
|
+
new RetrySubscriptionPurchasePayment('purchase-id', 'cash'),
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Refund a completed offline purchase:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { RefundSubscriptionPurchase } from '@deliverart/sdk-js-subscription'
|
|
125
|
+
|
|
126
|
+
await sdk.call(
|
|
127
|
+
new RefundSubscriptionPurchase('purchase-id', {
|
|
128
|
+
response: 'manual refund approved',
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
65
133
|
## Renewal Payment Start
|
|
66
134
|
|
|
67
135
|
Consumption renewal:
|
|
@@ -116,6 +184,62 @@ await sdk.call(
|
|
|
116
184
|
|
|
117
185
|
Allowed statuses are `paid`, `failed` and `canceled`.
|
|
118
186
|
|
|
187
|
+
## Renewal Lifecycle Actions
|
|
188
|
+
|
|
189
|
+
Consumption renewal:
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import {
|
|
193
|
+
CancelSubscriptionConsumptionRenewal,
|
|
194
|
+
RetrySubscriptionConsumptionRenewalPayment,
|
|
195
|
+
RefundSubscriptionConsumptionRenewal,
|
|
196
|
+
} from '@deliverart/sdk-js-subscription'
|
|
197
|
+
|
|
198
|
+
await sdk.call(
|
|
199
|
+
new CancelSubscriptionConsumptionRenewal('renewal-id', {
|
|
200
|
+
response: 'operator canceled renewal',
|
|
201
|
+
}),
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
const payment = await sdk.call(
|
|
205
|
+
new RetrySubscriptionConsumptionRenewalPayment('renewal-id', 'bank_transfer'),
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
await sdk.call(
|
|
209
|
+
new RefundSubscriptionConsumptionRenewal('renewal-id', {
|
|
210
|
+
response: 'manual credit refund',
|
|
211
|
+
}),
|
|
212
|
+
)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Time-based renewal:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import {
|
|
219
|
+
CancelSubscriptionTimeBasedRenewal,
|
|
220
|
+
RetrySubscriptionTimeBasedRenewalPayment,
|
|
221
|
+
RefundSubscriptionTimeBasedRenewal,
|
|
222
|
+
} from '@deliverart/sdk-js-subscription'
|
|
223
|
+
|
|
224
|
+
await sdk.call(
|
|
225
|
+
new CancelSubscriptionTimeBasedRenewal('renewal-id', {
|
|
226
|
+
response: 'operator canceled renewal',
|
|
227
|
+
}),
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
const payment = await sdk.call(
|
|
231
|
+
new RetrySubscriptionTimeBasedRenewalPayment('renewal-id', 'cash'),
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
await sdk.call(
|
|
235
|
+
new RefundSubscriptionTimeBasedRenewal('renewal-id', {
|
|
236
|
+
response: 'manual time-based refund',
|
|
237
|
+
}),
|
|
238
|
+
)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`cancel` and `retry_payment` are for non-completed renewals. `refund` is for completed offline renewals and returns a lifecycle summary including payment info plus rolled-back credits or restored expiration.
|
|
242
|
+
|
|
119
243
|
## Renewal Payment Relation
|
|
120
244
|
|
|
121
245
|
Renewal list/detail schemas now expose the linked `payment` IRI when a payment attempt already exists.
|