@deliverart/sdk-js-subscription 2.13.6 → 2.14.0

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 CHANGED
@@ -11,8 +11,10 @@ Subscription management package for the Deliverart JavaScript SDK.
11
11
  - renewal CRUD for `consumption` and `time_based`
12
12
  - subscription overview from point of sale
13
13
  - credit adjustments for consumption subscriptions
14
- - renewal payment initialization for `stripe`, `bank_transfer`, `cash` and `credit_card`
14
+ - renewal payment initialization for `stripe` and `bank_transfer`
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
 
@@ -77,10 +79,16 @@ Start payment for the purchase:
77
79
  import { PaySubscriptionPurchase } from '@deliverart/sdk-js-subscription'
78
80
 
79
81
  const payment = await sdk.call(
80
- new PaySubscriptionPurchase('purchase-id', 'cash'),
82
+ new PaySubscriptionPurchase('purchase-id', 'bank_transfer'),
81
83
  )
82
84
  ```
83
85
 
86
+ Subscription billing is platform-level:
87
+
88
+ - order and ecommerce payments still use each POS payment configuration
89
+ - subscription purchases and renewals use the central platform billing account
90
+ - the SDK therefore accepts only `stripe` and `bank_transfer` for subscription payment start and retry
91
+
84
92
  Resolve offline payment:
85
93
 
86
94
  ```ts
@@ -94,6 +102,40 @@ await sdk.call(
94
102
  )
95
103
  ```
96
104
 
105
+ Cancel a non-completed purchase:
106
+
107
+ ```ts
108
+ import { CancelSubscriptionPurchase } from '@deliverart/sdk-js-subscription'
109
+
110
+ await sdk.call(
111
+ new CancelSubscriptionPurchase('purchase-id', {
112
+ response: 'customer cancelled before payment',
113
+ }),
114
+ )
115
+ ```
116
+
117
+ Retry a failed purchase payment:
118
+
119
+ ```ts
120
+ import { RetrySubscriptionPurchasePayment } from '@deliverart/sdk-js-subscription'
121
+
122
+ const payment = await sdk.call(
123
+ new RetrySubscriptionPurchasePayment('purchase-id', 'bank_transfer'),
124
+ )
125
+ ```
126
+
127
+ Refund a completed offline purchase:
128
+
129
+ ```ts
130
+ import { RefundSubscriptionPurchase } from '@deliverart/sdk-js-subscription'
131
+
132
+ await sdk.call(
133
+ new RefundSubscriptionPurchase('purchase-id', {
134
+ response: 'manual refund approved',
135
+ }),
136
+ )
137
+ ```
138
+
97
139
  ## Renewal Payment Start
98
140
 
99
141
  Consumption renewal:
@@ -148,6 +190,62 @@ await sdk.call(
148
190
 
149
191
  Allowed statuses are `paid`, `failed` and `canceled`.
150
192
 
193
+ ## Renewal Lifecycle Actions
194
+
195
+ Consumption renewal:
196
+
197
+ ```ts
198
+ import {
199
+ CancelSubscriptionConsumptionRenewal,
200
+ RetrySubscriptionConsumptionRenewalPayment,
201
+ RefundSubscriptionConsumptionRenewal,
202
+ } from '@deliverart/sdk-js-subscription'
203
+
204
+ await sdk.call(
205
+ new CancelSubscriptionConsumptionRenewal('renewal-id', {
206
+ response: 'operator canceled renewal',
207
+ }),
208
+ )
209
+
210
+ const payment = await sdk.call(
211
+ new RetrySubscriptionConsumptionRenewalPayment('renewal-id', 'bank_transfer'),
212
+ )
213
+
214
+ await sdk.call(
215
+ new RefundSubscriptionConsumptionRenewal('renewal-id', {
216
+ response: 'manual credit refund',
217
+ }),
218
+ )
219
+ ```
220
+
221
+ Time-based renewal:
222
+
223
+ ```ts
224
+ import {
225
+ CancelSubscriptionTimeBasedRenewal,
226
+ RetrySubscriptionTimeBasedRenewalPayment,
227
+ RefundSubscriptionTimeBasedRenewal,
228
+ } from '@deliverart/sdk-js-subscription'
229
+
230
+ await sdk.call(
231
+ new CancelSubscriptionTimeBasedRenewal('renewal-id', {
232
+ response: 'operator canceled renewal',
233
+ }),
234
+ )
235
+
236
+ const payment = await sdk.call(
237
+ new RetrySubscriptionTimeBasedRenewalPayment('renewal-id', 'bank_transfer'),
238
+ )
239
+
240
+ await sdk.call(
241
+ new RefundSubscriptionTimeBasedRenewal('renewal-id', {
242
+ response: 'manual time-based refund',
243
+ }),
244
+ )
245
+ ```
246
+
247
+ `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.
248
+
151
249
  ## Renewal Payment Relation
152
250
 
153
251
  Renewal list/detail schemas now expose the linked `payment` IRI when a payment attempt already exists.