@antelopejs/payment-subscriptions 0.0.5 → 0.0.6
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.
- package/README.md +49 -28
- package/dist/records.js +10 -6
- package/dist/records.js.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
<a href="https://github.com/AntelopeJS/antelopejs"><img data-illustration src="./.github/readme/strip.svg" width="100%" alt="PROVIDER · PAYMENT SUBSCRIPTIONS: part of AntelopeJS, hexagonal architecture beyond your own code. A glowing button reads Star AntelopeJS."></a>
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<a href="./docs/1.introduction.md"><img data-illustration alt="
|
|
4
|
+
|
|
5
|
+
# `@antelopejs/payment-subscriptions`
|
|
6
|
+
|
|
7
|
+
<a href="https://www.npmjs.com/package/@antelopejs/payment-subscriptions"><img data-illustration alt="npm" src="https://img.shields.io/npm/v/@antelopejs/payment-subscriptions?style=for-the-badge&labelColor=000000&color=000000"></a> <a href="./LICENSE"><img data-illustration alt="License" src="https://img.shields.io/npm/l/@antelopejs/payment-subscriptions?style=for-the-badge&labelColor=000000&color=000000"></a> <a href="https://discord.gg/g4pFt6eXqu"><img data-illustration alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000"></a> <a href="./docs/1.introduction.md"><img data-illustration alt="Documentation" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000"></a> <a href="https://github.com/AntelopeJS/antelopejs"><img data-illustration alt="Star AntelopeJS" src="https://img.shields.io/github/stars/AntelopeJS/antelopejs?label=Star%20AntelopeJS&style=for-the-badge&labelColor=000000&color=000000&logo=github"></a>
|
|
8
|
+
|
|
9
|
+
**Subscriptions for any AntelopeJS payment provider. It runs the renewal clock on saved payment methods and off-session charges.**
|
|
10
|
+
|
|
11
|
+
[Documentation](./docs/1.introduction.md) · [Interfaces](#compatibility) · [All interfaces and providers](https://github.com/AntelopeJS/antelopejs#ecosystem)
|
|
12
|
+
|
|
8
13
|
</div>
|
|
9
14
|
|
|
10
15
|
Subscriptions for any AntelopeJS payment provider. This module implements
|
|
@@ -14,9 +19,7 @@ It is the implementation for providers that leave each renewal to the merchant,
|
|
|
14
19
|
such as Adyen, Checkout.com, and Mangopay, and it works with any payment
|
|
15
20
|
provider.
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
22
|
+
## Install
|
|
20
23
|
|
|
21
24
|
```bash
|
|
22
25
|
ajs project modules add @antelopejs/payment-subscriptions
|
|
@@ -47,14 +50,14 @@ export default defineConfig({
|
|
|
47
50
|
source: {
|
|
48
51
|
type: "package",
|
|
49
52
|
package: "@antelopejs/payment-subscriptions",
|
|
50
|
-
version: "
|
|
53
|
+
version: ">=0.0.5 <0.1.0",
|
|
51
54
|
},
|
|
52
55
|
},
|
|
53
56
|
stripe: {
|
|
54
57
|
source: {
|
|
55
58
|
type: "package",
|
|
56
59
|
package: "@antelopejs/stripe",
|
|
57
|
-
version: "
|
|
60
|
+
version: "~1.2.2",
|
|
58
61
|
},
|
|
59
62
|
disabledExports: ["@antelopejs/interface-subscriptions"],
|
|
60
63
|
config: { apiKey: "REPLACE_VIA_ENV", webhookSecret: "REPLACE_VIA_ENV" },
|
|
@@ -63,7 +66,7 @@ export default defineConfig({
|
|
|
63
66
|
source: {
|
|
64
67
|
type: "package",
|
|
65
68
|
package: "@antelopejs/mongodb",
|
|
66
|
-
version: "
|
|
69
|
+
version: "~1.8.0",
|
|
67
70
|
},
|
|
68
71
|
config: { url: "REPLACE_VIA_ENV", database: "billing" },
|
|
69
72
|
},
|
|
@@ -135,6 +138,15 @@ No portable API reports that capability, and the module does not assume a
|
|
|
135
138
|
Stripe-style 24-hour window. See
|
|
136
139
|
[reconciliation and operational recovery](./docs/3.failed-renewals.md#reconciliation-and-operational-recovery).
|
|
137
140
|
|
|
141
|
+
## Testing
|
|
142
|
+
|
|
143
|
+
`pnpm test` runs the suite twice, once per clock. Both runs use a real MongoDB,
|
|
144
|
+
and the second run also uses a real Redis. The suite starts both. The
|
|
145
|
+
conformance suite of the interface runs in both. A test-only payment provider in
|
|
146
|
+
`test/payment-provider` stands in for the payment module, and it is never
|
|
147
|
+
published. The scripts run `ajs module test .` from the `@antelopejs/core`
|
|
148
|
+
version that `devDependencies` pins.
|
|
149
|
+
|
|
138
150
|
## Documentation
|
|
139
151
|
|
|
140
152
|
| Document | Contents |
|
|
@@ -148,14 +160,14 @@ Stripe-style 24-hour window. See
|
|
|
148
160
|
|
|
149
161
|
<!-- antelopejs-docs-compat:start -->
|
|
150
162
|
|
|
151
|
-
| Package | Supported
|
|
152
|
-
| --------------------------------------- |
|
|
153
|
-
| `@antelopejs/interface-core` | `>=0.
|
|
154
|
-
| `@antelopejs/interface-database` | `>=0.
|
|
155
|
-
| `@antelopejs/interface-payment` | `>=0.
|
|
156
|
-
| `@antelopejs/interface-redis` | `>=0.0.
|
|
157
|
-
| `@antelopejs/interface-redis-scheduler` | `>=0.0.
|
|
158
|
-
| `@antelopejs/interface-subscriptions` | `>=0.1.
|
|
163
|
+
| Package | Supported | Tested with |
|
|
164
|
+
| --------------------------------------- | ----------------- | ----------- |
|
|
165
|
+
| `@antelopejs/interface-core` | `>=0.5.1 <0.6.0` | `0.5.1` |
|
|
166
|
+
| `@antelopejs/interface-database` | `>=0.4.0 <0.5.0` | `0.4.0` |
|
|
167
|
+
| `@antelopejs/interface-payment` | `>=0.2.1 <0.3.0` | `0.2.1` |
|
|
168
|
+
| `@antelopejs/interface-redis` | `>=0.0.10 <0.1.0` | `0.0.10` |
|
|
169
|
+
| `@antelopejs/interface-redis-scheduler` | `>=0.0.12 <0.1.0` | `0.0.12` |
|
|
170
|
+
| `@antelopejs/interface-subscriptions` | `>=0.1.2 <0.2.0` | `0.1.2` |
|
|
159
171
|
|
|
160
172
|
<!-- antelopejs-docs-compat:end -->
|
|
161
173
|
|
|
@@ -163,15 +175,6 @@ The table lists the interface requirements in `package.json`. Provider modules
|
|
|
163
175
|
can add requirements of their own. Check the compatibility table of each
|
|
164
176
|
provider module that you wire.
|
|
165
177
|
|
|
166
|
-
## Testing
|
|
167
|
-
|
|
168
|
-
`pnpm test` runs the suite twice, once per clock. Both runs use a real MongoDB,
|
|
169
|
-
and the second run also uses a real Redis. The suite starts both. The
|
|
170
|
-
conformance suite of the interface runs in both. A test-only payment provider in
|
|
171
|
-
`test/payment-provider` stands in for the payment module, and it is never
|
|
172
|
-
published. The scripts run `ajs module test .` from the `@antelopejs/core`
|
|
173
|
-
version that `devDependencies` pins.
|
|
174
|
-
|
|
175
178
|
## Contributing
|
|
176
179
|
|
|
177
180
|
Read [CONTRIBUTING.md](./CONTRIBUTING.md). Use the Node.js version in `.nvmrc`
|
|
@@ -187,6 +190,24 @@ pnpm knip
|
|
|
187
190
|
|
|
188
191
|
The first test run downloads MongoDB and builds Redis, so it needs network access and a local C/C++ build toolchain. No Stripe credentials are required.
|
|
189
192
|
|
|
193
|
+
## Part of AntelopeJS
|
|
194
|
+
|
|
195
|
+
This package belongs to [AntelopeJS](https://github.com/AntelopeJS/antelopejs), the TypeScript framework where modules depend on contracts and the application chooses the provider. The open-source back office [AntelopeJS DMS](https://github.com/AntelopeJS/dms) is built on it.
|
|
196
|
+
|
|
197
|
+
<!-- antelopejs-framework-modules:start -->
|
|
198
|
+
|
|
199
|
+
| Area | Contracts | Providers |
|
|
200
|
+
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
201
|
+
| API | [`interface-api`](https://github.com/AntelopeJS/interface-api) · [`interface-api-util`](https://github.com/AntelopeJS/interface-api-util) · [`interface-data-api`](https://github.com/AntelopeJS/interface-data-api) | [`api`](https://github.com/AntelopeJS/api) |
|
|
202
|
+
| Auth | [`interface-auth`](https://github.com/AntelopeJS/interface-auth) | [`auth-jwt`](https://github.com/AntelopeJS/auth-jwt) |
|
|
203
|
+
| Database | [`interface-database`](https://github.com/AntelopeJS/interface-database) · [`interface-database-decorators`](https://github.com/AntelopeJS/interface-database-decorators) · [`interface-database-catalog`](https://github.com/AntelopeJS/interface-database-catalog) · [`interface-mongodb`](https://github.com/AntelopeJS/interface-mongodb) · [`interface-rethinkdb`](https://github.com/AntelopeJS/interface-rethinkdb) | [`postgres`](https://github.com/AntelopeJS/postgres) · [`mysql`](https://github.com/AntelopeJS/mysql) · [`mongodb`](https://github.com/AntelopeJS/mongodb) · [`rethinkdb`](https://github.com/AntelopeJS/rethinkdb) |
|
|
204
|
+
| Redis | [`interface-redis`](https://github.com/AntelopeJS/interface-redis) · [`interface-redis-scheduler`](https://github.com/AntelopeJS/interface-redis-scheduler) | [`redis`](https://github.com/AntelopeJS/redis) |
|
|
205
|
+
| Email | [`interface-email`](https://github.com/AntelopeJS/interface-email) | [`nodemailer`](https://github.com/AntelopeJS/nodemailer) · [`brevo`](https://github.com/AntelopeJS/brevo) |
|
|
206
|
+
| File storage | [`interface-file-storage`](https://github.com/AntelopeJS/interface-file-storage) | [`file-storage-local`](https://github.com/AntelopeJS/file-storage-local) · [`file-storage-s3`](https://github.com/AntelopeJS/file-storage-s3) |
|
|
207
|
+
| Payments | [`interface-payment`](https://github.com/AntelopeJS/interface-payment) · [`interface-subscriptions`](https://github.com/AntelopeJS/interface-subscriptions) · [`interface-stripe`](https://github.com/AntelopeJS/interface-stripe) | [`stripe`](https://github.com/AntelopeJS/stripe) · [`mollie`](https://github.com/AntelopeJS/mollie) · [`checkout-com`](https://github.com/AntelopeJS/checkout-com) · **`payment-subscriptions`** |
|
|
208
|
+
|
|
209
|
+
<!-- antelopejs-framework-modules:end -->
|
|
210
|
+
|
|
190
211
|
## License
|
|
191
212
|
|
|
192
213
|
[Apache-2.0](./LICENSE)
|
package/dist/records.js
CHANGED
|
@@ -23,11 +23,11 @@ function NewRevision() {
|
|
|
23
23
|
return (0, node_crypto_1.randomUUID)();
|
|
24
24
|
}
|
|
25
25
|
async function LoadRecord(id) {
|
|
26
|
-
return (await table().get(id)) ?? undefined;
|
|
26
|
+
return (await table().get(id).run()) ?? undefined;
|
|
27
27
|
}
|
|
28
28
|
async function InsertRecord(record) {
|
|
29
29
|
try {
|
|
30
|
-
await table().insert(record);
|
|
30
|
+
await table().insert(record).run();
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
@@ -38,13 +38,15 @@ async function InsertRecord(record) {
|
|
|
38
38
|
}
|
|
39
39
|
async function MutateRecord(record, patch) {
|
|
40
40
|
const nextRevision = NewRevision();
|
|
41
|
-
const outcome = await table()
|
|
41
|
+
const outcome = await table()
|
|
42
|
+
.atomicMutation(record._id, {
|
|
42
43
|
type: "update",
|
|
43
44
|
revisionField: "revision",
|
|
44
45
|
expectedRevision: record.revision,
|
|
45
46
|
nextRevision,
|
|
46
47
|
patch,
|
|
47
|
-
})
|
|
48
|
+
})
|
|
49
|
+
.run();
|
|
48
50
|
if (outcome !== "applied")
|
|
49
51
|
return undefined;
|
|
50
52
|
return { ...record, ...patch, revision: nextRevision };
|
|
@@ -53,7 +55,8 @@ async function DueRecordIds(now, limit) {
|
|
|
53
55
|
const due = await table()
|
|
54
56
|
.filter((record) => record.key("dueAt").ne(NOT_DUE).and(record.key("dueAt").le(now)))
|
|
55
57
|
.orderBy("dueAt", "asc")
|
|
56
|
-
.slice(0, limit)
|
|
58
|
+
.slice(0, limit)
|
|
59
|
+
.run();
|
|
57
60
|
return due.map((record) => record._id);
|
|
58
61
|
}
|
|
59
62
|
async function CustomerRecords(customer, provider) {
|
|
@@ -63,6 +66,7 @@ async function CustomerRecords(customer, provider) {
|
|
|
63
66
|
.eq(customer)
|
|
64
67
|
.and(record.key("provider").eq(provider))
|
|
65
68
|
.and(record.key("phase").eq("live")))
|
|
66
|
-
.orderBy("createdOrder", "desc")
|
|
69
|
+
.orderBy("createdOrder", "desc")
|
|
70
|
+
.run();
|
|
67
71
|
}
|
|
68
72
|
//# sourceMappingURL=records.js.map
|
package/dist/records.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":";;AAqFA,kCAEC;AAED,gCAIC;AAED,oCAUC;AAED,
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":";;AAqFA,kCAEC;AAED,gCAIC;AAED,oCAUC;AAED,oCAgBC;AAED,oCAYC;AAED,0CAcC;AAzJD,6CAAyC;AACzC,uEAAwD;AAsExD,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAC1C,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB,MAAM,MAAM,GAAG,IAAI,2BAAM,CAAS,SAAS,EAAE;IAC3C,aAAa,EAAE;QACb,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;KACrC;CACF,CAAC,CAAC;AAEH,SAAS,KAAK;IACZ,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,WAAW;IACzB,OAAO,IAAA,wBAAU,GAAE,CAAC;AACtB,CAAC;AAEM,KAAK,UAAU,UAAU,CAC9B,EAAU;IAEV,OAAO,CAAC,MAAM,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC;AACpD,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,MAA0B;IAE1B,IAAI,CAAC;QACH,MAAM,KAAK,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAA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,MAAM,EAAE,EAAE,CACjB,MAAM;SACH,GAAG,CAAC,UAAU,CAAC;SACf,EAAE,CAAC,QAAQ,CAAC;SACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;SACxC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CACvC;SACA,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC;SAC/B,GAAG,EAAE,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/payment-subscriptions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Generic AntelopeJS subscriptions on top of any payment interface provider: saved methods charged off-session, on a renewal clock the module owns",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rimraf dist && tsc",
|
|
35
35
|
"format": "oxfmt .",
|
|
36
|
-
"lint": "oxlint
|
|
36
|
+
"lint": "oxlint",
|
|
37
37
|
"lint:fix": "oxlint --fix",
|
|
38
38
|
"prepack": "pnpm run build",
|
|
39
39
|
"release": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run prepack && release-it",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"suppressions:update": "antelopejs-suppressions --update"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@antelopejs/interface-core": ">=0.
|
|
56
|
-
"@antelopejs/interface-database": ">=0.
|
|
57
|
-
"@antelopejs/interface-payment": ">=0.
|
|
58
|
-
"@antelopejs/interface-subscriptions": ">=0.1.
|
|
55
|
+
"@antelopejs/interface-core": ">=0.5.1 <0.6.0",
|
|
56
|
+
"@antelopejs/interface-database": ">=0.4.0 <0.5.0",
|
|
57
|
+
"@antelopejs/interface-payment": ">=0.2.1 <0.3.0",
|
|
58
|
+
"@antelopejs/interface-subscriptions": ">=0.1.2 <0.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@antelopejs/core": "1.
|
|
62
|
-
"@antelopejs/mongodb": "
|
|
63
|
-
"@antelopejs/redis": "
|
|
64
|
-
"@antelopejs/tooling-configs": "
|
|
61
|
+
"@antelopejs/core": "~1.23.0",
|
|
62
|
+
"@antelopejs/mongodb": "~1.8.0",
|
|
63
|
+
"@antelopejs/redis": "~1.1.1",
|
|
64
|
+
"@antelopejs/tooling-configs": ">=0.6.0 <0.7.0",
|
|
65
65
|
"@types/mocha": "^10.0.10",
|
|
66
66
|
"@types/node": "^22.19.15",
|
|
67
67
|
"@types/semver": "^7.8.0",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"typescript": "^5.9.3"
|
|
81
81
|
},
|
|
82
82
|
"optionalDependencies": {
|
|
83
|
-
"@antelopejs/interface-redis": ">=0.0.
|
|
84
|
-
"@antelopejs/interface-redis-scheduler": ">=0.0.
|
|
83
|
+
"@antelopejs/interface-redis": ">=0.0.10 <0.1.0",
|
|
84
|
+
"@antelopejs/interface-redis-scheduler": ">=0.0.12 <0.1.0"
|
|
85
85
|
},
|
|
86
86
|
"packageManager": "pnpm@10.6.5",
|
|
87
87
|
"antelopeJs": {
|