backend-manager 5.9.7 → 5.9.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 (216) hide show
  1. package/package.json +5 -3
  2. package/src/cli/commands/setup-tests/bem-config.js +3 -2
  3. package/src/cli/commands/setup-tests/helpers.js +5 -0
  4. package/src/cli/commands/setup-tests/project-id-consistency.js +2 -1
  5. package/src/test/fixtures/firebase-project/.temp/test-mode.json +1 -1
  6. package/src/test/fixtures/firebase-project/database-debug.log +8 -8
  7. package/src/test/fixtures/firebase-project/firestore-debug.log +57 -55
  8. package/src/test/fixtures/firebase-project/pubsub-debug.log +3 -3
  9. package/templates/_.env +42 -0
  10. package/templates/_.gitignore +60 -0
  11. package/templates/backend-manager-config.json +249 -0
  12. package/templates/database.rules.json +83 -0
  13. package/templates/firebase.json +66 -0
  14. package/templates/firestore.indexes.json +4 -0
  15. package/templates/firestore.rules +112 -0
  16. package/templates/public/404.html +26 -0
  17. package/templates/public/index.html +24 -0
  18. package/templates/remoteconfig.template.json +1 -0
  19. package/templates/storage-lifecycle-config-1-day.json +9 -0
  20. package/templates/storage-lifecycle-config-30-days.json +9 -0
  21. package/templates/storage.rules +8 -0
  22. package/test/_init/accounts-validation.js +58 -0
  23. package/test/_legacy/ai/index.js +231 -0
  24. package/test/_legacy/ai/test.jpg +0 -0
  25. package/test/_legacy/ai/test.pdf +0 -0
  26. package/test/_legacy/index.js +31 -0
  27. package/test/_legacy/payment-resolver/chargebee/orders/refunded.json +0 -0
  28. package/test/_legacy/payment-resolver/chargebee/orders/unpaid.json +98 -0
  29. package/test/_legacy/payment-resolver/chargebee/subscriptions/active.json +578 -0
  30. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-in-trial.json +38 -0
  31. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-skipped-to-active.json +135 -0
  32. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-active-to-cancelled.json +42 -0
  33. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-active.json +44 -0
  34. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-cancelled.json +39 -0
  35. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-refund.json +143 -0
  36. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-suspended.json +48 -0
  37. package/test/_legacy/payment-resolver/coinbase/orders/regular.json +204 -0
  38. package/test/_legacy/payment-resolver/coinbase/subscriptions/cancelled.json +204 -0
  39. package/test/_legacy/payment-resolver/coinbase/subscriptions/paid-2.json +125 -0
  40. package/test/_legacy/payment-resolver/index.js +1558 -0
  41. package/test/_legacy/payment-resolver/paypal/orders/refunded.json +0 -0
  42. package/test/_legacy/payment-resolver/paypal/orders/regular.json +120 -0
  43. package/test/_legacy/payment-resolver/paypal/subscriptions/active-refund-previous-stmnt.json +323 -0
  44. package/test/_legacy/payment-resolver/paypal/subscriptions/active.json +192 -0
  45. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-in-trial.json +125 -0
  46. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-not-complete.json +76 -0
  47. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-overdue-2.json +114 -0
  48. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-overdue.json +114 -0
  49. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-active-to-cancelled.json +111 -0
  50. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-active.json +132 -0
  51. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-cancelled.json +107 -0
  52. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-expired.json +91 -0
  53. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-refund.json +147 -0
  54. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-suspended.json +120 -0
  55. package/test/_legacy/payment-resolver/stripe/orders/refunded.json +0 -0
  56. package/test/_legacy/payment-resolver/stripe/orders/regular.json +91 -0
  57. package/test/_legacy/payment-resolver/stripe/subscriptions/active.json +421 -0
  58. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-in-trial.json +349 -0
  59. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-active-failed-authorization.json +430 -0
  60. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-active.json +319 -0
  61. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-cancelled.json +319 -0
  62. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-refund.json +414 -0
  63. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-suspended.json +319 -0
  64. package/test/_legacy/payment-resolver/stripe/subscriptions/unsure.json +339 -0
  65. package/test/_legacy/test-new +1178 -0
  66. package/test/_legacy/test.md +89 -0
  67. package/test/_legacy/usage.js +175 -0
  68. package/test/_legacy/user.js +31 -0
  69. package/test/ai/tools-live.js +170 -0
  70. package/test/boot/emulator-boots.js +37 -0
  71. package/test/content/blog-generate.js +160 -0
  72. package/test/email/campaign-send.js +45 -0
  73. package/test/email/consent-lifecycle.js +257 -0
  74. package/test/email/feedback-and-plain-send.js +52 -0
  75. package/test/email/fixtures/clean.json +30 -0
  76. package/test/email/fixtures/editorial.json +30 -0
  77. package/test/email/fixtures/field-report.json +53 -0
  78. package/test/email/marketing-lifecycle.js +132 -0
  79. package/test/email/newsletter-generate.js +819 -0
  80. package/test/email/newsletter-templates.js +491 -0
  81. package/test/email/templates.js +207 -0
  82. package/test/email/transactional-send.js +34 -0
  83. package/test/email/transactional.js +560 -0
  84. package/test/email/validation.js +710 -0
  85. package/test/events/auth-delete-race.js +201 -0
  86. package/test/events/payments/journey-payments-cancel-endpoint.js +100 -0
  87. package/test/events/payments/journey-payments-cancel.js +182 -0
  88. package/test/events/payments/journey-payments-discount.js +89 -0
  89. package/test/events/payments/journey-payments-failure.js +146 -0
  90. package/test/events/payments/journey-payments-legacy-product.js +149 -0
  91. package/test/events/payments/journey-payments-one-time-failure.js +111 -0
  92. package/test/events/payments/journey-payments-one-time.js +136 -0
  93. package/test/events/payments/journey-payments-plan-change.js +144 -0
  94. package/test/events/payments/journey-payments-refund-webhook.js +180 -0
  95. package/test/events/payments/journey-payments-suspend.js +181 -0
  96. package/test/events/payments/journey-payments-trial-cancel.js +130 -0
  97. package/test/events/payments/journey-payments-trial.js +171 -0
  98. package/test/events/payments/journey-payments-uid-resolution.js +132 -0
  99. package/test/events/payments/journey-payments-upgrade.js +135 -0
  100. package/test/fixtures/chargebee/invoice-one-time.json +27 -0
  101. package/test/fixtures/chargebee/subscription-active.json +44 -0
  102. package/test/fixtures/chargebee/subscription-cancelled.json +42 -0
  103. package/test/fixtures/chargebee/subscription-in-trial.json +41 -0
  104. package/test/fixtures/chargebee/subscription-legacy-plan.json +41 -0
  105. package/test/fixtures/chargebee/subscription-non-renewing.json +41 -0
  106. package/test/fixtures/chargebee/subscription-paused.json +42 -0
  107. package/test/fixtures/chargebee/webhook-payment-failed.json +51 -0
  108. package/test/fixtures/chargebee/webhook-subscription-created.json +47 -0
  109. package/test/fixtures/paypal/order-approved.json +62 -0
  110. package/test/fixtures/paypal/order-completed.json +110 -0
  111. package/test/fixtures/paypal/subscription-active.json +76 -0
  112. package/test/fixtures/paypal/subscription-cancelled.json +50 -0
  113. package/test/fixtures/paypal/subscription-suspended.json +65 -0
  114. package/test/fixtures/stripe/checkout-session-completed.json +130 -0
  115. package/test/fixtures/stripe/invoice-payment-failed.json +148 -0
  116. package/test/fixtures/stripe/invoice-subscription-payment-failed.json +28 -0
  117. package/test/fixtures/stripe/subscription-active.json +161 -0
  118. package/test/fixtures/stripe/subscription-canceled.json +161 -0
  119. package/test/fixtures/stripe/subscription-trialing.json +161 -0
  120. package/test/functions/admin/database-read.js +134 -0
  121. package/test/functions/admin/database-write.js +159 -0
  122. package/test/functions/admin/edit-post.js +366 -0
  123. package/test/functions/admin/firestore-query.js +207 -0
  124. package/test/functions/admin/firestore-read.js +129 -0
  125. package/test/functions/admin/firestore-write.js +105 -0
  126. package/test/functions/admin/get-stats.js +115 -0
  127. package/test/functions/admin/send-email.js +119 -0
  128. package/test/functions/admin/send-notification.js +208 -0
  129. package/test/functions/admin/write-repo-content.js +223 -0
  130. package/test/functions/general/add-marketing-contact.js +335 -0
  131. package/test/functions/general/fetch-post.js +54 -0
  132. package/test/functions/general/generate-uuid.js +114 -0
  133. package/test/functions/test/authenticate.js +64 -0
  134. package/test/functions/user/create-custom-token.js +73 -0
  135. package/test/functions/user/delete.js +135 -0
  136. package/test/functions/user/get-active-sessions.js +111 -0
  137. package/test/functions/user/get-subscription-info.js +99 -0
  138. package/test/functions/user/regenerate-api-keys.js +156 -0
  139. package/test/functions/user/resolve.js +52 -0
  140. package/test/functions/user/sign-out-all-sessions.js +94 -0
  141. package/test/functions/user/sign-up.js +252 -0
  142. package/test/functions/user/submit-feedback.js +104 -0
  143. package/test/functions/user/validate-settings.js +82 -0
  144. package/test/helpers/ai-request-payload.js +300 -0
  145. package/test/helpers/ai-test-provider.js +202 -0
  146. package/test/helpers/ai-tools-format.js +383 -0
  147. package/test/helpers/content/blog-auto-publisher.js +484 -0
  148. package/test/helpers/content/feed-parser.js +528 -0
  149. package/test/helpers/content/ghostii-blocks.js +134 -0
  150. package/test/helpers/content/ghostii-feed-integration.js +404 -0
  151. package/test/helpers/content/ghostii-write-article.js +243 -0
  152. package/test/helpers/environment.js +230 -0
  153. package/test/helpers/infer-contact.js +113 -0
  154. package/test/helpers/merge-line-files.js +271 -0
  155. package/test/helpers/payment/chargebee/parse-webhook.js +413 -0
  156. package/test/helpers/payment/chargebee/to-unified-one-time.js +147 -0
  157. package/test/helpers/payment/chargebee/to-unified-subscription.js +648 -0
  158. package/test/helpers/payment/paypal/parse-webhook.js +539 -0
  159. package/test/helpers/payment/paypal/to-unified-one-time.js +382 -0
  160. package/test/helpers/payment/paypal/to-unified-subscription.js +820 -0
  161. package/test/helpers/payment/stripe/parse-webhook.js +447 -0
  162. package/test/helpers/payment/stripe/to-unified-one-time.js +306 -0
  163. package/test/helpers/payment/stripe/to-unified-subscription.js +708 -0
  164. package/test/helpers/sanitize.js +222 -0
  165. package/test/helpers/slugify.js +394 -0
  166. package/test/helpers/storage.js +194 -0
  167. package/test/helpers/user.js +755 -0
  168. package/test/helpers/webhook-forward.js +418 -0
  169. package/test/mcp/discovery.js +53 -0
  170. package/test/mcp/oauth.js +161 -0
  171. package/test/mcp/protocol.js +268 -0
  172. package/test/mcp/roles.js +188 -0
  173. package/test/mcp/utils.js +245 -0
  174. package/test/routes/admin/create-post.js +364 -0
  175. package/test/routes/admin/database.js +131 -0
  176. package/test/routes/admin/deduplicate-image-alts.js +190 -0
  177. package/test/routes/admin/email.js +114 -0
  178. package/test/routes/admin/firestore-query.js +204 -0
  179. package/test/routes/admin/firestore.js +127 -0
  180. package/test/routes/admin/infer-contact.js +218 -0
  181. package/test/routes/admin/notification.js +198 -0
  182. package/test/routes/admin/post-resize-image.js +184 -0
  183. package/test/routes/admin/post.js +368 -0
  184. package/test/routes/admin/repo-content.js +223 -0
  185. package/test/routes/admin/stats.js +112 -0
  186. package/test/routes/content/post.js +54 -0
  187. package/test/routes/general/uuid.js +115 -0
  188. package/test/routes/marketing/campaign.js +125 -0
  189. package/test/routes/marketing/contact.js +370 -0
  190. package/test/routes/marketing/email-preferences.js +292 -0
  191. package/test/routes/marketing/push-send.js +32 -0
  192. package/test/routes/marketing/webhook-forward.js +61 -0
  193. package/test/routes/marketing/webhook.js +639 -0
  194. package/test/routes/payments/cancel.js +163 -0
  195. package/test/routes/payments/discount.js +80 -0
  196. package/test/routes/payments/dispute-alert.js +320 -0
  197. package/test/routes/payments/intent.js +336 -0
  198. package/test/routes/payments/portal.js +92 -0
  199. package/test/routes/payments/refund.js +179 -0
  200. package/test/routes/payments/trial-eligibility.js +71 -0
  201. package/test/routes/payments/webhook.js +107 -0
  202. package/test/routes/test/authenticate.js +59 -0
  203. package/test/routes/test/schema.js +554 -0
  204. package/test/routes/test/usage.js +342 -0
  205. package/test/routes/user/api-keys.js +156 -0
  206. package/test/routes/user/delete.js +136 -0
  207. package/test/routes/user/feedback.js +104 -0
  208. package/test/routes/user/sessions.js +199 -0
  209. package/test/routes/user/settings-validate.js +82 -0
  210. package/test/routes/user/signup.js +542 -0
  211. package/test/routes/user/subscription.js +99 -0
  212. package/test/routes/user/token.js +73 -0
  213. package/test/routes/user/user.js +157 -0
  214. package/test/rules/notifications.js +410 -0
  215. package/test/rules/payments-carts.js +371 -0
  216. package/test/rules/user.js +396 -0
@@ -0,0 +1,1558 @@
1
+ const package = require('../package.json');
2
+ const assert = require('assert');
3
+
4
+ beforeEach(() => {
5
+ });
6
+
7
+ before(() => {
8
+ });
9
+
10
+ after(() => {
11
+ });
12
+
13
+ /*
14
+ * ============
15
+ * Test Cases
16
+ * ============
17
+ */
18
+ describe(`${package.name}`, () => {
19
+ const Manager = (new (require('../src/manager/index.js')));
20
+
21
+ const options = {
22
+ resolveProcessor: true,
23
+ resolveType: true,
24
+
25
+ today: '2023-04-28T00:00:00.000Z',
26
+ // today: '2023-08-28T00:00:00.000Z',
27
+
28
+ // log: true,
29
+
30
+ message: false,
31
+ }
32
+
33
+ const defaultProfileOrder = {
34
+ type: 'order',
35
+ details: {
36
+ }
37
+ }
38
+
39
+ const profileSubscriptionDefault = {
40
+ type: 'subscription',
41
+ details: {
42
+ planFrequency: 'monthly',
43
+ }
44
+ }
45
+
46
+ const profileSubscriptionFailedAuthorization = {
47
+ type: 'subscription',
48
+ details: {
49
+ planFrequency: 'monthly',
50
+ },
51
+ authorization: {
52
+ status: 'failed',
53
+ }
54
+ }
55
+
56
+ function log() {
57
+ // console.log(...arguments);
58
+ }
59
+
60
+ describe('.subscriptionResolver()', () => {
61
+
62
+ /*
63
+ GENERIC
64
+ */
65
+ // describe('error test', () => {
66
+ // const result = Manager.SubscriptionResolver({}, new Error('Test')).resolve(options);
67
+
68
+ // console.log('result', result);
69
+
70
+ // it('should resolve correctly', () => {
71
+ // return assert.deepStrictEqual(result, expected);
72
+ // });
73
+ // });
74
+
75
+ /*
76
+ * PAYPAL
77
+ */
78
+ describe('paypal', () => {
79
+ // Orders
80
+ describe('orders', () => {
81
+ describe('regular', () => {
82
+ const item = require('./payment-resolver/paypal/orders/regular.json');
83
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
84
+ const expected = {
85
+ processor: 'paypal',
86
+ type: 'order',
87
+ status: 'cancelled',
88
+ frequency: 'single',
89
+ resource: { id: '5CA68427PY850452F' },
90
+ payment: {
91
+ completed: true,
92
+ refunded: false,
93
+ },
94
+ start: { timestamp: '2023-04-27T03:39:50.000Z', timestampUNIX: 1682566790 },
95
+ expires: { timestamp: '2023-04-27T03:39:50.000Z', timestampUNIX: 1682566790 },
96
+ cancelled: { timestamp: '2023-04-27T03:39:50.000Z', timestampUNIX: 1682566790 },
97
+ lastPayment: {
98
+ amount: 1,
99
+ date: { timestamp: '2023-04-27T03:40:38.000Z', timestampUNIX: 1682566838 }
100
+ },
101
+ trial: {
102
+ active: false,
103
+ claimed: false,
104
+ daysLeft: 0,
105
+ expires: {
106
+ timestamp: '1970-01-01T00:00:00.000Z',
107
+ timestampUNIX: 0,
108
+ },
109
+ },
110
+ details: {
111
+ message: '[REDACTED]',
112
+ },
113
+ }
114
+
115
+ log('result', result);
116
+
117
+ it('should resolve correctly', () => {
118
+ return assert.deepStrictEqual(result, expected);
119
+ });
120
+ });
121
+ });
122
+
123
+ // Subscriptions
124
+ describe('subscriptions', () => {
125
+ describe('active', () => {
126
+ const item = require('./payment-resolver/paypal/subscriptions/active.json');
127
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
128
+ const expected = {
129
+ processor: 'paypal',
130
+ type: 'subscription',
131
+ status: 'active',
132
+ frequency: 'monthly',
133
+ resource: { id: 'I-GLYNACJCERDD' },
134
+ payment: {
135
+ completed: true,
136
+ refunded: false,
137
+ },
138
+ start: { timestamp: '2023-03-22T22:38:03.000Z', timestampUNIX: 1679524683 },
139
+ expires: { timestamp: '2024-09-21T11:03:15.000Z', timestampUNIX: 1726916595 },
140
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
141
+ lastPayment: {
142
+ amount: 59.85,
143
+ date: { timestamp: '2023-08-22T11:03:15.000Z', timestampUNIX: 1692702195 }
144
+ },
145
+ trial: {
146
+ active: false,
147
+ claimed: false,
148
+ daysLeft: 0,
149
+ expires: {
150
+ timestamp: '1970-01-01T00:00:00.000Z',
151
+ timestampUNIX: 0,
152
+ },
153
+ },
154
+ details: {
155
+ message: '[REDACTED]',
156
+ },
157
+ }
158
+
159
+ log('result', result);
160
+
161
+ it('should resolve correctly', () => {
162
+ return assert.deepStrictEqual(result, expected);
163
+ });
164
+ });
165
+
166
+ describe('active => refund previous stmnt', () => {
167
+ const item = require('./payment-resolver/paypal/subscriptions/active-refund-previous-stmnt.json');
168
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
169
+ const expected = {
170
+ processor: 'paypal',
171
+ type: 'subscription',
172
+ status: 'active',
173
+ frequency: 'monthly',
174
+ resource: { id: 'I-PXC8BVN91X5W' },
175
+ payment: {
176
+ completed: true,
177
+ refunded: true,
178
+ },
179
+ start: { timestamp: '2023-02-12T13:34:46.000Z', timestampUNIX: 1676208886 },
180
+ expires: { timestamp: '2025-02-11T10:29:45.000Z', timestampUNIX: 1739269785 },
181
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
182
+ lastPayment: {
183
+ amount: 19.95,
184
+ date: { timestamp: '2024-01-12T10:29:45.000Z', timestampUNIX: 1705055385 }
185
+ },
186
+ trial: {
187
+ active: false,
188
+ claimed: false,
189
+ daysLeft: 0,
190
+ expires: {
191
+ timestamp: '1970-01-01T00:00:00.000Z',
192
+ timestampUNIX: 0,
193
+ },
194
+ },
195
+ details: {
196
+ message: '[REDACTED]',
197
+ },
198
+ }
199
+
200
+ log('result', result);
201
+
202
+ it('should resolve correctly', () => {
203
+ return assert.deepStrictEqual(result, expected);
204
+ });
205
+ });
206
+
207
+ describe('trial => in-trial', () => {
208
+ const item = require('./payment-resolver/paypal/subscriptions/trial-in-trial.json');
209
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
210
+ const expected = {
211
+ processor: 'paypal',
212
+ type: 'subscription',
213
+ status: 'active',
214
+ frequency: 'annually',
215
+ resource: { id: 'I-HG5K7XD0BVPJ' },
216
+ payment: {
217
+ completed: true,
218
+ refunded: false,
219
+ },
220
+ start: { timestamp: '2023-04-28T02:16:58.000Z', timestampUNIX: 1682648218 },
221
+ expires: { timestamp: '2024-06-10T10:00:00.000Z', timestampUNIX: 1718013600 },
222
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
223
+ lastPayment: {
224
+ amount: 0,
225
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
226
+ },
227
+ trial: {
228
+ active: true,
229
+ claimed: true,
230
+ daysLeft: 13,
231
+ expires: {
232
+ timestamp: '2023-05-12T02:16:58.000Z',
233
+ timestampUNIX: 1683857818,
234
+ },
235
+ },
236
+ details: {
237
+ message: '[REDACTED]',
238
+ },
239
+ }
240
+
241
+ log('result', result);
242
+
243
+ it('should resolve correctly', () => {
244
+ return assert.deepStrictEqual(result, expected);
245
+ });
246
+ });
247
+
248
+ describe('trial => payment not completed', () => {
249
+ const item = require('./payment-resolver/paypal/subscriptions/trial-payment-not-complete.json');
250
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
251
+ const expected = {
252
+ processor: 'paypal',
253
+ type: 'subscription',
254
+ status: 'cancelled',
255
+ frequency: 'monthly',
256
+ resource: { id: 'I-6YN0VNT6KM4W' },
257
+ payment: {
258
+ completed: false,
259
+ refunded: false,
260
+ },
261
+ start: { timestamp: '2023-05-11T10:52:00.000Z', timestampUNIX: 1683802320 },
262
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
263
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
264
+ lastPayment: {
265
+ amount: 0,
266
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
267
+ },
268
+ trial: {
269
+ active: false,
270
+ claimed: true,
271
+ daysLeft: 0,
272
+ expires: {
273
+ timestamp: '1970-01-01T00:00:00.000Z',
274
+ timestampUNIX: 0,
275
+ },
276
+ },
277
+ details: {
278
+ message: '[REDACTED]',
279
+ },
280
+ }
281
+
282
+ log('result', result);
283
+
284
+ it('should resolve correctly', () => {
285
+ return assert.deepStrictEqual(result, expected);
286
+ });
287
+ });
288
+
289
+ describe('trial => payment overdue', () => {
290
+ const item = require('./payment-resolver/paypal/subscriptions/trial-payment-overdue.json');
291
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
292
+ const expected = {
293
+ processor: 'paypal',
294
+ type: 'subscription',
295
+ status: 'suspended',
296
+ frequency: 'annually',
297
+ resource: { id: 'I-PFLFF5TTAN4S' },
298
+ payment: {
299
+ completed: true,
300
+ refunded: false,
301
+ },
302
+ start: { timestamp: '2023-09-09T05:58:41.000Z', timestampUNIX: 1694239121 },
303
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
304
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
305
+ lastPayment: {
306
+ amount: 0,
307
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
308
+ },
309
+ trial: {
310
+ active: false,
311
+ claimed: true,
312
+ daysLeft: 0,
313
+ expires: {
314
+ timestamp: '1970-01-01T00:00:00.000Z',
315
+ timestampUNIX: 0,
316
+ },
317
+ },
318
+ details: {
319
+ message: '[REDACTED]',
320
+ },
321
+ }
322
+
323
+ log('result', result);
324
+
325
+ it('should resolve correctly', () => {
326
+ return assert.deepStrictEqual(result, expected);
327
+ });
328
+ });
329
+
330
+ describe('trial => payment overdue (2)', () => {
331
+ const item = require('./payment-resolver/paypal/subscriptions/trial-payment-overdue-2.json');
332
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
333
+ const expected = {
334
+ processor: 'paypal',
335
+ type: 'subscription',
336
+ status: 'suspended',
337
+ frequency: 'annually',
338
+ resource: { id: 'I-JU1H0XF32WU5' },
339
+ payment: {
340
+ completed: true,
341
+ refunded: false,
342
+ },
343
+ start: { timestamp: '2023-09-08T07:15:10.000Z', timestampUNIX: 1694157310 },
344
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
345
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
346
+ lastPayment: {
347
+ amount: 0,
348
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
349
+ },
350
+ trial: {
351
+ active: false,
352
+ claimed: true,
353
+ daysLeft: 0,
354
+ expires: {
355
+ timestamp: '1970-01-01T00:00:00.000Z',
356
+ timestampUNIX: 0,
357
+ },
358
+ },
359
+ details: {
360
+ message: '[REDACTED]',
361
+ },
362
+ }
363
+
364
+ log('result', result);
365
+
366
+ it('should resolve correctly', () => {
367
+ return assert.deepStrictEqual(result, expected);
368
+ });
369
+ });
370
+
371
+ describe('trial => active => cancelled', () => {
372
+ const item = require('./payment-resolver/paypal/subscriptions/trial-to-active-to-cancelled.json');
373
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
374
+ const expected = {
375
+ processor: 'paypal',
376
+ type: 'subscription',
377
+ status: 'cancelled',
378
+ frequency: 'monthly',
379
+ resource: { id: 'I-MH92AV4A3EA6' },
380
+ payment: {
381
+ completed: true,
382
+ refunded: false,
383
+ },
384
+ start: { timestamp: '2023-03-31T14:48:51.000Z', timestampUNIX: 1680274131 },
385
+ expires: { timestamp: '2023-05-14T10:56:15.000Z', timestampUNIX: 1684061775 },
386
+ cancelled: { timestamp: '2023-04-18T10:14:56.000Z', timestampUNIX: 1681812896 },
387
+ lastPayment: {
388
+ amount: 19.95,
389
+ date: { timestamp: '2023-04-14T10:56:15.000Z', timestampUNIX: 1681469775 }
390
+ },
391
+ trial: {
392
+ active: false,
393
+ claimed: true,
394
+ daysLeft: 0,
395
+ expires: {
396
+ timestamp: '1970-01-01T00:00:00.000Z',
397
+ timestampUNIX: 0,
398
+ },
399
+ },
400
+ details: {
401
+ message: '[REDACTED]',
402
+ },
403
+ }
404
+
405
+ log('result', result);
406
+
407
+ it('should resolve correctly', () => {
408
+ return assert.deepStrictEqual(result, expected);
409
+ });
410
+ });
411
+
412
+ describe('trial => active', () => {
413
+ const item = require('./payment-resolver/paypal/subscriptions/trial-to-active.json');
414
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
415
+ const expected = {
416
+ processor: 'paypal',
417
+ type: 'subscription',
418
+ status: 'active',
419
+ frequency: 'monthly',
420
+ resource: { id: 'I-VTXGPKDTMMK2' },
421
+ payment: {
422
+ completed: true,
423
+ refunded: false,
424
+ },
425
+ start: { timestamp: '2023-04-11T17:37:58.000Z', timestampUNIX: 1681234678 },
426
+ expires: { timestamp: '2024-05-25T10:28:22.000Z', timestampUNIX: 1716632902 },
427
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
428
+ lastPayment: {
429
+ amount: 19.95,
430
+ date: { timestamp: '2023-04-25T10:28:22.000Z', timestampUNIX: 1682418502 }
431
+ },
432
+ trial: {
433
+ active: false,
434
+ claimed: false,
435
+ daysLeft: 0,
436
+ expires: {
437
+ timestamp: '1970-01-01T00:00:00.000Z',
438
+ timestampUNIX: 0,
439
+ },
440
+ },
441
+ details: {
442
+ message: '[REDACTED]',
443
+ },
444
+ }
445
+
446
+ log('result', result);
447
+
448
+ it('should resolve correctly', () => {
449
+ return assert.deepStrictEqual(result, expected);
450
+ });
451
+ });
452
+
453
+ describe('trial => cancelled', () => {
454
+ const item = require('./payment-resolver/paypal/subscriptions/trial-to-cancelled.json');
455
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
456
+ const expected = {
457
+ processor: 'paypal',
458
+ type: 'subscription',
459
+ status: 'cancelled',
460
+ frequency: 'monthly',
461
+ resource: { id: 'I-79C4RSSVKN95' },
462
+ payment: {
463
+ completed: true,
464
+ refunded: false,
465
+ },
466
+ start: { timestamp: '2023-03-31T08:41:35.000Z', timestampUNIX: 1680252095 },
467
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
468
+ cancelled: { timestamp: '2023-04-02T23:38:44.000Z', timestampUNIX: 1680478724 },
469
+ lastPayment: {
470
+ amount: 0,
471
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
472
+ },
473
+ trial: {
474
+ active: false,
475
+ claimed: true,
476
+ daysLeft: 0,
477
+ expires: {
478
+ timestamp: '1970-01-01T00:00:00.000Z',
479
+ timestampUNIX: 0,
480
+ },
481
+ },
482
+ details: {
483
+ message: '[REDACTED]',
484
+ },
485
+ }
486
+
487
+ log('result', result);
488
+
489
+ it('should resolve correctly', () => {
490
+ return assert.deepStrictEqual(result, expected);
491
+ });
492
+ });
493
+
494
+ describe('trial => expired', () => {
495
+ const item = require('./payment-resolver/paypal/subscriptions/trial-to-expired.json');
496
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
497
+ const expected = {
498
+ processor: 'paypal',
499
+ type: 'subscription',
500
+ status: 'cancelled',
501
+ frequency: 'monthly',
502
+ resource: { id: 'I-BC83SG8TF205' },
503
+ payment: {
504
+ completed: true,
505
+ refunded: false,
506
+ },
507
+ start: { timestamp: '2023-06-05T15:16:16.000Z', timestampUNIX: 1685978176 },
508
+ expires: { timestamp: '2023-07-05T15:16:31.000Z', timestampUNIX: 1688570191 },
509
+ cancelled: { timestamp: '2023-06-05T15:16:33.000Z', timestampUNIX: 1685978193 },
510
+ lastPayment: {
511
+ amount: 3,
512
+ date: { timestamp: '2023-06-05T15:16:31.000Z', timestampUNIX: 1685978191 }
513
+ },
514
+ trial: {
515
+ active: false,
516
+ claimed: false,
517
+ daysLeft: 0,
518
+ expires: {
519
+ timestamp: '1970-01-01T00:00:00.000Z',
520
+ timestampUNIX: 0,
521
+ },
522
+ },
523
+ details: {
524
+ message: '[REDACTED]',
525
+ },
526
+ }
527
+
528
+ log('result', result);
529
+
530
+ it('should resolve correctly', () => {
531
+ return assert.deepStrictEqual(result, expected);
532
+ });
533
+ });
534
+
535
+ describe('trial => refund', () => {
536
+ const item = require('./payment-resolver/paypal/subscriptions/trial-to-refund.json');
537
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
538
+ const expected = {
539
+ processor: 'paypal',
540
+ type: 'subscription',
541
+ status: 'cancelled',
542
+ frequency: 'annually',
543
+ resource: { id: 'I-JW7F1RK5KN8W' },
544
+ payment: {
545
+ completed: true,
546
+ refunded: true,
547
+ },
548
+ start: { timestamp: '2023-07-17T14:31:50.000Z', timestampUNIX: 1689604310 },
549
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
550
+ cancelled: { timestamp: '2023-07-31T11:33:32.000Z', timestampUNIX: 1690803212 },
551
+ lastPayment: {
552
+ amount: 191.4,
553
+ date: { timestamp: '2023-07-31T11:13:59.000Z', timestampUNIX: 1690802039 }
554
+ },
555
+ trial: {
556
+ active: false,
557
+ claimed: false,
558
+ daysLeft: 0,
559
+ expires: {
560
+ timestamp: '1970-01-01T00:00:00.000Z',
561
+ timestampUNIX: 0,
562
+ },
563
+ },
564
+ details: {
565
+ message: '[REDACTED]',
566
+ },
567
+ }
568
+
569
+ log('result', result);
570
+
571
+ it('should resolve correctly', () => {
572
+ return assert.deepStrictEqual(result, expected);
573
+ });
574
+ });
575
+
576
+ describe('trial => suspended', () => {
577
+ const item = require('./payment-resolver/paypal/subscriptions/trial-to-suspended.json');
578
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
579
+ const expected = {
580
+ processor: 'paypal',
581
+ type: 'subscription',
582
+ status: 'suspended',
583
+ frequency: 'monthly',
584
+ resource: { id: 'I-A3AS9XBE0JEG' },
585
+ payment: {
586
+ completed: true,
587
+ refunded: false,
588
+ },
589
+ start: { timestamp: '2023-07-11T16:52:11.000Z', timestampUNIX: 1689094331 },
590
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
591
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
592
+ lastPayment: {
593
+ amount: 9.97,
594
+ date: { timestamp: '2023-07-11T16:53:50.000Z', timestampUNIX: 1689094430 }
595
+ },
596
+ trial: {
597
+ active: false,
598
+ claimed: false,
599
+ daysLeft: 0,
600
+ expires: {
601
+ timestamp: '1970-01-01T00:00:00.000Z',
602
+ timestampUNIX: 0,
603
+ },
604
+ },
605
+ details: {
606
+ message: '[REDACTED]',
607
+ },
608
+ }
609
+
610
+ log('result', result);
611
+
612
+ it('should resolve correctly', () => {
613
+ return assert.deepStrictEqual(result, expected);
614
+ });
615
+ });
616
+ });
617
+ });
618
+
619
+ /*
620
+ * CHARGEBEE
621
+ */
622
+ describe('chargebee', () => {
623
+ // Orders
624
+ describe('orders', () => {
625
+ // describe('regular', () => {
626
+ // const item = require('./payment-resolver/chargebee/orders/regular.json');
627
+ // const result = Manager.SubscriptionResolver({}, item).resolve(options);
628
+ // const expected = {
629
+ // processor: 'chargebee',
630
+ // type: 'order',
631
+ // status: 'cancelled',
632
+ // frequency: 'single',
633
+ // resource: { id: '3065' },
634
+ // payment: {
635
+ // completed: false,
636
+ // refunded: false,
637
+ // },
638
+ // start: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
639
+ // expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
640
+ // cancelled: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
641
+ // lastPayment: {
642
+ // amount: 0,
643
+ // date: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 }
644
+ // },
645
+ // trial: {
646
+ // active: false,
647
+ // claimed: false,
648
+ // daysLeft: 0,
649
+ // expires: {
650
+ // timestamp: '1970-01-01T00:00:00.000Z',
651
+ // timestampUNIX: 0,
652
+ // },
653
+ // },
654
+ // details: {
655
+ // message: '[REDACTED]',
656
+ // },
657
+ // }
658
+
659
+ // log('result', result);
660
+
661
+ // it('should resolve correctly', () => {
662
+ // return assert.deepStrictEqual(result, expected);
663
+ // });
664
+ // });
665
+
666
+ describe('unpaid', () => {
667
+ const item = require('./payment-resolver/chargebee/orders/unpaid.json');
668
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
669
+ const expected = {
670
+ processor: 'chargebee',
671
+ type: 'order',
672
+ status: 'cancelled',
673
+ frequency: 'single',
674
+ resource: { id: '3065' },
675
+ payment: {
676
+ completed: false,
677
+ refunded: false,
678
+ },
679
+ start: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
680
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
681
+ cancelled: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
682
+ lastPayment: {
683
+ amount: 0,
684
+ date: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 }
685
+ },
686
+ trial: {
687
+ active: false,
688
+ claimed: false,
689
+ daysLeft: 0,
690
+ expires: {
691
+ timestamp: '1970-01-01T00:00:00.000Z',
692
+ timestampUNIX: 0,
693
+ },
694
+ },
695
+ details: {
696
+ message: '[REDACTED]',
697
+ },
698
+ }
699
+
700
+ log('result', result);
701
+
702
+ it('should resolve correctly', () => {
703
+ return assert.deepStrictEqual(result, expected);
704
+ });
705
+ });
706
+ });
707
+
708
+ // Subscriptions
709
+ describe('subscriptions', () => {
710
+ describe('active', () => {
711
+ const item = require('./payment-resolver/chargebee/subscriptions/active.json');
712
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
713
+ const expected = {
714
+ processor: 'chargebee',
715
+ type: 'subscription',
716
+ status: 'active',
717
+ frequency: 'monthly',
718
+ resource: { id: 'AzZMxvTYTQUmw1Iw7' },
719
+ payment: {
720
+ completed: true,
721
+ refunded: false,
722
+ },
723
+ start: { timestamp: '2023-03-14T10:37:33.000Z', timestampUNIX: 1678790253 },
724
+ expires: { timestamp: '2024-09-13T10:37:33.000Z', timestampUNIX: 1726223853 },
725
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
726
+ lastPayment: {
727
+ amount: 19.95,
728
+ date: { timestamp: '2023-08-14T10:37:33.000Z', timestampUNIX: 1692009453 }
729
+ },
730
+ trial: {
731
+ active: false,
732
+ claimed: false,
733
+ daysLeft: 0,
734
+ expires: {
735
+ timestamp: '1970-01-01T00:00:00.000Z',
736
+ timestampUNIX: 0,
737
+ },
738
+ },
739
+ details: {
740
+ message: '[REDACTED]',
741
+ },
742
+ }
743
+
744
+ log('result', result);
745
+
746
+ it('should resolve correctly', () => {
747
+ return assert.deepStrictEqual(result, expected);
748
+ });
749
+ });
750
+
751
+ describe('trial => skipped-to-active', () => {
752
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-skipped-to-active.json');
753
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
754
+ const expected = {
755
+ processor: 'chargebee',
756
+ type: 'subscription',
757
+ status: 'active',
758
+ frequency: 'monthly',
759
+ resource: { id: '6oqX0TnhKo5R513B' },
760
+ payment: {
761
+ completed: true,
762
+ refunded: false,
763
+ },
764
+ start: { timestamp: '2023-08-22T20:55:52.000Z', timestampUNIX: 1692737752 },
765
+ expires: { timestamp: '2024-09-21T20:55:57.000Z', timestampUNIX: 1726952157 },
766
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
767
+ lastPayment: {
768
+ amount: 19.95,
769
+ date: { timestamp: '2023-08-22T20:55:57.000Z', timestampUNIX: 1692737757 }
770
+ },
771
+ trial: {
772
+ active: false,
773
+ claimed: false,
774
+ daysLeft: 0,
775
+ expires: {
776
+ timestamp: '1970-01-01T00:00:00.000Z',
777
+ timestampUNIX: 0,
778
+ },
779
+ },
780
+ details: {
781
+ message: '[REDACTED]',
782
+ },
783
+ }
784
+
785
+ log('result', result);
786
+
787
+ it('should resolve correctly', () => {
788
+ return assert.deepStrictEqual(result, expected);
789
+ });
790
+ });
791
+
792
+ describe('trial => in-trial', () => {
793
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-in-trial.json');
794
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
795
+ const expected = {
796
+ processor: 'chargebee',
797
+ type: 'subscription',
798
+ status: 'active',
799
+ frequency: 'monthly',
800
+ resource: { id: '16CRCcTcWmQYKyT5' },
801
+ payment: {
802
+ completed: true,
803
+ refunded: false,
804
+ },
805
+ start: { timestamp: '2023-04-26T10:19:48.000Z', timestampUNIX: 1682504388 },
806
+ expires: { timestamp: '2024-06-09T10:19:48.000Z', timestampUNIX: 1717928388 },
807
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
808
+ lastPayment: {
809
+ amount: 0,
810
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
811
+ },
812
+ trial: {
813
+ active: true,
814
+ claimed: true,
815
+ daysLeft: 12,
816
+ expires: {
817
+ timestamp: '2023-05-10T10:19:48.000Z',
818
+ timestampUNIX: 1683713988,
819
+ },
820
+ },
821
+ details: {
822
+ message: '[REDACTED]',
823
+ },
824
+ }
825
+
826
+ log('result', result);
827
+
828
+ it('should resolve correctly', () => {
829
+ return assert.deepStrictEqual(result, expected);
830
+ });
831
+ });
832
+
833
+ describe('trial => active => cancelled', () => {
834
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-to-active-to-cancelled.json');
835
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
836
+ const expected = {
837
+ processor: 'chargebee',
838
+ type: 'subscription',
839
+ status: 'cancelled',
840
+ frequency: 'monthly',
841
+ resource: { id: 'AzqJXiTaQKh4m5Ta7' },
842
+ payment: {
843
+ completed: true,
844
+ refunded: false,
845
+ },
846
+ start: { timestamp: '2023-04-04T02:53:37.000Z', timestampUNIX: 1680576817 },
847
+ expires: { timestamp: '2023-05-18T02:53:37.000Z', timestampUNIX: 1684378417 },
848
+ cancelled: { timestamp: '2023-04-19T03:42:24.000Z', timestampUNIX: 1681875744 },
849
+ lastPayment: {
850
+ amount: 19.95,
851
+ date: { timestamp: '2023-04-18T02:53:37.000Z', timestampUNIX: 1681786417 }
852
+ },
853
+ trial: {
854
+ active: false,
855
+ claimed: true,
856
+ daysLeft: 0,
857
+ expires: {
858
+ timestamp: '1970-01-01T00:00:00.000Z',
859
+ timestampUNIX: 0,
860
+ },
861
+ },
862
+ details: {
863
+ message: '[REDACTED]',
864
+ },
865
+ }
866
+
867
+ log('result', result);
868
+
869
+ it('should resolve correctly', () => {
870
+ return assert.deepStrictEqual(result, expected);
871
+ });
872
+ });
873
+
874
+ describe('trial => active', () => {
875
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-to-active.json');
876
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
877
+ const expected = {
878
+ processor: 'chargebee',
879
+ type: 'subscription',
880
+ status: 'active',
881
+ frequency: 'monthly',
882
+ resource: { id: 'AzyfbtTbMhiFM51DW' },
883
+ payment: {
884
+ completed: true,
885
+ refunded: false,
886
+ },
887
+ start: { timestamp: '2023-04-14T02:29:56.000Z', timestampUNIX: 1681439396 },
888
+ expires: { timestamp: '2024-05-28T02:29:56.000Z', timestampUNIX: 1716863396 },
889
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
890
+ lastPayment: {
891
+ amount: 19.95,
892
+ date: { timestamp: '2023-04-28T02:29:56.000Z', timestampUNIX: 1682648996 }
893
+ },
894
+ trial: {
895
+ active: false,
896
+ claimed: true,
897
+ daysLeft: 0,
898
+ expires: {
899
+ timestamp: '1970-01-01T00:00:00.000Z',
900
+ timestampUNIX: 0,
901
+ },
902
+ },
903
+ details: {
904
+ message: '[REDACTED]',
905
+ },
906
+ }
907
+
908
+ log('result', result);
909
+
910
+ it('should resolve correctly', () => {
911
+ return assert.deepStrictEqual(result, expected);
912
+ });
913
+ });
914
+
915
+ describe('trial => cancelled', () => {
916
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-to-cancelled.json');
917
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
918
+ const expected = {
919
+ processor: 'chargebee',
920
+ type: 'subscription',
921
+ status: 'cancelled',
922
+ frequency: 'monthly',
923
+ resource: { id: 'AzZMshTbnEv7r1Eck' },
924
+ payment: {
925
+ completed: true,
926
+ refunded: false,
927
+ },
928
+ start: { timestamp: '2023-04-18T15:24:28.000Z', timestampUNIX: 1681831468 },
929
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
930
+ cancelled: { timestamp: '2023-04-25T10:41:02.000Z', timestampUNIX: 1682419262 },
931
+ lastPayment: {
932
+ amount: 0,
933
+ date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
934
+ },
935
+ trial: {
936
+ active: false,
937
+ claimed: true,
938
+ daysLeft: 0,
939
+ expires: {
940
+ timestamp: '1970-01-01T00:00:00.000Z',
941
+ timestampUNIX: 0,
942
+ },
943
+ },
944
+ details: {
945
+ message: '[REDACTED]',
946
+ },
947
+ }
948
+
949
+ log('result', result);
950
+
951
+ it('should resolve correctly', () => {
952
+ return assert.deepStrictEqual(result, expected);
953
+ });
954
+ });
955
+
956
+ describe('trial => refund', () => {
957
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-to-refund.json');
958
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
959
+ const expected = {
960
+ processor: 'chargebee',
961
+ type: 'subscription',
962
+ status: 'cancelled',
963
+ frequency: 'monthly',
964
+ resource: { id: 'AzymDoTjgzDShlvd' },
965
+ payment: {
966
+ completed: true,
967
+ refunded: true,
968
+ },
969
+ start: { timestamp: '2023-07-11T09:37:47.000Z', timestampUNIX: 1689068267 },
970
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
971
+ cancelled: { timestamp: '2023-07-15T13:23:15.000Z', timestampUNIX: 1689427395 },
972
+ lastPayment: {
973
+ amount: 19.95,
974
+ date: { timestamp: '2023-07-11T09:37:54.000Z', timestampUNIX: 1689068274 }
975
+ },
976
+ trial: {
977
+ active: false,
978
+ claimed: false,
979
+ daysLeft: 0,
980
+ expires: {
981
+ timestamp: '1970-01-01T00:00:00.000Z',
982
+ timestampUNIX: 0,
983
+ },
984
+ },
985
+ details: {
986
+ message: '[REDACTED]',
987
+ },
988
+ }
989
+
990
+ log('result', result);
991
+
992
+ it('should resolve correctly', () => {
993
+ return assert.deepStrictEqual(result, expected);
994
+ });
995
+ });
996
+
997
+ describe('trial => suspendeded', () => {
998
+ const item = require('./payment-resolver/chargebee/subscriptions/trial-to-suspended.json');
999
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1000
+ const expected = {
1001
+ processor: 'chargebee',
1002
+ type: 'subscription',
1003
+ status: 'suspended',
1004
+ frequency: 'monthly',
1005
+ resource: { id: 'Azym2sTkewehg121r' },
1006
+ payment: {
1007
+ completed: true,
1008
+ refunded: false,
1009
+ },
1010
+ start: { timestamp: '2023-07-21T15:40:12.000Z', timestampUNIX: 1689954012 },
1011
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1012
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1013
+ lastPayment: {
1014
+ amount: 0,
1015
+ date: { timestamp: '2023-08-04T15:40:12.000Z', timestampUNIX: 1691163612 }
1016
+ },
1017
+ trial: {
1018
+ active: false,
1019
+ claimed: true,
1020
+ daysLeft: 0,
1021
+ expires: {
1022
+ timestamp: '1970-01-01T00:00:00.000Z',
1023
+ timestampUNIX: 0,
1024
+ },
1025
+ },
1026
+ details: {
1027
+ message: '[REDACTED]',
1028
+ },
1029
+ }
1030
+
1031
+ log('result', result);
1032
+
1033
+ it('should resolve correctly', () => {
1034
+ return assert.deepStrictEqual(result, expected);
1035
+ });
1036
+ });
1037
+ });
1038
+
1039
+ });
1040
+
1041
+ /*
1042
+ * STRIPE
1043
+ */
1044
+ describe('stripe', () => {
1045
+ // Orders
1046
+ describe('orders', () => {
1047
+ describe('regular', () => {
1048
+ const item = require('./payment-resolver/stripe/orders/regular.json');
1049
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1050
+ const expected = {
1051
+ processor: 'stripe',
1052
+ type: 'order',
1053
+ status: 'cancelled',
1054
+ frequency: 'single',
1055
+ resource: { id: 'ch_3N1pAXJVFkvVyI7h1FM4wdxL' },
1056
+ payment: {
1057
+ completed: true,
1058
+ refunded: false,
1059
+ },
1060
+ start: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 },
1061
+ expires: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 },
1062
+ cancelled: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 },
1063
+ lastPayment: {
1064
+ amount: 1.01,
1065
+ date: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 }
1066
+ },
1067
+ trial: {
1068
+ active: false,
1069
+ claimed: false,
1070
+ daysLeft: 0,
1071
+ expires: {
1072
+ timestamp: '1970-01-01T00:00:00.000Z',
1073
+ timestampUNIX: 0,
1074
+ },
1075
+ },
1076
+ details: {
1077
+ message: '[REDACTED]',
1078
+ },
1079
+ }
1080
+
1081
+ log('result', result);
1082
+
1083
+ it('should resolve correctly', () => {
1084
+ return assert.deepStrictEqual(result, expected);
1085
+ });
1086
+ });
1087
+ });
1088
+
1089
+ // Subscriptions
1090
+ describe('subscriptions', () => {
1091
+ describe('active', () => {
1092
+ const item = require('./payment-resolver/stripe/subscriptions/active.json');
1093
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1094
+ const expected = {
1095
+ processor: 'stripe',
1096
+ type: 'subscription',
1097
+ status: 'active',
1098
+ frequency: 'monthly',
1099
+ resource: { id: 'sub_1McA4ZEvB7hJrWnu1o7GMybv' },
1100
+ payment: {
1101
+ completed: true,
1102
+ refunded: false,
1103
+ },
1104
+ start: { timestamp: '2023-02-16T16:12:39.000Z', timestampUNIX: 1676563959 },
1105
+ expires: { timestamp: '2024-09-15T16:12:39.000Z', timestampUNIX: 1726416759 },
1106
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1107
+ lastPayment: {
1108
+ amount: 6,
1109
+ date: { timestamp: '2023-08-16T16:13:11.000Z', timestampUNIX: 1692202391 }
1110
+ },
1111
+ trial: {
1112
+ active: false,
1113
+ claimed: false,
1114
+ daysLeft: 0,
1115
+ expires: {
1116
+ timestamp: '1970-01-01T00:00:00.000Z',
1117
+ timestampUNIX: 0,
1118
+ },
1119
+ },
1120
+ details: {
1121
+ message: '[REDACTED]',
1122
+ },
1123
+ }
1124
+
1125
+ log('result', result);
1126
+
1127
+ it('should resolve correctly', () => {
1128
+ return assert.deepStrictEqual(result, expected);
1129
+ });
1130
+ });
1131
+
1132
+ describe('trial => in trial', () => {
1133
+ const item = require('./payment-resolver/stripe/subscriptions/trial-in-trial.json');
1134
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1135
+ const expected = {
1136
+ processor: 'stripe',
1137
+ type: 'subscription',
1138
+ status: 'active',
1139
+ frequency: 'monthly',
1140
+ resource: { id: 'sub_1N1a4yEvB7hJrWnuCzx5ssWK' },
1141
+ payment: {
1142
+ completed: true,
1143
+ refunded: false,
1144
+ },
1145
+ start: { timestamp: '2023-04-27T19:02:08.000Z', timestampUNIX: 1682622128 },
1146
+ expires: { timestamp: '2024-06-10T19:02:08.000Z', timestampUNIX: 1718046128 },
1147
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1148
+ lastPayment: {
1149
+ amount: 0,
1150
+ date: { timestamp: '2023-04-27T19:02:08.000Z', timestampUNIX: 1682622128 }
1151
+ },
1152
+ trial: {
1153
+ active: true,
1154
+ claimed: true,
1155
+ daysLeft: 13,
1156
+ expires: {
1157
+ timestamp: '2023-05-11T19:02:08.000Z',
1158
+ timestampUNIX: 1683831728,
1159
+ },
1160
+ },
1161
+ details: {
1162
+ message: '[REDACTED]',
1163
+ },
1164
+ }
1165
+
1166
+ log('result', result);
1167
+
1168
+ it('should resolve correctly', () => {
1169
+ return assert.deepStrictEqual(result, expected);
1170
+ });
1171
+ });
1172
+
1173
+ describe('trial => active', () => {
1174
+ const item = require('./payment-resolver/stripe/subscriptions/trial-to-active.json');
1175
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1176
+ const expected = {
1177
+ processor: 'stripe',
1178
+ type: 'subscription',
1179
+ status: 'active',
1180
+ frequency: 'monthly',
1181
+ resource: { id: 'sub_1MqedqJVFkvVyI7hYGbJyOFD' },
1182
+ payment: {
1183
+ completed: true,
1184
+ refunded: false,
1185
+ },
1186
+ start: { timestamp: '2023-03-28T15:40:58.000Z', timestampUNIX: 1680018058 },
1187
+ expires: { timestamp: '2024-05-11T15:40:58.000Z', timestampUNIX: 1715442058 },
1188
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1189
+ lastPayment: {
1190
+ amount: 6,
1191
+ date: { timestamp: '2023-04-11T15:41:07.000Z', timestampUNIX: 1681227667 }
1192
+ },
1193
+ trial: {
1194
+ active: false,
1195
+ claimed: true,
1196
+ daysLeft: 0,
1197
+ expires: {
1198
+ timestamp: '1970-01-01T00:00:00.000Z',
1199
+ timestampUNIX: 0,
1200
+ },
1201
+ },
1202
+ details: {
1203
+ message: '[REDACTED]',
1204
+ },
1205
+ }
1206
+
1207
+ log('result', result);
1208
+
1209
+ it('should resolve correctly', () => {
1210
+ return assert.deepStrictEqual(result, expected);
1211
+ });
1212
+ });
1213
+
1214
+ describe('trial => active-failed-authorization', () => {
1215
+ const item = require('./payment-resolver/stripe/subscriptions/trial-to-active-failed-authorization.json');
1216
+ const result = Manager.SubscriptionResolver(profileSubscriptionFailedAuthorization, item).resolve(options);
1217
+ const expected = {
1218
+ processor: 'stripe',
1219
+ type: 'subscription',
1220
+ status: 'active',
1221
+ frequency: 'monthly',
1222
+ resource: { id: 'sub_1OAJjOHGybgi7uQGicdK4TGm' },
1223
+ payment: {
1224
+ completed: true,
1225
+ refunded: false,
1226
+ },
1227
+ start: { timestamp: '2023-11-08T21:56:14.000Z', timestampUNIX: 1699480574 },
1228
+ expires: { timestamp: '2024-12-22T21:56:14.000Z', timestampUNIX: 1734904574 },
1229
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1230
+ lastPayment: {
1231
+ amount: 8,
1232
+ date: { timestamp: '2023-11-22T21:56:26.000Z', timestampUNIX: 1700690186 }
1233
+ },
1234
+ trial: {
1235
+ active: false,
1236
+ claimed: true,
1237
+ daysLeft: 0,
1238
+ expires: {
1239
+ timestamp: '1970-01-01T00:00:00.000Z',
1240
+ timestampUNIX: 0,
1241
+ },
1242
+ },
1243
+ details: {
1244
+ message: '[REDACTED]',
1245
+ },
1246
+ }
1247
+
1248
+ log('result', result);
1249
+
1250
+ it('should resolve correctly', () => {
1251
+ return assert.deepStrictEqual(result, expected);
1252
+ });
1253
+ });
1254
+
1255
+ describe('trial => cancelled', () => {
1256
+ const item = require('./payment-resolver/stripe/subscriptions/trial-to-cancelled.json');
1257
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1258
+ const expected = {
1259
+ processor: 'stripe',
1260
+ type: 'subscription',
1261
+ status: 'cancelled',
1262
+ frequency: 'monthly',
1263
+ resource: { id: 'sub_1Mv9VtCzY9baOpL0I2MRKfoj' },
1264
+ payment: {
1265
+ completed: true,
1266
+ refunded: false,
1267
+ },
1268
+ start: { timestamp: '2023-04-10T01:27:21.000Z', timestampUNIX: 1681090041 },
1269
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1270
+ cancelled: { timestamp: '2023-04-17T07:13:15.000Z', timestampUNIX: 1681715595 },
1271
+ lastPayment: {
1272
+ amount: 0,
1273
+ date: { timestamp: '2023-04-10T01:27:21.000Z', timestampUNIX: 1681090041 }
1274
+ },
1275
+ trial: {
1276
+ active: false,
1277
+ claimed: true,
1278
+ daysLeft: 0,
1279
+ expires: {
1280
+ timestamp: '1970-01-01T00:00:00.000Z',
1281
+ timestampUNIX: 0,
1282
+ },
1283
+ },
1284
+ details: {
1285
+ message: '[REDACTED]',
1286
+ },
1287
+ }
1288
+
1289
+ log('result', result);
1290
+
1291
+ it('should resolve correctly', () => {
1292
+ return assert.deepStrictEqual(result, expected);
1293
+ });
1294
+ });
1295
+
1296
+ describe('trial => refund', () => {
1297
+ const item = require('./payment-resolver/stripe/subscriptions/trial-to-refund.json');
1298
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1299
+ const expected = {
1300
+ processor: 'stripe',
1301
+ type: 'subscription',
1302
+ status: 'cancelled',
1303
+ frequency: 'annually',
1304
+ resource: { id: 'sub_1NWA2ZHGybgi7uQGF7ODZNEZ' },
1305
+ payment: {
1306
+ completed: true,
1307
+ refunded: true,
1308
+ },
1309
+ start: { timestamp: '2023-07-21T03:30:03.000Z', timestampUNIX: 1689910203 },
1310
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1311
+ cancelled: { timestamp: '2023-08-03T19:51:57.000Z', timestampUNIX: 1691092317 },
1312
+ lastPayment: {
1313
+ amount: 72,
1314
+ date: { timestamp: '2023-07-21T03:30:03.000Z', timestampUNIX: 1689910203 }
1315
+ },
1316
+ trial: {
1317
+ active: false,
1318
+ claimed: false,
1319
+ daysLeft: 0,
1320
+ expires: {
1321
+ timestamp: '1970-01-01T00:00:00.000Z',
1322
+ timestampUNIX: 0,
1323
+ },
1324
+ },
1325
+ details: {
1326
+ message: '[REDACTED]',
1327
+ },
1328
+ }
1329
+
1330
+ log('result', result);
1331
+
1332
+ it('should resolve correctly', () => {
1333
+ return assert.deepStrictEqual(result, expected);
1334
+ });
1335
+ });
1336
+
1337
+ describe('trial => suspended', () => {
1338
+ const item = require('./payment-resolver/stripe/subscriptions/trial-to-suspended.json');
1339
+ const result = Manager.SubscriptionResolver({}, item).resolve(options);
1340
+ const expected = {
1341
+ processor: 'stripe',
1342
+ type: 'subscription',
1343
+ status: 'suspended',
1344
+ frequency: 'monthly',
1345
+ resource: { id: 'sub_1MrOiKCzY9baOpL0TNU5sQZQ' },
1346
+ payment: {
1347
+ completed: true,
1348
+ refunded: false,
1349
+ },
1350
+ start: { timestamp: '2023-03-30T16:52:40.000Z', timestampUNIX: 1680195160 },
1351
+ expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1352
+ cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1353
+ lastPayment: {
1354
+ amount: 0,
1355
+ date: { timestamp: '2023-04-13T16:52:51.000Z', timestampUNIX: 1681404771 }
1356
+ },
1357
+ trial: {
1358
+ active: false,
1359
+ claimed: true,
1360
+ daysLeft: 0,
1361
+ expires: {
1362
+ timestamp: '1970-01-01T00:00:00.000Z',
1363
+ timestampUNIX: 0,
1364
+ },
1365
+ },
1366
+ details: {
1367
+ message: '[REDACTED]',
1368
+ },
1369
+ }
1370
+
1371
+ log('result', result);
1372
+
1373
+ it('should resolve correctly', () => {
1374
+ return assert.deepStrictEqual(result, expected);
1375
+ });
1376
+ });
1377
+
1378
+ // describe('unsure', () => {
1379
+ // const item = require('./payment-resolver/stripe/subscriptions/unsure.json');
1380
+ // const result = Manager.SubscriptionResolver({}, item).resolve(options);
1381
+ // const expected = {
1382
+ // processor: 'stripe',
1383
+ // type: 'subscription',
1384
+ // status: 'active',
1385
+ // frequency: 'monthly',
1386
+ // resource: { id: 'sub_1OkWCdHGybgi7uQGxQDhAQ51' },
1387
+ // payment: {
1388
+ // completed: true,
1389
+ // refunded: false,
1390
+ // },
1391
+ // start: { timestamp: '2024-02-16T18:32:03.000Z', timestampUNIX: 1708108323 },
1392
+ // expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1393
+ // cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1394
+ // lastPayment: {
1395
+ // amount: 0,
1396
+ // date: { timestamp: '2023-04-13T16:52:51.000Z', timestampUNIX: 1681404771 }
1397
+ // },
1398
+ // trial: {
1399
+ // active: false,
1400
+ // claimed: true,
1401
+ // daysLeft: 0,
1402
+ // expires: {
1403
+ // timestamp: '1970-01-01T00:00:00.000Z',
1404
+ // timestampUNIX: 0,
1405
+ // },
1406
+ // },
1407
+ // details: {
1408
+ // message: '[REDACTED]',
1409
+ // },
1410
+ // }
1411
+
1412
+ // log('result', result);
1413
+
1414
+ // it('should resolve correctly', () => {
1415
+ // return assert.deepStrictEqual(result, expected);
1416
+ // });
1417
+ // });
1418
+
1419
+
1420
+ });
1421
+
1422
+ });
1423
+
1424
+ /*
1425
+ * COINBASE
1426
+ */
1427
+ describe('coinbase', () => {
1428
+ describe('order', () => {
1429
+ describe('regular', () => {
1430
+ const item = require('./payment-resolver/coinbase/orders/regular.json');
1431
+ const result = Manager.SubscriptionResolver(defaultProfileOrder, item).resolve(options);
1432
+ const expected = {
1433
+ processor: 'coinbase',
1434
+ type: 'order',
1435
+ status: 'cancelled',
1436
+ frequency: 'single',
1437
+ resource: { id: '8f783fa6-eaa3-4460-af64-cac26b183ed1' },
1438
+ payment: {
1439
+ completed: true,
1440
+ refunded: false,
1441
+ },
1442
+ start: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1443
+ expires: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1444
+ cancelled: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1445
+ lastPayment: {
1446
+ amount: 16,
1447
+ date: { timestamp: '2023-04-26T10:06:55.000Z', timestampUNIX: 1682503615 }
1448
+ },
1449
+ trial: {
1450
+ active: false,
1451
+ claimed: false,
1452
+ daysLeft: 0,
1453
+ expires: {
1454
+ timestamp: '1970-01-01T00:00:00.000Z',
1455
+ timestampUNIX: 0,
1456
+ },
1457
+ },
1458
+ details: {
1459
+ message: '[REDACTED]',
1460
+ },
1461
+ }
1462
+
1463
+ log('result', result);
1464
+
1465
+ it('should resolve correctly', () => {
1466
+ return assert.deepStrictEqual(result, expected);
1467
+ });
1468
+ });
1469
+ });
1470
+
1471
+ describe('subscription', () => {
1472
+ describe('cancelled', () => {
1473
+ const item = require('./payment-resolver/coinbase/subscriptions/cancelled.json');
1474
+ const result = Manager.SubscriptionResolver(profileSubscriptionDefault, item).resolve(options);
1475
+ const expected = {
1476
+ processor: 'coinbase',
1477
+ type: 'subscription',
1478
+ status: 'cancelled',
1479
+ frequency: 'monthly',
1480
+ resource: { id: '8f783fa6-eaa3-4460-af64-cac26b183ed1' },
1481
+ payment: {
1482
+ completed: true,
1483
+ refunded: false,
1484
+ },
1485
+ start: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1486
+ expires: { timestamp: '2023-05-26T09:59:19.000Z', timestampUNIX: 1685095159 },
1487
+ cancelled: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1488
+ lastPayment: {
1489
+ amount: 16,
1490
+ date: { timestamp: '2023-04-26T10:06:55.000Z', timestampUNIX: 1682503615 }
1491
+ },
1492
+ trial: {
1493
+ active: false,
1494
+ claimed: false,
1495
+ daysLeft: 0,
1496
+ expires: {
1497
+ timestamp: '1970-01-01T00:00:00.000Z',
1498
+ timestampUNIX: 0,
1499
+ },
1500
+ },
1501
+ details: {
1502
+ message: '[REDACTED]',
1503
+ },
1504
+ }
1505
+
1506
+ log('result', result);
1507
+
1508
+ it('should resolve correctly', () => {
1509
+ return assert.deepStrictEqual(result, expected);
1510
+ });
1511
+ });
1512
+
1513
+ describe('paid 2', () => {
1514
+ const item = require('./payment-resolver/coinbase/subscriptions/paid-2.json');
1515
+ const result = Manager.SubscriptionResolver(profileSubscriptionDefault, item).resolve(options);
1516
+ const expected = {
1517
+ processor: 'coinbase',
1518
+ type: 'subscription',
1519
+ status: 'cancelled',
1520
+ frequency: 'monthly',
1521
+ resource: { id: '1baa71fb-318c-400c-9020-08b894a1fa6e' },
1522
+ payment: {
1523
+ completed: true,
1524
+ refunded: false,
1525
+ },
1526
+ start: { timestamp: '2024-01-23T21:59:03.000Z', timestampUNIX: 1706047143 },
1527
+ expires: { timestamp: '2024-02-23T21:59:03.000Z', timestampUNIX: 1708725543 },
1528
+ cancelled: { timestamp: '2024-01-23T21:59:03.000Z', timestampUNIX: 1706047143 },
1529
+ lastPayment: {
1530
+ amount: 10,
1531
+ date: { timestamp: '2024-01-23T22:40:35.000Z', timestampUNIX: 1706049635 }
1532
+ },
1533
+ trial: {
1534
+ active: false,
1535
+ claimed: false,
1536
+ daysLeft: 0,
1537
+ expires: {
1538
+ timestamp: '1970-01-01T00:00:00.000Z',
1539
+ timestampUNIX: 0,
1540
+ },
1541
+ },
1542
+ details: {
1543
+ message: '[REDACTED]',
1544
+ },
1545
+ }
1546
+
1547
+ log('result', result);
1548
+
1549
+ it('should resolve correctly', () => {
1550
+ return assert.deepStrictEqual(result, expected);
1551
+ });
1552
+ });
1553
+ });
1554
+ });
1555
+
1556
+ });
1557
+
1558
+ })