@wix/auto_sdk_pricing-plans_orders 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +18 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/index.typings.d.ts +1 -0
  5. package/build/cjs/index.typings.js +18 -0
  6. package/build/cjs/index.typings.js.map +1 -0
  7. package/build/cjs/meta.d.ts +1 -0
  8. package/build/cjs/meta.js +18 -0
  9. package/build/cjs/meta.js.map +1 -0
  10. package/build/cjs/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
  11. package/build/cjs/src/pricing-plans-v2-order-orders.context.js +126 -0
  12. package/build/cjs/src/pricing-plans-v2-order-orders.context.js.map +1 -0
  13. package/build/cjs/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
  14. package/build/cjs/src/pricing-plans-v2-order-orders.http.js +877 -0
  15. package/build/cjs/src/pricing-plans-v2-order-orders.http.js.map +1 -0
  16. package/build/cjs/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
  17. package/build/cjs/src/pricing-plans-v2-order-orders.meta.js +313 -0
  18. package/build/cjs/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
  19. package/build/cjs/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
  20. package/build/cjs/src/pricing-plans-v2-order-orders.public.js +373 -0
  21. package/build/cjs/src/pricing-plans-v2-order-orders.public.js.map +1 -0
  22. package/build/cjs/src/pricing-plans-v2-order-orders.types.d.ts +1331 -0
  23. package/build/cjs/src/pricing-plans-v2-order-orders.types.js +145 -0
  24. package/build/cjs/src/pricing-plans-v2-order-orders.types.js.map +1 -0
  25. package/build/cjs/src/pricing-plans-v2-order-orders.universal.d.ts +2015 -0
  26. package/build/cjs/src/pricing-plans-v2-order-orders.universal.js +889 -0
  27. package/build/cjs/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
  28. package/build/es/index.d.ts +1 -0
  29. package/build/es/index.js +2 -0
  30. package/build/es/index.js.map +1 -0
  31. package/build/es/index.typings.d.ts +1 -0
  32. package/build/es/index.typings.js +2 -0
  33. package/build/es/index.typings.js.map +1 -0
  34. package/build/es/meta.d.ts +1 -0
  35. package/build/es/meta.js +2 -0
  36. package/build/es/meta.js.map +1 -0
  37. package/build/es/package.json +3 -0
  38. package/build/es/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
  39. package/build/es/src/pricing-plans-v2-order-orders.context.js +111 -0
  40. package/build/es/src/pricing-plans-v2-order-orders.context.js.map +1 -0
  41. package/build/es/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
  42. package/build/es/src/pricing-plans-v2-order-orders.http.js +859 -0
  43. package/build/es/src/pricing-plans-v2-order-orders.http.js.map +1 -0
  44. package/build/es/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
  45. package/build/es/src/pricing-plans-v2-order-orders.meta.js +272 -0
  46. package/build/es/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
  47. package/build/es/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
  48. package/build/es/src/pricing-plans-v2-order-orders.public.js +343 -0
  49. package/build/es/src/pricing-plans-v2-order-orders.public.js.map +1 -0
  50. package/build/es/src/pricing-plans-v2-order-orders.types.d.ts +1331 -0
  51. package/build/es/src/pricing-plans-v2-order-orders.types.js +142 -0
  52. package/build/es/src/pricing-plans-v2-order-orders.types.js.map +1 -0
  53. package/build/es/src/pricing-plans-v2-order-orders.universal.d.ts +2015 -0
  54. package/build/es/src/pricing-plans-v2-order-orders.universal.js +848 -0
  55. package/build/es/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
  56. package/build/internal/cjs/index.d.ts +1 -0
  57. package/build/internal/cjs/index.js +18 -0
  58. package/build/internal/cjs/index.js.map +1 -0
  59. package/build/internal/cjs/index.typings.d.ts +1 -0
  60. package/build/internal/cjs/index.typings.js +18 -0
  61. package/build/internal/cjs/index.typings.js.map +1 -0
  62. package/build/internal/cjs/meta.d.ts +1 -0
  63. package/build/internal/cjs/meta.js +18 -0
  64. package/build/internal/cjs/meta.js.map +1 -0
  65. package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
  66. package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.js +126 -0
  67. package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.js.map +1 -0
  68. package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
  69. package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.js +877 -0
  70. package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.js.map +1 -0
  71. package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
  72. package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.js +313 -0
  73. package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
  74. package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
  75. package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.js +373 -0
  76. package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.js.map +1 -0
  77. package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.d.ts +1333 -0
  78. package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.js +145 -0
  79. package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.js.map +1 -0
  80. package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.d.ts +2034 -0
  81. package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.js +889 -0
  82. package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
  83. package/build/internal/es/index.d.ts +1 -0
  84. package/build/internal/es/index.js +2 -0
  85. package/build/internal/es/index.js.map +1 -0
  86. package/build/internal/es/index.typings.d.ts +1 -0
  87. package/build/internal/es/index.typings.js +2 -0
  88. package/build/internal/es/index.typings.js.map +1 -0
  89. package/build/internal/es/meta.d.ts +1 -0
  90. package/build/internal/es/meta.js +2 -0
  91. package/build/internal/es/meta.js.map +1 -0
  92. package/build/internal/es/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
  93. package/build/internal/es/src/pricing-plans-v2-order-orders.context.js +111 -0
  94. package/build/internal/es/src/pricing-plans-v2-order-orders.context.js.map +1 -0
  95. package/build/internal/es/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
  96. package/build/internal/es/src/pricing-plans-v2-order-orders.http.js +859 -0
  97. package/build/internal/es/src/pricing-plans-v2-order-orders.http.js.map +1 -0
  98. package/build/internal/es/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
  99. package/build/internal/es/src/pricing-plans-v2-order-orders.meta.js +272 -0
  100. package/build/internal/es/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
  101. package/build/internal/es/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
  102. package/build/internal/es/src/pricing-plans-v2-order-orders.public.js +343 -0
  103. package/build/internal/es/src/pricing-plans-v2-order-orders.public.js.map +1 -0
  104. package/build/internal/es/src/pricing-plans-v2-order-orders.types.d.ts +1333 -0
  105. package/build/internal/es/src/pricing-plans-v2-order-orders.types.js +142 -0
  106. package/build/internal/es/src/pricing-plans-v2-order-orders.types.js.map +1 -0
  107. package/build/internal/es/src/pricing-plans-v2-order-orders.universal.d.ts +2034 -0
  108. package/build/internal/es/src/pricing-plans-v2-order-orders.universal.js +848 -0
  109. package/build/internal/es/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
  110. package/meta/package.json +3 -0
  111. package/package.json +52 -0
@@ -0,0 +1,889 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
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;
27
+ const transform_error_1 = require("@wix/sdk-runtime/transform-error");
28
+ const rename_all_nested_keys_1 = require("@wix/sdk-runtime/rename-all-nested-keys");
29
+ const ambassadorWixPricingPlansV2Order = __importStar(require("./pricing-plans-v2-order-orders.http.js"));
30
+ var PeriodUnit;
31
+ (function (PeriodUnit) {
32
+ /** Not defined. */
33
+ PeriodUnit["UNDEFINED"] = "UNDEFINED";
34
+ /** Time unit is a day. */
35
+ PeriodUnit["DAY"] = "DAY";
36
+ /** Time unit is a week. */
37
+ PeriodUnit["WEEK"] = "WEEK";
38
+ /** Time unit is a month. */
39
+ PeriodUnit["MONTH"] = "MONTH";
40
+ /** Time unit is a year. */
41
+ PeriodUnit["YEAR"] = "YEAR";
42
+ })(PeriodUnit || (exports.PeriodUnit = PeriodUnit = {}));
43
+ var OrderType;
44
+ (function (OrderType) {
45
+ /** Undefined order type. */
46
+ OrderType["UNDEFINED"] = "UNDEFINED";
47
+ /** The buyer purchased the plan using the site. */
48
+ OrderType["ONLINE"] = "ONLINE";
49
+ /** The buyer made a manual, offline purchase without using the site. */
50
+ OrderType["OFFLINE"] = "OFFLINE";
51
+ /** The buyer made a purchase through an external payment provider. */
52
+ OrderType["EXTERNAL"] = "EXTERNAL";
53
+ })(OrderType || (exports.OrderType = OrderType = {}));
54
+ var OrderMethod;
55
+ (function (OrderMethod) {
56
+ /** Unknown order method. */
57
+ OrderMethod["UNKNOWN"] = "UNKNOWN";
58
+ /** Mail Order / Telephone Order transaction. */
59
+ OrderMethod["MOTO"] = "MOTO";
60
+ /** Point of Sale transaction. */
61
+ OrderMethod["POS"] = "POS";
62
+ })(OrderMethod || (exports.OrderMethod = OrderMethod = {}));
63
+ var OrderStatus;
64
+ (function (OrderStatus) {
65
+ /** Undefined order status. */
66
+ OrderStatus["UNDEFINED"] = "UNDEFINED";
67
+ /** Order has been initiated but payment hasn't been processed yet. The plan isn't yet available for use to the buyer. */
68
+ OrderStatus["DRAFT"] = "DRAFT";
69
+ /** Order has been purchased and its start date is set in the future. */
70
+ OrderStatus["PENDING"] = "PENDING";
71
+ /** Order has been processed. The plan is available for use. */
72
+ OrderStatus["ACTIVE"] = "ACTIVE";
73
+ /** Order, and use of the plan, is paused. The order, and use of the plan, can be resumed. */
74
+ OrderStatus["PAUSED"] = "PAUSED";
75
+ /** Order has completed its duration and is no longer available for use. */
76
+ OrderStatus["ENDED"] = "ENDED";
77
+ /** Order has been canceled. */
78
+ OrderStatus["CANCELED"] = "CANCELED";
79
+ })(OrderStatus || (exports.OrderStatus = OrderStatus = {}));
80
+ var CancellationCause;
81
+ (function (CancellationCause) {
82
+ /** Undefined cancellation cause. */
83
+ CancellationCause["UNDEFINED"] = "UNDEFINED";
84
+ /** Wix user canceled the order. */
85
+ CancellationCause["OWNER_ACTION"] = "OWNER_ACTION";
86
+ /** Buyer initiated the cancellation. */
87
+ CancellationCause["MEMBER_ACTION"] = "MEMBER_ACTION";
88
+ /** Payment transaction failed. */
89
+ CancellationCause["PAYMENT_FAILURE"] = "PAYMENT_FAILURE";
90
+ /** Buyer's payment details weren't set up correctly. */
91
+ CancellationCause["PAYMENT_SETUP_FAILURE"] = "PAYMENT_SETUP_FAILURE";
92
+ /** Reason for the cancellation is unknown. */
93
+ CancellationCause["UNKNOWN"] = "UNKNOWN";
94
+ })(CancellationCause || (exports.CancellationCause = CancellationCause = {}));
95
+ var CancellationEffectiveAt;
96
+ (function (CancellationEffectiveAt) {
97
+ /** Undefined cancellation time. */
98
+ CancellationEffectiveAt["UNDEFINED"] = "UNDEFINED";
99
+ /** Cancellation occurs immediately and the buyer can no longer use the plan. */
100
+ CancellationEffectiveAt["IMMEDIATELY"] = "IMMEDIATELY";
101
+ /** Cancellation occurs at the next payment date and time. Buyer can continue to use the plan until that date and time. */
102
+ CancellationEffectiveAt["NEXT_PAYMENT_DATE"] = "NEXT_PAYMENT_DATE";
103
+ })(CancellationEffectiveAt || (exports.CancellationEffectiveAt = CancellationEffectiveAt = {}));
104
+ var PaymentStatus;
105
+ (function (PaymentStatus) {
106
+ /** Undefined payment status. */
107
+ PaymentStatus["UNDEFINED"] = "UNDEFINED";
108
+ /** Payment has been paid. */
109
+ PaymentStatus["PAID"] = "PAID";
110
+ /** Payment has been refunded. */
111
+ PaymentStatus["REFUNDED"] = "REFUNDED";
112
+ /** Payment transaction didn't complete. */
113
+ PaymentStatus["FAILED"] = "FAILED";
114
+ /** Payment has not been paid. */
115
+ PaymentStatus["UNPAID"] = "UNPAID";
116
+ /** Billing has been initialized, but actual charge is yet to be made. This can happen for free trials and payments made with PayPal. */
117
+ PaymentStatus["PENDING"] = "PENDING";
118
+ /** No payment was necessary. For example, for free plans or free trials. */
119
+ PaymentStatus["NOT_APPLICABLE"] = "NOT_APPLICABLE";
120
+ })(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
121
+ var Status;
122
+ (function (Status) {
123
+ /** Undefined status. */
124
+ Status["UNDEFINED"] = "UNDEFINED";
125
+ /** Status while the order is paused. */
126
+ Status["ACTIVE"] = "ACTIVE";
127
+ /** Status when the order is resumed. */
128
+ Status["ENDED"] = "ENDED";
129
+ })(Status || (exports.Status = Status = {}));
130
+ var Set;
131
+ (function (Set) {
132
+ /** Same behavior as `BASIC`.` */
133
+ Set["UNKNOWN_SET"] = "UNKNOWN_SET";
134
+ /** Doesn't return any order form submission data. */
135
+ Set["BASIC"] = "BASIC";
136
+ /** Returns all order form submission data. */
137
+ Set["FULL"] = "FULL";
138
+ })(Set || (exports.Set = Set = {}));
139
+ var SortOrder;
140
+ (function (SortOrder) {
141
+ SortOrder["ASC"] = "ASC";
142
+ SortOrder["DESC"] = "DESC";
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
+ var ReasonNotSuspendable;
153
+ (function (ReasonNotSuspendable) {
154
+ /** Undefined reason. */
155
+ ReasonNotSuspendable["UNDEFINED"] = "UNDEFINED";
156
+ /** Saved in the database but is awaiting payment. Non-active orders can't be suspended. */
157
+ ReasonNotSuspendable["PENDING"] = "PENDING";
158
+ /** Trial orders can't be suspended. */
159
+ ReasonNotSuspendable["TRIAL"] = "TRIAL";
160
+ /** Canceled orders can't be suspended. */
161
+ ReasonNotSuspendable["CANCELED"] = "CANCELED";
162
+ /** Ended orders can't be suspended. */
163
+ ReasonNotSuspendable["ENDED"] = "ENDED";
164
+ /** Paid for orders with future start dates can't be suspended. */
165
+ ReasonNotSuspendable["NOT_STARTED"] = "NOT_STARTED";
166
+ /** Order is already suspended. */
167
+ ReasonNotSuspendable["ALREADY_SUSPENDED"] = "ALREADY_SUSPENDED";
168
+ /** Orders based on recurring payments using older stripe versions can't be suspended. */
169
+ ReasonNotSuspendable["OLD_STRIPE"] = "OLD_STRIPE";
170
+ })(ReasonNotSuspendable || (exports.ReasonNotSuspendable = ReasonNotSuspendable = {}));
171
+ /**
172
+ * Retrieves an order for the currently logged-in member by ID.
173
+ * @param _id - Order ID.
174
+ * @public
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
181
+ */
182
+ async function memberGetOrder(_id, options) {
183
+ // @ts-ignore
184
+ const { httpClient, sideEffects } = arguments[2];
185
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
186
+ id: _id,
187
+ fieldSet: options?.fieldSet,
188
+ });
189
+ const reqOpts = ambassadorWixPricingPlansV2Order.memberGetOrder(payload);
190
+ sideEffects?.onSiteCall?.();
191
+ try {
192
+ const result = await httpClient.request(reqOpts);
193
+ sideEffects?.onSuccess?.(result);
194
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data)?.order;
195
+ }
196
+ catch (err) {
197
+ const transformedError = (0, transform_error_1.transformError)(err, {
198
+ spreadPathsToArguments: {},
199
+ explicitPathsToArguments: { id: '$[0]', fieldSet: '$[1].fieldSet' },
200
+ singleArgumentUnchanged: false,
201
+ }, ['_id', 'options']);
202
+ sideEffects?.onError?.(err);
203
+ throw transformedError;
204
+ }
205
+ }
206
+ exports.memberGetOrder = memberGetOrder;
207
+ /**
208
+ * Retrieves a list of up to 100 pricing plan orders for currently logged-in member.
209
+ * @public
210
+ * @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
214
+ */
215
+ async function memberListOrders(options) {
216
+ // @ts-ignore
217
+ const { httpClient, sideEffects } = arguments[1];
218
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
219
+ planIds: options?.planIds,
220
+ autoRenewCanceled: options?.autoRenewCanceled,
221
+ orderStatuses: options?.orderStatuses,
222
+ paymentStatuses: options?.paymentStatuses,
223
+ limit: options?.limit,
224
+ offset: options?.offset,
225
+ sorting: options?.sorting,
226
+ fieldSet: options?.fieldSet,
227
+ });
228
+ const reqOpts = ambassadorWixPricingPlansV2Order.memberListOrders(payload);
229
+ sideEffects?.onSiteCall?.();
230
+ try {
231
+ const result = await httpClient.request(reqOpts);
232
+ sideEffects?.onSuccess?.(result);
233
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
234
+ }
235
+ catch (err) {
236
+ const transformedError = (0, transform_error_1.transformError)(err, {
237
+ spreadPathsToArguments: {},
238
+ explicitPathsToArguments: {
239
+ planIds: '$[0].planIds',
240
+ autoRenewCanceled: '$[0].autoRenewCanceled',
241
+ orderStatuses: '$[0].orderStatuses',
242
+ paymentStatuses: '$[0].paymentStatuses',
243
+ limit: '$[0].limit',
244
+ offset: '$[0].offset',
245
+ sorting: '$[0].sorting',
246
+ fieldSet: '$[0].fieldSet',
247
+ },
248
+ singleArgumentUnchanged: false,
249
+ }, ['options']);
250
+ sideEffects?.onError?.(err);
251
+ throw transformedError;
252
+ }
253
+ }
254
+ exports.memberListOrders = memberListOrders;
255
+ /**
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.
261
+ *
262
+ * >**Note:**
263
+ * >This method requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions).
264
+ * @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.
266
+ * @public
267
+ * @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
273
+ */
274
+ async function requestCancellation(_id, effectiveAt) {
275
+ // @ts-ignore
276
+ const { httpClient, sideEffects } = arguments[2];
277
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
278
+ id: _id,
279
+ effectiveAt: effectiveAt,
280
+ });
281
+ const reqOpts = ambassadorWixPricingPlansV2Order.requestCancellation(payload);
282
+ sideEffects?.onSiteCall?.();
283
+ try {
284
+ const result = await httpClient.request(reqOpts);
285
+ sideEffects?.onSuccess?.(result);
286
+ }
287
+ catch (err) {
288
+ const transformedError = (0, transform_error_1.transformError)(err, {
289
+ spreadPathsToArguments: {},
290
+ explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
291
+ singleArgumentUnchanged: false,
292
+ }, ['_id', 'effectiveAt']);
293
+ sideEffects?.onError?.(err);
294
+ throw transformedError;
295
+ }
296
+ }
297
+ exports.requestCancellation = requestCancellation;
298
+ /**
299
+ * Creates an online order for a site member.
300
+ *
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.
302
+ *
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.
305
+ * @public
306
+ * @requiredField options.onBehalf.memberId
307
+ * @requiredField planId
308
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOnlineOrder
309
+ */
310
+ async function createOnlineOrder(planId, options) {
311
+ // @ts-ignore
312
+ const { httpClient, sideEffects } = arguments[2];
313
+ 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,
319
+ });
320
+ const reqOpts = ambassadorWixPricingPlansV2Order.createOnlineOrder(payload);
321
+ sideEffects?.onSiteCall?.();
322
+ try {
323
+ const result = await httpClient.request(reqOpts);
324
+ sideEffects?.onSuccess?.(result);
325
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
326
+ }
327
+ catch (err) {
328
+ const transformedError = (0, transform_error_1.transformError)(err, {
329
+ spreadPathsToArguments: {},
330
+ explicitPathsToArguments: {
331
+ planId: '$[0]',
332
+ startDate: '$[1].startDate',
333
+ couponCode: '$[1].couponCode',
334
+ onBehalf: '$[1].onBehalf',
335
+ submissionId: '$[1].submissionId',
336
+ },
337
+ singleArgumentUnchanged: false,
338
+ }, ['planId', 'options']);
339
+ sideEffects?.onError?.(err);
340
+ throw transformedError;
341
+ }
342
+ }
343
+ exports.createOnlineOrder = createOnlineOrder;
344
+ /**
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"`. "
354
+ *
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.
358
+ *
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.
364
+ * @public
365
+ * @requiredField memberId
366
+ * @requiredField planId
367
+ * @param options - Options for creating an offline order.
368
+ * @permissionId PRICING_PLANS.REGISTER_OFFLINE_ORDERS
369
+ * @permissionScope Manage Orders
370
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
371
+ * @applicableIdentity APP
372
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOfflineOrder
373
+ */
374
+ async function createOfflineOrder(planId, memberId, options) {
375
+ // @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);
386
+ sideEffects?.onSiteCall?.();
387
+ try {
388
+ const result = await httpClient.request(reqOpts);
389
+ sideEffects?.onSuccess?.(result);
390
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
391
+ }
392
+ catch (err) {
393
+ const transformedError = (0, transform_error_1.transformError)(err, {
394
+ 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
+ },
403
+ singleArgumentUnchanged: false,
404
+ }, ['planId', 'memberId', 'options']);
405
+ sideEffects?.onError?.(err);
406
+ throw transformedError;
407
+ }
408
+ }
409
+ exports.createOfflineOrder = createOfflineOrder;
410
+ /**
411
+ * Returns an `order` object that represents a potential online order for a site member.
412
+ *
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.
414
+ *
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.
417
+ * @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 Portfolio
423
+ * @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
424
+ * @permissionScope Manage Restaurants - all permissions
425
+ * @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
426
+ * @applicableIdentity APP
427
+ * @applicableIdentity MEMBER
428
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOnlineOrderPreview
429
+ */
430
+ async function getOnlineOrderPreview(planId, options) {
431
+ // @ts-ignore
432
+ const { httpClient, sideEffects } = arguments[2];
433
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
434
+ planId: planId,
435
+ startDate: options?.startDate,
436
+ couponCode: options?.couponCode,
437
+ });
438
+ const reqOpts = ambassadorWixPricingPlansV2Order.getOnlineOrderPreview(payload);
439
+ sideEffects?.onSiteCall?.();
440
+ try {
441
+ const result = await httpClient.request(reqOpts);
442
+ sideEffects?.onSuccess?.(result);
443
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
444
+ }
445
+ catch (err) {
446
+ const transformedError = (0, transform_error_1.transformError)(err, {
447
+ spreadPathsToArguments: {},
448
+ explicitPathsToArguments: {
449
+ planId: '$[0]',
450
+ startDate: '$[1].startDate',
451
+ couponCode: '$[1].couponCode',
452
+ },
453
+ singleArgumentUnchanged: false,
454
+ }, ['planId', 'options']);
455
+ sideEffects?.onError?.(err);
456
+ throw transformedError;
457
+ }
458
+ }
459
+ exports.getOnlineOrderPreview = getOnlineOrderPreview;
460
+ /**
461
+ * Performs a dry run of a purchase and provides an order preview.
462
+ *
463
+ * The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually
464
+ * created, the preview order's `orderId` and `subscriptionId` are displayed as a string of multiple zero characters
465
+ * (`000000-0000`). Tax is only calculated if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
466
+ * <br>
467
+ * If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview.
468
+ * But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then
469
+ * `purchaseLimitExceeded` will return as `true`.
470
+ *
471
+ * To get a general price preview for a plan that's not buyer-specific, call Get Price Preview.
472
+ * @param memberId - Member ID of the buyer the previewed order is for, from the Members API.
473
+ * @public
474
+ * @requiredField memberId
475
+ * @requiredField planId
476
+ * @param options - Options for previewing the offline order.
477
+ * @param planId - ID of the plan of the previewed order.
478
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
479
+ * @permissionScope Manage Orders
480
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
481
+ * @applicableIdentity APP
482
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOfflineOrderPreview
483
+ */
484
+ async function getOfflineOrderPreview(planId, memberId, options) {
485
+ // @ts-ignore
486
+ const { httpClient, sideEffects } = arguments[3];
487
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
488
+ planId: planId,
489
+ memberId: memberId,
490
+ startDate: options?.startDate,
491
+ couponCode: options?.couponCode,
492
+ });
493
+ const reqOpts = ambassadorWixPricingPlansV2Order.getOfflineOrderPreview(payload);
494
+ sideEffects?.onSiteCall?.();
495
+ try {
496
+ const result = await httpClient.request(reqOpts);
497
+ sideEffects?.onSuccess?.(result);
498
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
499
+ }
500
+ catch (err) {
501
+ const transformedError = (0, transform_error_1.transformError)(err, {
502
+ spreadPathsToArguments: {},
503
+ explicitPathsToArguments: {
504
+ planId: '$[0]',
505
+ memberId: '$[1]',
506
+ startDate: '$[2].startDate',
507
+ couponCode: '$[2].couponCode',
508
+ },
509
+ singleArgumentUnchanged: false,
510
+ }, ['planId', 'memberId', 'options']);
511
+ sideEffects?.onError?.(err);
512
+ throw transformedError;
513
+ }
514
+ }
515
+ exports.getOfflineOrderPreview = getOfflineOrderPreview;
516
+ /**
517
+ * Retrieves a plan's pricing.
518
+ *
519
+ * The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if
520
+ * the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned
521
+ * 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)).
522
+ *
523
+ * Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To
524
+ * generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.
525
+ * @param planId - ID of plan to preview.
526
+ * @public
527
+ * @requiredField planId
528
+ * @param options - Options for getting a price preview.
529
+ * @permissionId PRICING_PLANS.READ_PUBLIC_PLANS
530
+ * @permissionScope Read Pricing Plans
531
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
532
+ * @permissionScope Manage Orders
533
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
534
+ * @permissionScope Manage Bookings Services and Settings
535
+ * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
536
+ * @permissionScope Read Orders
537
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
538
+ * @permissionScope Manage Portfolio
539
+ * @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
540
+ * @permissionScope Manage Pricing Plans
541
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
542
+ * @permissionScope Manage Restaurants - all permissions
543
+ * @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
544
+ * @applicableIdentity APP
545
+ * @applicableIdentity VISITOR
546
+ * @fqn com.wixpress.membership.v2.orders.CheckoutService.GetPricePreview
547
+ */
548
+ async function getPricePreview(planId, options) {
549
+ // @ts-ignore
550
+ const { httpClient, sideEffects } = arguments[2];
551
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
552
+ planId: planId,
553
+ couponCode: options?.couponCode,
554
+ });
555
+ const reqOpts = ambassadorWixPricingPlansV2Order.getPricePreview(payload);
556
+ sideEffects?.onSiteCall?.();
557
+ try {
558
+ const result = await httpClient.request(reqOpts);
559
+ sideEffects?.onSuccess?.(result);
560
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
561
+ }
562
+ catch (err) {
563
+ const transformedError = (0, transform_error_1.transformError)(err, {
564
+ spreadPathsToArguments: {},
565
+ explicitPathsToArguments: {
566
+ planId: '$[0]',
567
+ couponCode: '$[1].couponCode',
568
+ },
569
+ singleArgumentUnchanged: false,
570
+ }, ['planId', 'options']);
571
+ sideEffects?.onError?.(err);
572
+ throw transformedError;
573
+ }
574
+ }
575
+ exports.getPricePreview = getPricePreview;
576
+ /**
577
+ * Retrieves an order by ID.
578
+ * @param _id - Order ID.
579
+ * @public
580
+ * @requiredField _id
581
+ * @param options - Options to use when getting an order.
582
+ * @permissionId PRICING_PLANS.READ_ORDERS
583
+ * @permissionScope Manage Orders
584
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
585
+ * @permissionScope Read Orders
586
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
587
+ * @applicableIdentity APP
588
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.GetOrder
589
+ */
590
+ async function managementGetOrder(_id, options) {
591
+ // @ts-ignore
592
+ const { httpClient, sideEffects } = arguments[2];
593
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
594
+ id: _id,
595
+ fieldSet: options?.fieldSet,
596
+ });
597
+ const reqOpts = ambassadorWixPricingPlansV2Order.managementGetOrder(payload);
598
+ sideEffects?.onSiteCall?.();
599
+ try {
600
+ const result = await httpClient.request(reqOpts);
601
+ sideEffects?.onSuccess?.(result);
602
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
603
+ }
604
+ catch (err) {
605
+ const transformedError = (0, transform_error_1.transformError)(err, {
606
+ spreadPathsToArguments: {},
607
+ explicitPathsToArguments: { id: '$[0]', fieldSet: '$[1].fieldSet' },
608
+ singleArgumentUnchanged: false,
609
+ }, ['_id', 'options']);
610
+ sideEffects?.onError?.(err);
611
+ throw transformedError;
612
+ }
613
+ }
614
+ exports.managementGetOrder = managementGetOrder;
615
+ /**
616
+ * Retrieves a list of up to 50 pricing plan orders and details, given the specified sorting and filtering.
617
+ *
618
+ * By default, this endpoint will retrieve all orders and return them sorted by `createdDate` in `DESC`, descending order.
619
+ * `sort.fieldName` supports `endDate` and `createdDate` fields and defaults to `ASC`, ascending order.
620
+ * @public
621
+ * @param options - Filtering, sorting, and pagination options.
622
+ * @permissionId PRICING_PLANS.READ_ORDERS
623
+ * @permissionScope Manage Orders
624
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
625
+ * @permissionScope Read Orders
626
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
627
+ * @applicableIdentity APP
628
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.ListOrders
629
+ */
630
+ async function managementListOrders(options) {
631
+ // @ts-ignore
632
+ const { httpClient, sideEffects } = arguments[1];
633
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
634
+ buyerIds: options?.buyerIds,
635
+ planIds: options?.planIds,
636
+ autoRenewCanceled: options?.autoRenewCanceled,
637
+ orderStatuses: options?.orderStatuses,
638
+ paymentStatuses: options?.paymentStatuses,
639
+ limit: options?.limit,
640
+ offset: options?.offset,
641
+ sorting: options?.sorting,
642
+ fieldSet: options?.fieldSet,
643
+ });
644
+ const reqOpts = ambassadorWixPricingPlansV2Order.managementListOrders(payload);
645
+ sideEffects?.onSiteCall?.();
646
+ try {
647
+ const result = await httpClient.request(reqOpts);
648
+ sideEffects?.onSuccess?.(result);
649
+ return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
650
+ }
651
+ catch (err) {
652
+ const transformedError = (0, transform_error_1.transformError)(err, {
653
+ spreadPathsToArguments: {},
654
+ explicitPathsToArguments: {
655
+ buyerIds: '$[0].buyerIds',
656
+ planIds: '$[0].planIds',
657
+ autoRenewCanceled: '$[0].autoRenewCanceled',
658
+ orderStatuses: '$[0].orderStatuses',
659
+ paymentStatuses: '$[0].paymentStatuses',
660
+ limit: '$[0].limit',
661
+ offset: '$[0].offset',
662
+ sorting: '$[0].sorting',
663
+ fieldSet: '$[0].fieldSet',
664
+ },
665
+ singleArgumentUnchanged: false,
666
+ }, ['options']);
667
+ sideEffects?.onError?.(err);
668
+ throw transformedError;
669
+ }
670
+ }
671
+ exports.managementListOrders = managementListOrders;
672
+ /**
673
+ * 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.
674
+ *
675
+ * New `endDate` must be later than the order's current `endDate`. Can't postpone orders that are unlimited.
676
+ * Can't postpone an order with `status`: `PAUSED`.
677
+ * @param _id - Order ID.
678
+ * @param endDate - New end date and time.
679
+ *
680
+ * Must be later than the current end date and time.
681
+ * @public
682
+ * @requiredField _id
683
+ * @requiredField endDate
684
+ * @param options - Options for postponing the end date of an order.
685
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
686
+ * @permissionScope Manage Orders
687
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
688
+ * @applicableIdentity APP
689
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.PostponeEndDate
690
+ */
691
+ async function postponeEndDate(_id, endDate) {
692
+ // @ts-ignore
693
+ const { httpClient, sideEffects } = arguments[2];
694
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
695
+ id: _id,
696
+ endDate: endDate,
697
+ });
698
+ const reqOpts = ambassadorWixPricingPlansV2Order.postponeEndDate(payload);
699
+ sideEffects?.onSiteCall?.();
700
+ try {
701
+ const result = await httpClient.request(reqOpts);
702
+ sideEffects?.onSuccess?.(result);
703
+ }
704
+ catch (err) {
705
+ const transformedError = (0, transform_error_1.transformError)(err, {
706
+ spreadPathsToArguments: {},
707
+ explicitPathsToArguments: { id: '$[0]', endDate: '$[1]' },
708
+ singleArgumentUnchanged: false,
709
+ }, ['_id', 'endDate']);
710
+ sideEffects?.onError?.(err);
711
+ throw transformedError;
712
+ }
713
+ }
714
+ exports.postponeEndDate = postponeEndDate;
715
+ /**
716
+ * Cancels an existing order.
717
+ *
718
+ * For orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
719
+ * For orders with one-time payments, a cancellation can only be set for `IMMEDIATELY`.
720
+ *
721
+ * #### Canceling during the free trial period.
722
+ *
723
+ * When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end
724
+ * of the free trial period and they will not be billed. The buyer may continue using the benefits until the end
725
+ * of the free trial period.
726
+ *
727
+ * When a Wix user cancels an ordered plan during the free trial period, they choose whether to apply the cancellation
728
+ * `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. Canceling `IMMEDIATELY` will end the subscription for the buyer
729
+ * immediately, even during the free trial period and the buyer won't be billed. Canceling at the
730
+ * `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period.
731
+ * Then, the subscription ends and the buyer is not billed.
732
+ * @param _id - Order ID.
733
+ * @param effectiveAt - __Required.__ When the order will be canceled. One-time orders can only be canceled `IMMEDIATELY`.
734
+ * @public
735
+ * @requiredField _id
736
+ * @requiredField effectiveAt
737
+ * @param options - Options for canceling orders.
738
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
739
+ * @permissionScope Manage Orders
740
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
741
+ * @applicableIdentity APP
742
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.CancelOrder
743
+ */
744
+ async function cancelOrder(_id, effectiveAt) {
745
+ // @ts-ignore
746
+ const { httpClient, sideEffects } = arguments[2];
747
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
748
+ id: _id,
749
+ effectiveAt: effectiveAt,
750
+ });
751
+ const reqOpts = ambassadorWixPricingPlansV2Order.cancelOrder(payload);
752
+ sideEffects?.onSiteCall?.();
753
+ try {
754
+ const result = await httpClient.request(reqOpts);
755
+ sideEffects?.onSuccess?.(result);
756
+ }
757
+ catch (err) {
758
+ const transformedError = (0, transform_error_1.transformError)(err, {
759
+ spreadPathsToArguments: {},
760
+ explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
761
+ singleArgumentUnchanged: false,
762
+ }, ['_id', 'effectiveAt']);
763
+ sideEffects?.onError?.(err);
764
+ throw transformedError;
765
+ }
766
+ }
767
+ exports.cancelOrder = cancelOrder;
768
+ /**
769
+ * Marks an offline order as paid.
770
+ * > __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.
771
+ *
772
+ * Marking an offline order as paid causes the following changes:
773
+ * - The order's `lastPaymentStatus` changes to `"PAID"`.
774
+ * - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`.
775
+ *
776
+ * An error occurs if you attempt to:
777
+ * - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice.
778
+ * - Mark an online order as paid. The Mark as Paid method is supported for offline orders only.
779
+ * @param _id - Order ID.
780
+ * @public
781
+ * @requiredField _id
782
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
783
+ * @permissionScope Manage Orders
784
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
785
+ * @applicableIdentity APP
786
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.MarkAsPaid
787
+ */
788
+ async function markAsPaid(_id) {
789
+ // @ts-ignore
790
+ const { httpClient, sideEffects } = arguments[1];
791
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
792
+ const reqOpts = ambassadorWixPricingPlansV2Order.markAsPaid(payload);
793
+ sideEffects?.onSiteCall?.();
794
+ try {
795
+ const result = await httpClient.request(reqOpts);
796
+ sideEffects?.onSuccess?.(result);
797
+ }
798
+ catch (err) {
799
+ const transformedError = (0, transform_error_1.transformError)(err, {
800
+ spreadPathsToArguments: {},
801
+ explicitPathsToArguments: { id: '$[0]' },
802
+ singleArgumentUnchanged: false,
803
+ }, ['_id']);
804
+ sideEffects?.onError?.(err);
805
+ throw transformedError;
806
+ }
807
+ }
808
+ exports.markAsPaid = markAsPaid;
809
+ /**
810
+ * Pauses an order. Calling this method changes the order status to `"PAUSED"` and updates the `pausePeriods` array.
811
+ *
812
+ * Only orders with `status`: `ACTIVE` can be paused.
813
+ * For orders with recurring payments, it also pauses the payment schedule. Buyers are not charged when an order is paused.
814
+ * Pausing an order affects the end date of the order by adding the time the order is paused to the `endDate`.
815
+ * The `endDate` and the `earliestEndDate` for the order are adjusted to include the pause period when the order is resumed.
816
+ *
817
+ * To resume a paused order, call Resume Order.
818
+ * @param _id - Order ID.
819
+ * @public
820
+ * @requiredField _id
821
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
822
+ * @permissionScope Manage Orders
823
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
824
+ * @applicableIdentity APP
825
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.PauseOrder
826
+ */
827
+ async function pauseOrder(_id) {
828
+ // @ts-ignore
829
+ const { httpClient, sideEffects } = arguments[1];
830
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
831
+ const reqOpts = ambassadorWixPricingPlansV2Order.pauseOrder(payload);
832
+ sideEffects?.onSiteCall?.();
833
+ try {
834
+ const result = await httpClient.request(reqOpts);
835
+ sideEffects?.onSuccess?.(result);
836
+ }
837
+ catch (err) {
838
+ const transformedError = (0, transform_error_1.transformError)(err, {
839
+ spreadPathsToArguments: {},
840
+ explicitPathsToArguments: { id: '$[0]' },
841
+ singleArgumentUnchanged: false,
842
+ }, ['_id']);
843
+ sideEffects?.onError?.(err);
844
+ throw transformedError;
845
+ }
846
+ }
847
+ exports.pauseOrder = pauseOrder;
848
+ /**
849
+ * Resumes a paused order. For orders with recurring payments, it also restarts the payment schedule.
850
+ *
851
+ * Resuming an order causes the following changes:
852
+ * - The order status changes to `"ACTIVE"`.
853
+ * - The `pausePeriods` array is updated.
854
+ * - The `endDate` for the order is adjusted to include the pause period.
855
+ * - For orders with recurring payments, the payment schedule is restarted.
856
+ * - The `earliestEndDate` is adjusted to include the pause period. (This property is reserved for future use).
857
+ *
858
+ * To pause an order, call Pause Order.
859
+ * @param _id - Order ID.
860
+ * @public
861
+ * @requiredField _id
862
+ * @permissionId PRICING_PLANS.MANAGE_ORDERS
863
+ * @permissionScope Manage Orders
864
+ * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
865
+ * @applicableIdentity APP
866
+ * @fqn com.wixpress.membership.v2.orders.OrderManagementService.ResumeOrder
867
+ */
868
+ async function resumeOrder(_id) {
869
+ // @ts-ignore
870
+ const { httpClient, sideEffects } = arguments[1];
871
+ const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
872
+ const reqOpts = ambassadorWixPricingPlansV2Order.resumeOrder(payload);
873
+ sideEffects?.onSiteCall?.();
874
+ try {
875
+ const result = await httpClient.request(reqOpts);
876
+ sideEffects?.onSuccess?.(result);
877
+ }
878
+ catch (err) {
879
+ const transformedError = (0, transform_error_1.transformError)(err, {
880
+ spreadPathsToArguments: {},
881
+ explicitPathsToArguments: { id: '$[0]' },
882
+ singleArgumentUnchanged: false,
883
+ }, ['_id']);
884
+ sideEffects?.onError?.(err);
885
+ throw transformedError;
886
+ }
887
+ }
888
+ exports.resumeOrder = resumeOrder;
889
+ //# sourceMappingURL=pricing-plans-v2-order-orders.universal.js.map