backend-manager 5.9.5 → 5.9.7

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 (246) hide show
  1. package/package.json +8 -1
  2. package/src/manager/events/cron/runner.js +0 -1
  3. package/src/manager/libraries/email/data/disposable-domains.json +21 -0
  4. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-11T03-28-07/metadata.json +14 -0
  5. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-11T03-28-07/newsletter.html +486 -0
  6. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-11T03-28-07/newsletter.md +41 -0
  7. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-11T03-28-07/newsletter.mjml +97 -0
  8. package/{test/email/fixtures/clean.json → src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-11T03-28-07/structure.json} +16 -4
  9. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-11T03-28-07/summary.md +1 -0
  10. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-00-28/metadata.json +14 -0
  11. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-00-28/newsletter.html +486 -0
  12. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-00-28/newsletter.md +41 -0
  13. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-00-28/newsletter.mjml +97 -0
  14. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-00-28/structure.json +42 -0
  15. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-00-28/summary.md +1 -0
  16. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-01-34/metadata.json +14 -0
  17. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-01-34/newsletter.html +486 -0
  18. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-01-34/newsletter.md +41 -0
  19. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-01-34/newsletter.mjml +97 -0
  20. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-01-34/structure.json +42 -0
  21. package/src/test/fixtures/firebase-project/.temp/newsletter/run-2026-06-18T01-01-34/summary.md +1 -0
  22. package/src/test/fixtures/firebase-project/.temp/test-mode.json +6 -0
  23. package/src/test/fixtures/firebase-project/database-debug.log +12 -0
  24. package/src/test/fixtures/firebase-project/firestore-debug.log +132 -0
  25. package/src/test/fixtures/firebase-project/pubsub-debug.log +17 -0
  26. package/.codeclimate.yml +0 -32
  27. package/.nvmrc +0 -1
  28. package/CHANGELOG.md +0 -1440
  29. package/PROGRESS.md +0 -93
  30. package/TODO-2.md +0 -121
  31. package/TODO-CHARGEBLAST.md +0 -32
  32. package/TODO-WEBHOOK-KEY-LEGACY-REMOVAL.md +0 -15
  33. package/TODO-WEBHOOK-KEY-UPGRADE.md +0 -138
  34. package/TODO-email-auth.md +0 -14
  35. package/TODO.md +0 -187
  36. package/plans/mcp2.md +0 -247
  37. package/plans/suspended-subscription-dead-zone.md +0 -97
  38. package/scripts/test-helper-providers.js +0 -162
  39. package/scripts/update-disposable-domains.js +0 -44
  40. package/templates/_.env +0 -42
  41. package/templates/_.gitignore +0 -60
  42. package/templates/backend-manager-config.json +0 -249
  43. package/templates/database.rules.json +0 -83
  44. package/templates/firebase.json +0 -66
  45. package/templates/firestore.indexes.json +0 -4
  46. package/templates/firestore.rules +0 -112
  47. package/templates/public/404.html +0 -26
  48. package/templates/public/index.html +0 -24
  49. package/templates/remoteconfig.template.json +0 -1
  50. package/templates/storage-lifecycle-config-1-day.json +0 -9
  51. package/templates/storage-lifecycle-config-30-days.json +0 -9
  52. package/templates/storage.rules +0 -8
  53. package/test/_init/accounts-validation.js +0 -58
  54. package/test/_legacy/ai/index.js +0 -231
  55. package/test/_legacy/ai/test.jpg +0 -0
  56. package/test/_legacy/ai/test.pdf +0 -0
  57. package/test/_legacy/index.js +0 -31
  58. package/test/_legacy/payment-resolver/chargebee/orders/refunded.json +0 -0
  59. package/test/_legacy/payment-resolver/chargebee/orders/unpaid.json +0 -98
  60. package/test/_legacy/payment-resolver/chargebee/subscriptions/active.json +0 -578
  61. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-in-trial.json +0 -38
  62. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-skipped-to-active.json +0 -135
  63. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-active-to-cancelled.json +0 -42
  64. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-active.json +0 -44
  65. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-cancelled.json +0 -39
  66. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-refund.json +0 -143
  67. package/test/_legacy/payment-resolver/chargebee/subscriptions/trial-to-suspended.json +0 -48
  68. package/test/_legacy/payment-resolver/coinbase/orders/regular.json +0 -204
  69. package/test/_legacy/payment-resolver/coinbase/subscriptions/cancelled.json +0 -204
  70. package/test/_legacy/payment-resolver/coinbase/subscriptions/paid-2.json +0 -125
  71. package/test/_legacy/payment-resolver/index.js +0 -1558
  72. package/test/_legacy/payment-resolver/paypal/orders/refunded.json +0 -0
  73. package/test/_legacy/payment-resolver/paypal/orders/regular.json +0 -120
  74. package/test/_legacy/payment-resolver/paypal/subscriptions/active-refund-previous-stmnt.json +0 -323
  75. package/test/_legacy/payment-resolver/paypal/subscriptions/active.json +0 -192
  76. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-in-trial.json +0 -125
  77. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-not-complete.json +0 -76
  78. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-overdue-2.json +0 -114
  79. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-payment-overdue.json +0 -114
  80. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-active-to-cancelled.json +0 -111
  81. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-active.json +0 -132
  82. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-cancelled.json +0 -107
  83. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-expired.json +0 -91
  84. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-refund.json +0 -147
  85. package/test/_legacy/payment-resolver/paypal/subscriptions/trial-to-suspended.json +0 -120
  86. package/test/_legacy/payment-resolver/stripe/orders/refunded.json +0 -0
  87. package/test/_legacy/payment-resolver/stripe/orders/regular.json +0 -91
  88. package/test/_legacy/payment-resolver/stripe/subscriptions/active.json +0 -421
  89. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-in-trial.json +0 -349
  90. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-active-failed-authorization.json +0 -430
  91. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-active.json +0 -319
  92. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-cancelled.json +0 -319
  93. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-refund.json +0 -414
  94. package/test/_legacy/payment-resolver/stripe/subscriptions/trial-to-suspended.json +0 -319
  95. package/test/_legacy/payment-resolver/stripe/subscriptions/unsure.json +0 -339
  96. package/test/_legacy/test-new +0 -1178
  97. package/test/_legacy/test.md +0 -89
  98. package/test/_legacy/usage.js +0 -175
  99. package/test/_legacy/user.js +0 -31
  100. package/test/ai/tools-live.js +0 -170
  101. package/test/boot/emulator-boots.js +0 -37
  102. package/test/content/blog-generate.js +0 -160
  103. package/test/email/campaign-send.js +0 -45
  104. package/test/email/consent-lifecycle.js +0 -257
  105. package/test/email/feedback-and-plain-send.js +0 -52
  106. package/test/email/fixtures/editorial.json +0 -30
  107. package/test/email/fixtures/field-report.json +0 -53
  108. package/test/email/marketing-lifecycle.js +0 -132
  109. package/test/email/newsletter-generate.js +0 -819
  110. package/test/email/newsletter-templates.js +0 -491
  111. package/test/email/templates.js +0 -207
  112. package/test/email/transactional-send.js +0 -34
  113. package/test/email/transactional.js +0 -560
  114. package/test/email/validation.js +0 -710
  115. package/test/events/auth-delete-race.js +0 -201
  116. package/test/events/payments/journey-payments-cancel-endpoint.js +0 -100
  117. package/test/events/payments/journey-payments-cancel.js +0 -182
  118. package/test/events/payments/journey-payments-discount.js +0 -89
  119. package/test/events/payments/journey-payments-failure.js +0 -146
  120. package/test/events/payments/journey-payments-legacy-product.js +0 -149
  121. package/test/events/payments/journey-payments-one-time-failure.js +0 -111
  122. package/test/events/payments/journey-payments-one-time.js +0 -136
  123. package/test/events/payments/journey-payments-plan-change.js +0 -144
  124. package/test/events/payments/journey-payments-refund-webhook.js +0 -180
  125. package/test/events/payments/journey-payments-suspend.js +0 -181
  126. package/test/events/payments/journey-payments-trial-cancel.js +0 -130
  127. package/test/events/payments/journey-payments-trial.js +0 -171
  128. package/test/events/payments/journey-payments-uid-resolution.js +0 -132
  129. package/test/events/payments/journey-payments-upgrade.js +0 -135
  130. package/test/fixtures/chargebee/invoice-one-time.json +0 -27
  131. package/test/fixtures/chargebee/subscription-active.json +0 -44
  132. package/test/fixtures/chargebee/subscription-cancelled.json +0 -42
  133. package/test/fixtures/chargebee/subscription-in-trial.json +0 -41
  134. package/test/fixtures/chargebee/subscription-legacy-plan.json +0 -41
  135. package/test/fixtures/chargebee/subscription-non-renewing.json +0 -41
  136. package/test/fixtures/chargebee/subscription-paused.json +0 -42
  137. package/test/fixtures/chargebee/webhook-payment-failed.json +0 -51
  138. package/test/fixtures/chargebee/webhook-subscription-created.json +0 -47
  139. package/test/fixtures/paypal/order-approved.json +0 -62
  140. package/test/fixtures/paypal/order-completed.json +0 -110
  141. package/test/fixtures/paypal/subscription-active.json +0 -76
  142. package/test/fixtures/paypal/subscription-cancelled.json +0 -50
  143. package/test/fixtures/paypal/subscription-suspended.json +0 -65
  144. package/test/fixtures/stripe/checkout-session-completed.json +0 -130
  145. package/test/fixtures/stripe/invoice-payment-failed.json +0 -148
  146. package/test/fixtures/stripe/invoice-subscription-payment-failed.json +0 -28
  147. package/test/fixtures/stripe/subscription-active.json +0 -161
  148. package/test/fixtures/stripe/subscription-canceled.json +0 -161
  149. package/test/fixtures/stripe/subscription-trialing.json +0 -161
  150. package/test/functions/admin/database-read.js +0 -134
  151. package/test/functions/admin/database-write.js +0 -159
  152. package/test/functions/admin/edit-post.js +0 -366
  153. package/test/functions/admin/firestore-query.js +0 -207
  154. package/test/functions/admin/firestore-read.js +0 -129
  155. package/test/functions/admin/firestore-write.js +0 -105
  156. package/test/functions/admin/get-stats.js +0 -115
  157. package/test/functions/admin/send-email.js +0 -119
  158. package/test/functions/admin/send-notification.js +0 -208
  159. package/test/functions/admin/write-repo-content.js +0 -223
  160. package/test/functions/general/add-marketing-contact.js +0 -335
  161. package/test/functions/general/fetch-post.js +0 -54
  162. package/test/functions/general/generate-uuid.js +0 -114
  163. package/test/functions/test/authenticate.js +0 -64
  164. package/test/functions/user/create-custom-token.js +0 -73
  165. package/test/functions/user/delete.js +0 -135
  166. package/test/functions/user/get-active-sessions.js +0 -111
  167. package/test/functions/user/get-subscription-info.js +0 -99
  168. package/test/functions/user/regenerate-api-keys.js +0 -156
  169. package/test/functions/user/resolve.js +0 -52
  170. package/test/functions/user/sign-out-all-sessions.js +0 -94
  171. package/test/functions/user/sign-up.js +0 -252
  172. package/test/functions/user/submit-feedback.js +0 -104
  173. package/test/functions/user/validate-settings.js +0 -82
  174. package/test/helpers/ai-request-payload.js +0 -300
  175. package/test/helpers/ai-test-provider.js +0 -202
  176. package/test/helpers/ai-tools-format.js +0 -383
  177. package/test/helpers/content/blog-auto-publisher.js +0 -484
  178. package/test/helpers/content/feed-parser.js +0 -528
  179. package/test/helpers/content/ghostii-blocks.js +0 -134
  180. package/test/helpers/content/ghostii-feed-integration.js +0 -404
  181. package/test/helpers/content/ghostii-write-article.js +0 -243
  182. package/test/helpers/environment.js +0 -230
  183. package/test/helpers/infer-contact.js +0 -113
  184. package/test/helpers/merge-line-files.js +0 -271
  185. package/test/helpers/payment/chargebee/parse-webhook.js +0 -413
  186. package/test/helpers/payment/chargebee/to-unified-one-time.js +0 -147
  187. package/test/helpers/payment/chargebee/to-unified-subscription.js +0 -648
  188. package/test/helpers/payment/paypal/parse-webhook.js +0 -539
  189. package/test/helpers/payment/paypal/to-unified-one-time.js +0 -382
  190. package/test/helpers/payment/paypal/to-unified-subscription.js +0 -820
  191. package/test/helpers/payment/stripe/parse-webhook.js +0 -447
  192. package/test/helpers/payment/stripe/to-unified-one-time.js +0 -306
  193. package/test/helpers/payment/stripe/to-unified-subscription.js +0 -708
  194. package/test/helpers/sanitize.js +0 -222
  195. package/test/helpers/slugify.js +0 -394
  196. package/test/helpers/storage.js +0 -194
  197. package/test/helpers/user.js +0 -755
  198. package/test/helpers/webhook-forward.js +0 -418
  199. package/test/mcp/discovery.js +0 -53
  200. package/test/mcp/oauth.js +0 -161
  201. package/test/mcp/protocol.js +0 -268
  202. package/test/mcp/roles.js +0 -188
  203. package/test/mcp/utils.js +0 -245
  204. package/test/routes/admin/create-post.js +0 -364
  205. package/test/routes/admin/database.js +0 -131
  206. package/test/routes/admin/deduplicate-image-alts.js +0 -190
  207. package/test/routes/admin/email.js +0 -114
  208. package/test/routes/admin/firestore-query.js +0 -204
  209. package/test/routes/admin/firestore.js +0 -127
  210. package/test/routes/admin/infer-contact.js +0 -218
  211. package/test/routes/admin/notification.js +0 -198
  212. package/test/routes/admin/post-resize-image.js +0 -184
  213. package/test/routes/admin/post.js +0 -368
  214. package/test/routes/admin/repo-content.js +0 -223
  215. package/test/routes/admin/stats.js +0 -112
  216. package/test/routes/content/post.js +0 -54
  217. package/test/routes/general/uuid.js +0 -115
  218. package/test/routes/marketing/campaign.js +0 -125
  219. package/test/routes/marketing/contact.js +0 -370
  220. package/test/routes/marketing/email-preferences.js +0 -292
  221. package/test/routes/marketing/push-send.js +0 -32
  222. package/test/routes/marketing/webhook-forward.js +0 -61
  223. package/test/routes/marketing/webhook.js +0 -639
  224. package/test/routes/payments/cancel.js +0 -163
  225. package/test/routes/payments/discount.js +0 -80
  226. package/test/routes/payments/dispute-alert.js +0 -320
  227. package/test/routes/payments/intent.js +0 -336
  228. package/test/routes/payments/portal.js +0 -92
  229. package/test/routes/payments/refund.js +0 -179
  230. package/test/routes/payments/trial-eligibility.js +0 -71
  231. package/test/routes/payments/webhook.js +0 -107
  232. package/test/routes/test/authenticate.js +0 -59
  233. package/test/routes/test/schema.js +0 -554
  234. package/test/routes/test/usage.js +0 -342
  235. package/test/routes/user/api-keys.js +0 -156
  236. package/test/routes/user/delete.js +0 -136
  237. package/test/routes/user/feedback.js +0 -104
  238. package/test/routes/user/sessions.js +0 -199
  239. package/test/routes/user/settings-validate.js +0 -82
  240. package/test/routes/user/signup.js +0 -542
  241. package/test/routes/user/subscription.js +0 -99
  242. package/test/routes/user/token.js +0 -73
  243. package/test/routes/user/user.js +0 -157
  244. package/test/rules/notifications.js +0 -410
  245. package/test/rules/payments-carts.js +0 -371
  246. package/test/rules/user.js +0 -396
@@ -1,1178 +0,0 @@
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
-
31
- const defaultProfileOrder = {
32
- type: 'order',
33
- details: {
34
- }
35
- }
36
-
37
- const defaultProfileSubscription = {
38
- type: 'subscription',
39
- details: {
40
- planFrequency: 'monthly',
41
- }
42
- }
43
-
44
- function log() {
45
- // console.log(...arguments);
46
- }
47
-
48
- describe('.dependencies()', () => {
49
- Object.keys(package.dependencies).forEach((dependency) => {
50
- it(`should load ${dependency}`, () => {
51
- try {
52
- const dep = require(dependency);
53
- assert.ok(dep);
54
- } catch (e) {
55
- assert.fail(`Failed to load ${dependency}: ${e.message}`);
56
- }
57
- });
58
- });
59
- });
60
-
61
- describe('.subscriptionResolver()', () => {
62
-
63
- /*
64
- GENERIC
65
- */
66
- // describe('error test', () => {
67
- // const result = Manager.SubscriptionResolver({}, new Error('Test')).resolve(options);
68
-
69
- // console.log('result', result);
70
-
71
- // it('should resolve correctly', () => {
72
- // return assert.deepStrictEqual(result, expected);
73
- // });
74
- // });
75
-
76
- /*
77
- * PAYPAL
78
- */
79
- describe('paypal', () => {
80
- // Orders
81
- describe('orders', () => {
82
- describe('regular', () => {
83
- const item = require('./payment-resolver/paypal/orders/regular.json');
84
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
85
- const expected = {
86
- processor: 'paypal',
87
- type: 'order',
88
- status: 'cancelled',
89
- frequency: 'single',
90
- resource: { id: '5CA68427PY850452F' },
91
- payment: {
92
- completed: true,
93
- refunded: false,
94
- },
95
- start: { timestamp: '2023-04-27T03:39:50.000Z', timestampUNIX: 1682566790 },
96
- expires: { timestamp: '2023-04-27T03:39:50.000Z', timestampUNIX: 1682566790 },
97
- cancelled: { timestamp: '2023-04-27T03:39:50.000Z', timestampUNIX: 1682566790 },
98
- lastPayment: {
99
- amount: 1,
100
- date: { timestamp: '2023-04-27T03:40:38.000Z', timestampUNIX: 1682566838 }
101
- },
102
- trial: {
103
- active: false,
104
- claimed: false,
105
- daysLeft: 0,
106
- },
107
- }
108
-
109
- log('result', result);
110
-
111
- it('should resolve correctly', () => {
112
- return assert.deepStrictEqual(result, expected);
113
- });
114
- });
115
- });
116
-
117
- // Subscriptions
118
- describe('subscriptions', () => {
119
- describe('active', () => {
120
- const item = require('./payment-resolver/paypal/subscriptions/active.json');
121
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
122
- const expected = {
123
- processor: 'paypal',
124
- type: 'subscription',
125
- status: 'active',
126
- frequency: 'monthly',
127
- resource: { id: 'I-GLYNACJCERDD' },
128
- payment: {
129
- completed: true,
130
- refunded: false,
131
- },
132
- start: { timestamp: '2023-03-22T22:38:03.000Z', timestampUNIX: 1679524683 },
133
- expires: { timestamp: '2024-09-21T11:03:15.000Z', timestampUNIX: 1726916595 },
134
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
135
- lastPayment: {
136
- amount: 59.85,
137
- date: { timestamp: '2023-08-22T11:03:15.000Z', timestampUNIX: 1692702195 }
138
- },
139
- trial: {
140
- active: false,
141
- claimed: false,
142
- daysLeft: 0,
143
- },
144
- }
145
-
146
- log('result', result);
147
-
148
- it('should resolve correctly', () => {
149
- return assert.deepStrictEqual(result, expected);
150
- });
151
- });
152
-
153
- describe('trial => in-trial', () => {
154
- const item = require('./payment-resolver/paypal/subscriptions/trial-in-trial.json');
155
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
156
- const expected = {
157
- processor: 'paypal',
158
- type: 'subscription',
159
- status: 'active',
160
- frequency: 'annually',
161
- resource: { id: 'I-HG5K7XD0BVPJ' },
162
- payment: {
163
- completed: true,
164
- refunded: false,
165
- },
166
- start: { timestamp: '2023-04-28T02:16:58.000Z', timestampUNIX: 1682648218 },
167
- expires: { timestamp: '2024-06-10T10:00:00.000Z', timestampUNIX: 1718013600 },
168
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
169
- lastPayment: {
170
- amount: 0,
171
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
172
- },
173
- trial: {
174
- active: true,
175
- claimed: true,
176
- daysLeft: 13,
177
- },
178
- }
179
-
180
- log('result', result);
181
-
182
- it('should resolve correctly', () => {
183
- return assert.deepStrictEqual(result, expected);
184
- });
185
- });
186
-
187
- describe('trial => payment not completed', () => {
188
- const item = require('./payment-resolver/paypal/subscriptions/trial-payment-not-complete.json');
189
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
190
- const expected = {
191
- processor: 'paypal',
192
- type: 'subscription',
193
- status: 'suspended',
194
- frequency: 'monthly',
195
- resource: { id: 'I-6YN0VNT6KM4W' },
196
- payment: {
197
- completed: false,
198
- refunded: false,
199
- },
200
- start: { timestamp: '2023-05-11T10:52:00.000Z', timestampUNIX: 1683802320 },
201
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
202
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
203
- lastPayment: {
204
- amount: 0,
205
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
206
- },
207
- trial: {
208
- active: false,
209
- claimed: true,
210
- daysLeft: 0,
211
- },
212
- }
213
-
214
- log('result', result);
215
-
216
- it('should resolve correctly', () => {
217
- return assert.deepStrictEqual(result, expected);
218
- });
219
- });
220
-
221
- describe('trial => payment overdue', () => {
222
- const item = require('./payment-resolver/paypal/subscriptions/trial-payment-overdue.json');
223
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
224
- const expected = {
225
- processor: 'paypal',
226
- type: 'subscription',
227
- status: 'suspended',
228
- frequency: 'annually',
229
- resource: { id: 'I-PFLFF5TTAN4S' },
230
- payment: {
231
- completed: true,
232
- refunded: false,
233
- },
234
- start: { timestamp: '2023-09-09T05:58:41.000Z', timestampUNIX: 1694239121 },
235
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
236
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
237
- lastPayment: {
238
- amount: 0,
239
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
240
- },
241
- trial: {
242
- active: false,
243
- claimed: true,
244
- daysLeft: 0,
245
- },
246
- }
247
-
248
- log('result', result);
249
-
250
- it('should resolve correctly', () => {
251
- return assert.deepStrictEqual(result, expected);
252
- });
253
- });
254
-
255
- describe('trial => payment overdue (2)', () => {
256
- const item = require('./payment-resolver/paypal/subscriptions/trial-payment-overdue-2.json');
257
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
258
- const expected = {
259
- processor: 'paypal',
260
- type: 'subscription',
261
- status: 'suspended',
262
- frequency: 'annually',
263
- resource: { id: 'I-JU1H0XF32WU5' },
264
- payment: {
265
- completed: true,
266
- refunded: false,
267
- },
268
- start: { timestamp: '2023-09-08T07:15:10.000Z', timestampUNIX: 1694157310 },
269
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
270
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
271
- lastPayment: {
272
- amount: 0,
273
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
274
- },
275
- trial: {
276
- active: false,
277
- claimed: true,
278
- daysLeft: 0,
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 => active => cancelled', () => {
290
- const item = require('./payment-resolver/paypal/subscriptions/trial-to-active-to-cancelled.json');
291
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
292
- const expected = {
293
- processor: 'paypal',
294
- type: 'subscription',
295
- status: 'cancelled',
296
- frequency: 'monthly',
297
- resource: { id: 'I-MH92AV4A3EA6' },
298
- payment: {
299
- completed: true,
300
- refunded: false,
301
- },
302
- start: { timestamp: '2023-03-31T14:48:51.000Z', timestampUNIX: 1680274131 },
303
- expires: { timestamp: '2023-05-14T10:56:15.000Z', timestampUNIX: 1684061775 },
304
- cancelled: { timestamp: '2023-04-18T10:14:56.000Z', timestampUNIX: 1681812896 },
305
- lastPayment: {
306
- amount: 19.95,
307
- date: { timestamp: '2023-04-14T10:56:15.000Z', timestampUNIX: 1681469775 }
308
- },
309
- trial: {
310
- active: false,
311
- claimed: true,
312
- daysLeft: 0,
313
- },
314
- }
315
-
316
- log('result', result);
317
-
318
- it('should resolve correctly', () => {
319
- return assert.deepStrictEqual(result, expected);
320
- });
321
- });
322
-
323
- describe('trial => active', () => {
324
- const item = require('./payment-resolver/paypal/subscriptions/trial-to-active.json');
325
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
326
- const expected = {
327
- processor: 'paypal',
328
- type: 'subscription',
329
- status: 'active',
330
- frequency: 'monthly',
331
- resource: { id: 'I-VTXGPKDTMMK2' },
332
- payment: {
333
- completed: true,
334
- refunded: false,
335
- },
336
- start: { timestamp: '2023-04-11T17:37:58.000Z', timestampUNIX: 1681234678 },
337
- expires: { timestamp: '2024-05-25T10:28:22.000Z', timestampUNIX: 1716632902 },
338
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
339
- lastPayment: {
340
- amount: 19.95,
341
- date: { timestamp: '2023-04-25T10:28:22.000Z', timestampUNIX: 1682418502 }
342
- },
343
- trial: {
344
- active: false,
345
- claimed: false,
346
- daysLeft: 0,
347
- },
348
- }
349
-
350
- log('result', result);
351
-
352
- it('should resolve correctly', () => {
353
- return assert.deepStrictEqual(result, expected);
354
- });
355
- });
356
-
357
- describe('trial => cancelled', () => {
358
- const item = require('./payment-resolver/paypal/subscriptions/trial-to-cancelled.json');
359
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
360
- const expected = {
361
- processor: 'paypal',
362
- type: 'subscription',
363
- status: 'cancelled',
364
- frequency: 'monthly',
365
- resource: { id: 'I-79C4RSSVKN95' },
366
- payment: {
367
- completed: true,
368
- refunded: false,
369
- },
370
- start: { timestamp: '2023-03-31T08:41:35.000Z', timestampUNIX: 1680252095 },
371
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
372
- cancelled: { timestamp: '2023-04-02T23:38:44.000Z', timestampUNIX: 1680478724 },
373
- lastPayment: {
374
- amount: 0,
375
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
376
- },
377
- trial: {
378
- active: false,
379
- claimed: true,
380
- daysLeft: 0,
381
- },
382
- }
383
-
384
- log('result', result);
385
-
386
- it('should resolve correctly', () => {
387
- return assert.deepStrictEqual(result, expected);
388
- });
389
- });
390
-
391
- describe('trial => expired', () => {
392
- const item = require('./payment-resolver/paypal/subscriptions/trial-to-expired.json');
393
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
394
- const expected = {
395
- processor: 'paypal',
396
- type: 'subscription',
397
- status: 'cancelled',
398
- frequency: 'monthly',
399
- resource: { id: 'I-BC83SG8TF205' },
400
- payment: {
401
- completed: true,
402
- refunded: false,
403
- },
404
- start: { timestamp: '2023-06-05T15:16:16.000Z', timestampUNIX: 1685978176 },
405
- expires: { timestamp: '2023-07-05T15:16:31.000Z', timestampUNIX: 1688570191 },
406
- cancelled: { timestamp: '2023-06-05T15:16:33.000Z', timestampUNIX: 1685978193 },
407
- lastPayment: {
408
- amount: 3,
409
- date: { timestamp: '2023-06-05T15:16:31.000Z', timestampUNIX: 1685978191 }
410
- },
411
- trial: {
412
- active: false,
413
- claimed: false,
414
- daysLeft: 0,
415
- },
416
- }
417
-
418
- log('result', result);
419
-
420
- it('should resolve correctly', () => {
421
- return assert.deepStrictEqual(result, expected);
422
- });
423
- });
424
-
425
- describe('trial => refund', () => {
426
- const item = require('./payment-resolver/paypal/subscriptions/trial-to-refund.json');
427
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
428
- const expected = {
429
- processor: 'paypal',
430
- type: 'subscription',
431
- status: 'cancelled',
432
- frequency: 'annually',
433
- resource: { id: 'I-JW7F1RK5KN8W' },
434
- payment: {
435
- completed: true,
436
- refunded: true,
437
- },
438
- start: { timestamp: '2023-07-17T14:31:50.000Z', timestampUNIX: 1689604310 },
439
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
440
- cancelled: { timestamp: '2023-07-31T11:33:32.000Z', timestampUNIX: 1690803212 },
441
- lastPayment: {
442
- amount: 191.4,
443
- date: { timestamp: '2023-07-31T11:13:59.000Z', timestampUNIX: 1690802039 }
444
- },
445
- trial: {
446
- active: false,
447
- claimed: false,
448
- daysLeft: 0,
449
- },
450
- }
451
-
452
- log('result', result);
453
-
454
- it('should resolve correctly', () => {
455
- return assert.deepStrictEqual(result, expected);
456
- });
457
- });
458
-
459
- describe('trial => suspended', () => {
460
- const item = require('./payment-resolver/paypal/subscriptions/trial-to-suspended.json');
461
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
462
- const expected = {
463
- processor: 'paypal',
464
- type: 'subscription',
465
- status: 'suspended',
466
- frequency: 'monthly',
467
- resource: { id: 'I-A3AS9XBE0JEG' },
468
- payment: {
469
- completed: true,
470
- refunded: false,
471
- },
472
- start: { timestamp: '2023-07-11T16:52:11.000Z', timestampUNIX: 1689094331 },
473
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
474
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
475
- lastPayment: {
476
- amount: 9.97,
477
- date: { timestamp: '2023-07-11T16:53:50.000Z', timestampUNIX: 1689094430 }
478
- },
479
- trial: {
480
- active: false,
481
- claimed: false,
482
- daysLeft: 0,
483
- },
484
- }
485
-
486
- log('result', result);
487
-
488
- it('should resolve correctly', () => {
489
- return assert.deepStrictEqual(result, expected);
490
- });
491
- });
492
- });
493
- });
494
-
495
- /*
496
- * CHARGEBEE
497
- */
498
- describe('chargebee', () => {
499
- // Orders
500
- describe('orders', () => {
501
- // describe('regular', () => {
502
- // const item = require('./payment-resolver/chargebee/orders/regular.json');
503
- // const result = Manager.SubscriptionResolver({}, item).resolve(options);
504
- // const expected = {
505
- // processor: 'chargebee',
506
- // type: 'order',
507
- // status: 'cancelled',
508
- // frequency: 'single',
509
- // resource: { id: '3065' },
510
- // payment: {
511
- // completed: false,
512
- // refunded: false,
513
- // },
514
- // start: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
515
- // expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
516
- // cancelled: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
517
- // lastPayment: {
518
- // amount: 0,
519
- // date: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 }
520
- // },
521
- // trial: {
522
- // active: false,
523
- // claimed: false,
524
- // daysLeft: 0,
525
- // },
526
- // }
527
-
528
- // log('result', result);
529
-
530
- // it('should resolve correctly', () => {
531
- // return assert.deepStrictEqual(result, expected);
532
- // });
533
- // });
534
-
535
- describe('unpaid', () => {
536
- const item = require('./payment-resolver/chargebee/orders/unpaid.json');
537
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
538
- const expected = {
539
- processor: 'chargebee',
540
- type: 'order',
541
- status: 'cancelled',
542
- frequency: 'single',
543
- resource: { id: '3065' },
544
- payment: {
545
- completed: false,
546
- refunded: false,
547
- },
548
- start: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
549
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
550
- cancelled: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 },
551
- lastPayment: {
552
- amount: 0,
553
- date: { timestamp: '2023-04-27T09:34:43.000Z', timestampUNIX: 1682588083 }
554
- },
555
- trial: {
556
- active: false,
557
- claimed: false,
558
- daysLeft: 0,
559
- },
560
- }
561
-
562
- log('result', result);
563
-
564
- it('should resolve correctly', () => {
565
- return assert.deepStrictEqual(result, expected);
566
- });
567
- });
568
- });
569
-
570
- // Subscriptions
571
- describe('subscriptions', () => {
572
- describe('active', () => {
573
- const item = require('./payment-resolver/chargebee/subscriptions/active.json');
574
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
575
- const expected = {
576
- processor: 'chargebee',
577
- type: 'subscription',
578
- status: 'active',
579
- frequency: 'monthly',
580
- resource: { id: 'AzZMxvTYTQUmw1Iw7' },
581
- payment: {
582
- completed: true,
583
- refunded: false,
584
- },
585
- start: { timestamp: '2023-03-14T10:37:33.000Z', timestampUNIX: 1678790253 },
586
- expires: { timestamp: '2024-09-13T10:37:33.000Z', timestampUNIX: 1726223853 },
587
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
588
- lastPayment: {
589
- amount: 19.95,
590
- date: { timestamp: '2023-08-14T10:37:33.000Z', timestampUNIX: 1692009453 }
591
- },
592
- trial: {
593
- active: false,
594
- claimed: false,
595
- daysLeft: 0,
596
- }
597
- }
598
-
599
- log('result', result);
600
-
601
- it('should resolve correctly', () => {
602
- return assert.deepStrictEqual(result, expected);
603
- });
604
- });
605
-
606
- describe('trial => skipped-to-active', () => {
607
- const item = require('./payment-resolver/chargebee/subscriptions/trial-skipped-to-active.json');
608
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
609
- const expected = {
610
- processor: 'chargebee',
611
- type: 'subscription',
612
- status: 'active',
613
- frequency: 'monthly',
614
- resource: { id: '6oqX0TnhKo5R513B' },
615
- payment: {
616
- completed: true,
617
- refunded: false,
618
- },
619
- start: { timestamp: '2023-08-22T20:55:52.000Z', timestampUNIX: 1692737752 },
620
- expires: { timestamp: '2024-09-21T20:55:57.000Z', timestampUNIX: 1726952157 },
621
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
622
- lastPayment: {
623
- amount: 19.95,
624
- date: { timestamp: '2023-08-22T20:55:57.000Z', timestampUNIX: 1692737757 }
625
- },
626
- trial: {
627
- active: false,
628
- claimed: false,
629
- daysLeft: 0,
630
- }
631
- }
632
-
633
- log('result', result);
634
-
635
- it('should resolve correctly', () => {
636
- return assert.deepStrictEqual(result, expected);
637
- });
638
- });
639
-
640
- describe('trial => in-trial', () => {
641
- const item = require('./payment-resolver/chargebee/subscriptions/trial-in-trial.json');
642
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
643
- const expected = {
644
- processor: 'chargebee',
645
- type: 'subscription',
646
- status: 'active',
647
- frequency: 'monthly',
648
- resource: { id: '16CRCcTcWmQYKyT5' },
649
- payment: {
650
- completed: true,
651
- refunded: false,
652
- },
653
- start: { timestamp: '2023-04-26T10:19:48.000Z', timestampUNIX: 1682504388 },
654
- expires: { timestamp: '2024-06-09T10:19:48.000Z', timestampUNIX: 1717928388 },
655
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
656
- lastPayment: {
657
- amount: 0,
658
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
659
- },
660
- trial: {
661
- active: true,
662
- claimed: true,
663
- daysLeft: 12,
664
- },
665
- }
666
-
667
- log('result', result);
668
-
669
- it('should resolve correctly', () => {
670
- return assert.deepStrictEqual(result, expected);
671
- });
672
- });
673
-
674
- describe('trial => active => cancelled', () => {
675
- const item = require('./payment-resolver/chargebee/subscriptions/trial-to-active-to-cancelled.json');
676
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
677
- const expected = {
678
- processor: 'chargebee',
679
- type: 'subscription',
680
- status: 'cancelled',
681
- frequency: 'monthly',
682
- resource: { id: 'AzqJXiTaQKh4m5Ta7' },
683
- payment: {
684
- completed: true,
685
- refunded: false,
686
- },
687
- start: { timestamp: '2023-04-04T02:53:37.000Z', timestampUNIX: 1680576817 },
688
- expires: { timestamp: '2023-05-18T02:53:37.000Z', timestampUNIX: 1684378417 },
689
- cancelled: { timestamp: '2023-04-19T03:42:24.000Z', timestampUNIX: 1681875744 },
690
- lastPayment: {
691
- amount: 19.95,
692
- date: { timestamp: '2023-04-18T02:53:37.000Z', timestampUNIX: 1681786417 }
693
- },
694
- trial: {
695
- active: false,
696
- claimed: true,
697
- daysLeft: 0,
698
- },
699
- }
700
-
701
- log('result', result);
702
-
703
- it('should resolve correctly', () => {
704
- return assert.deepStrictEqual(result, expected);
705
- });
706
- });
707
-
708
- describe('trial => active', () => {
709
- const item = require('./payment-resolver/chargebee/subscriptions/trial-to-active.json');
710
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
711
- const expected = {
712
- processor: 'chargebee',
713
- type: 'subscription',
714
- status: 'active',
715
- frequency: 'monthly',
716
- resource: { id: 'AzyfbtTbMhiFM51DW' },
717
- payment: {
718
- completed: true,
719
- refunded: false,
720
- },
721
- start: { timestamp: '2023-04-14T02:29:56.000Z', timestampUNIX: 1681439396 },
722
- expires: { timestamp: '2024-05-28T02:29:56.000Z', timestampUNIX: 1716863396 },
723
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
724
- lastPayment: {
725
- amount: 19.95,
726
- date: { timestamp: '2023-04-28T02:29:56.000Z', timestampUNIX: 1682648996 }
727
- },
728
- trial: {
729
- active: false,
730
- claimed: true,
731
- daysLeft: 0,
732
- },
733
- }
734
-
735
- log('result', result);
736
-
737
- it('should resolve correctly', () => {
738
- return assert.deepStrictEqual(result, expected);
739
- });
740
- });
741
-
742
- describe('trial => cancelled', () => {
743
- const item = require('./payment-resolver/chargebee/subscriptions/trial-to-cancelled.json');
744
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
745
- const expected = {
746
- processor: 'chargebee',
747
- type: 'subscription',
748
- status: 'cancelled',
749
- frequency: 'monthly',
750
- resource: { id: 'AzZMshTbnEv7r1Eck' },
751
- payment: {
752
- completed: true,
753
- refunded: false,
754
- },
755
- start: { timestamp: '2023-04-18T15:24:28.000Z', timestampUNIX: 1681831468 },
756
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
757
- cancelled: { timestamp: '2023-04-25T10:41:02.000Z', timestampUNIX: 1682419262 },
758
- lastPayment: {
759
- amount: 0,
760
- date: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 }
761
- },
762
- trial: {
763
- active: false,
764
- claimed: true,
765
- daysLeft: 0,
766
- },
767
- }
768
-
769
- log('result', result);
770
-
771
- it('should resolve correctly', () => {
772
- return assert.deepStrictEqual(result, expected);
773
- });
774
- });
775
-
776
- describe('trial => refund', () => {
777
- const item = require('./payment-resolver/chargebee/subscriptions/trial-to-refund.json');
778
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
779
- const expected = {
780
- processor: 'chargebee',
781
- type: 'subscription',
782
- status: 'cancelled',
783
- frequency: 'monthly',
784
- resource: { id: 'AzymDoTjgzDShlvd' },
785
- payment: {
786
- completed: true,
787
- refunded: true,
788
- },
789
- start: { timestamp: '2023-07-11T09:37:47.000Z', timestampUNIX: 1689068267 },
790
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
791
- cancelled: { timestamp: '2023-07-15T13:23:15.000Z', timestampUNIX: 1689427395 },
792
- lastPayment: {
793
- amount: 19.95,
794
- date: { timestamp: '2023-07-11T09:37:54.000Z', timestampUNIX: 1689068274 }
795
- },
796
- trial: {
797
- active: false,
798
- claimed: false,
799
- daysLeft: 0,
800
- },
801
- }
802
-
803
- log('result', result);
804
-
805
- it('should resolve correctly', () => {
806
- return assert.deepStrictEqual(result, expected);
807
- });
808
- });
809
-
810
- describe('trial => suspendeded', () => {
811
- const item = require('./payment-resolver/chargebee/subscriptions/trial-to-suspended.json');
812
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
813
- const expected = {
814
- processor: 'chargebee',
815
- type: 'subscription',
816
- status: 'suspended',
817
- frequency: 'monthly',
818
- resource: { id: 'Azym2sTkewehg121r' },
819
- payment: {
820
- completed: true,
821
- refunded: false,
822
- },
823
- start: { timestamp: '2023-07-21T15:40:12.000Z', timestampUNIX: 1689954012 },
824
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
825
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
826
- lastPayment: {
827
- amount: 0,
828
- date: { timestamp: '2023-08-04T15:40:12.000Z', timestampUNIX: 1691163612 }
829
- },
830
- trial: {
831
- active: false,
832
- claimed: true,
833
- daysLeft: 0,
834
- },
835
- }
836
-
837
- log('result', result);
838
-
839
- it('should resolve correctly', () => {
840
- return assert.deepStrictEqual(result, expected);
841
- });
842
- });
843
- });
844
-
845
- });
846
-
847
- /*
848
- * STRIPE
849
- */
850
- describe('stripe', () => {
851
- // Orders
852
- describe('orders', () => {
853
- describe('regular', () => {
854
- const item = require('./payment-resolver/stripe/orders/regular.json');
855
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
856
- const expected = {
857
- processor: 'stripe',
858
- type: 'order',
859
- status: 'cancelled',
860
- frequency: 'single',
861
- resource: { id: 'ch_3N1pAXJVFkvVyI7h1FM4wdxL' },
862
- payment: {
863
- completed: true,
864
- refunded: false,
865
- },
866
- start: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 },
867
- expires: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 },
868
- cancelled: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 },
869
- lastPayment: {
870
- amount: 1.01,
871
- date: { timestamp: '2023-04-28T11:08:54.000Z', timestampUNIX: 1682680134 }
872
- },
873
- trial: {
874
- active: false,
875
- claimed: false,
876
- daysLeft: 0,
877
- },
878
- }
879
-
880
- log('result', result);
881
-
882
- it('should resolve correctly', () => {
883
- return assert.deepStrictEqual(result, expected);
884
- });
885
- });
886
- });
887
-
888
- // Subscriptions
889
- describe('subscriptions', () => {
890
- describe('active', () => {
891
- const item = require('./payment-resolver/stripe/subscriptions/active.json');
892
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
893
- const expected = {
894
- processor: 'stripe',
895
- type: 'subscription',
896
- status: 'active',
897
- frequency: 'monthly',
898
- resource: { id: 'sub_1McA4ZEvB7hJrWnu1o7GMybv' },
899
- payment: {
900
- completed: true,
901
- refunded: false,
902
- },
903
- start: { timestamp: '2023-02-16T16:12:39.000Z', timestampUNIX: 1676563959 },
904
- expires: { timestamp: '2024-09-15T16:12:39.000Z', timestampUNIX: 1726416759 },
905
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
906
- lastPayment: {
907
- amount: 6,
908
- date: { timestamp: '2023-08-16T16:13:11.000Z', timestampUNIX: 1692202391 }
909
- },
910
- trial: {
911
- active: false,
912
- claimed: false,
913
- daysLeft: 0,
914
- },
915
- }
916
-
917
- log('result', result);
918
-
919
- it('should resolve correctly', () => {
920
- return assert.deepStrictEqual(result, expected);
921
- });
922
- });
923
-
924
- describe('trial => in trial', () => {
925
- const item = require('./payment-resolver/stripe/subscriptions/trial-in-trial.json');
926
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
927
- const expected = {
928
- processor: 'stripe',
929
- type: 'subscription',
930
- status: 'active',
931
- frequency: 'monthly',
932
- resource: { id: 'sub_1N1a4yEvB7hJrWnuCzx5ssWK' },
933
- payment: {
934
- completed: true,
935
- refunded: false,
936
- },
937
- start: { timestamp: '2023-04-27T19:02:08.000Z', timestampUNIX: 1682622128 },
938
- expires: { timestamp: '2024-06-10T19:02:08.000Z', timestampUNIX: 1718046128 },
939
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
940
- lastPayment: {
941
- amount: 0,
942
- date: { timestamp: '2023-04-27T19:02:08.000Z', timestampUNIX: 1682622128 }
943
- },
944
- trial: {
945
- active: true,
946
- claimed: true,
947
- daysLeft: 13,
948
- },
949
- }
950
-
951
- log('result', result);
952
-
953
- it('should resolve correctly', () => {
954
- return assert.deepStrictEqual(result, expected);
955
- });
956
- });
957
-
958
- describe('trial => active', () => {
959
- const item = require('./payment-resolver/stripe/subscriptions/trial-to-active.json');
960
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
961
- const expected = {
962
- processor: 'stripe',
963
- type: 'subscription',
964
- status: 'active',
965
- frequency: 'monthly',
966
- resource: { id: 'sub_1MqedqJVFkvVyI7hYGbJyOFD' },
967
- payment: {
968
- completed: true,
969
- refunded: false,
970
- },
971
- start: { timestamp: '2023-03-28T15:40:58.000Z', timestampUNIX: 1680018058 },
972
- expires: { timestamp: '2024-05-11T15:40:58.000Z', timestampUNIX: 1715442058 },
973
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
974
- lastPayment: {
975
- amount: 6,
976
- date: { timestamp: '2023-04-11T15:41:07.000Z', timestampUNIX: 1681227667 }
977
- },
978
- trial: {
979
- active: false,
980
- claimed: true,
981
- daysLeft: 0,
982
- },
983
- }
984
-
985
- log('result', result);
986
-
987
- it('should resolve correctly', () => {
988
- return assert.deepStrictEqual(result, expected);
989
- });
990
- });
991
-
992
- // ...
993
-
994
- describe('trial => cancelled', () => {
995
- const item = require('./payment-resolver/stripe/subscriptions/trial-to-cancelled.json');
996
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
997
- const expected = {
998
- processor: 'stripe',
999
- type: 'subscription',
1000
- status: 'cancelled',
1001
- frequency: 'monthly',
1002
- resource: { id: 'sub_1Mv9VtCzY9baOpL0I2MRKfoj' },
1003
- payment: {
1004
- completed: true,
1005
- refunded: false,
1006
- },
1007
- start: { timestamp: '2023-04-10T01:27:21.000Z', timestampUNIX: 1681090041 },
1008
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1009
- cancelled: { timestamp: '2023-04-17T07:13:15.000Z', timestampUNIX: 1681715595 },
1010
- lastPayment: {
1011
- amount: 0,
1012
- date: { timestamp: '2023-04-10T01:27:21.000Z', timestampUNIX: 1681090041 }
1013
- },
1014
- trial: {
1015
- active: false,
1016
- claimed: true,
1017
- daysLeft: 0,
1018
- },
1019
- }
1020
-
1021
- log('result', result);
1022
-
1023
- it('should resolve correctly', () => {
1024
- return assert.deepStrictEqual(result, expected);
1025
- });
1026
- });
1027
-
1028
- describe('trial => refund', () => {
1029
- const item = require('./payment-resolver/stripe/subscriptions/trial-to-refund.json');
1030
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
1031
- const expected = {
1032
- processor: 'stripe',
1033
- type: 'subscription',
1034
- status: 'cancelled',
1035
- frequency: 'annually',
1036
- resource: { id: 'sub_1NWA2ZHGybgi7uQGF7ODZNEZ' },
1037
- payment: {
1038
- completed: true,
1039
- refunded: true,
1040
- },
1041
- start: { timestamp: '2023-07-21T03:30:03.000Z', timestampUNIX: 1689910203 },
1042
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1043
- cancelled: { timestamp: '2023-08-03T19:51:57.000Z', timestampUNIX: 1691092317 },
1044
- lastPayment: {
1045
- amount: 72,
1046
- date: { timestamp: '2023-07-21T03:30:03.000Z', timestampUNIX: 1689910203 }
1047
- },
1048
- trial: {
1049
- active: false,
1050
- claimed: false,
1051
- daysLeft: 0,
1052
- },
1053
- }
1054
-
1055
- log('result', result);
1056
-
1057
- it('should resolve correctly', () => {
1058
- return assert.deepStrictEqual(result, expected);
1059
- });
1060
- });
1061
-
1062
- describe('trial => suspended', () => {
1063
- const item = require('./payment-resolver/stripe/subscriptions/trial-to-suspended.json');
1064
- const result = Manager.SubscriptionResolver({}, item).resolve(options);
1065
- const expected = {
1066
- processor: 'stripe',
1067
- type: 'subscription',
1068
- status: 'suspended',
1069
- frequency: 'monthly',
1070
- resource: { id: 'sub_1MrOiKCzY9baOpL0TNU5sQZQ' },
1071
- payment: {
1072
- completed: true,
1073
- refunded: false,
1074
- },
1075
- start: { timestamp: '2023-03-30T16:52:40.000Z', timestampUNIX: 1680195160 },
1076
- expires: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1077
- cancelled: { timestamp: '1970-01-01T00:00:00.000Z', timestampUNIX: 0 },
1078
- lastPayment: {
1079
- amount: 0,
1080
- date: { timestamp: '2023-04-13T16:52:51.000Z', timestampUNIX: 1681404771 }
1081
- },
1082
- trial: {
1083
- active: false,
1084
- claimed: true,
1085
- daysLeft: 0,
1086
- },
1087
- }
1088
-
1089
- log('result', result);
1090
-
1091
- it('should resolve correctly', () => {
1092
- return assert.deepStrictEqual(result, expected);
1093
- });
1094
- });
1095
- });
1096
-
1097
- });
1098
-
1099
- /*
1100
- * COINBASE
1101
- */
1102
- describe('coinbase', () => {
1103
- describe('order', () => {
1104
- describe('regular', () => {
1105
- const item = require('./payment-resolver/coinbase/orders/regular.json');
1106
- const result = Manager.SubscriptionResolver(defaultProfileOrder, item).resolve(options);
1107
- const expected = {
1108
- processor: 'coinbase',
1109
- type: 'order',
1110
- status: 'cancelled',
1111
- frequency: 'single',
1112
- resource: { id: '8f783fa6-eaa3-4460-af64-cac26b183ed1' },
1113
- payment: {
1114
- completed: true,
1115
- refunded: false,
1116
- },
1117
- start: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1118
- expires: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1119
- cancelled: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1120
- lastPayment: {
1121
- amount: 16,
1122
- date: { timestamp: '2023-04-26T10:06:55.000Z', timestampUNIX: 1682503615 }
1123
- },
1124
- trial: {
1125
- active: false,
1126
- claimed: false,
1127
- daysLeft: 0,
1128
- },
1129
- }
1130
-
1131
- log('result', result);
1132
-
1133
- it('should resolve correctly', () => {
1134
- return assert.deepStrictEqual(result, expected);
1135
- });
1136
- });
1137
- });
1138
-
1139
- describe('subscription', () => {
1140
- describe('cancelled', () => {
1141
- const item = require('./payment-resolver/coinbase/subscriptions/cancelled.json');
1142
- const result = Manager.SubscriptionResolver(defaultProfileSubscription, item).resolve(options);
1143
- const expected = {
1144
- processor: 'coinbase',
1145
- type: 'subscription',
1146
- status: 'cancelled',
1147
- frequency: 'monthly',
1148
- resource: { id: '8f783fa6-eaa3-4460-af64-cac26b183ed1' },
1149
- payment: {
1150
- completed: true,
1151
- refunded: false,
1152
- },
1153
- start: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1154
- expires: { timestamp: '2023-05-26T09:59:19.000Z', timestampUNIX: 1685095159 },
1155
- cancelled: { timestamp: '2023-04-26T09:59:19.000Z', timestampUNIX: 1682503159 },
1156
- lastPayment: {
1157
- amount: 16,
1158
- date: { timestamp: '2023-04-26T10:06:55.000Z', timestampUNIX: 1682503615 }
1159
- },
1160
- trial: {
1161
- active: false,
1162
- claimed: false,
1163
- daysLeft: 0,
1164
- },
1165
- }
1166
-
1167
- log('result', result);
1168
-
1169
- it('should resolve correctly', () => {
1170
- return assert.deepStrictEqual(result, expected);
1171
- });
1172
- });
1173
- });
1174
- });
1175
-
1176
- });
1177
-
1178
- })