@wix/auto_sdk_pricing-plans_orders 1.0.2 → 1.0.4

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.
Files changed (73) hide show
  1. package/build/cjs/src/pricing-plans-v2-order-orders.context.d.ts +42 -42
  2. package/build/cjs/src/pricing-plans-v2-order-orders.context.js +46 -46
  3. package/build/cjs/src/pricing-plans-v2-order-orders.context.js.map +1 -1
  4. package/build/cjs/src/pricing-plans-v2-order-orders.http.d.ts +72 -72
  5. package/build/cjs/src/pricing-plans-v2-order-orders.http.js +343 -343
  6. package/build/cjs/src/pricing-plans-v2-order-orders.http.js.map +1 -1
  7. package/build/cjs/src/pricing-plans-v2-order-orders.meta.d.ts +12 -12
  8. package/build/cjs/src/pricing-plans-v2-order-orders.meta.js +89 -89
  9. package/build/cjs/src/pricing-plans-v2-order-orders.meta.js.map +1 -1
  10. package/build/cjs/src/pricing-plans-v2-order-orders.public.d.ts +113 -113
  11. package/build/cjs/src/pricing-plans-v2-order-orders.public.js +94 -94
  12. package/build/cjs/src/pricing-plans-v2-order-orders.public.js.map +1 -1
  13. package/build/cjs/src/pricing-plans-v2-order-orders.types.d.ts +640 -382
  14. package/build/cjs/src/pricing-plans-v2-order-orders.types.js +9 -9
  15. package/build/cjs/src/pricing-plans-v2-order-orders.types.js.map +1 -1
  16. package/build/cjs/src/pricing-plans-v2-order-orders.universal.d.ts +1042 -729
  17. package/build/cjs/src/pricing-plans-v2-order-orders.universal.js +387 -379
  18. package/build/cjs/src/pricing-plans-v2-order-orders.universal.js.map +1 -1
  19. package/build/es/src/pricing-plans-v2-order-orders.context.d.ts +42 -42
  20. package/build/es/src/pricing-plans-v2-order-orders.context.js +41 -41
  21. package/build/es/src/pricing-plans-v2-order-orders.context.js.map +1 -1
  22. package/build/es/src/pricing-plans-v2-order-orders.http.d.ts +72 -72
  23. package/build/es/src/pricing-plans-v2-order-orders.http.js +335 -335
  24. package/build/es/src/pricing-plans-v2-order-orders.http.js.map +1 -1
  25. package/build/es/src/pricing-plans-v2-order-orders.meta.d.ts +12 -12
  26. package/build/es/src/pricing-plans-v2-order-orders.meta.js +73 -73
  27. package/build/es/src/pricing-plans-v2-order-orders.meta.js.map +1 -1
  28. package/build/es/src/pricing-plans-v2-order-orders.public.d.ts +113 -113
  29. package/build/es/src/pricing-plans-v2-order-orders.public.js +81 -81
  30. package/build/es/src/pricing-plans-v2-order-orders.public.js.map +1 -1
  31. package/build/es/src/pricing-plans-v2-order-orders.types.d.ts +640 -382
  32. package/build/es/src/pricing-plans-v2-order-orders.types.js +8 -8
  33. package/build/es/src/pricing-plans-v2-order-orders.types.js.map +1 -1
  34. package/build/es/src/pricing-plans-v2-order-orders.universal.d.ts +1042 -729
  35. package/build/es/src/pricing-plans-v2-order-orders.universal.js +371 -363
  36. package/build/es/src/pricing-plans-v2-order-orders.universal.js.map +1 -1
  37. package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.d.ts +42 -42
  38. package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.js +46 -46
  39. package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.js.map +1 -1
  40. package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.d.ts +72 -72
  41. package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.js +343 -343
  42. package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.js.map +1 -1
  43. package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.d.ts +12 -12
  44. package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.js +89 -89
  45. package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.js.map +1 -1
  46. package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.d.ts +113 -113
  47. package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.js +94 -94
  48. package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.js.map +1 -1
  49. package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.d.ts +640 -382
  50. package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.js +9 -9
  51. package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.js.map +1 -1
  52. package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.d.ts +1044 -731
  53. package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.js +387 -379
  54. package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.js.map +1 -1
  55. package/build/internal/es/src/pricing-plans-v2-order-orders.context.d.ts +42 -42
  56. package/build/internal/es/src/pricing-plans-v2-order-orders.context.js +41 -41
  57. package/build/internal/es/src/pricing-plans-v2-order-orders.context.js.map +1 -1
  58. package/build/internal/es/src/pricing-plans-v2-order-orders.http.d.ts +72 -72
  59. package/build/internal/es/src/pricing-plans-v2-order-orders.http.js +335 -335
  60. package/build/internal/es/src/pricing-plans-v2-order-orders.http.js.map +1 -1
  61. package/build/internal/es/src/pricing-plans-v2-order-orders.meta.d.ts +12 -12
  62. package/build/internal/es/src/pricing-plans-v2-order-orders.meta.js +73 -73
  63. package/build/internal/es/src/pricing-plans-v2-order-orders.meta.js.map +1 -1
  64. package/build/internal/es/src/pricing-plans-v2-order-orders.public.d.ts +113 -113
  65. package/build/internal/es/src/pricing-plans-v2-order-orders.public.js +81 -81
  66. package/build/internal/es/src/pricing-plans-v2-order-orders.public.js.map +1 -1
  67. package/build/internal/es/src/pricing-plans-v2-order-orders.types.d.ts +640 -382
  68. package/build/internal/es/src/pricing-plans-v2-order-orders.types.js +8 -8
  69. package/build/internal/es/src/pricing-plans-v2-order-orders.types.js.map +1 -1
  70. package/build/internal/es/src/pricing-plans-v2-order-orders.universal.d.ts +1044 -731
  71. package/build/internal/es/src/pricing-plans-v2-order-orders.universal.js +371 -363
  72. package/build/internal/es/src/pricing-plans-v2-order-orders.universal.js.map +1 -1
  73. package/package.json +4 -4
@@ -115,14 +115,6 @@ export var SortOrder;
115
115
  SortOrder["ASC"] = "ASC";
116
116
  SortOrder["DESC"] = "DESC";
117
117
  })(SortOrder || (SortOrder = {}));
118
- export var WebhookIdentityType;
119
- (function (WebhookIdentityType) {
120
- WebhookIdentityType["UNKNOWN"] = "UNKNOWN";
121
- WebhookIdentityType["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
122
- WebhookIdentityType["MEMBER"] = "MEMBER";
123
- WebhookIdentityType["WIX_USER"] = "WIX_USER";
124
- WebhookIdentityType["APP"] = "APP";
125
- })(WebhookIdentityType || (WebhookIdentityType = {}));
126
118
  export var ReasonNotSuspendable;
127
119
  (function (ReasonNotSuspendable) {
128
120
  /** Undefined reason. */
@@ -142,30 +134,43 @@ export var ReasonNotSuspendable;
142
134
  /** Orders based on recurring payments using older stripe versions can't be suspended. */
143
135
  ReasonNotSuspendable["OLD_STRIPE"] = "OLD_STRIPE";
144
136
  })(ReasonNotSuspendable || (ReasonNotSuspendable = {}));
137
+ export var WebhookIdentityType;
138
+ (function (WebhookIdentityType) {
139
+ WebhookIdentityType["UNKNOWN"] = "UNKNOWN";
140
+ WebhookIdentityType["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
141
+ WebhookIdentityType["MEMBER"] = "MEMBER";
142
+ WebhookIdentityType["WIX_USER"] = "WIX_USER";
143
+ WebhookIdentityType["APP"] = "APP";
144
+ })(WebhookIdentityType || (WebhookIdentityType = {}));
145
145
  /**
146
- * Retrieves an order for the currently logged-in member by ID.
146
+ * Retrieves an order by ID.
147
147
  * @param _id - Order ID.
148
148
  * @public
149
149
  * @requiredField _id
150
- * @param options - Options for getting a logged-in member's order.
151
- * @permissionId PRICING_PLANS.READ_OWN_ORDERS
152
- * @applicableIdentity MEMBER
153
- * @returns Requested order.
154
- * @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.GetOrder
150
+ * @param options - Options to use when getting an order.
151
+ * @permissionId PRICING_PLANS.READ_ORDERS
152
+ * @permissionScope Manage Orders
153
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
154
+ * @permissionScope Read Orders
155
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
156
+ * @permissionScope Manage Events
157
+ * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
158
+ * @applicableIdentity APP
159
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.GetOrder
155
160
  */
156
- export async function memberGetOrder(_id, options) {
161
+ export async function managementGetOrder(_id, options) {
157
162
  // @ts-ignore
158
163
  const { httpClient, sideEffects } = arguments[2];
159
164
  const payload = renameKeysFromSDKRequestToRESTRequest({
160
165
  id: _id,
161
166
  fieldSet: options?.fieldSet,
162
167
  });
163
- const reqOpts = ambassadorWixPricingPlansV2Order.memberGetOrder(payload);
168
+ const reqOpts = ambassadorWixPricingPlansV2Order.managementGetOrder(payload);
164
169
  sideEffects?.onSiteCall?.();
165
170
  try {
166
171
  const result = await httpClient.request(reqOpts);
167
172
  sideEffects?.onSuccess?.(result);
168
- return renameKeysFromRESTResponseToSDKResponse(result.data)?.order;
173
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
169
174
  }
170
175
  catch (err) {
171
176
  const transformedError = sdkTransformError(err, {
@@ -178,17 +183,27 @@ export async function memberGetOrder(_id, options) {
178
183
  }
179
184
  }
180
185
  /**
181
- * Retrieves a list of up to 100 pricing plan orders for currently logged-in member.
186
+ * Retrieves a list of up to 50 pricing plan orders and details, given the specified sorting and filtering.
187
+ *
188
+ * By default, this endpoint will retrieve all orders and return them sorted by `createdDate` in `DESC`, descending order.
189
+ * `sort.fieldName` supports `endDate` and `createdDate` fields and defaults to `ASC`, ascending order.
182
190
  * @public
183
191
  * @param options - Filtering, sorting, and pagination options.
184
- * @permissionId PRICING_PLANS.READ_OWN_ORDERS
185
- * @applicableIdentity MEMBER
186
- * @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.ListOrders
192
+ * @permissionId PRICING_PLANS.READ_ORDERS
193
+ * @permissionScope Manage Orders
194
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
195
+ * @permissionScope Read Orders
196
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
197
+ * @permissionScope Manage Events
198
+ * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
199
+ * @applicableIdentity APP
200
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.ListOrders
187
201
  */
188
- export async function memberListOrders(options) {
202
+ export async function managementListOrders(options) {
189
203
  // @ts-ignore
190
204
  const { httpClient, sideEffects } = arguments[1];
191
205
  const payload = renameKeysFromSDKRequestToRESTRequest({
206
+ buyerIds: options?.buyerIds,
192
207
  planIds: options?.planIds,
193
208
  autoRenewCanceled: options?.autoRenewCanceled,
194
209
  orderStatuses: options?.orderStatuses,
@@ -198,7 +213,7 @@ export async function memberListOrders(options) {
198
213
  sorting: options?.sorting,
199
214
  fieldSet: options?.fieldSet,
200
215
  });
201
- const reqOpts = ambassadorWixPricingPlansV2Order.memberListOrders(payload);
216
+ const reqOpts = ambassadorWixPricingPlansV2Order.managementListOrders(payload);
202
217
  sideEffects?.onSiteCall?.();
203
218
  try {
204
219
  const result = await httpClient.request(reqOpts);
@@ -209,6 +224,7 @@ export async function memberListOrders(options) {
209
224
  const transformedError = sdkTransformError(err, {
210
225
  spreadPathsToArguments: {},
211
226
  explicitPathsToArguments: {
227
+ buyerIds: '$[0].buyerIds',
212
228
  planIds: '$[0].planIds',
213
229
  autoRenewCanceled: '$[0].autoRenewCanceled',
214
230
  orderStatuses: '$[0].orderStatuses',
@@ -225,32 +241,32 @@ export async function memberListOrders(options) {
225
241
  }
226
242
  }
227
243
  /**
228
- * Cancels an order. Recurring orders can be canceled either immediately or at the next payment date. One time orders can only be canceled immediately.
229
- *
230
- * There may be some operations that continue to be processed before the status of the order is changed to `"CANCELED"`. For example, payments might need to be refunded before the order is fully canceled.
231
- *
232
- * Canceling during the free trial period: When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end of the free trial period and they won't be billed. The buyer may continue using the benefits until the end of the free trial period.
244
+ * Extends the duration of a pricing plan order by postponing the order's `endDate`. Postponing the end date of an order does not impact payments.
233
245
  *
234
- * >**Note:**
235
- * >This method requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions).
246
+ * New `endDate` must be later than the order's current `endDate`. Can't postpone orders that are unlimited.
247
+ * Can't postpone an order with `status`: `PAUSED`.
236
248
  * @param _id - Order ID.
237
- * @param effectiveAt - Required. Whether to cancel the order effective immediately or at the next payment date. One-time orders can only be canceled immediately.
249
+ * @param endDate - New end date and time.
250
+ *
251
+ * Must be later than the current end date and time.
238
252
  * @public
239
253
  * @requiredField _id
240
- * @requiredField effectiveAt
241
- * @param options - Options for requesting a cancellation.
242
- * @permissionId PRICING_PLANS.MANAGE_OWN_ORDERS
243
- * @applicableIdentity MEMBER
244
- * @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.RequestCancellation
254
+ * @requiredField endDate
255
+ * @param options - Options for postponing the end date of an order.
256
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
257
+ * @permissionScope Manage Orders
258
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
259
+ * @applicableIdentity APP
260
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.PostponeEndDate
245
261
  */
246
- export async function requestCancellation(_id, effectiveAt) {
262
+ export async function postponeEndDate(_id, endDate) {
247
263
  // @ts-ignore
248
264
  const { httpClient, sideEffects } = arguments[2];
249
265
  const payload = renameKeysFromSDKRequestToRESTRequest({
250
266
  id: _id,
251
- effectiveAt: effectiveAt,
267
+ endDate: endDate,
252
268
  });
253
- const reqOpts = ambassadorWixPricingPlansV2Order.requestCancellation(payload);
269
+ const reqOpts = ambassadorWixPricingPlansV2Order.postponeEndDate(payload);
254
270
  sideEffects?.onSiteCall?.();
255
271
  try {
256
272
  const result = await httpClient.request(reqOpts);
@@ -259,323 +275,207 @@ export async function requestCancellation(_id, effectiveAt) {
259
275
  catch (err) {
260
276
  const transformedError = sdkTransformError(err, {
261
277
  spreadPathsToArguments: {},
262
- explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
278
+ explicitPathsToArguments: { id: '$[0]', endDate: '$[1]' },
263
279
  singleArgumentUnchanged: false,
264
- }, ['_id', 'effectiveAt']);
280
+ }, ['_id', 'endDate']);
265
281
  sideEffects?.onError?.(err);
266
282
  throw transformedError;
267
283
  }
268
284
  }
269
285
  /**
270
- * Creates an online order for a site member.
286
+ * Cancels an existing order.
271
287
  *
272
- * If this method is called by a site member ([SDK](https://dev.wix.com/docs/sdk/articles/get-started/about-identities#site-member) | [REST](https://dev.wix.com/docs/rest/articles/getting-started/about-identities#site-member)), the plan is automatically ordered on behalf of that site member. Otherwise, you must specify `onBehalf.memberId` in your call.
288
+ * For orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
289
+ * For orders with one-time payments, a cancellation can only be set for `IMMEDIATELY`.
273
290
  *
274
- * When an online order is created, but payment hasn't been processed, its status is set to `DRAFT`. After the payment has been processed, if the start date is in the future the order's status is set to `PENDING`. Otherwise, it's set to `ACTIVE`.
275
- * @param planId - Plan ID.
291
+ * #### Canceling during the free trial period.
292
+ *
293
+ * When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end
294
+ * of the free trial period and they will not be billed. The buyer may continue using the benefits until the end
295
+ * of the free trial period.
296
+ *
297
+ * When a Wix user cancels an ordered plan during the free trial period, they choose whether to apply the cancellation
298
+ * `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. Canceling `IMMEDIATELY` will end the subscription for the buyer
299
+ * immediately, even during the free trial period and the buyer won't be billed. Canceling at the
300
+ * `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period.
301
+ * Then, the subscription ends and the buyer is not billed.
302
+ * @param _id - Order ID.
303
+ * @param effectiveAt - __Required.__ When the order will be canceled. One-time orders can only be canceled `IMMEDIATELY`.
276
304
  * @public
277
- * @requiredField options.onBehalf.memberId
278
- * @requiredField planId
279
- * @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOnlineOrder
305
+ * @requiredField _id
306
+ * @requiredField effectiveAt
307
+ * @param options - Options for canceling orders.
308
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
309
+ * @permissionScope Manage Orders
310
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
311
+ * @applicableIdentity APP
312
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.CancelOrder
280
313
  */
281
- export async function createOnlineOrder(planId, options) {
314
+ export async function cancelOrder(_id, effectiveAt) {
282
315
  // @ts-ignore
283
316
  const { httpClient, sideEffects } = arguments[2];
284
317
  const payload = renameKeysFromSDKRequestToRESTRequest({
285
- planId: planId,
286
- startDate: options?.startDate,
287
- couponCode: options?.couponCode,
288
- onBehalf: options?.onBehalf,
289
- submissionId: options?.submissionId,
318
+ id: _id,
319
+ effectiveAt: effectiveAt,
290
320
  });
291
- const reqOpts = ambassadorWixPricingPlansV2Order.createOnlineOrder(payload);
321
+ const reqOpts = ambassadorWixPricingPlansV2Order.cancelOrder(payload);
292
322
  sideEffects?.onSiteCall?.();
293
323
  try {
294
324
  const result = await httpClient.request(reqOpts);
295
325
  sideEffects?.onSuccess?.(result);
296
- return renameKeysFromRESTResponseToSDKResponse(result.data);
297
326
  }
298
327
  catch (err) {
299
328
  const transformedError = sdkTransformError(err, {
300
329
  spreadPathsToArguments: {},
301
- explicitPathsToArguments: {
302
- planId: '$[0]',
303
- startDate: '$[1].startDate',
304
- couponCode: '$[1].couponCode',
305
- onBehalf: '$[1].onBehalf',
306
- submissionId: '$[1].submissionId',
307
- },
330
+ explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
308
331
  singleArgumentUnchanged: false,
309
- }, ['planId', 'options']);
332
+ }, ['_id', 'effectiveAt']);
310
333
  sideEffects?.onError?.(err);
311
334
  throw transformedError;
312
335
  }
313
336
  }
314
337
  /**
315
- * Creates an order for a buyer who purchased the plan with an offline transaction.
316
- *
317
- * An offline order is handled off of the Wix site and is marked as `type`: `offline`. If a pricing plan
318
- * has a limit on the amount of purchases per buyer, that limit is ignored for offline orders.
319
- * Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
320
- *
321
- * When creating a free offline order:
322
- * The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
323
- * The order's last payment status is set to `"NOT_APPLICABLE"`. "
338
+ * Marks an offline order as paid.
339
+ * > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments.
324
340
  *
325
- * When creating a non-free offline order:
326
- * The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
327
- * The order's last payment status is set to `"UNPAID"` or `"PAID"` based on the data passed in the `paid` boolean in the request.
341
+ * Marking an offline order as paid causes the following changes:
342
+ * - The order's `lastPaymentStatus` changes to `"PAID"`.
343
+ * - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`.
328
344
  *
329
- * Payment for an offline order can be set in 1 of 2 ways:
330
- * + During order creation, set `paid`: `true`.
331
- * + After creation, call Mark As Paid.
332
- * @param planId - ID of the plan being ordered, from the Plans API.
333
- * @param memberId - ID of the member ordering the plan, from the Members API.
345
+ * An error occurs if you attempt to:
346
+ * - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice.
347
+ * - Mark an online order as paid. The Mark as Paid method is supported for offline orders only.
348
+ * @param _id - Order ID.
334
349
  * @public
335
- * @requiredField memberId
336
- * @requiredField planId
337
- * @param options - Options for creating an offline order.
338
- * @permissionId PRICING_PLANS.REGISTER_OFFLINE_ORDERS
350
+ * @requiredField _id
351
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
339
352
  * @permissionScope Manage Orders
340
353
  * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
341
354
  * @applicableIdentity APP
342
- * @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOfflineOrder
355
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.MarkAsPaid
343
356
  */
344
- export async function createOfflineOrder(planId, memberId, options) {
357
+ export async function markAsPaid(_id) {
345
358
  // @ts-ignore
346
- const { httpClient, sideEffects } = arguments[3];
347
- const payload = renameKeysFromSDKRequestToRESTRequest({
348
- planId: planId,
349
- memberId: memberId,
350
- startDate: options?.startDate,
351
- paid: options?.paid,
352
- couponCode: options?.couponCode,
353
- submissionId: options?.submissionId,
354
- });
355
- const reqOpts = ambassadorWixPricingPlansV2Order.createOfflineOrder(payload);
359
+ const { httpClient, sideEffects } = arguments[1];
360
+ const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
361
+ const reqOpts = ambassadorWixPricingPlansV2Order.markAsPaid(payload);
356
362
  sideEffects?.onSiteCall?.();
357
363
  try {
358
364
  const result = await httpClient.request(reqOpts);
359
365
  sideEffects?.onSuccess?.(result);
360
- return renameKeysFromRESTResponseToSDKResponse(result.data);
361
366
  }
362
367
  catch (err) {
363
368
  const transformedError = sdkTransformError(err, {
364
369
  spreadPathsToArguments: {},
365
- explicitPathsToArguments: {
366
- planId: '$[0]',
367
- memberId: '$[1]',
368
- startDate: '$[2].startDate',
369
- paid: '$[2].paid',
370
- couponCode: '$[2].couponCode',
371
- submissionId: '$[2].submissionId',
372
- },
370
+ explicitPathsToArguments: { id: '$[0]' },
373
371
  singleArgumentUnchanged: false,
374
- }, ['planId', 'memberId', 'options']);
372
+ }, ['_id']);
375
373
  sideEffects?.onError?.(err);
376
374
  throw transformedError;
377
375
  }
378
376
  }
379
377
  /**
380
- * Returns an `order` object that represents a potential online order for a site member.
378
+ * Pauses an order. Calling this method changes the order status to `"PAUSED"` and updates the `pausePeriods` array.
381
379
  *
382
- * You can use this method to show a site member a preview of an online order before [creating](https://dev.wix.com/docs/rest/business-solutions/pricing-plans/pricing-plans/orders/create-online-order) it.
380
+ * Only orders with `status`: `ACTIVE` can be paused.
381
+ * For orders with recurring payments, it also pauses the payment schedule. Buyers are not charged when an order is paused.
382
+ * Pausing an order affects the end date of the order by adding the time the order is paused to the `endDate`.
383
+ * The `endDate` and the `earliestEndDate` for the order are adjusted to include the pause period when the order is resumed.
383
384
  *
384
- * This method must be called using the site member identity ([SDK](https://dev.wix.com/docs/sdk/articles/get-started/about-identities#site-member) | [REST](https://dev.wix.com/docs/rest/articles/getting-started/about-identities#site-member)). Therefore, [Wix apps](https://dev.wix.com/docs/build-apps) can't currently call this method using REST.
385
- * @param planId - Plan ID.
385
+ * To resume a paused order, call Resume Order.
386
+ * @param _id - Order ID.
386
387
  * @public
387
- * @requiredField planId
388
- * @permissionId PRICING_PLANS.PURCHASE_PLANS
389
- * @permissionScope Manage Bookings Services and Settings
390
- * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
391
- * @permissionScope Manage Events
392
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
393
- * @permissionScope Manage Portfolio
394
- * @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
395
- * @permissionScope Access Verticals by Automations
396
- * @permissionScopeId SCOPE.CRM.ACCESS-VERTICALS-BY-AUTOMATIONS
397
- * @permissionScope Manage Restaurants - all permissions
398
- * @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
388
+ * @requiredField _id
389
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
390
+ * @permissionScope Manage Orders
391
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
399
392
  * @applicableIdentity APP
400
- * @applicableIdentity MEMBER
401
- * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOnlineOrderPreview
393
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.PauseOrder
402
394
  */
403
- export async function getOnlineOrderPreview(planId, options) {
395
+ export async function pauseOrder(_id) {
404
396
  // @ts-ignore
405
- const { httpClient, sideEffects } = arguments[2];
406
- const payload = renameKeysFromSDKRequestToRESTRequest({
407
- planId: planId,
408
- startDate: options?.startDate,
409
- couponCode: options?.couponCode,
410
- });
411
- const reqOpts = ambassadorWixPricingPlansV2Order.getOnlineOrderPreview(payload);
397
+ const { httpClient, sideEffects } = arguments[1];
398
+ const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
399
+ const reqOpts = ambassadorWixPricingPlansV2Order.pauseOrder(payload);
412
400
  sideEffects?.onSiteCall?.();
413
401
  try {
414
402
  const result = await httpClient.request(reqOpts);
415
403
  sideEffects?.onSuccess?.(result);
416
- return renameKeysFromRESTResponseToSDKResponse(result.data);
417
404
  }
418
405
  catch (err) {
419
406
  const transformedError = sdkTransformError(err, {
420
407
  spreadPathsToArguments: {},
421
- explicitPathsToArguments: {
422
- planId: '$[0]',
423
- startDate: '$[1].startDate',
424
- couponCode: '$[1].couponCode',
425
- },
408
+ explicitPathsToArguments: { id: '$[0]' },
426
409
  singleArgumentUnchanged: false,
427
- }, ['planId', 'options']);
410
+ }, ['_id']);
428
411
  sideEffects?.onError?.(err);
429
412
  throw transformedError;
430
413
  }
431
414
  }
432
415
  /**
433
- * Performs a dry run of a purchase and provides an order preview.
416
+ * Resumes a paused order. For orders with recurring payments, it also restarts the payment schedule.
434
417
  *
435
- * The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually
436
- * created, the preview order's `orderId` and `subscriptionId` are displayed as a string of multiple zero characters
437
- * (`000000-0000`). Tax is only calculated if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
438
- * <br>
439
- * If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview.
440
- * But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then
441
- * `purchaseLimitExceeded` will return as `true`.
418
+ * Resuming an order causes the following changes:
419
+ * - The order status changes to `"ACTIVE"`.
420
+ * - The `pausePeriods` array is updated.
421
+ * - The `endDate` for the order is adjusted to include the pause period.
422
+ * - For orders with recurring payments, the payment schedule is restarted.
423
+ * - The `earliestEndDate` is adjusted to include the pause period. (This property is reserved for future use).
442
424
  *
443
- * To get a general price preview for a plan that's not buyer-specific, call Get Price Preview.
444
- * @param memberId - Member ID of the buyer the previewed order is for, from the Members API.
425
+ * To pause an order, call Pause Order.
426
+ * @param _id - Order ID.
445
427
  * @public
446
- * @requiredField memberId
447
- * @requiredField planId
448
- * @param options - Options for previewing the offline order.
449
- * @param planId - ID of the plan of the previewed order.
428
+ * @requiredField _id
450
429
  * @permissionId PRICING_PLANS.MANAGE_ORDERS
451
430
  * @permissionScope Manage Orders
452
431
  * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
453
432
  * @applicableIdentity APP
454
- * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOfflineOrderPreview
455
- */
456
- export async function getOfflineOrderPreview(planId, memberId, options) {
457
- // @ts-ignore
458
- const { httpClient, sideEffects } = arguments[3];
459
- const payload = renameKeysFromSDKRequestToRESTRequest({
460
- planId: planId,
461
- memberId: memberId,
462
- startDate: options?.startDate,
463
- couponCode: options?.couponCode,
464
- });
465
- const reqOpts = ambassadorWixPricingPlansV2Order.getOfflineOrderPreview(payload);
466
- sideEffects?.onSiteCall?.();
467
- try {
468
- const result = await httpClient.request(reqOpts);
469
- sideEffects?.onSuccess?.(result);
470
- return renameKeysFromRESTResponseToSDKResponse(result.data);
471
- }
472
- catch (err) {
473
- const transformedError = sdkTransformError(err, {
474
- spreadPathsToArguments: {},
475
- explicitPathsToArguments: {
476
- planId: '$[0]',
477
- memberId: '$[1]',
478
- startDate: '$[2].startDate',
479
- couponCode: '$[2].couponCode',
480
- },
481
- singleArgumentUnchanged: false,
482
- }, ['planId', 'memberId', 'options']);
483
- sideEffects?.onError?.(err);
484
- throw transformedError;
485
- }
486
- }
487
- /**
488
- * Retrieves a plan's pricing.
489
- *
490
- * The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if
491
- * the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned
492
- * in the pricing model format used for orders. Learn more about pricing models ([REST](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models)|[SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/introduction#pricing-models)).
493
- *
494
- * Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To
495
- * generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.
496
- * @param planId - ID of plan to preview.
497
- * @public
498
- * @requiredField planId
499
- * @param options - Options for getting a price preview.
500
- * @permissionId PRICING_PLANS.READ_PUBLIC_PLANS
501
- * @permissionScope Read Pricing Plans
502
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
503
- * @permissionScope Manage Orders
504
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
505
- * @permissionScope Manage Bookings Services and Settings
506
- * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
507
- * @permissionScope Read Orders
508
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
509
- * @permissionScope Manage Events
510
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
511
- * @permissionScope Manage Portfolio
512
- * @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
513
- * @permissionScope Access Verticals by Automations
514
- * @permissionScopeId SCOPE.CRM.ACCESS-VERTICALS-BY-AUTOMATIONS
515
- * @permissionScope Manage Pricing Plans
516
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
517
- * @permissionScope Manage Restaurants - all permissions
518
- * @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
519
- * @applicableIdentity APP
520
- * @applicableIdentity VISITOR
521
- * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetPricePreview
433
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.ResumeOrder
522
434
  */
523
- export async function getPricePreview(planId, options) {
435
+ export async function resumeOrder(_id) {
524
436
  // @ts-ignore
525
- const { httpClient, sideEffects } = arguments[2];
526
- const payload = renameKeysFromSDKRequestToRESTRequest({
527
- planId: planId,
528
- couponCode: options?.couponCode,
529
- });
530
- const reqOpts = ambassadorWixPricingPlansV2Order.getPricePreview(payload);
437
+ const { httpClient, sideEffects } = arguments[1];
438
+ const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
439
+ const reqOpts = ambassadorWixPricingPlansV2Order.resumeOrder(payload);
531
440
  sideEffects?.onSiteCall?.();
532
441
  try {
533
442
  const result = await httpClient.request(reqOpts);
534
443
  sideEffects?.onSuccess?.(result);
535
- return renameKeysFromRESTResponseToSDKResponse(result.data);
536
444
  }
537
445
  catch (err) {
538
446
  const transformedError = sdkTransformError(err, {
539
447
  spreadPathsToArguments: {},
540
- explicitPathsToArguments: {
541
- planId: '$[0]',
542
- couponCode: '$[1].couponCode',
543
- },
448
+ explicitPathsToArguments: { id: '$[0]' },
544
449
  singleArgumentUnchanged: false,
545
- }, ['planId', 'options']);
450
+ }, ['_id']);
546
451
  sideEffects?.onError?.(err);
547
452
  throw transformedError;
548
453
  }
549
454
  }
550
455
  /**
551
- * Retrieves an order by ID.
456
+ * Retrieves an order for the currently logged-in member by ID.
552
457
  * @param _id - Order ID.
553
458
  * @public
554
459
  * @requiredField _id
555
- * @param options - Options to use when getting an order.
556
- * @permissionId PRICING_PLANS.READ_ORDERS
557
- * @permissionScope Manage Orders
558
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
559
- * @permissionScope Read Orders
560
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
561
- * @permissionScope Manage Events
562
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
563
- * @applicableIdentity APP
564
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.GetOrder
460
+ * @param options - Options for getting a logged-in member's order.
461
+ * @permissionId PRICING_PLANS.READ_OWN_ORDERS
462
+ * @applicableIdentity MEMBER
463
+ * @returns Requested order.
464
+ * @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.GetOrder
565
465
  */
566
- export async function managementGetOrder(_id, options) {
466
+ export async function memberGetOrder(_id, options) {
567
467
  // @ts-ignore
568
468
  const { httpClient, sideEffects } = arguments[2];
569
469
  const payload = renameKeysFromSDKRequestToRESTRequest({
570
470
  id: _id,
571
471
  fieldSet: options?.fieldSet,
572
472
  });
573
- const reqOpts = ambassadorWixPricingPlansV2Order.managementGetOrder(payload);
473
+ const reqOpts = ambassadorWixPricingPlansV2Order.memberGetOrder(payload);
574
474
  sideEffects?.onSiteCall?.();
575
475
  try {
576
476
  const result = await httpClient.request(reqOpts);
577
477
  sideEffects?.onSuccess?.(result);
578
- return renameKeysFromRESTResponseToSDKResponse(result.data);
478
+ return renameKeysFromRESTResponseToSDKResponse(result.data)?.order;
579
479
  }
580
480
  catch (err) {
581
481
  const transformedError = sdkTransformError(err, {
@@ -588,27 +488,17 @@ export async function managementGetOrder(_id, options) {
588
488
  }
589
489
  }
590
490
  /**
591
- * Retrieves a list of up to 50 pricing plan orders and details, given the specified sorting and filtering.
592
- *
593
- * By default, this endpoint will retrieve all orders and return them sorted by `createdDate` in `DESC`, descending order.
594
- * `sort.fieldName` supports `endDate` and `createdDate` fields and defaults to `ASC`, ascending order.
491
+ * Retrieves a list of up to 100 pricing plan orders for currently logged-in member.
595
492
  * @public
596
493
  * @param options - Filtering, sorting, and pagination options.
597
- * @permissionId PRICING_PLANS.READ_ORDERS
598
- * @permissionScope Manage Orders
599
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
600
- * @permissionScope Read Orders
601
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
602
- * @permissionScope Manage Events
603
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
604
- * @applicableIdentity APP
605
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.ListOrders
494
+ * @permissionId PRICING_PLANS.READ_OWN_ORDERS
495
+ * @applicableIdentity MEMBER
496
+ * @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.ListOrders
606
497
  */
607
- export async function managementListOrders(options) {
498
+ export async function memberListOrders(options) {
608
499
  // @ts-ignore
609
500
  const { httpClient, sideEffects } = arguments[1];
610
501
  const payload = renameKeysFromSDKRequestToRESTRequest({
611
- buyerIds: options?.buyerIds,
612
502
  planIds: options?.planIds,
613
503
  autoRenewCanceled: options?.autoRenewCanceled,
614
504
  orderStatuses: options?.orderStatuses,
@@ -618,7 +508,7 @@ export async function managementListOrders(options) {
618
508
  sorting: options?.sorting,
619
509
  fieldSet: options?.fieldSet,
620
510
  });
621
- const reqOpts = ambassadorWixPricingPlansV2Order.managementListOrders(payload);
511
+ const reqOpts = ambassadorWixPricingPlansV2Order.memberListOrders(payload);
622
512
  sideEffects?.onSiteCall?.();
623
513
  try {
624
514
  const result = await httpClient.request(reqOpts);
@@ -629,7 +519,6 @@ export async function managementListOrders(options) {
629
519
  const transformedError = sdkTransformError(err, {
630
520
  spreadPathsToArguments: {},
631
521
  explicitPathsToArguments: {
632
- buyerIds: '$[0].buyerIds',
633
522
  planIds: '$[0].planIds',
634
523
  autoRenewCanceled: '$[0].autoRenewCanceled',
635
524
  orderStatuses: '$[0].orderStatuses',
@@ -646,32 +535,32 @@ export async function managementListOrders(options) {
646
535
  }
647
536
  }
648
537
  /**
649
- * Extends the duration of a pricing plan order by postponing the order's `endDate`. Postponing the end date of an order does not impact payments.
538
+ * Cancels an order. Recurring orders can be canceled either immediately or at the next payment date. One time orders can only be canceled immediately.
650
539
  *
651
- * New `endDate` must be later than the order's current `endDate`. Can't postpone orders that are unlimited.
652
- * Can't postpone an order with `status`: `PAUSED`.
653
- * @param _id - Order ID.
654
- * @param endDate - New end date and time.
540
+ * There may be some operations that continue to be processed before the status of the order is changed to `"CANCELED"`. For example, payments might need to be refunded before the order is fully canceled.
655
541
  *
656
- * Must be later than the current end date and time.
542
+ * Canceling during the free trial period: When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end of the free trial period and they won't be billed. The buyer may continue using the benefits until the end of the free trial period.
543
+ *
544
+ * >**Note:**
545
+ * >This method requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions).
546
+ * @param _id - Order ID.
547
+ * @param effectiveAt - Required. Whether to cancel the order effective immediately or at the next payment date. One-time orders can only be canceled immediately.
657
548
  * @public
658
549
  * @requiredField _id
659
- * @requiredField endDate
660
- * @param options - Options for postponing the end date of an order.
661
- * @permissionId PRICING_PLANS.MANAGE_ORDERS
662
- * @permissionScope Manage Orders
663
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
664
- * @applicableIdentity APP
665
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.PostponeEndDate
550
+ * @requiredField effectiveAt
551
+ * @param options - Options for requesting a cancellation.
552
+ * @permissionId PRICING_PLANS.MANAGE_OWN_ORDERS
553
+ * @applicableIdentity MEMBER
554
+ * @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.RequestCancellation
666
555
  */
667
- export async function postponeEndDate(_id, endDate) {
556
+ export async function requestCancellation(_id, effectiveAt) {
668
557
  // @ts-ignore
669
558
  const { httpClient, sideEffects } = arguments[2];
670
559
  const payload = renameKeysFromSDKRequestToRESTRequest({
671
560
  id: _id,
672
- endDate: endDate,
561
+ effectiveAt: effectiveAt,
673
562
  });
674
- const reqOpts = ambassadorWixPricingPlansV2Order.postponeEndDate(payload);
563
+ const reqOpts = ambassadorWixPricingPlansV2Order.requestCancellation(payload);
675
564
  sideEffects?.onSiteCall?.();
676
565
  try {
677
566
  const result = await httpClient.request(reqOpts);
@@ -680,179 +569,298 @@ export async function postponeEndDate(_id, endDate) {
680
569
  catch (err) {
681
570
  const transformedError = sdkTransformError(err, {
682
571
  spreadPathsToArguments: {},
683
- explicitPathsToArguments: { id: '$[0]', endDate: '$[1]' },
572
+ explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
684
573
  singleArgumentUnchanged: false,
685
- }, ['_id', 'endDate']);
574
+ }, ['_id', 'effectiveAt']);
686
575
  sideEffects?.onError?.(err);
687
576
  throw transformedError;
688
577
  }
689
578
  }
690
579
  /**
691
- * Cancels an existing order.
580
+ * Creates an online order for a site member.
692
581
  *
693
- * For orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
694
- * For orders with one-time payments, a cancellation can only be set for `IMMEDIATELY`.
582
+ * If this method is called by a site member ([SDK](https://dev.wix.com/docs/sdk/articles/get-started/about-identities#site-member) | [REST](https://dev.wix.com/docs/rest/articles/getting-started/about-identities#site-member)), the plan is automatically ordered on behalf of that site member. Otherwise, you must specify `onBehalf.memberId` in your call.
695
583
  *
696
- * #### Canceling during the free trial period.
584
+ * When an online order is created, but payment hasn't been processed, its status is set to `DRAFT`. After the payment has been processed, if the start date is in the future the order's status is set to `PENDING`. Otherwise, it's set to `ACTIVE`.
585
+ * @param planId - Plan ID.
586
+ * @public
587
+ * @requiredField options.onBehalf.memberId
588
+ * @requiredField planId
589
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOnlineOrder
590
+ */
591
+ export async function createOnlineOrder(planId, options) {
592
+ // @ts-ignore
593
+ const { httpClient, sideEffects } = arguments[2];
594
+ const payload = renameKeysFromSDKRequestToRESTRequest({
595
+ planId: planId,
596
+ startDate: options?.startDate,
597
+ couponCode: options?.couponCode,
598
+ onBehalf: options?.onBehalf,
599
+ submissionId: options?.submissionId,
600
+ });
601
+ const reqOpts = ambassadorWixPricingPlansV2Order.createOnlineOrder(payload);
602
+ sideEffects?.onSiteCall?.();
603
+ try {
604
+ const result = await httpClient.request(reqOpts);
605
+ sideEffects?.onSuccess?.(result);
606
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
607
+ }
608
+ catch (err) {
609
+ const transformedError = sdkTransformError(err, {
610
+ spreadPathsToArguments: {},
611
+ explicitPathsToArguments: {
612
+ planId: '$[0]',
613
+ startDate: '$[1].startDate',
614
+ couponCode: '$[1].couponCode',
615
+ onBehalf: '$[1].onBehalf',
616
+ submissionId: '$[1].submissionId',
617
+ },
618
+ singleArgumentUnchanged: false,
619
+ }, ['planId', 'options']);
620
+ sideEffects?.onError?.(err);
621
+ throw transformedError;
622
+ }
623
+ }
624
+ /**
625
+ * Creates an order for a buyer who purchased the plan with an offline transaction.
697
626
  *
698
- * When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end
699
- * of the free trial period and they will not be billed. The buyer may continue using the benefits until the end
700
- * of the free trial period.
627
+ * An offline order is handled off of the Wix site and is marked as `type`: `offline`. If a pricing plan
628
+ * has a limit on the amount of purchases per buyer, that limit is ignored for offline orders.
629
+ * Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
701
630
  *
702
- * When a Wix user cancels an ordered plan during the free trial period, they choose whether to apply the cancellation
703
- * `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. Canceling `IMMEDIATELY` will end the subscription for the buyer
704
- * immediately, even during the free trial period and the buyer won't be billed. Canceling at the
705
- * `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period.
706
- * Then, the subscription ends and the buyer is not billed.
707
- * @param _id - Order ID.
708
- * @param effectiveAt - __Required.__ When the order will be canceled. One-time orders can only be canceled `IMMEDIATELY`.
631
+ * When creating a free offline order:
632
+ * The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
633
+ * The order's last payment status is set to `"NOT_APPLICABLE"`. "
634
+ *
635
+ * When creating a non-free offline order:
636
+ * The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
637
+ * The order's last payment status is set to `"UNPAID"` or `"PAID"` based on the data passed in the `paid` boolean in the request.
638
+ *
639
+ * Payment for an offline order can be set in 1 of 2 ways:
640
+ * + During order creation, set `paid`: `true`.
641
+ * + After creation, call Mark As Paid.
642
+ * @param planId - ID of the plan being ordered, from the Plans API.
643
+ * @param memberId - ID of the member ordering the plan, from the Members API.
709
644
  * @public
710
- * @requiredField _id
711
- * @requiredField effectiveAt
712
- * @param options - Options for canceling orders.
713
- * @permissionId PRICING_PLANS.MANAGE_ORDERS
645
+ * @requiredField memberId
646
+ * @requiredField planId
647
+ * @param options - Options for creating an offline order.
648
+ * @permissionId PRICING_PLANS.REGISTER_OFFLINE_ORDERS
714
649
  * @permissionScope Manage Orders
715
650
  * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
716
651
  * @applicableIdentity APP
717
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.CancelOrder
652
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOfflineOrder
718
653
  */
719
- export async function cancelOrder(_id, effectiveAt) {
654
+ export async function createOfflineOrder(planId, memberId, options) {
720
655
  // @ts-ignore
721
- const { httpClient, sideEffects } = arguments[2];
656
+ const { httpClient, sideEffects } = arguments[3];
722
657
  const payload = renameKeysFromSDKRequestToRESTRequest({
723
- id: _id,
724
- effectiveAt: effectiveAt,
658
+ planId: planId,
659
+ memberId: memberId,
660
+ startDate: options?.startDate,
661
+ paid: options?.paid,
662
+ couponCode: options?.couponCode,
663
+ submissionId: options?.submissionId,
725
664
  });
726
- const reqOpts = ambassadorWixPricingPlansV2Order.cancelOrder(payload);
665
+ const reqOpts = ambassadorWixPricingPlansV2Order.createOfflineOrder(payload);
727
666
  sideEffects?.onSiteCall?.();
728
667
  try {
729
668
  const result = await httpClient.request(reqOpts);
730
669
  sideEffects?.onSuccess?.(result);
670
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
731
671
  }
732
672
  catch (err) {
733
673
  const transformedError = sdkTransformError(err, {
734
674
  spreadPathsToArguments: {},
735
- explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
675
+ explicitPathsToArguments: {
676
+ planId: '$[0]',
677
+ memberId: '$[1]',
678
+ startDate: '$[2].startDate',
679
+ paid: '$[2].paid',
680
+ couponCode: '$[2].couponCode',
681
+ submissionId: '$[2].submissionId',
682
+ },
736
683
  singleArgumentUnchanged: false,
737
- }, ['_id', 'effectiveAt']);
684
+ }, ['planId', 'memberId', 'options']);
738
685
  sideEffects?.onError?.(err);
739
686
  throw transformedError;
740
687
  }
741
688
  }
742
689
  /**
743
- * Marks an offline order as paid.
744
- * > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments.
690
+ * Returns an `order` object that represents a potential online order for a site member.
745
691
  *
746
- * Marking an offline order as paid causes the following changes:
747
- * - The order's `lastPaymentStatus` changes to `"PAID"`.
748
- * - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`.
692
+ * You can use this method to show a site member a preview of an online order before [creating](https://dev.wix.com/docs/rest/business-solutions/pricing-plans/pricing-plans/orders/create-online-order) it.
749
693
  *
750
- * An error occurs if you attempt to:
751
- * - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice.
752
- * - Mark an online order as paid. The Mark as Paid method is supported for offline orders only.
753
- * @param _id - Order ID.
694
+ * This method must be called using the site member identity ([SDK](https://dev.wix.com/docs/sdk/articles/get-started/about-identities#site-member) | [REST](https://dev.wix.com/docs/rest/articles/getting-started/about-identities#site-member)). Therefore, [Wix apps](https://dev.wix.com/docs/build-apps) can't currently call this method using REST.
695
+ * @param planId - Plan ID.
754
696
  * @public
755
- * @requiredField _id
756
- * @permissionId PRICING_PLANS.MANAGE_ORDERS
757
- * @permissionScope Manage Orders
758
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
697
+ * @requiredField planId
698
+ * @permissionId PRICING_PLANS.PURCHASE_PLANS
699
+ * @permissionScope Manage Bookings Services and Settings
700
+ * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
701
+ * @permissionScope Manage Events
702
+ * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
703
+ * @permissionScope Manage Challenges
704
+ * @permissionScopeId SCOPE.CHALLENGES.MANAGE
705
+ * @permissionScope Manage Portfolio
706
+ * @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
707
+ * @permissionScope Access Verticals by Automations
708
+ * @permissionScopeId SCOPE.CRM.ACCESS-VERTICALS-BY-AUTOMATIONS
709
+ * @permissionScope Manage Restaurants - all permissions
710
+ * @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
711
+ * @permissionScope Set Up Automations
712
+ * @permissionScopeId SCOPE.CRM.SETUP-AUTOMATIONS
759
713
  * @applicableIdentity APP
760
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.MarkAsPaid
714
+ * @applicableIdentity MEMBER
715
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOnlineOrderPreview
761
716
  */
762
- export async function markAsPaid(_id) {
717
+ export async function getOnlineOrderPreview(planId, options) {
763
718
  // @ts-ignore
764
- const { httpClient, sideEffects } = arguments[1];
765
- const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
766
- const reqOpts = ambassadorWixPricingPlansV2Order.markAsPaid(payload);
719
+ const { httpClient, sideEffects } = arguments[2];
720
+ const payload = renameKeysFromSDKRequestToRESTRequest({
721
+ planId: planId,
722
+ startDate: options?.startDate,
723
+ couponCode: options?.couponCode,
724
+ });
725
+ const reqOpts = ambassadorWixPricingPlansV2Order.getOnlineOrderPreview(payload);
767
726
  sideEffects?.onSiteCall?.();
768
727
  try {
769
728
  const result = await httpClient.request(reqOpts);
770
729
  sideEffects?.onSuccess?.(result);
730
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
771
731
  }
772
732
  catch (err) {
773
733
  const transformedError = sdkTransformError(err, {
774
734
  spreadPathsToArguments: {},
775
- explicitPathsToArguments: { id: '$[0]' },
735
+ explicitPathsToArguments: {
736
+ planId: '$[0]',
737
+ startDate: '$[1].startDate',
738
+ couponCode: '$[1].couponCode',
739
+ },
776
740
  singleArgumentUnchanged: false,
777
- }, ['_id']);
741
+ }, ['planId', 'options']);
778
742
  sideEffects?.onError?.(err);
779
743
  throw transformedError;
780
744
  }
781
745
  }
782
746
  /**
783
- * Pauses an order. Calling this method changes the order status to `"PAUSED"` and updates the `pausePeriods` array.
747
+ * Performs a dry run of a purchase and provides an order preview.
784
748
  *
785
- * Only orders with `status`: `ACTIVE` can be paused.
786
- * For orders with recurring payments, it also pauses the payment schedule. Buyers are not charged when an order is paused.
787
- * Pausing an order affects the end date of the order by adding the time the order is paused to the `endDate`.
788
- * The `endDate` and the `earliestEndDate` for the order are adjusted to include the pause period when the order is resumed.
749
+ * The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually
750
+ * created, the preview order's `orderId` and `subscriptionId` are displayed as a string of multiple zero characters
751
+ * (`000000-0000`). Tax is only calculated if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
752
+ * <br>
753
+ * If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview.
754
+ * But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then
755
+ * `purchaseLimitExceeded` will return as `true`.
789
756
  *
790
- * To resume a paused order, call Resume Order.
791
- * @param _id - Order ID.
757
+ * To get a general price preview for a plan that's not buyer-specific, call Get Price Preview.
758
+ * @param memberId - Member ID of the buyer the previewed order is for, from the Members API.
792
759
  * @public
793
- * @requiredField _id
760
+ * @requiredField memberId
761
+ * @requiredField planId
762
+ * @param options - Options for previewing the offline order.
763
+ * @param planId - ID of the plan of the previewed order.
794
764
  * @permissionId PRICING_PLANS.MANAGE_ORDERS
795
765
  * @permissionScope Manage Orders
796
766
  * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
797
767
  * @applicableIdentity APP
798
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.PauseOrder
768
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOfflineOrderPreview
799
769
  */
800
- export async function pauseOrder(_id) {
770
+ export async function getOfflineOrderPreview(planId, memberId, options) {
801
771
  // @ts-ignore
802
- const { httpClient, sideEffects } = arguments[1];
803
- const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
804
- const reqOpts = ambassadorWixPricingPlansV2Order.pauseOrder(payload);
772
+ const { httpClient, sideEffects } = arguments[3];
773
+ const payload = renameKeysFromSDKRequestToRESTRequest({
774
+ planId: planId,
775
+ memberId: memberId,
776
+ startDate: options?.startDate,
777
+ couponCode: options?.couponCode,
778
+ });
779
+ const reqOpts = ambassadorWixPricingPlansV2Order.getOfflineOrderPreview(payload);
805
780
  sideEffects?.onSiteCall?.();
806
781
  try {
807
782
  const result = await httpClient.request(reqOpts);
808
783
  sideEffects?.onSuccess?.(result);
784
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
809
785
  }
810
786
  catch (err) {
811
787
  const transformedError = sdkTransformError(err, {
812
788
  spreadPathsToArguments: {},
813
- explicitPathsToArguments: { id: '$[0]' },
789
+ explicitPathsToArguments: {
790
+ planId: '$[0]',
791
+ memberId: '$[1]',
792
+ startDate: '$[2].startDate',
793
+ couponCode: '$[2].couponCode',
794
+ },
814
795
  singleArgumentUnchanged: false,
815
- }, ['_id']);
796
+ }, ['planId', 'memberId', 'options']);
816
797
  sideEffects?.onError?.(err);
817
798
  throw transformedError;
818
799
  }
819
800
  }
820
801
  /**
821
- * Resumes a paused order. For orders with recurring payments, it also restarts the payment schedule.
802
+ * Retrieves a plan's pricing.
822
803
  *
823
- * Resuming an order causes the following changes:
824
- * - The order status changes to `"ACTIVE"`.
825
- * - The `pausePeriods` array is updated.
826
- * - The `endDate` for the order is adjusted to include the pause period.
827
- * - For orders with recurring payments, the payment schedule is restarted.
828
- * - The `earliestEndDate` is adjusted to include the pause period. (This property is reserved for future use).
804
+ * The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if
805
+ * the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned
806
+ * in the pricing model format used for orders. Learn more about pricing models ([REST](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models)|[SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/introduction#pricing-models)).
829
807
  *
830
- * To pause an order, call Pause Order.
831
- * @param _id - Order ID.
808
+ * Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To
809
+ * generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.
810
+ * @param planId - ID of plan to preview.
832
811
  * @public
833
- * @requiredField _id
834
- * @permissionId PRICING_PLANS.MANAGE_ORDERS
812
+ * @requiredField planId
813
+ * @param options - Options for getting a price preview.
814
+ * @permissionId PRICING_PLANS.READ_PUBLIC_PLANS
815
+ * @permissionScope Read Pricing Plans
816
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
835
817
  * @permissionScope Manage Orders
836
818
  * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
819
+ * @permissionScope Manage Bookings Services and Settings
820
+ * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
821
+ * @permissionScope Read Orders
822
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
823
+ * @permissionScope Manage Events
824
+ * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
825
+ * @permissionScope Manage Challenges
826
+ * @permissionScopeId SCOPE.CHALLENGES.MANAGE
827
+ * @permissionScope Manage Portfolio
828
+ * @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
829
+ * @permissionScope Access Verticals by Automations
830
+ * @permissionScopeId SCOPE.CRM.ACCESS-VERTICALS-BY-AUTOMATIONS
831
+ * @permissionScope Manage Pricing Plans
832
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
833
+ * @permissionScope Manage Restaurants - all permissions
834
+ * @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
835
+ * @permissionScope Set Up Automations
836
+ * @permissionScopeId SCOPE.CRM.SETUP-AUTOMATIONS
837
837
  * @applicableIdentity APP
838
- * @fqn com.wixpress.membership.v2.orders.OrderManagementService.ResumeOrder
838
+ * @applicableIdentity VISITOR
839
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetPricePreview
839
840
  */
840
- export async function resumeOrder(_id) {
841
+ export async function getPricePreview(planId, options) {
841
842
  // @ts-ignore
842
- const { httpClient, sideEffects } = arguments[1];
843
- const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
844
- const reqOpts = ambassadorWixPricingPlansV2Order.resumeOrder(payload);
843
+ const { httpClient, sideEffects } = arguments[2];
844
+ const payload = renameKeysFromSDKRequestToRESTRequest({
845
+ planId: planId,
846
+ couponCode: options?.couponCode,
847
+ });
848
+ const reqOpts = ambassadorWixPricingPlansV2Order.getPricePreview(payload);
845
849
  sideEffects?.onSiteCall?.();
846
850
  try {
847
851
  const result = await httpClient.request(reqOpts);
848
852
  sideEffects?.onSuccess?.(result);
853
+ return renameKeysFromRESTResponseToSDKResponse(result.data);
849
854
  }
850
855
  catch (err) {
851
856
  const transformedError = sdkTransformError(err, {
852
857
  spreadPathsToArguments: {},
853
- explicitPathsToArguments: { id: '$[0]' },
858
+ explicitPathsToArguments: {
859
+ planId: '$[0]',
860
+ couponCode: '$[1].couponCode',
861
+ },
854
862
  singleArgumentUnchanged: false,
855
- }, ['_id']);
863
+ }, ['planId', 'options']);
856
864
  sideEffects?.onError?.(err);
857
865
  throw transformedError;
858
866
  }