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