@deliverart/sdk-js-subscription 2.13.6 → 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 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
 
@@ -94,6 +96,40 @@ await sdk.call(
94
96
  )
95
97
  ```
96
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
+
97
133
  ## Renewal Payment Start
98
134
 
99
135
  Consumption renewal:
@@ -148,6 +184,62 @@ await sdk.call(
148
184
 
149
185
  Allowed statuses are `paid`, `failed` and `canceled`.
150
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
+
151
243
  ## Renewal Payment Relation
152
244
 
153
245
  Renewal list/detail schemas now expose the linked `payment` IRI when a payment attempt already exists.