@wix/auto_sdk_subscription_subscriptions 1.0.7 → 1.0.9

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 (125) hide show
  1. package/build/cjs/index.d.ts +379 -1
  2. package/build/cjs/index.js +5705 -15
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/index.typings.d.ts +4684 -1
  5. package/build/cjs/index.typings.js +4768 -15
  6. package/build/cjs/index.typings.js.map +1 -1
  7. package/build/cjs/meta.d.ts +2379 -1
  8. package/build/cjs/meta.js +3660 -15
  9. package/build/cjs/meta.js.map +1 -1
  10. package/build/es/index.d.mts +379 -0
  11. package/build/es/index.mjs +5603 -0
  12. package/build/es/index.mjs.map +1 -0
  13. package/build/{internal/cjs/src/billing-v1-subscription-subscriptions.universal.d.ts → es/index.typings.d.mts} +796 -1149
  14. package/build/es/index.typings.mjs +4679 -0
  15. package/build/es/index.typings.mjs.map +1 -0
  16. package/build/es/meta.d.mts +2379 -0
  17. package/build/es/meta.mjs +3605 -0
  18. package/build/es/meta.mjs.map +1 -0
  19. package/build/internal/cjs/index.d.ts +403 -1
  20. package/build/internal/cjs/index.js +5705 -15
  21. package/build/internal/cjs/index.js.map +1 -1
  22. package/build/internal/cjs/index.typings.d.ts +4708 -1
  23. package/build/internal/cjs/index.typings.js +4768 -15
  24. package/build/internal/cjs/index.typings.js.map +1 -1
  25. package/build/internal/cjs/meta.d.ts +2379 -1
  26. package/build/internal/cjs/meta.js +3660 -15
  27. package/build/internal/cjs/meta.js.map +1 -1
  28. package/build/internal/es/index.d.mts +403 -0
  29. package/build/internal/es/index.mjs +5603 -0
  30. package/build/internal/es/index.mjs.map +1 -0
  31. package/build/internal/es/{src/billing-v1-subscription-subscriptions.universal.d.ts → index.typings.d.mts} +799 -1128
  32. package/build/internal/es/index.typings.mjs +4679 -0
  33. package/build/internal/es/index.typings.mjs.map +1 -0
  34. package/build/internal/es/meta.d.mts +2379 -0
  35. package/build/internal/es/meta.mjs +3605 -0
  36. package/build/internal/es/meta.mjs.map +1 -0
  37. package/package.json +12 -10
  38. package/build/cjs/src/billing-v1-subscription-subscriptions.context.d.ts +0 -99
  39. package/build/cjs/src/billing-v1-subscription-subscriptions.context.js +0 -142
  40. package/build/cjs/src/billing-v1-subscription-subscriptions.context.js.map +0 -1
  41. package/build/cjs/src/billing-v1-subscription-subscriptions.http.d.ts +0 -134
  42. package/build/cjs/src/billing-v1-subscription-subscriptions.http.js +0 -3048
  43. package/build/cjs/src/billing-v1-subscription-subscriptions.http.js.map +0 -1
  44. package/build/cjs/src/billing-v1-subscription-subscriptions.meta.d.ts +0 -94
  45. package/build/cjs/src/billing-v1-subscription-subscriptions.meta.js +0 -636
  46. package/build/cjs/src/billing-v1-subscription-subscriptions.meta.js.map +0 -1
  47. package/build/cjs/src/billing-v1-subscription-subscriptions.public.d.ts +0 -273
  48. package/build/cjs/src/billing-v1-subscription-subscriptions.public.js +0 -769
  49. package/build/cjs/src/billing-v1-subscription-subscriptions.public.js.map +0 -1
  50. package/build/cjs/src/billing-v1-subscription-subscriptions.types.d.ts +0 -4203
  51. package/build/cjs/src/billing-v1-subscription-subscriptions.types.js +0 -347
  52. package/build/cjs/src/billing-v1-subscription-subscriptions.types.js.map +0 -1
  53. package/build/cjs/src/billing-v1-subscription-subscriptions.universal.d.ts +0 -5013
  54. package/build/cjs/src/billing-v1-subscription-subscriptions.universal.js +0 -1997
  55. package/build/cjs/src/billing-v1-subscription-subscriptions.universal.js.map +0 -1
  56. package/build/es/index.d.ts +0 -1
  57. package/build/es/index.js +0 -2
  58. package/build/es/index.js.map +0 -1
  59. package/build/es/index.typings.d.ts +0 -1
  60. package/build/es/index.typings.js +0 -2
  61. package/build/es/index.typings.js.map +0 -1
  62. package/build/es/meta.d.ts +0 -1
  63. package/build/es/meta.js +0 -2
  64. package/build/es/meta.js.map +0 -1
  65. package/build/es/src/billing-v1-subscription-subscriptions.context.d.ts +0 -99
  66. package/build/es/src/billing-v1-subscription-subscriptions.context.js +0 -101
  67. package/build/es/src/billing-v1-subscription-subscriptions.context.js.map +0 -1
  68. package/build/es/src/billing-v1-subscription-subscriptions.http.d.ts +0 -134
  69. package/build/es/src/billing-v1-subscription-subscriptions.http.js +0 -3013
  70. package/build/es/src/billing-v1-subscription-subscriptions.http.js.map +0 -1
  71. package/build/es/src/billing-v1-subscription-subscriptions.meta.d.ts +0 -94
  72. package/build/es/src/billing-v1-subscription-subscriptions.meta.js +0 -578
  73. package/build/es/src/billing-v1-subscription-subscriptions.meta.js.map +0 -1
  74. package/build/es/src/billing-v1-subscription-subscriptions.public.d.ts +0 -273
  75. package/build/es/src/billing-v1-subscription-subscriptions.public.js +0 -696
  76. package/build/es/src/billing-v1-subscription-subscriptions.public.js.map +0 -1
  77. package/build/es/src/billing-v1-subscription-subscriptions.types.d.ts +0 -4203
  78. package/build/es/src/billing-v1-subscription-subscriptions.types.js +0 -344
  79. package/build/es/src/billing-v1-subscription-subscriptions.types.js.map +0 -1
  80. package/build/es/src/billing-v1-subscription-subscriptions.universal.d.ts +0 -5013
  81. package/build/es/src/billing-v1-subscription-subscriptions.universal.js +0 -1938
  82. package/build/es/src/billing-v1-subscription-subscriptions.universal.js.map +0 -1
  83. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.context.d.ts +0 -101
  84. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.context.js +0 -142
  85. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.context.js.map +0 -1
  86. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.http.d.ts +0 -134
  87. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.http.js +0 -3048
  88. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.http.js.map +0 -1
  89. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.meta.d.ts +0 -94
  90. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.meta.js +0 -636
  91. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.meta.js.map +0 -1
  92. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.public.d.ts +0 -293
  93. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.public.js +0 -769
  94. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.public.js.map +0 -1
  95. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.types.d.ts +0 -4203
  96. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.types.js +0 -347
  97. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.types.js.map +0 -1
  98. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.universal.js +0 -1997
  99. package/build/internal/cjs/src/billing-v1-subscription-subscriptions.universal.js.map +0 -1
  100. package/build/internal/es/index.d.ts +0 -1
  101. package/build/internal/es/index.js +0 -2
  102. package/build/internal/es/index.js.map +0 -1
  103. package/build/internal/es/index.typings.d.ts +0 -1
  104. package/build/internal/es/index.typings.js +0 -2
  105. package/build/internal/es/index.typings.js.map +0 -1
  106. package/build/internal/es/meta.d.ts +0 -1
  107. package/build/internal/es/meta.js +0 -2
  108. package/build/internal/es/meta.js.map +0 -1
  109. package/build/internal/es/src/billing-v1-subscription-subscriptions.context.d.ts +0 -101
  110. package/build/internal/es/src/billing-v1-subscription-subscriptions.context.js +0 -101
  111. package/build/internal/es/src/billing-v1-subscription-subscriptions.context.js.map +0 -1
  112. package/build/internal/es/src/billing-v1-subscription-subscriptions.http.d.ts +0 -134
  113. package/build/internal/es/src/billing-v1-subscription-subscriptions.http.js +0 -3013
  114. package/build/internal/es/src/billing-v1-subscription-subscriptions.http.js.map +0 -1
  115. package/build/internal/es/src/billing-v1-subscription-subscriptions.meta.d.ts +0 -94
  116. package/build/internal/es/src/billing-v1-subscription-subscriptions.meta.js +0 -578
  117. package/build/internal/es/src/billing-v1-subscription-subscriptions.meta.js.map +0 -1
  118. package/build/internal/es/src/billing-v1-subscription-subscriptions.public.d.ts +0 -293
  119. package/build/internal/es/src/billing-v1-subscription-subscriptions.public.js +0 -696
  120. package/build/internal/es/src/billing-v1-subscription-subscriptions.public.js.map +0 -1
  121. package/build/internal/es/src/billing-v1-subscription-subscriptions.types.d.ts +0 -4203
  122. package/build/internal/es/src/billing-v1-subscription-subscriptions.types.js +0 -344
  123. package/build/internal/es/src/billing-v1-subscription-subscriptions.types.js.map +0 -1
  124. package/build/internal/es/src/billing-v1-subscription-subscriptions.universal.js +0 -1938
  125. package/build/internal/es/src/billing-v1-subscription-subscriptions.universal.js.map +0 -1
@@ -1,1997 +0,0 @@
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.updateSubscriptionPaymentMethod = exports.getSubscription = exports.payCycle = exports.customerInitiatePaymentMethodSetup = exports.customerListUpcomingCharges = exports.customerAllowedActions = exports.customerUpdateSubscriptionPaymentMethod = exports.customerQuerySubscriptions = exports.customerExtendSubscription = exports.customerTurnOffSubscriptionAutoRenewal = exports.customerTurnOnSubscriptionAutoRenewal = exports.customerCancelSubscription = exports.customerGetSubscription = exports.PaymentSettlementMethod = exports.HistoryViewMode = exports.Status = exports.CancellationInitiator = exports.SubscriptionFrequency = exports.PaymentStatusEnumPaymentStatus = exports.V1SubscriptionStatusEnumSubscriptionStatus = exports.SubscriptionType = exports.IdentityType = exports.RefundReason = exports.PaymentAttemptStatus = exports.CreationMode = exports.CollectionMethod = exports.InvoiceStatus = exports.RequestedFields = exports.UpdateAction = exports.ActionInitiator = exports.RevivePolicy = exports.PaymentTestMode = exports.WebhookIdentityType = exports.OrderMethod = exports.PaymentMode = exports.ExtendPolicyType = exports.ActionType = exports.SubscriptionStatusGroup = exports.SortOrder = exports.ItemCategory = exports.HistoryActionInitiator = exports.ResumeAt = exports.PauseAt = exports.PausePolicy = exports.PaymentStatus = exports.TaxableAddressType = exports.AdditionalFeeTrigger = exports.DurationUnit = exports.CollectionMethodEnumCollectionMethod = exports.SubscriptionStatusEnumSubscriptionStatus = void 0;
27
- exports.listSubscriptionHistory = exports.initiatePaymentMethodSetup = exports.previewSubscriptionsCharges = exports.previewSubscriptionCharges = exports.listUpcomingCharges = exports.allowedActions = exports.extendSubscription = exports.getSubscriptionsStats = exports.markBillingCycleAsPaid = exports.markLatestInvoiceAsPaid = exports.turnOffSubscriptionAutoRenewal = exports.turnOnSubscriptionAutoRenewal = exports.countSubscriptions = exports.searchSubscriptions = exports.querySubscriptions = exports.resumeSubscription = exports.pauseSubscription = exports.cancelSubscription = exports.updateSubscriptionBillingDate = void 0;
28
- const transform_error_1 = require("@wix/sdk-runtime/transform-error");
29
- const rename_all_nested_keys_1 = require("@wix/sdk-runtime/rename-all-nested-keys");
30
- const ambassadorWixBillingV1Subscription = __importStar(require("./billing-v1-subscription-subscriptions.http.js"));
31
- const address_1 = require("@wix/sdk-runtime/transformations/address");
32
- const address_2 = require("@wix/sdk-runtime/transformations/address");
33
- const transform_paths_1 = require("@wix/sdk-runtime/transformations/transform-paths");
34
- var SubscriptionStatusEnumSubscriptionStatus;
35
- (function (SubscriptionStatusEnumSubscriptionStatus) {
36
- SubscriptionStatusEnumSubscriptionStatus["UNKNOWN"] = "UNKNOWN";
37
- /** Subscription created in this status, but hasn't been paid for yet. Filtered out from subscriptions querying. */
38
- SubscriptionStatusEnumSubscriptionStatus["DRAFT"] = "DRAFT";
39
- /** Subscription that will be active in future. */
40
- SubscriptionStatusEnumSubscriptionStatus["PENDING"] = "PENDING";
41
- /** Subscription is active */
42
- SubscriptionStatusEnumSubscriptionStatus["ACTIVE"] = "ACTIVE";
43
- /** Subscription is paused */
44
- SubscriptionStatusEnumSubscriptionStatus["PAUSED"] = "PAUSED";
45
- /** Subscription was ended */
46
- SubscriptionStatusEnumSubscriptionStatus["ENDED"] = "ENDED";
47
- /** Subscription was canceled or auto-renew off. Ended before its time. */
48
- SubscriptionStatusEnumSubscriptionStatus["CANCELED"] = "CANCELED";
49
- })(SubscriptionStatusEnumSubscriptionStatus || (exports.SubscriptionStatusEnumSubscriptionStatus = SubscriptionStatusEnumSubscriptionStatus = {}));
50
- var CollectionMethodEnumCollectionMethod;
51
- (function (CollectionMethodEnumCollectionMethod) {
52
- CollectionMethodEnumCollectionMethod["UNKNOWN"] = "UNKNOWN";
53
- /** Subscriber automatically charged */
54
- CollectionMethodEnumCollectionMethod["AUTO_CHARGE"] = "AUTO_CHARGE";
55
- /** Payments manually collected and managed by owner */
56
- CollectionMethodEnumCollectionMethod["OFFLINE"] = "OFFLINE";
57
- /** Payment will be collected somehow. Billing only issues invoice per cycle. */
58
- CollectionMethodEnumCollectionMethod["SEND_INVOICE"] = "SEND_INVOICE";
59
- /** Payment will be collected externally */
60
- CollectionMethodEnumCollectionMethod["EXTERNAL"] = "EXTERNAL";
61
- /** Indicates the product has a zero amount, meaning its free with no payment required. */
62
- CollectionMethodEnumCollectionMethod["FREE"] = "FREE";
63
- })(CollectionMethodEnumCollectionMethod || (exports.CollectionMethodEnumCollectionMethod = CollectionMethodEnumCollectionMethod = {}));
64
- var DurationUnit;
65
- (function (DurationUnit) {
66
- DurationUnit["UNKNOWN"] = "UNKNOWN";
67
- DurationUnit["DAY"] = "DAY";
68
- DurationUnit["WEEK"] = "WEEK";
69
- DurationUnit["MONTH"] = "MONTH";
70
- DurationUnit["YEAR"] = "YEAR";
71
- })(DurationUnit || (exports.DurationUnit = DurationUnit = {}));
72
- var AdditionalFeeTrigger;
73
- (function (AdditionalFeeTrigger) {
74
- AdditionalFeeTrigger["UNKNOWN"] = "UNKNOWN";
75
- /** Charge upon subscription first payment */
76
- AdditionalFeeTrigger["FIRST_PAYMENT"] = "FIRST_PAYMENT";
77
- })(AdditionalFeeTrigger || (exports.AdditionalFeeTrigger = AdditionalFeeTrigger = {}));
78
- var TaxableAddressType;
79
- (function (TaxableAddressType) {
80
- TaxableAddressType["UNKNOWN"] = "UNKNOWN";
81
- /** Tax will be calculated using a single address */
82
- TaxableAddressType["BUSINESS"] = "BUSINESS";
83
- /** Tax will be calculated using multiple address (from BUSINESS to BILLING) */
84
- TaxableAddressType["BILLING"] = "BILLING";
85
- /** Tax will be calculated using multiple address (from BUSINESS to SHIPPING) */
86
- TaxableAddressType["SHIPPING"] = "SHIPPING";
87
- })(TaxableAddressType || (exports.TaxableAddressType = TaxableAddressType = {}));
88
- var PaymentStatus;
89
- (function (PaymentStatus) {
90
- /** Payment status unknown */
91
- PaymentStatus["UNKNOWN"] = "UNKNOWN";
92
- /** Payment has not been paid */
93
- PaymentStatus["UNPAID"] = "UNPAID";
94
- /** Payment has been paid // TODO: p13n review: we are not sending event when in SEND_INVOICE mode cycle was paid. should we and which event? */
95
- PaymentStatus["PAID"] = "PAID";
96
- /** Payment failed */
97
- PaymentStatus["FAILED"] = "FAILED";
98
- })(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
99
- var PausePolicy;
100
- (function (PausePolicy) {
101
- PausePolicy["NONE"] = "NONE";
102
- /** Pause the payment and the service. When resuming, the subscription end date is extended by the number of cycles postponed, and if the pause happened in a middle of a cycle, the payment date is postponed by the amount of days that already paid. */
103
- PausePolicy["SERVICE_AND_PAYMENTS"] = "SERVICE_AND_PAYMENTS";
104
- /** Pause the service and continue the billing. When resuming, extend the service by the time that was paused */
105
- PausePolicy["SERVICE_ONLY"] = "SERVICE_ONLY";
106
- })(PausePolicy || (exports.PausePolicy = PausePolicy = {}));
107
- var PauseAt;
108
- (function (PauseAt) {
109
- /** Cancel scheduled pause */
110
- PauseAt["NONE"] = "NONE";
111
- /** Pause the subscription now */
112
- PauseAt["IMMEDIATELY"] = "IMMEDIATELY";
113
- /** Pause the subscription at the next billing date */
114
- PauseAt["NEXT_BILLING_DATE"] = "NEXT_BILLING_DATE";
115
- /** A specific date must be defined in Schedule.specific_date */
116
- PauseAt["SPECIFIC_DATE"] = "SPECIFIC_DATE";
117
- /** The number of cycles must be defined in Schedule.number_of_cycles */
118
- PauseAt["NUMBER_OF_CYCLES_FROM_TODAY"] = "NUMBER_OF_CYCLES_FROM_TODAY";
119
- })(PauseAt || (exports.PauseAt = PauseAt = {}));
120
- var ResumeAt;
121
- (function (ResumeAt) {
122
- /** Cancel scheduled resume */
123
- ResumeAt["NONE"] = "NONE";
124
- /** Resume the subscription now */
125
- ResumeAt["IMMEDIATELY"] = "IMMEDIATELY";
126
- /** Resume the subscription at the next billing date */
127
- ResumeAt["NEXT_BILLING_DATE"] = "NEXT_BILLING_DATE";
128
- /** A specific date must be defined in Schedule.specific_date */
129
- ResumeAt["SPECIFIC_DATE"] = "SPECIFIC_DATE";
130
- })(ResumeAt || (exports.ResumeAt = ResumeAt = {}));
131
- var HistoryActionInitiator;
132
- (function (HistoryActionInitiator) {
133
- HistoryActionInitiator["UNDEFINED"] = "UNDEFINED";
134
- HistoryActionInitiator["BUSINESS"] = "BUSINESS";
135
- HistoryActionInitiator["CUSTOMER"] = "CUSTOMER";
136
- HistoryActionInitiator["SYSTEM"] = "SYSTEM";
137
- HistoryActionInitiator["PAYMENT_FAILURE"] = "PAYMENT_FAILURE";
138
- })(HistoryActionInitiator || (exports.HistoryActionInitiator = HistoryActionInitiator = {}));
139
- var ItemCategory;
140
- (function (ItemCategory) {
141
- ItemCategory["UNKNOWN"] = "UNKNOWN";
142
- ItemCategory["PHYSICAL"] = "PHYSICAL";
143
- ItemCategory["DIGITAL"] = "DIGITAL";
144
- })(ItemCategory || (exports.ItemCategory = ItemCategory = {}));
145
- var SortOrder;
146
- (function (SortOrder) {
147
- SortOrder["ASC"] = "ASC";
148
- SortOrder["DESC"] = "DESC";
149
- })(SortOrder || (exports.SortOrder = SortOrder = {}));
150
- var SubscriptionStatusGroup;
151
- (function (SubscriptionStatusGroup) {
152
- SubscriptionStatusGroup["ALL"] = "ALL";
153
- /** Union of ACTIVE, PAUSED and PENDING */
154
- SubscriptionStatusGroup["LIVE"] = "LIVE";
155
- })(SubscriptionStatusGroup || (exports.SubscriptionStatusGroup = SubscriptionStatusGroup = {}));
156
- var ActionType;
157
- (function (ActionType) {
158
- ActionType["NONE"] = "NONE";
159
- ActionType["CREATION"] = "CREATION";
160
- ActionType["CANCEL"] = "CANCEL";
161
- ActionType["CYCLE_AUTO_RENEW_ON"] = "CYCLE_AUTO_RENEW_ON";
162
- ActionType["CYCLE_AUTO_RENEW_OFF"] = "CYCLE_AUTO_RENEW_OFF";
163
- ActionType["PAUSE"] = "PAUSE";
164
- ActionType["RESUME"] = "RESUME";
165
- ActionType["MARK_AS_PAID"] = "MARK_AS_PAID";
166
- ActionType["EXTEND"] = "EXTEND";
167
- ActionType["UPDATE"] = "UPDATE";
168
- ActionType["UPDATE_START_DATE"] = "UPDATE_START_DATE";
169
- ActionType["UPM"] = "UPM";
170
- ActionType["UPDATE_BILLING_DATE"] = "UPDATE_BILLING_DATE";
171
- ActionType["UPDATE_COLLECTION_METHOD"] = "UPDATE_COLLECTION_METHOD";
172
- })(ActionType || (exports.ActionType = ActionType = {}));
173
- var ExtendPolicyType;
174
- (function (ExtendPolicyType) {
175
- ExtendPolicyType["PERIOD"] = "PERIOD";
176
- ExtendPolicyType["BILLING_CYCLE"] = "BILLING_CYCLE";
177
- })(ExtendPolicyType || (exports.ExtendPolicyType = ExtendPolicyType = {}));
178
- var PaymentMode;
179
- (function (PaymentMode) {
180
- PaymentMode["NONE"] = "NONE";
181
- /** The latest invoice of the subscription will be charged. */
182
- PaymentMode["CHARGE"] = "CHARGE";
183
- /** An authorization invoice with zero amount will be created. */
184
- PaymentMode["AUTHORIZATION"] = "AUTHORIZATION";
185
- })(PaymentMode || (exports.PaymentMode = PaymentMode = {}));
186
- var OrderMethod;
187
- (function (OrderMethod) {
188
- OrderMethod["UNKNOWN"] = "UNKNOWN";
189
- OrderMethod["MOTO"] = "MOTO";
190
- OrderMethod["NOT_MOTO"] = "NOT_MOTO";
191
- })(OrderMethod || (exports.OrderMethod = OrderMethod = {}));
192
- var WebhookIdentityType;
193
- (function (WebhookIdentityType) {
194
- WebhookIdentityType["UNKNOWN"] = "UNKNOWN";
195
- WebhookIdentityType["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
196
- WebhookIdentityType["MEMBER"] = "MEMBER";
197
- WebhookIdentityType["WIX_USER"] = "WIX_USER";
198
- WebhookIdentityType["APP"] = "APP";
199
- })(WebhookIdentityType || (exports.WebhookIdentityType = WebhookIdentityType = {}));
200
- var PaymentTestMode;
201
- (function (PaymentTestMode) {
202
- PaymentTestMode["REGULAR"] = "REGULAR";
203
- PaymentTestMode["FAIL_TECHNICAL"] = "FAIL_TECHNICAL";
204
- PaymentTestMode["FAIL_DECLINE"] = "FAIL_DECLINE";
205
- PaymentTestMode["FAIL_RETRYABLE_DECLINE"] = "FAIL_RETRYABLE_DECLINE";
206
- })(PaymentTestMode || (exports.PaymentTestMode = PaymentTestMode = {}));
207
- var RevivePolicy;
208
- (function (RevivePolicy) {
209
- RevivePolicy["SIMPLE"] = "SIMPLE";
210
- RevivePolicy["RESUME"] = "RESUME";
211
- })(RevivePolicy || (exports.RevivePolicy = RevivePolicy = {}));
212
- var ActionInitiator;
213
- (function (ActionInitiator) {
214
- ActionInitiator["UNDEFINED"] = "UNDEFINED";
215
- ActionInitiator["BUSINESS"] = "BUSINESS";
216
- ActionInitiator["CUSTOMER"] = "CUSTOMER";
217
- ActionInitiator["SYSTEM"] = "SYSTEM";
218
- })(ActionInitiator || (exports.ActionInitiator = ActionInitiator = {}));
219
- var UpdateAction;
220
- (function (UpdateAction) {
221
- UpdateAction["NONE"] = "NONE";
222
- /** Update subscription immediately, please note proration for updates changing price are not yet supported */
223
- UpdateAction["IMMEDIATELY"] = "IMMEDIATELY";
224
- /** Request updates that will take affect only at the start of the next billing cycle. */
225
- UpdateAction["NEXT_BILLING_CYCLE"] = "NEXT_BILLING_CYCLE";
226
- /** Reset all pending updates */
227
- UpdateAction["RESET_PENDING_UPDATES"] = "RESET_PENDING_UPDATES";
228
- /** Request updates that will take affect only at a specific date. */
229
- UpdateAction["SPECIFIC_DATE"] = "SPECIFIC_DATE";
230
- })(UpdateAction || (exports.UpdateAction = UpdateAction = {}));
231
- var RequestedFields;
232
- (function (RequestedFields) {
233
- RequestedFields["UNKNOWN_REQUESTED_FIELD"] = "UNKNOWN_REQUESTED_FIELD";
234
- /** Include unsupported action list, including the reasons for the lack of support */
235
- RequestedFields["UNSUPPORTED_ACTION"] = "UNSUPPORTED_ACTION";
236
- })(RequestedFields || (exports.RequestedFields = RequestedFields = {}));
237
- var InvoiceStatus;
238
- (function (InvoiceStatus) {
239
- InvoiceStatus["UNKNOWN"] = "UNKNOWN";
240
- InvoiceStatus["OPEN"] = "OPEN";
241
- InvoiceStatus["PAID"] = "PAID";
242
- InvoiceStatus["FAILED"] = "FAILED";
243
- InvoiceStatus["ATTEMPT_FAILED"] = "ATTEMPT_FAILED";
244
- InvoiceStatus["CANCELED"] = "CANCELED";
245
- InvoiceStatus["REFUNDED"] = "REFUNDED";
246
- })(InvoiceStatus || (exports.InvoiceStatus = InvoiceStatus = {}));
247
- var CollectionMethod;
248
- (function (CollectionMethod) {
249
- CollectionMethod["UNKNOWN"] = "UNKNOWN";
250
- CollectionMethod["AUTO_CHARGE"] = "AUTO_CHARGE";
251
- CollectionMethod["OFFLINE"] = "OFFLINE";
252
- CollectionMethod["SEND_INVOICE"] = "SEND_INVOICE";
253
- })(CollectionMethod || (exports.CollectionMethod = CollectionMethod = {}));
254
- var CreationMode;
255
- (function (CreationMode) {
256
- CreationMode["UNKNOWN"] = "UNKNOWN";
257
- CreationMode["SYSTEM"] = "SYSTEM";
258
- CreationMode["MANUAL"] = "MANUAL";
259
- })(CreationMode || (exports.CreationMode = CreationMode = {}));
260
- var PaymentAttemptStatus;
261
- (function (PaymentAttemptStatus) {
262
- PaymentAttemptStatus["UNKNOWN"] = "UNKNOWN";
263
- PaymentAttemptStatus["SCHEDULED"] = "SCHEDULED";
264
- PaymentAttemptStatus["IN_PROGRESS"] = "IN_PROGRESS";
265
- PaymentAttemptStatus["PAID"] = "PAID";
266
- PaymentAttemptStatus["DECLINED"] = "DECLINED";
267
- PaymentAttemptStatus["TECHNICAL_FAILURE"] = "TECHNICAL_FAILURE";
268
- PaymentAttemptStatus["CANCELED"] = "CANCELED";
269
- PaymentAttemptStatus["PENDING"] = "PENDING";
270
- })(PaymentAttemptStatus || (exports.PaymentAttemptStatus = PaymentAttemptStatus = {}));
271
- var RefundReason;
272
- (function (RefundReason) {
273
- RefundReason["UNKNOWN_REFUND_REASON"] = "UNKNOWN_REFUND_REASON";
274
- RefundReason["DUPLICATE_CHARGE"] = "DUPLICATE_CHARGE";
275
- RefundReason["FRAUDULENT"] = "FRAUDULENT";
276
- RefundReason["CUSTOMER_REQUEST"] = "CUSTOMER_REQUEST";
277
- RefundReason["PROVISION_FAILED"] = "PROVISION_FAILED";
278
- RefundReason["OTHER"] = "OTHER";
279
- })(RefundReason || (exports.RefundReason = RefundReason = {}));
280
- var IdentityType;
281
- (function (IdentityType) {
282
- /** Identity type undefined */
283
- IdentityType["UNDEFINED"] = "UNDEFINED";
284
- /** Subscription is associated with a member ID */
285
- IdentityType["MEMBER"] = "MEMBER";
286
- /** Subscriptions is associated with a contact ID */
287
- IdentityType["CONTACT"] = "CONTACT";
288
- })(IdentityType || (exports.IdentityType = IdentityType = {}));
289
- var SubscriptionType;
290
- (function (SubscriptionType) {
291
- SubscriptionType["UNDEFINED"] = "UNDEFINED";
292
- /** Payments made by the subscriber */
293
- SubscriptionType["ONLINE"] = "ONLINE";
294
- /** Payments managed manually by the site owner */
295
- SubscriptionType["OFFLINE"] = "OFFLINE";
296
- })(SubscriptionType || (exports.SubscriptionType = SubscriptionType = {}));
297
- var V1SubscriptionStatusEnumSubscriptionStatus;
298
- (function (V1SubscriptionStatusEnumSubscriptionStatus) {
299
- /** Subscription status undefined */
300
- V1SubscriptionStatusEnumSubscriptionStatus["UNDEFINED"] = "UNDEFINED";
301
- /** Subscription created, but hasn't been paid for yet. This status if filtered out in ListSubscriptions response by default. */
302
- V1SubscriptionStatusEnumSubscriptionStatus["DRAFT"] = "DRAFT";
303
- /** Subscription has been paid for, but the start date is in the future */
304
- V1SubscriptionStatusEnumSubscriptionStatus["PENDING"] = "PENDING";
305
- /** Subscription is active */
306
- V1SubscriptionStatusEnumSubscriptionStatus["ACTIVE"] = "ACTIVE";
307
- /** Subscription has expired */
308
- V1SubscriptionStatusEnumSubscriptionStatus["EXPIRED"] = "EXPIRED";
309
- /** Subscription has been canceled */
310
- V1SubscriptionStatusEnumSubscriptionStatus["CANCELED"] = "CANCELED";
311
- /** Subscription has been set to be canceled at a future date */
312
- V1SubscriptionStatusEnumSubscriptionStatus["PENDING_CANCELLATION"] = "PENDING_CANCELLATION";
313
- /** Subscription is suspended */
314
- V1SubscriptionStatusEnumSubscriptionStatus["SUSPENDED"] = "SUSPENDED";
315
- })(V1SubscriptionStatusEnumSubscriptionStatus || (exports.V1SubscriptionStatusEnumSubscriptionStatus = V1SubscriptionStatusEnumSubscriptionStatus = {}));
316
- var PaymentStatusEnumPaymentStatus;
317
- (function (PaymentStatusEnumPaymentStatus) {
318
- /** Payment status undefined */
319
- PaymentStatusEnumPaymentStatus["UNDEFINED"] = "UNDEFINED";
320
- /** Payment has been paid */
321
- PaymentStatusEnumPaymentStatus["PAID"] = "PAID";
322
- /** Payment has been refunded */
323
- PaymentStatusEnumPaymentStatus["REFUNDED"] = "REFUNDED";
324
- /** Recurring payment has failed */
325
- PaymentStatusEnumPaymentStatus["FAILED"] = "FAILED";
326
- /** Payment has not been paid */
327
- PaymentStatusEnumPaymentStatus["UNPAID"] = "UNPAID";
328
- /** Billing has been initialized, but actual charge is yet to be made. Can happen for free trial and PayPal */
329
- PaymentStatusEnumPaymentStatus["PENDING"] = "PENDING";
330
- })(PaymentStatusEnumPaymentStatus || (exports.PaymentStatusEnumPaymentStatus = PaymentStatusEnumPaymentStatus = {}));
331
- /** Frequency unit of recurring payment */
332
- var SubscriptionFrequency;
333
- (function (SubscriptionFrequency) {
334
- SubscriptionFrequency["UNDEFINED"] = "UNDEFINED";
335
- SubscriptionFrequency["DAY"] = "DAY";
336
- SubscriptionFrequency["WEEK"] = "WEEK";
337
- SubscriptionFrequency["MONTH"] = "MONTH";
338
- SubscriptionFrequency["YEAR"] = "YEAR";
339
- })(SubscriptionFrequency || (exports.SubscriptionFrequency = SubscriptionFrequency = {}));
340
- var CancellationInitiator;
341
- (function (CancellationInitiator) {
342
- /** Cancellation initiator undefined */
343
- CancellationInitiator["UNDEFINED"] = "UNDEFINED";
344
- /** Subscription was canceled by site owner (default if canceled by user or service identity) */
345
- CancellationInitiator["OWNER"] = "OWNER";
346
- /** Subscription was canceled by member (default if canceled by member identity) */
347
- CancellationInitiator["MEMBER"] = "MEMBER";
348
- /** Subscription was canceled because of payment failure */
349
- CancellationInitiator["PAYMENT_FAILURE"] = "PAYMENT_FAILURE";
350
- /** Subscription was canceled because of payment setup failure */
351
- CancellationInitiator["SETUP_FAILURE"] = "SETUP_FAILURE";
352
- })(CancellationInitiator || (exports.CancellationInitiator = CancellationInitiator = {}));
353
- var Status;
354
- (function (Status) {
355
- Status["UNDEFINED"] = "UNDEFINED";
356
- Status["ACTIVE"] = "ACTIVE";
357
- Status["ENDED"] = "ENDED";
358
- })(Status || (exports.Status = Status = {}));
359
- var HistoryViewMode;
360
- (function (HistoryViewMode) {
361
- HistoryViewMode["UNKNOWN"] = "UNKNOWN";
362
- /** Comprehensive view including all history events. */
363
- HistoryViewMode["BACKOFFICE"] = "BACKOFFICE";
364
- /** User-centric view of the history. */
365
- HistoryViewMode["USER"] = "USER";
366
- })(HistoryViewMode || (exports.HistoryViewMode = HistoryViewMode = {}));
367
- var PaymentSettlementMethod;
368
- (function (PaymentSettlementMethod) {
369
- PaymentSettlementMethod["UNKNOWN"] = "UNKNOWN";
370
- /** System-defined payment settlement. */
371
- PaymentSettlementMethod["SYSTEM"] = "SYSTEM";
372
- /** Manually mark the payment as paid. */
373
- PaymentSettlementMethod["MARK_AS_PAID"] = "MARK_AS_PAID";
374
- /** Require the customer to pay immediately, by insert a new payment method. */
375
- PaymentSettlementMethod["CUSTOMER_PAY_NOW"] = "CUSTOMER_PAY_NOW";
376
- })(PaymentSettlementMethod || (exports.PaymentSettlementMethod = PaymentSettlementMethod = {}));
377
- /**
378
- * Identity must be a site member and customer subscription belongs to
379
- * @public
380
- * @documentationMaturity preview
381
- * @requiredField _id
382
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.GetSubscription
383
- */
384
- async function customerGetSubscription(_id) {
385
- // @ts-ignore
386
- const { httpClient, sideEffects } = arguments[1];
387
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
388
- const reqOpts = ambassadorWixBillingV1Subscription.customerGetSubscription(payload);
389
- sideEffects?.onSiteCall?.();
390
- try {
391
- const result = await httpClient.request(reqOpts);
392
- sideEffects?.onSuccess?.(result);
393
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
394
- {
395
- transformFn: address_2.transformRESTAddressToSDKAddress,
396
- paths: [
397
- { path: 'subscription.billingSettings.billingAddress.address' },
398
- { path: 'subscription.shippingAddress.address' },
399
- ],
400
- },
401
- ]));
402
- }
403
- catch (err) {
404
- const transformedError = (0, transform_error_1.transformError)(err, {
405
- spreadPathsToArguments: {},
406
- explicitPathsToArguments: { id: '$[0]' },
407
- singleArgumentUnchanged: false,
408
- }, ['_id']);
409
- sideEffects?.onError?.(err);
410
- throw transformedError;
411
- }
412
- }
413
- exports.customerGetSubscription = customerGetSubscription;
414
- /**
415
- * Identity must be a site member and customer subscription belongs to
416
- * @public
417
- * @documentationMaturity preview
418
- * @requiredField _id
419
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.CancelSubscription
420
- */
421
- async function customerCancelSubscription(_id, options) {
422
- // @ts-ignore
423
- const { httpClient, sideEffects } = arguments[2];
424
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
425
- id: _id,
426
- reason: options?.reason,
427
- });
428
- const reqOpts = ambassadorWixBillingV1Subscription.customerCancelSubscription(payload);
429
- sideEffects?.onSiteCall?.();
430
- try {
431
- const result = await httpClient.request(reqOpts);
432
- sideEffects?.onSuccess?.(result);
433
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
434
- {
435
- transformFn: address_2.transformRESTAddressToSDKAddress,
436
- paths: [
437
- { path: 'subscription.billingSettings.billingAddress.address' },
438
- { path: 'subscription.shippingAddress.address' },
439
- ],
440
- },
441
- ]));
442
- }
443
- catch (err) {
444
- const transformedError = (0, transform_error_1.transformError)(err, {
445
- spreadPathsToArguments: {},
446
- explicitPathsToArguments: { id: '$[0]', reason: '$[1].reason' },
447
- singleArgumentUnchanged: false,
448
- }, ['_id', 'options']);
449
- sideEffects?.onError?.(err);
450
- throw transformedError;
451
- }
452
- }
453
- exports.customerCancelSubscription = customerCancelSubscription;
454
- /**
455
- * Identity must be a site member and customer subscription belongs to
456
- * @public
457
- * @documentationMaturity preview
458
- * @requiredField _id
459
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.TurnOnSubscriptionAutoRenewal
460
- */
461
- async function customerTurnOnSubscriptionAutoRenewal(_id, options) {
462
- // @ts-ignore
463
- const { httpClient, sideEffects } = arguments[2];
464
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
465
- id: _id,
466
- reason: options?.reason,
467
- });
468
- const reqOpts = ambassadorWixBillingV1Subscription.customerTurnOnSubscriptionAutoRenewal(payload);
469
- sideEffects?.onSiteCall?.();
470
- try {
471
- const result = await httpClient.request(reqOpts);
472
- sideEffects?.onSuccess?.(result);
473
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
474
- {
475
- transformFn: address_2.transformRESTAddressToSDKAddress,
476
- paths: [
477
- { path: 'subscription.billingSettings.billingAddress.address' },
478
- { path: 'subscription.shippingAddress.address' },
479
- ],
480
- },
481
- ]));
482
- }
483
- catch (err) {
484
- const transformedError = (0, transform_error_1.transformError)(err, {
485
- spreadPathsToArguments: {},
486
- explicitPathsToArguments: { id: '$[0]', reason: '$[1].reason' },
487
- singleArgumentUnchanged: false,
488
- }, ['_id', 'options']);
489
- sideEffects?.onError?.(err);
490
- throw transformedError;
491
- }
492
- }
493
- exports.customerTurnOnSubscriptionAutoRenewal = customerTurnOnSubscriptionAutoRenewal;
494
- /**
495
- * Identity must be a site member and customer subscription belongs to
496
- * @public
497
- * @documentationMaturity preview
498
- * @requiredField _id
499
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.TurnOffSubscriptionAutoRenewal
500
- */
501
- async function customerTurnOffSubscriptionAutoRenewal(_id, options) {
502
- // @ts-ignore
503
- const { httpClient, sideEffects } = arguments[2];
504
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
505
- id: _id,
506
- reason: options?.reason,
507
- });
508
- const reqOpts = ambassadorWixBillingV1Subscription.customerTurnOffSubscriptionAutoRenewal(payload);
509
- sideEffects?.onSiteCall?.();
510
- try {
511
- const result = await httpClient.request(reqOpts);
512
- sideEffects?.onSuccess?.(result);
513
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
514
- {
515
- transformFn: address_2.transformRESTAddressToSDKAddress,
516
- paths: [
517
- { path: 'subscription.billingSettings.billingAddress.address' },
518
- { path: 'subscription.shippingAddress.address' },
519
- ],
520
- },
521
- ]));
522
- }
523
- catch (err) {
524
- const transformedError = (0, transform_error_1.transformError)(err, {
525
- spreadPathsToArguments: {},
526
- explicitPathsToArguments: { id: '$[0]', reason: '$[1].reason' },
527
- singleArgumentUnchanged: false,
528
- }, ['_id', 'options']);
529
- sideEffects?.onError?.(err);
530
- throw transformedError;
531
- }
532
- }
533
- exports.customerTurnOffSubscriptionAutoRenewal = customerTurnOffSubscriptionAutoRenewal;
534
- /** @param _id - The ID of the subscription to be extended
535
- * @public
536
- * @documentationMaturity preview
537
- * @requiredField _id
538
- * @requiredField options.billingCyclesToAdd
539
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.ExtendSubscription
540
- */
541
- async function customerExtendSubscription(_id, options) {
542
- // @ts-ignore
543
- const { httpClient, sideEffects } = arguments[2];
544
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
545
- id: _id,
546
- reason: options?.reason,
547
- billingCyclesToAdd: options?.billingCyclesToAdd,
548
- });
549
- const reqOpts = ambassadorWixBillingV1Subscription.customerExtendSubscription(payload);
550
- sideEffects?.onSiteCall?.();
551
- try {
552
- const result = await httpClient.request(reqOpts);
553
- sideEffects?.onSuccess?.(result);
554
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
555
- {
556
- transformFn: address_2.transformRESTAddressToSDKAddress,
557
- paths: [
558
- { path: 'subscription.billingSettings.billingAddress.address' },
559
- { path: 'subscription.shippingAddress.address' },
560
- ],
561
- },
562
- ]));
563
- }
564
- catch (err) {
565
- const transformedError = (0, transform_error_1.transformError)(err, {
566
- spreadPathsToArguments: {},
567
- explicitPathsToArguments: {
568
- id: '$[0]',
569
- reason: '$[1].reason',
570
- billingCyclesToAdd: '$[1].billingCyclesToAdd',
571
- },
572
- singleArgumentUnchanged: false,
573
- }, ['_id', 'options']);
574
- sideEffects?.onError?.(err);
575
- throw transformedError;
576
- }
577
- }
578
- exports.customerExtendSubscription = customerExtendSubscription;
579
- /**
580
- * identity must be a site member
581
- * @public
582
- * @documentationMaturity preview
583
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.QuerySubscriptions
584
- */
585
- async function customerQuerySubscriptions(options) {
586
- // @ts-ignore
587
- const { httpClient, sideEffects } = arguments[1];
588
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
589
- query: options?.query,
590
- });
591
- const reqOpts = ambassadorWixBillingV1Subscription.customerQuerySubscriptions(payload);
592
- sideEffects?.onSiteCall?.();
593
- try {
594
- const result = await httpClient.request(reqOpts);
595
- sideEffects?.onSuccess?.(result);
596
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
597
- {
598
- transformFn: address_2.transformRESTAddressToSDKAddress,
599
- paths: [
600
- { path: 'subscriptions.billingSettings.billingAddress.address' },
601
- { path: 'subscriptions.shippingAddress.address' },
602
- ],
603
- },
604
- ]));
605
- }
606
- catch (err) {
607
- const transformedError = (0, transform_error_1.transformError)(err, {
608
- spreadPathsToArguments: {},
609
- explicitPathsToArguments: { query: '$[0].query' },
610
- singleArgumentUnchanged: false,
611
- }, ['options']);
612
- sideEffects?.onError?.(err);
613
- throw transformedError;
614
- }
615
- }
616
- exports.customerQuerySubscriptions = customerQuerySubscriptions;
617
- /**
618
- * Update subscription's payment method.
619
- * Supported only for recurring subscriptions or one time subscriptions during free trial.
620
- * @param _id - Subscription ID
621
- * @public
622
- * @documentationMaturity preview
623
- * @requiredField _id
624
- * @requiredField paymentMethodId
625
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.UpdateSubscriptionPaymentMethod
626
- */
627
- async function customerUpdateSubscriptionPaymentMethod(_id, paymentMethodId) {
628
- // @ts-ignore
629
- const { httpClient, sideEffects } = arguments[2];
630
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
631
- id: _id,
632
- paymentMethodId: paymentMethodId,
633
- });
634
- const reqOpts = ambassadorWixBillingV1Subscription.customerUpdateSubscriptionPaymentMethod(payload);
635
- sideEffects?.onSiteCall?.();
636
- try {
637
- const result = await httpClient.request(reqOpts);
638
- sideEffects?.onSuccess?.(result);
639
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
640
- {
641
- transformFn: address_2.transformRESTAddressToSDKAddress,
642
- paths: [
643
- { path: 'subscription.billingSettings.billingAddress.address' },
644
- { path: 'subscription.shippingAddress.address' },
645
- ],
646
- },
647
- ]));
648
- }
649
- catch (err) {
650
- const transformedError = (0, transform_error_1.transformError)(err, {
651
- spreadPathsToArguments: {},
652
- explicitPathsToArguments: { id: '$[0]', paymentMethodId: '$[1]' },
653
- singleArgumentUnchanged: false,
654
- }, ['_id', 'paymentMethodId']);
655
- sideEffects?.onError?.(err);
656
- throw transformedError;
657
- }
658
- }
659
- exports.customerUpdateSubscriptionPaymentMethod = customerUpdateSubscriptionPaymentMethod;
660
- /** @public
661
- * @documentationMaturity preview
662
- * @requiredField _id
663
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.AllowedActions
664
- */
665
- async function customerAllowedActions(_id) {
666
- // @ts-ignore
667
- const { httpClient, sideEffects } = arguments[1];
668
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
669
- const reqOpts = ambassadorWixBillingV1Subscription.customerAllowedActions(payload);
670
- sideEffects?.onSiteCall?.();
671
- try {
672
- const result = await httpClient.request(reqOpts);
673
- sideEffects?.onSuccess?.(result);
674
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
675
- }
676
- catch (err) {
677
- const transformedError = (0, transform_error_1.transformError)(err, {
678
- spreadPathsToArguments: {},
679
- explicitPathsToArguments: { id: '$[0]' },
680
- singleArgumentUnchanged: false,
681
- }, ['_id']);
682
- sideEffects?.onError?.(err);
683
- throw transformedError;
684
- }
685
- }
686
- exports.customerAllowedActions = customerAllowedActions;
687
- /**
688
- * List future subscriptions charges.
689
- * @param _id - Subscription id upcoming charge to be previewed for
690
- * @public
691
- * @documentationMaturity preview
692
- * @requiredField _id
693
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.ListUpcomingCharges
694
- */
695
- async function customerListUpcomingCharges(_id) {
696
- // @ts-ignore
697
- const { httpClient, sideEffects } = arguments[1];
698
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
699
- const reqOpts = ambassadorWixBillingV1Subscription.customerListUpcomingCharges(payload);
700
- sideEffects?.onSiteCall?.();
701
- try {
702
- const result = await httpClient.request(reqOpts);
703
- sideEffects?.onSuccess?.(result);
704
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
705
- }
706
- catch (err) {
707
- const transformedError = (0, transform_error_1.transformError)(err, {
708
- spreadPathsToArguments: {},
709
- explicitPathsToArguments: { id: '$[0]' },
710
- singleArgumentUnchanged: false,
711
- }, ['_id']);
712
- sideEffects?.onError?.(err);
713
- throw transformedError;
714
- }
715
- }
716
- exports.customerListUpcomingCharges = customerListUpcomingCharges;
717
- /**
718
- * Creates auto-charge order that can be paid by customer
719
- * @public
720
- * @documentationMaturity preview
721
- * @requiredField _id
722
- * @fqn com.wixpress.billing.subscriptions.api.v1.CustomerSubscriptionsService.InitiatePaymentMethodSetup
723
- */
724
- async function customerInitiatePaymentMethodSetup(_id, options) {
725
- // @ts-ignore
726
- const { httpClient, sideEffects } = arguments[2];
727
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
728
- id: _id,
729
- paymentMode: options?.paymentMode,
730
- paymentSettings: options?.paymentSettings,
731
- });
732
- const reqOpts = ambassadorWixBillingV1Subscription.customerInitiatePaymentMethodSetup(payload);
733
- sideEffects?.onSiteCall?.();
734
- try {
735
- const result = await httpClient.request(reqOpts);
736
- sideEffects?.onSuccess?.(result);
737
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
738
- }
739
- catch (err) {
740
- const transformedError = (0, transform_error_1.transformError)(err, {
741
- spreadPathsToArguments: {},
742
- explicitPathsToArguments: {
743
- id: '$[0]',
744
- paymentMode: '$[1].paymentMode',
745
- paymentSettings: '$[1].paymentSettings',
746
- },
747
- singleArgumentUnchanged: false,
748
- }, ['_id', 'options']);
749
- sideEffects?.onError?.(err);
750
- throw transformedError;
751
- }
752
- }
753
- exports.customerInitiatePaymentMethodSetup = customerInitiatePaymentMethodSetup;
754
- /**
755
- * This used only for automation and permitted tenants (QA & testing)
756
- * @public
757
- * @documentationMaturity preview
758
- * @requiredField options.tenantId
759
- * @requiredField subscriptionId
760
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsBackOfficeService.PayCycle
761
- */
762
- async function payCycle(subscriptionId, options) {
763
- // @ts-ignore
764
- const { httpClient, sideEffects } = arguments[2];
765
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
766
- subscriptionId: subscriptionId,
767
- paymentTestMode: options?.paymentTestMode,
768
- tenantId: options?.tenantId,
769
- });
770
- const reqOpts = ambassadorWixBillingV1Subscription.payCycle(payload);
771
- sideEffects?.onSiteCall?.();
772
- try {
773
- const result = await httpClient.request(reqOpts);
774
- sideEffects?.onSuccess?.(result);
775
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
776
- {
777
- transformFn: address_2.transformRESTAddressToSDKAddress,
778
- paths: [
779
- { path: 'subscription.billingSettings.billingAddress.address' },
780
- { path: 'subscription.shippingAddress.address' },
781
- ],
782
- },
783
- ]));
784
- }
785
- catch (err) {
786
- const transformedError = (0, transform_error_1.transformError)(err, {
787
- spreadPathsToArguments: {},
788
- explicitPathsToArguments: {
789
- subscriptionId: '$[0]',
790
- paymentTestMode: '$[1].paymentTestMode',
791
- tenantId: '$[1].tenantId',
792
- },
793
- singleArgumentUnchanged: false,
794
- }, ['subscriptionId', 'options']);
795
- sideEffects?.onError?.(err);
796
- throw transformedError;
797
- }
798
- }
799
- exports.payCycle = payCycle;
800
- /**
801
- * Returns a single subscription by its id
802
- * @public
803
- * @documentationMaturity preview
804
- * @requiredField _id
805
- * @permissionId subscriptions.view
806
- * @permissionScope Manage Events
807
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
808
- * @applicableIdentity APP
809
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.GetSubscription
810
- */
811
- async function getSubscription(_id) {
812
- // @ts-ignore
813
- const { httpClient, sideEffects } = arguments[1];
814
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ id: _id });
815
- const reqOpts = ambassadorWixBillingV1Subscription.getSubscription(payload);
816
- sideEffects?.onSiteCall?.();
817
- try {
818
- const result = await httpClient.request(reqOpts);
819
- sideEffects?.onSuccess?.(result);
820
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
821
- {
822
- transformFn: address_2.transformRESTAddressToSDKAddress,
823
- paths: [
824
- { path: 'subscription.billingSettings.billingAddress.address' },
825
- { path: 'subscription.shippingAddress.address' },
826
- ],
827
- },
828
- ]));
829
- }
830
- catch (err) {
831
- const transformedError = (0, transform_error_1.transformError)(err, {
832
- spreadPathsToArguments: {},
833
- explicitPathsToArguments: { id: '$[0]' },
834
- singleArgumentUnchanged: false,
835
- }, ['_id']);
836
- sideEffects?.onError?.(err);
837
- throw transformedError;
838
- }
839
- }
840
- exports.getSubscription = getSubscription;
841
- /**
842
- * Update subscription's payment method.
843
- * Supported only for recurring subscriptions or one time subscriptions during free trial.
844
- * @param _id - Subscription ID
845
- * @public
846
- * @documentationMaturity preview
847
- * @requiredField _id
848
- * @requiredField paymentMethodId
849
- * @permissionId subscriptions.manage
850
- * @permissionScope Manage Orders
851
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
852
- * @applicableIdentity APP
853
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.UpdateSubscriptionPaymentMethod
854
- */
855
- async function updateSubscriptionPaymentMethod(_id, paymentMethodId) {
856
- // @ts-ignore
857
- const { httpClient, sideEffects } = arguments[2];
858
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
859
- id: _id,
860
- paymentMethodId: paymentMethodId,
861
- });
862
- const reqOpts = ambassadorWixBillingV1Subscription.updateSubscriptionPaymentMethod(payload);
863
- sideEffects?.onSiteCall?.();
864
- try {
865
- const result = await httpClient.request(reqOpts);
866
- sideEffects?.onSuccess?.(result);
867
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
868
- {
869
- transformFn: address_2.transformRESTAddressToSDKAddress,
870
- paths: [
871
- { path: 'subscription.billingSettings.billingAddress.address' },
872
- { path: 'subscription.shippingAddress.address' },
873
- ],
874
- },
875
- ]));
876
- }
877
- catch (err) {
878
- const transformedError = (0, transform_error_1.transformError)(err, {
879
- spreadPathsToArguments: {},
880
- explicitPathsToArguments: { id: '$[0]', paymentMethodId: '$[1]' },
881
- singleArgumentUnchanged: false,
882
- }, ['_id', 'paymentMethodId']);
883
- sideEffects?.onError?.(err);
884
- throw transformedError;
885
- }
886
- }
887
- exports.updateSubscriptionPaymentMethod = updateSubscriptionPaymentMethod;
888
- /**
889
- * Updates the next billing date for a subscription.
890
- *
891
- *
892
- * Updating the billing date may add a proration charge or credit to the next
893
- * invoice. The customer must pay more in case you extend the current billing
894
- * cycle. They pay less in case you shorten the current billing cycle. You can
895
- * choose whether BASS automatically calculates the proration amount based on
896
- * the number of days added to or removed from the current billing cycle.
897
- * Alternatively, you can pass a proration amount based on your own custom
898
- * calculation. The custom proration amount can't exceed the total of the
899
- * current billing cycle.
900
- * @param _id - ID of the subscription to update the billing date for.
901
- * @param billingDate - New billing date in `YYYY-MM-DDThh:mm:ss:sssZ` format.
902
- * @public
903
- * @documentationMaturity preview
904
- * @requiredField _id
905
- * @requiredField billingDate
906
- * @permissionId subscriptions.manage
907
- * @permissionScope Manage Orders
908
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
909
- * @applicableIdentity APP
910
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.UpdateSubscriptionBillingDate
911
- */
912
- async function updateSubscriptionBillingDate(_id, billingDate, options) {
913
- // @ts-ignore
914
- const { httpClient, sideEffects } = arguments[3];
915
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
916
- id: _id,
917
- billingDate: billingDate,
918
- proration: options?.proration,
919
- });
920
- const reqOpts = ambassadorWixBillingV1Subscription.updateSubscriptionBillingDate(payload);
921
- sideEffects?.onSiteCall?.();
922
- try {
923
- const result = await httpClient.request(reqOpts);
924
- sideEffects?.onSuccess?.(result);
925
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
926
- {
927
- transformFn: address_2.transformRESTAddressToSDKAddress,
928
- paths: [
929
- { path: 'subscription.billingSettings.billingAddress.address' },
930
- { path: 'subscription.shippingAddress.address' },
931
- ],
932
- },
933
- ]));
934
- }
935
- catch (err) {
936
- const transformedError = (0, transform_error_1.transformError)(err, {
937
- spreadPathsToArguments: {},
938
- explicitPathsToArguments: {
939
- id: '$[0]',
940
- billingDate: '$[1]',
941
- proration: '$[2].proration',
942
- },
943
- singleArgumentUnchanged: false,
944
- }, ['_id', 'billingDate', 'options']);
945
- sideEffects?.onError?.(err);
946
- throw transformedError;
947
- }
948
- }
949
- exports.updateSubscriptionBillingDate = updateSubscriptionBillingDate;
950
- /**
951
- * Cancels subscription immediately. Can be canceled by member if subscription policy allows it
952
- * Only PENDING, ACTIVE or PAUSED subscriptions can be canceled
953
- * @public
954
- * @documentationMaturity preview
955
- * @requiredField _id
956
- * @requiredField actionContext
957
- * @permissionId subscriptions.manage
958
- * @permissionScope Manage Orders
959
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
960
- * @applicableIdentity APP
961
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.CancelSubscription
962
- */
963
- async function cancelSubscription(_id, actionContext) {
964
- // @ts-ignore
965
- const { httpClient, sideEffects } = arguments[2];
966
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
967
- id: _id,
968
- actionContext: actionContext,
969
- });
970
- const reqOpts = ambassadorWixBillingV1Subscription.cancelSubscription(payload);
971
- sideEffects?.onSiteCall?.();
972
- try {
973
- const result = await httpClient.request(reqOpts);
974
- sideEffects?.onSuccess?.(result);
975
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
976
- {
977
- transformFn: address_2.transformRESTAddressToSDKAddress,
978
- paths: [
979
- { path: 'subscription.billingSettings.billingAddress.address' },
980
- { path: 'subscription.shippingAddress.address' },
981
- ],
982
- },
983
- ]));
984
- }
985
- catch (err) {
986
- const transformedError = (0, transform_error_1.transformError)(err, {
987
- spreadPathsToArguments: {},
988
- explicitPathsToArguments: { id: '$[0]', actionContext: '$[1]' },
989
- singleArgumentUnchanged: false,
990
- }, ['_id', 'actionContext']);
991
- sideEffects?.onError?.(err);
992
- throw transformedError;
993
- }
994
- }
995
- exports.cancelSubscription = cancelSubscription;
996
- /**
997
- * Pauses subscription now or in future. Possible to pause also payments schedule.
998
- * @public
999
- * @documentationMaturity preview
1000
- * @requiredField _id
1001
- * @requiredField options.actionContext
1002
- * @permissionId subscriptions.manage
1003
- * @permissionScope Manage Orders
1004
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1005
- * @applicableIdentity APP
1006
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.PauseSubscription
1007
- */
1008
- async function pauseSubscription(_id, options) {
1009
- // @ts-ignore
1010
- const { httpClient, sideEffects } = arguments[2];
1011
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1012
- id: _id,
1013
- pausePolicy: options?.pausePolicy,
1014
- pauseAt: options?.pauseAt,
1015
- pauseAtSchedule: options?.pauseAtSchedule,
1016
- autoResumeAtSchedule: options?.autoResumeAtSchedule,
1017
- actionContext: options?.actionContext,
1018
- });
1019
- const reqOpts = ambassadorWixBillingV1Subscription.pauseSubscription(payload);
1020
- sideEffects?.onSiteCall?.();
1021
- try {
1022
- const result = await httpClient.request(reqOpts);
1023
- sideEffects?.onSuccess?.(result);
1024
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1025
- {
1026
- transformFn: address_2.transformRESTAddressToSDKAddress,
1027
- paths: [
1028
- { path: 'subscription.billingSettings.billingAddress.address' },
1029
- { path: 'subscription.shippingAddress.address' },
1030
- ],
1031
- },
1032
- ]));
1033
- }
1034
- catch (err) {
1035
- const transformedError = (0, transform_error_1.transformError)(err, {
1036
- spreadPathsToArguments: {},
1037
- explicitPathsToArguments: {
1038
- id: '$[0]',
1039
- pausePolicy: '$[1].pausePolicy',
1040
- pauseAt: '$[1].pauseAt',
1041
- pauseAtSchedule: '$[1].pauseAtSchedule',
1042
- autoResumeAtSchedule: '$[1].autoResumeAtSchedule',
1043
- actionContext: '$[1].actionContext',
1044
- },
1045
- singleArgumentUnchanged: false,
1046
- }, ['_id', 'options']);
1047
- sideEffects?.onError?.(err);
1048
- throw transformedError;
1049
- }
1050
- }
1051
- exports.pauseSubscription = pauseSubscription;
1052
- /**
1053
- * Resumes paused subscription now or in future.
1054
- * @public
1055
- * @documentationMaturity preview
1056
- * @requiredField _id
1057
- * @requiredField options.actionContext
1058
- * @permissionId subscriptions.manage
1059
- * @permissionScope Manage Orders
1060
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1061
- * @applicableIdentity APP
1062
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.ResumeSubscription
1063
- */
1064
- async function resumeSubscription(_id, options) {
1065
- // @ts-ignore
1066
- const { httpClient, sideEffects } = arguments[2];
1067
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1068
- id: _id,
1069
- resumeAt: options?.resumeAt,
1070
- resumeAtSchedule: options?.resumeAtSchedule,
1071
- actionContext: options?.actionContext,
1072
- });
1073
- const reqOpts = ambassadorWixBillingV1Subscription.resumeSubscription(payload);
1074
- sideEffects?.onSiteCall?.();
1075
- try {
1076
- const result = await httpClient.request(reqOpts);
1077
- sideEffects?.onSuccess?.(result);
1078
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1079
- {
1080
- transformFn: address_2.transformRESTAddressToSDKAddress,
1081
- paths: [
1082
- { path: 'subscription.billingSettings.billingAddress.address' },
1083
- { path: 'subscription.shippingAddress.address' },
1084
- ],
1085
- },
1086
- ]));
1087
- }
1088
- catch (err) {
1089
- const transformedError = (0, transform_error_1.transformError)(err, {
1090
- spreadPathsToArguments: {},
1091
- explicitPathsToArguments: {
1092
- id: '$[0]',
1093
- resumeAt: '$[1].resumeAt',
1094
- resumeAtSchedule: '$[1].resumeAtSchedule',
1095
- actionContext: '$[1].actionContext',
1096
- },
1097
- singleArgumentUnchanged: false,
1098
- }, ['_id', 'options']);
1099
- sideEffects?.onError?.(err);
1100
- throw transformedError;
1101
- }
1102
- }
1103
- exports.resumeSubscription = resumeSubscription;
1104
- /**
1105
- * Lists subscriptions based on specified filters.
1106
- * By default non-draft subscriptions returned.
1107
- * @public
1108
- * @documentationMaturity preview
1109
- * @requiredField query
1110
- * @permissionId subscriptions.view
1111
- * @permissionScope Manage Events
1112
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1113
- * @applicableIdentity APP
1114
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.QuerySubscriptions
1115
- */
1116
- async function querySubscriptions(query) {
1117
- // @ts-ignore
1118
- const { httpClient, sideEffects } = arguments[1];
1119
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({ query: query });
1120
- const reqOpts = ambassadorWixBillingV1Subscription.querySubscriptions(payload);
1121
- sideEffects?.onSiteCall?.();
1122
- try {
1123
- const result = await httpClient.request(reqOpts);
1124
- sideEffects?.onSuccess?.(result);
1125
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1126
- {
1127
- transformFn: address_2.transformRESTAddressToSDKAddress,
1128
- paths: [
1129
- { path: 'subscriptions.billingSettings.billingAddress.address' },
1130
- { path: 'subscriptions.shippingAddress.address' },
1131
- ],
1132
- },
1133
- ]));
1134
- }
1135
- catch (err) {
1136
- const transformedError = (0, transform_error_1.transformError)(err, {
1137
- spreadPathsToArguments: {},
1138
- explicitPathsToArguments: { query: '$[0]' },
1139
- singleArgumentUnchanged: false,
1140
- }, ['query']);
1141
- sideEffects?.onError?.(err);
1142
- throw transformedError;
1143
- }
1144
- }
1145
- exports.querySubscriptions = querySubscriptions;
1146
- /** @public
1147
- * @documentationMaturity preview
1148
- * @permissionId subscriptions.view
1149
- * @permissionScope Manage Events
1150
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1151
- * @applicableIdentity APP
1152
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.SearchSubscriptions
1153
- */
1154
- async function searchSubscriptions(options) {
1155
- // @ts-ignore
1156
- const { httpClient, sideEffects } = arguments[1];
1157
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1158
- filter: options?.filter,
1159
- paging: options?.paging,
1160
- cursor: options?.cursor,
1161
- sorting: options?.sorting,
1162
- });
1163
- const reqOpts = ambassadorWixBillingV1Subscription.searchSubscriptions(payload);
1164
- sideEffects?.onSiteCall?.();
1165
- try {
1166
- const result = await httpClient.request(reqOpts);
1167
- sideEffects?.onSuccess?.(result);
1168
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1169
- {
1170
- transformFn: address_2.transformRESTAddressToSDKAddress,
1171
- paths: [
1172
- { path: 'subscriptions.billingSettings.billingAddress.address' },
1173
- { path: 'subscriptions.shippingAddress.address' },
1174
- ],
1175
- },
1176
- ]));
1177
- }
1178
- catch (err) {
1179
- const transformedError = (0, transform_error_1.transformError)(err, {
1180
- spreadPathsToArguments: {},
1181
- explicitPathsToArguments: {
1182
- filter: '$[0].filter',
1183
- paging: '$[0].paging',
1184
- cursor: '$[0].cursor',
1185
- sorting: '$[0].sorting',
1186
- },
1187
- singleArgumentUnchanged: false,
1188
- }, ['options']);
1189
- sideEffects?.onError?.(err);
1190
- throw transformedError;
1191
- }
1192
- }
1193
- exports.searchSubscriptions = searchSubscriptions;
1194
- /**
1195
- * Counts subscriptions given the provided filters. Returns the total number
1196
- * of subscriptions matching the filters and a count per status.
1197
- *
1198
- *
1199
- * You can either pass a list of statuses or a `statusGroup`, which is a
1200
- * pre-defined combination of statuses.
1201
- *
1202
- * If you don't provide any filters, all subscription statuses with the
1203
- * exception of `"DRAFT"` are counted.
1204
- *
1205
- * You may also specify a `customerId` as filter. Then, only subscriptions for
1206
- * this customer are counted. When providing a `customerId`, you must also
1207
- * specify a `paymentMethodId`.
1208
- * @public
1209
- * @documentationMaturity preview
1210
- * @permissionId subscriptions.view
1211
- * @permissionScope Manage Events
1212
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1213
- * @applicableIdentity APP
1214
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.CountSubscriptions
1215
- */
1216
- async function countSubscriptions(options) {
1217
- // @ts-ignore
1218
- const { httpClient, sideEffects } = arguments[1];
1219
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1220
- filter: options?.filter,
1221
- });
1222
- const reqOpts = ambassadorWixBillingV1Subscription.countSubscriptions(payload);
1223
- sideEffects?.onSiteCall?.();
1224
- try {
1225
- const result = await httpClient.request(reqOpts);
1226
- sideEffects?.onSuccess?.(result);
1227
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1228
- }
1229
- catch (err) {
1230
- const transformedError = (0, transform_error_1.transformError)(err, {
1231
- spreadPathsToArguments: {},
1232
- explicitPathsToArguments: { filter: '$[0].filter' },
1233
- singleArgumentUnchanged: false,
1234
- }, ['options']);
1235
- sideEffects?.onError?.(err);
1236
- throw transformedError;
1237
- }
1238
- }
1239
- exports.countSubscriptions = countSubscriptions;
1240
- /**
1241
- * Turn on auto-renew subscription in case auto-renew was turned off. The operation changes back cycle_auto_renew
1242
- * to true, which will ensure subscription billing will continue. Also cancellation info holding information about
1243
- * auto renew off will be cleared.
1244
- * @public
1245
- * @documentationMaturity preview
1246
- * @requiredField _id
1247
- * @requiredField actionContext
1248
- * @permissionId subscriptions.manage
1249
- * @permissionScope Manage Orders
1250
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1251
- * @applicableIdentity APP
1252
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.TurnOnSubscriptionAutoRenewal
1253
- */
1254
- async function turnOnSubscriptionAutoRenewal(_id, actionContext) {
1255
- // @ts-ignore
1256
- const { httpClient, sideEffects } = arguments[2];
1257
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1258
- id: _id,
1259
- actionContext: actionContext,
1260
- });
1261
- const reqOpts = ambassadorWixBillingV1Subscription.turnOnSubscriptionAutoRenewal(payload);
1262
- sideEffects?.onSiteCall?.();
1263
- try {
1264
- const result = await httpClient.request(reqOpts);
1265
- sideEffects?.onSuccess?.(result);
1266
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1267
- {
1268
- transformFn: address_2.transformRESTAddressToSDKAddress,
1269
- paths: [
1270
- { path: 'subscription.billingSettings.billingAddress.address' },
1271
- { path: 'subscription.shippingAddress.address' },
1272
- ],
1273
- },
1274
- ]));
1275
- }
1276
- catch (err) {
1277
- const transformedError = (0, transform_error_1.transformError)(err, {
1278
- spreadPathsToArguments: {},
1279
- explicitPathsToArguments: { id: '$[0]', actionContext: '$[1]' },
1280
- singleArgumentUnchanged: false,
1281
- }, ['_id', 'actionContext']);
1282
- sideEffects?.onError?.(err);
1283
- throw transformedError;
1284
- }
1285
- }
1286
- exports.turnOnSubscriptionAutoRenewal = turnOnSubscriptionAutoRenewal;
1287
- /**
1288
- * Turn off auto-renew of subscription. At next billing date subscription will be canceled.
1289
- * Billing settings flag cycle_auto_renew is set to false and information about this operation stored
1290
- * in cancellation info for future usage in cancellation.
1291
- * @public
1292
- * @documentationMaturity preview
1293
- * @requiredField _id
1294
- * @requiredField actionContext
1295
- * @permissionId subscriptions.manage
1296
- * @permissionScope Manage Orders
1297
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1298
- * @applicableIdentity APP
1299
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.TurnOffSubscriptionAutoRenewal
1300
- */
1301
- async function turnOffSubscriptionAutoRenewal(_id, actionContext) {
1302
- // @ts-ignore
1303
- const { httpClient, sideEffects } = arguments[2];
1304
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1305
- id: _id,
1306
- actionContext: actionContext,
1307
- });
1308
- const reqOpts = ambassadorWixBillingV1Subscription.turnOffSubscriptionAutoRenewal(payload);
1309
- sideEffects?.onSiteCall?.();
1310
- try {
1311
- const result = await httpClient.request(reqOpts);
1312
- sideEffects?.onSuccess?.(result);
1313
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1314
- {
1315
- transformFn: address_2.transformRESTAddressToSDKAddress,
1316
- paths: [
1317
- { path: 'subscription.billingSettings.billingAddress.address' },
1318
- { path: 'subscription.shippingAddress.address' },
1319
- ],
1320
- },
1321
- ]));
1322
- }
1323
- catch (err) {
1324
- const transformedError = (0, transform_error_1.transformError)(err, {
1325
- spreadPathsToArguments: {},
1326
- explicitPathsToArguments: { id: '$[0]', actionContext: '$[1]' },
1327
- singleArgumentUnchanged: false,
1328
- }, ['_id', 'actionContext']);
1329
- sideEffects?.onError?.(err);
1330
- throw transformedError;
1331
- }
1332
- }
1333
- exports.turnOffSubscriptionAutoRenewal = turnOffSubscriptionAutoRenewal;
1334
- /**
1335
- * Marks the last invoice as paid used for the following scenarios:
1336
- * * Offline subscriptions.
1337
- * * Online subscriptions during grace period. The operation will convert invoice to offline, remove grace period
1338
- * and will send BillingCycleStarted event after invoice closing.
1339
- * * Online one time payment subscription with total price of zero during purchase flow.
1340
- * Activated event will be sent after invoice closing and subscription will be activated.
1341
- * @param subscriptionId - The ID of the offline subscription to mark as paid its latest invoice
1342
- * @public
1343
- * @documentationMaturity preview
1344
- * @requiredField subscriptionId
1345
- * @permissionId subscriptions.manage
1346
- * @permissionScope Manage Orders
1347
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1348
- * @applicableIdentity APP
1349
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.MarkLatestInvoiceAsPaid
1350
- * @deprecated
1351
- * @replacedBy com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.MarkInvoiceAsPaid
1352
- * @targetRemovalDate 2025-09-30
1353
- */
1354
- async function markLatestInvoiceAsPaid(subscriptionId) {
1355
- // @ts-ignore
1356
- const { httpClient, sideEffects } = arguments[1];
1357
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1358
- subscriptionId: subscriptionId,
1359
- });
1360
- const reqOpts = ambassadorWixBillingV1Subscription.markLatestInvoiceAsPaid(payload);
1361
- sideEffects?.onSiteCall?.();
1362
- try {
1363
- const result = await httpClient.request(reqOpts);
1364
- sideEffects?.onSuccess?.(result);
1365
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1366
- {
1367
- transformFn: address_2.transformRESTAddressToSDKAddress,
1368
- paths: [
1369
- { path: 'subscription.billingSettings.billingAddress.address' },
1370
- { path: 'subscription.shippingAddress.address' },
1371
- ],
1372
- },
1373
- ]));
1374
- }
1375
- catch (err) {
1376
- const transformedError = (0, transform_error_1.transformError)(err, {
1377
- spreadPathsToArguments: {},
1378
- explicitPathsToArguments: { subscriptionId: '$[0]' },
1379
- singleArgumentUnchanged: false,
1380
- }, ['subscriptionId']);
1381
- sideEffects?.onError?.(err);
1382
- throw transformedError;
1383
- }
1384
- }
1385
- exports.markLatestInvoiceAsPaid = markLatestInvoiceAsPaid;
1386
- /**
1387
- * Marks the invoice associated with given subscription cycle as paid for the following scenarios:
1388
- * If `paid_cycle` is left empty, the most recent invoice will be marked as paid.
1389
- * If the invoice contains items other than subscription items, an error will be thrown.
1390
- *
1391
- * Marks the invoice as paid for the following scenarios:
1392
- * 1. Offline subscriptions.
1393
- * 2. Online subscriptions during the grace period.
1394
- * This operation will convert the invoice to offline, remove the grace period,
1395
- * and send a BillingCycleStarted event after the invoice is closed.
1396
- * 3. Online one-time payment subscriptions with a total price of zero during the purchase flow.
1397
- * An Activated event will be sent after the invoice is closed, and the subscription will be activated.
1398
- * 4. For external subscriptions, where the payment occurs outside of BASS, an invoice is created and marked as paid
1399
- * @param subscriptionId - The ID of the subscription to mark as paid its invoice.
1400
- * @internal
1401
- * @documentationMaturity preview
1402
- * @requiredField subscriptionId
1403
- * @permissionId subscriptions.manage
1404
- * @permissionScope Manage Orders
1405
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1406
- * @applicableIdentity APP
1407
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.MarkBillingCycleAsPaid
1408
- */
1409
- async function markBillingCycleAsPaid(subscriptionId, options) {
1410
- // @ts-ignore
1411
- const { httpClient, sideEffects } = arguments[2];
1412
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1413
- subscriptionId: subscriptionId,
1414
- paidCycle: options?.paidCycle,
1415
- });
1416
- const reqOpts = ambassadorWixBillingV1Subscription.markBillingCycleAsPaid(payload);
1417
- sideEffects?.onSiteCall?.();
1418
- try {
1419
- const result = await httpClient.request(reqOpts);
1420
- sideEffects?.onSuccess?.(result);
1421
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1422
- {
1423
- transformFn: address_2.transformRESTAddressToSDKAddress,
1424
- paths: [
1425
- { path: 'subscription.billingSettings.billingAddress.address' },
1426
- { path: 'subscription.shippingAddress.address' },
1427
- ],
1428
- },
1429
- ]));
1430
- }
1431
- catch (err) {
1432
- const transformedError = (0, transform_error_1.transformError)(err, {
1433
- spreadPathsToArguments: {},
1434
- explicitPathsToArguments: {
1435
- subscriptionId: '$[0]',
1436
- paidCycle: '$[1].paidCycle',
1437
- },
1438
- singleArgumentUnchanged: false,
1439
- }, ['subscriptionId', 'options']);
1440
- sideEffects?.onError?.(err);
1441
- throw transformedError;
1442
- }
1443
- }
1444
- exports.markBillingCycleAsPaid = markBillingCycleAsPaid;
1445
- /**
1446
- * Returns number of subscriptions in each state.
1447
- * @public
1448
- * @documentationMaturity preview
1449
- * @permissionId subscriptions.view
1450
- * @permissionScope Manage Events
1451
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1452
- * @applicableIdentity APP
1453
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.GetSubscriptionsStats
1454
- */
1455
- async function getSubscriptionsStats() {
1456
- // @ts-ignore
1457
- const { httpClient, sideEffects } = arguments[0];
1458
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({});
1459
- const reqOpts = ambassadorWixBillingV1Subscription.getSubscriptionsStats(payload);
1460
- sideEffects?.onSiteCall?.();
1461
- try {
1462
- const result = await httpClient.request(reqOpts);
1463
- sideEffects?.onSuccess?.(result);
1464
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1465
- }
1466
- catch (err) {
1467
- const transformedError = (0, transform_error_1.transformError)(err, {
1468
- spreadPathsToArguments: {},
1469
- explicitPathsToArguments: {},
1470
- singleArgumentUnchanged: false,
1471
- }, []);
1472
- sideEffects?.onError?.(err);
1473
- throw transformedError;
1474
- }
1475
- }
1476
- exports.getSubscriptionsStats = getSubscriptionsStats;
1477
- /**
1478
- * Extends subscription by moving end date with or without billing cycles addition.
1479
- * @param _id - The ID of the subscription to be extended
1480
- * @public
1481
- * @documentationMaturity preview
1482
- * @requiredField _id
1483
- * @requiredField actionContext
1484
- * @requiredField options
1485
- * @requiredField options.extendPolicy
1486
- * @permissionId subscriptions.manage
1487
- * @permissionScope Manage Orders
1488
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1489
- * @applicableIdentity APP
1490
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.ExtendSubscription
1491
- */
1492
- async function extendSubscription(_id, actionContext, options) {
1493
- // @ts-ignore
1494
- const { httpClient, sideEffects } = arguments[3];
1495
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1496
- id: _id,
1497
- actionContext: actionContext,
1498
- extensionPeriod: options?.extensionPeriod,
1499
- extensionBillingCycles: options?.extensionBillingCycles,
1500
- });
1501
- const reqOpts = ambassadorWixBillingV1Subscription.extendSubscription(payload);
1502
- sideEffects?.onSiteCall?.();
1503
- try {
1504
- const result = await httpClient.request(reqOpts);
1505
- sideEffects?.onSuccess?.(result);
1506
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1507
- {
1508
- transformFn: address_2.transformRESTAddressToSDKAddress,
1509
- paths: [
1510
- { path: 'subscription.billingSettings.billingAddress.address' },
1511
- { path: 'subscription.shippingAddress.address' },
1512
- ],
1513
- },
1514
- ]));
1515
- }
1516
- catch (err) {
1517
- const transformedError = (0, transform_error_1.transformError)(err, {
1518
- spreadPathsToArguments: {},
1519
- explicitPathsToArguments: {
1520
- id: '$[0]',
1521
- actionContext: '$[1]',
1522
- extensionPeriod: '$[2].extensionPeriod',
1523
- extensionBillingCycles: '$[2].extensionBillingCycles',
1524
- },
1525
- singleArgumentUnchanged: false,
1526
- }, ['_id', 'actionContext', 'options']);
1527
- sideEffects?.onError?.(err);
1528
- throw transformedError;
1529
- }
1530
- }
1531
- exports.extendSubscription = extendSubscription;
1532
- /** @public
1533
- * @documentationMaturity preview
1534
- * @requiredField _id
1535
- * @permissionId subscriptions.manage
1536
- * @permissionScope Manage Orders
1537
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1538
- * @applicableIdentity APP
1539
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.AllowedActions
1540
- */
1541
- async function allowedActions(_id, options) {
1542
- // @ts-ignore
1543
- const { httpClient, sideEffects } = arguments[2];
1544
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1545
- id: _id,
1546
- fields: options?.fields,
1547
- });
1548
- const reqOpts = ambassadorWixBillingV1Subscription.allowedActions(payload);
1549
- sideEffects?.onSiteCall?.();
1550
- try {
1551
- const result = await httpClient.request(reqOpts);
1552
- sideEffects?.onSuccess?.(result);
1553
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1554
- }
1555
- catch (err) {
1556
- const transformedError = (0, transform_error_1.transformError)(err, {
1557
- spreadPathsToArguments: {},
1558
- explicitPathsToArguments: { id: '$[0]', fields: '$[1].fields' },
1559
- singleArgumentUnchanged: false,
1560
- }, ['_id', 'options']);
1561
- sideEffects?.onError?.(err);
1562
- throw transformedError;
1563
- }
1564
- }
1565
- exports.allowedActions = allowedActions;
1566
- /**
1567
- * List future subscriptions charges
1568
- * @param subscriptionId - Subscription id charges to be previewed for
1569
- * @public
1570
- * @documentationMaturity preview
1571
- * @requiredField subscriptionId
1572
- * @permissionId subscriptions.view
1573
- * @permissionScope Manage Events
1574
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1575
- * @applicableIdentity APP
1576
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.ListUpcomingCharges
1577
- */
1578
- async function listUpcomingCharges(subscriptionId, options) {
1579
- // @ts-ignore
1580
- const { httpClient, sideEffects } = arguments[2];
1581
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1582
- subscriptionId: subscriptionId,
1583
- customDuration: options?.customDuration,
1584
- nextBillingDate: options?.nextBillingDate,
1585
- });
1586
- const reqOpts = ambassadorWixBillingV1Subscription.listUpcomingCharges(payload);
1587
- sideEffects?.onSiteCall?.();
1588
- try {
1589
- const result = await httpClient.request(reqOpts);
1590
- sideEffects?.onSuccess?.(result);
1591
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1592
- }
1593
- catch (err) {
1594
- const transformedError = (0, transform_error_1.transformError)(err, {
1595
- spreadPathsToArguments: {},
1596
- explicitPathsToArguments: {
1597
- subscriptionId: '$[0]',
1598
- customDuration: '$[1].customDuration',
1599
- nextBillingDate: '$[1].nextBillingDate',
1600
- },
1601
- singleArgumentUnchanged: false,
1602
- }, ['subscriptionId', 'options']);
1603
- sideEffects?.onError?.(err);
1604
- throw transformedError;
1605
- }
1606
- }
1607
- exports.listUpcomingCharges = listUpcomingCharges;
1608
- /**
1609
- * Retrieves the preview of subscription charges.
1610
- * Returns all the charges applicable to a subscription based on the provided subscription information.
1611
- * @public
1612
- * @documentationMaturity preview
1613
- * @requiredField options.subscription.subscriptionInfo
1614
- * @requiredField options.subscription.subscriptionInfo.billingSettings
1615
- * @requiredField options.subscription.subscriptionInfo.items
1616
- * @requiredField options.subscription.subscriptionInfo.items.pricingModel
1617
- * @permissionId subscriptions.view
1618
- * @permissionScope Manage Events
1619
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1620
- * @applicableIdentity APP
1621
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.PreviewSubscriptionCharges
1622
- * @deprecated
1623
- * @replacedBy com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.PreviewSubscriptionsCharges
1624
- * @targetRemovalDate 2025-06-30
1625
- */
1626
- async function previewSubscriptionCharges(options) {
1627
- // @ts-ignore
1628
- const { httpClient, sideEffects } = arguments[1];
1629
- const payload = (0, transform_paths_1.transformPaths)((0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1630
- subscriptionInfo: options?.subscriptionInfo,
1631
- }), [
1632
- {
1633
- transformFn: address_1.transformSDKAddressToRESTAddress,
1634
- paths: [
1635
- { path: 'subscriptionInfo.billingSettings.billingAddress.address' },
1636
- ],
1637
- },
1638
- ]);
1639
- const reqOpts = ambassadorWixBillingV1Subscription.previewSubscriptionCharges(payload);
1640
- sideEffects?.onSiteCall?.();
1641
- try {
1642
- const result = await httpClient.request(reqOpts);
1643
- sideEffects?.onSuccess?.(result);
1644
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1645
- }
1646
- catch (err) {
1647
- const transformedError = (0, transform_error_1.transformError)(err, {
1648
- spreadPathsToArguments: {},
1649
- explicitPathsToArguments: { subscriptionInfo: '$[0].subscriptionInfo' },
1650
- singleArgumentUnchanged: false,
1651
- }, ['options']);
1652
- sideEffects?.onError?.(err);
1653
- throw transformedError;
1654
- }
1655
- }
1656
- exports.previewSubscriptionCharges = previewSubscriptionCharges;
1657
- /**
1658
- * Retrieves the preview of subscription charges for a bulk of subscriptions.
1659
- * Returns all the charges applicable to all subscriptions, based on the provided subscriptions information.
1660
- * @public
1661
- * @documentationMaturity preview
1662
- * @requiredField options.subscriptionsBillingDetails.billingSettings
1663
- * @requiredField options.subscriptionsBillingDetails.billingSettings.shippingCharges.tax.value
1664
- * @requiredField options.subscriptionsBillingDetails.externalId
1665
- * @requiredField options.subscriptionsBillingDetails.items
1666
- * @requiredField options.subscriptionsBillingDetails.items.pricingModel
1667
- * @requiredField options.subscriptionsBillingDetails.items.pricingModel.model
1668
- * @requiredField options.subscriptionsBillingDetails.items.tax.value
1669
- * @permissionId subscriptions.view
1670
- * @permissionScope Manage Events
1671
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1672
- * @applicableIdentity APP
1673
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.PreviewSubscriptionsCharges
1674
- */
1675
- async function previewSubscriptionsCharges(options) {
1676
- // @ts-ignore
1677
- const { httpClient, sideEffects } = arguments[1];
1678
- const payload = (0, transform_paths_1.transformPaths)((0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1679
- subscriptionsBillingDetails: options?.subscriptionsBillingDetails,
1680
- numberOfNextRecurringCharges: options?.numberOfNextRecurringCharges,
1681
- }), [
1682
- {
1683
- transformFn: address_1.transformSDKAddressToRESTAddress,
1684
- paths: [
1685
- {
1686
- path: 'subscriptionsBillingDetails.billingSettings.billingAddress.address',
1687
- },
1688
- { path: 'subscriptionsBillingDetails.shippingAddress.address' },
1689
- ],
1690
- },
1691
- ]);
1692
- const reqOpts = ambassadorWixBillingV1Subscription.previewSubscriptionsCharges(payload);
1693
- sideEffects?.onSiteCall?.();
1694
- try {
1695
- const result = await httpClient.request(reqOpts);
1696
- sideEffects?.onSuccess?.(result);
1697
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1698
- }
1699
- catch (err) {
1700
- const transformedError = (0, transform_error_1.transformError)(err, {
1701
- spreadPathsToArguments: {},
1702
- explicitPathsToArguments: {
1703
- subscriptionsBillingDetails: '$[0].subscriptionsBillingDetails',
1704
- numberOfNextRecurringCharges: '$[0].numberOfNextRecurringCharges',
1705
- },
1706
- singleArgumentUnchanged: false,
1707
- }, ['options']);
1708
- sideEffects?.onError?.(err);
1709
- throw transformedError;
1710
- }
1711
- }
1712
- exports.previewSubscriptionsCharges = previewSubscriptionsCharges;
1713
- /**
1714
- * Creates authorization invoice with Moto settings in order to create
1715
- * @public
1716
- * @documentationMaturity preview
1717
- * @requiredField _id
1718
- * @permissionId subscriptions.manage
1719
- * @permissionScope Manage Orders
1720
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1721
- * @applicableIdentity APP
1722
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionsService.InitiatePaymentMethodSetup
1723
- */
1724
- async function initiatePaymentMethodSetup(_id, options) {
1725
- // @ts-ignore
1726
- const { httpClient, sideEffects } = arguments[2];
1727
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1728
- id: _id,
1729
- paymentMode: options?.paymentMode,
1730
- paymentSettings: options?.paymentSettings,
1731
- });
1732
- const reqOpts = ambassadorWixBillingV1Subscription.initiatePaymentMethodSetup(payload);
1733
- sideEffects?.onSiteCall?.();
1734
- try {
1735
- const result = await httpClient.request(reqOpts);
1736
- sideEffects?.onSuccess?.(result);
1737
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)(result.data);
1738
- }
1739
- catch (err) {
1740
- const transformedError = (0, transform_error_1.transformError)(err, {
1741
- spreadPathsToArguments: {},
1742
- explicitPathsToArguments: {
1743
- id: '$[0]',
1744
- paymentMode: '$[1].paymentMode',
1745
- paymentSettings: '$[1].paymentSettings',
1746
- },
1747
- singleArgumentUnchanged: false,
1748
- }, ['_id', 'options']);
1749
- sideEffects?.onError?.(err);
1750
- throw transformedError;
1751
- }
1752
- }
1753
- exports.initiatePaymentMethodSetup = initiatePaymentMethodSetup;
1754
- /** @public
1755
- * @documentationMaturity preview
1756
- * @requiredField subscriptionId
1757
- * @permissionId subscriptions.view
1758
- * @permissionScope Manage Events
1759
- * @permissionScopeId SCOPE.EVENTS.MANAGE-EVENTS
1760
- * @applicableIdentity APP
1761
- * @fqn com.wixpress.billing.subscriptions.api.v1.SubscriptionHistoryService.ListSubscriptionHistory
1762
- */
1763
- async function listSubscriptionHistory(subscriptionId, options) {
1764
- // @ts-ignore
1765
- const { httpClient, sideEffects } = arguments[2];
1766
- const payload = (0, rename_all_nested_keys_1.renameKeysFromSDKRequestToRESTRequest)({
1767
- subscriptionId: subscriptionId,
1768
- mode: options?.mode,
1769
- cursor: options?.cursor,
1770
- });
1771
- const reqOpts = ambassadorWixBillingV1Subscription.listSubscriptionHistory(payload);
1772
- sideEffects?.onSiteCall?.();
1773
- try {
1774
- const result = await httpClient.request(reqOpts);
1775
- sideEffects?.onSuccess?.(result);
1776
- return (0, rename_all_nested_keys_1.renameKeysFromRESTResponseToSDKResponse)((0, transform_paths_1.transformPaths)(result.data, [
1777
- {
1778
- transformFn: address_2.transformRESTAddressToSDKAddress,
1779
- paths: [
1780
- {
1781
- path: 'historyEntries.event.created.subscription.billingSettings.billingAddress.address',
1782
- },
1783
- {
1784
- path: 'historyEntries.event.created.subscription.shippingAddress.address',
1785
- },
1786
- {
1787
- path: 'historyEntries.event.updated.current.billingSettings.billingAddress.address',
1788
- },
1789
- {
1790
- path: 'historyEntries.event.updated.current.shippingAddress.address',
1791
- },
1792
- {
1793
- path: 'historyEntries.event.updated.previous.billingSettings.billingAddress.address',
1794
- },
1795
- {
1796
- path: 'historyEntries.event.updated.previous.shippingAddress.address',
1797
- },
1798
- {
1799
- path: 'historyEntries.event.activated.subscription.billingSettings.billingAddress.address',
1800
- },
1801
- {
1802
- path: 'historyEntries.event.activated.subscription.shippingAddress.address',
1803
- },
1804
- {
1805
- path: 'historyEntries.event.ended.subscription.billingSettings.billingAddress.address',
1806
- },
1807
- {
1808
- path: 'historyEntries.event.ended.subscription.shippingAddress.address',
1809
- },
1810
- {
1811
- path: 'historyEntries.event.canceled.subscription.billingSettings.billingAddress.address',
1812
- },
1813
- {
1814
- path: 'historyEntries.event.canceled.subscription.shippingAddress.address',
1815
- },
1816
- {
1817
- path: 'historyEntries.event.paused.subscription.billingSettings.billingAddress.address',
1818
- },
1819
- {
1820
- path: 'historyEntries.event.paused.subscription.shippingAddress.address',
1821
- },
1822
- {
1823
- path: 'historyEntries.event.resumed.subscription.billingSettings.billingAddress.address',
1824
- },
1825
- {
1826
- path: 'historyEntries.event.resumed.subscription.shippingAddress.address',
1827
- },
1828
- {
1829
- path: 'historyEntries.event.pauseRequested.subscription.billingSettings.billingAddress.address',
1830
- },
1831
- {
1832
- path: 'historyEntries.event.pauseRequested.subscription.shippingAddress.address',
1833
- },
1834
- {
1835
- path: 'historyEntries.event.resumeRequested.subscription.billingSettings.billingAddress.address',
1836
- },
1837
- {
1838
- path: 'historyEntries.event.resumeRequested.subscription.shippingAddress.address',
1839
- },
1840
- {
1841
- path: 'historyEntries.event.scheduledPauseCanceled.subscription.billingSettings.billingAddress.address',
1842
- },
1843
- {
1844
- path: 'historyEntries.event.scheduledPauseCanceled.subscription.shippingAddress.address',
1845
- },
1846
- {
1847
- path: 'historyEntries.event.scheduledResumeCanceled.subscription.billingSettings.billingAddress.address',
1848
- },
1849
- {
1850
- path: 'historyEntries.event.scheduledResumeCanceled.subscription.shippingAddress.address',
1851
- },
1852
- {
1853
- path: 'historyEntries.event.billingCycleStarted.subscription.billingSettings.billingAddress.address',
1854
- },
1855
- {
1856
- path: 'historyEntries.event.billingCycleStarted.subscription.shippingAddress.address',
1857
- },
1858
- {
1859
- path: 'historyEntries.event.autoRenewalTurnedOn.subscription.billingSettings.billingAddress.address',
1860
- },
1861
- {
1862
- path: 'historyEntries.event.autoRenewalTurnedOn.subscription.shippingAddress.address',
1863
- },
1864
- {
1865
- path: 'historyEntries.event.autoRenewalTurnedOff.subscription.billingSettings.billingAddress.address',
1866
- },
1867
- {
1868
- path: 'historyEntries.event.autoRenewalTurnedOff.subscription.shippingAddress.address',
1869
- },
1870
- {
1871
- path: 'historyEntries.event.cycleReadyToPay.subscription.billingSettings.billingAddress.address',
1872
- },
1873
- {
1874
- path: 'historyEntries.event.cycleReadyToPay.subscription.shippingAddress.address',
1875
- },
1876
- {
1877
- path: 'historyEntries.event.extended.subscription.billingSettings.billingAddress.address',
1878
- },
1879
- {
1880
- path: 'historyEntries.event.extended.subscription.shippingAddress.address',
1881
- },
1882
- {
1883
- path: 'historyEntries.event.initialPurchaseCompleted.subscription.billingSettings.billingAddress.address',
1884
- },
1885
- {
1886
- path: 'historyEntries.event.initialPurchaseCompleted.subscription.shippingAddress.address',
1887
- },
1888
- {
1889
- path: 'historyEntries.event.latestInvoiceMarkedAsPaid.subscription.billingSettings.billingAddress.address',
1890
- },
1891
- {
1892
- path: 'historyEntries.event.latestInvoiceMarkedAsPaid.subscription.shippingAddress.address',
1893
- },
1894
- {
1895
- path: 'historyEntries.event.revived.subscription.billingSettings.billingAddress.address',
1896
- },
1897
- {
1898
- path: 'historyEntries.event.revived.subscription.shippingAddress.address',
1899
- },
1900
- {
1901
- path: 'historyEntries.event.billingDateUpdated.subscription.billingSettings.billingAddress.address',
1902
- },
1903
- {
1904
- path: 'historyEntries.event.billingDateUpdated.subscription.shippingAddress.address',
1905
- },
1906
- {
1907
- path: 'historyEntries.event.futureUpdatesRequested.subscription.billingSettings.billingAddress.address',
1908
- },
1909
- {
1910
- path: 'historyEntries.event.futureUpdatesRequested.subscription.shippingAddress.address',
1911
- },
1912
- {
1913
- path: 'historyEntries.event.updatesApplied.subscription.billingSettings.billingAddress.address',
1914
- },
1915
- {
1916
- path: 'historyEntries.event.updatesApplied.subscription.shippingAddress.address',
1917
- },
1918
- {
1919
- path: 'historyEntries.event.resetPendingUpdates.subscription.billingSettings.billingAddress.address',
1920
- },
1921
- {
1922
- path: 'historyEntries.event.resetPendingUpdates.subscription.shippingAddress.address',
1923
- },
1924
- {
1925
- path: 'historyEntries.event.gracePeriodStarted.subscription.billingSettings.billingAddress.address',
1926
- },
1927
- {
1928
- path: 'historyEntries.event.gracePeriodStarted.subscription.shippingAddress.address',
1929
- },
1930
- {
1931
- path: 'historyEntries.event.gracePeriodEnded.subscription.billingSettings.billingAddress.address',
1932
- },
1933
- {
1934
- path: 'historyEntries.event.gracePeriodEnded.subscription.shippingAddress.address',
1935
- },
1936
- {
1937
- path: 'historyEntries.event.paymentMethodUpdated.subscription.billingSettings.billingAddress.address',
1938
- },
1939
- {
1940
- path: 'historyEntries.event.paymentMethodUpdated.subscription.shippingAddress.address',
1941
- },
1942
- {
1943
- path: 'historyEntries.event.collectionMethodUpdated.subscription.billingSettings.billingAddress.address',
1944
- },
1945
- {
1946
- path: 'historyEntries.event.collectionMethodUpdated.subscription.shippingAddress.address',
1947
- },
1948
- {
1949
- path: 'historyEntries.event.freeTrailStarted.subscription.billingSettings.billingAddress.address',
1950
- },
1951
- {
1952
- path: 'historyEntries.event.freeTrailStarted.subscription.shippingAddress.address',
1953
- },
1954
- {
1955
- path: 'historyEntries.event.freeTrailEnded.subscription.billingSettings.billingAddress.address',
1956
- },
1957
- {
1958
- path: 'historyEntries.event.freeTrailEnded.subscription.shippingAddress.address',
1959
- },
1960
- {
1961
- path: 'historyEntries.event.billingCyclePaid.subscription.billingSettings.billingAddress.address',
1962
- },
1963
- {
1964
- path: 'historyEntries.event.billingCyclePaid.subscription.shippingAddress.address',
1965
- },
1966
- {
1967
- path: 'historyEntries.event.initiatePaymentMethodSetup.subscription.billingSettings.billingAddress.address',
1968
- },
1969
- {
1970
- path: 'historyEntries.event.initiatePaymentMethodSetup.subscription.shippingAddress.address',
1971
- },
1972
- {
1973
- path: 'historyEntries.event.subscriptionBoAction.subscription.billingSettings.billingAddress.address',
1974
- },
1975
- {
1976
- path: 'historyEntries.event.subscriptionBoAction.subscription.shippingAddress.address',
1977
- },
1978
- ],
1979
- },
1980
- ]));
1981
- }
1982
- catch (err) {
1983
- const transformedError = (0, transform_error_1.transformError)(err, {
1984
- spreadPathsToArguments: {},
1985
- explicitPathsToArguments: {
1986
- subscriptionId: '$[0]',
1987
- mode: '$[1].mode',
1988
- cursor: '$[1].cursor',
1989
- },
1990
- singleArgumentUnchanged: false,
1991
- }, ['subscriptionId', 'options']);
1992
- sideEffects?.onError?.(err);
1993
- throw transformedError;
1994
- }
1995
- }
1996
- exports.listSubscriptionHistory = listSubscriptionHistory;
1997
- //# sourceMappingURL=billing-v1-subscription-subscriptions.universal.js.map