@antelopejs/payment-subscriptions 0.0.2 → 0.0.4
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 +154 -67
- package/dist/config.d.ts +3 -1
- package/dist/config.js.map +1 -1
- package/dist/engine.js +6 -1
- package/dist/engine.js.map +1 -1
- package/dist/implementation.js +12 -11
- package/dist/implementation.js.map +1 -1
- package/dist/schedule.js +5 -5
- package/dist/schedule.js.map +1 -1
- package/dist/triggers.js +27 -11
- package/dist/triggers.js.map +1 -1
- package/dist/view.js +12 -9
- package/dist/view.js.map +1 -1
- package/docs/1.introduction.md +50 -37
- package/docs/2.renewal-clock.md +89 -73
- package/docs/3.failed-renewals.md +123 -93
- package/docs/4.provider-schedule.md +29 -20
- package/docs/tsconfig.json +10 -0
- package/package.json +19 -8
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: The provider schedule
|
|
3
|
+
description: Why the module can mirror part of a subscription with a provider such as Mangopay, and how the providerSchedule extension point works.
|
|
4
|
+
mode: explanation
|
|
5
|
+
---
|
|
2
6
|
|
|
3
|
-
This module always owns the clock. Some providers
|
|
4
|
-
|
|
5
|
-
chain between charges
|
|
6
|
-
frequency, dates and amounts
|
|
7
|
-
the
|
|
7
|
+
This module always owns the clock. Some providers leave the merchant to fire
|
|
8
|
+
each charge, but still store the schedule if asked, and handle the
|
|
9
|
+
authentication chain between charges. The Recurring PayIn Registration of
|
|
10
|
+
Mangopay stores the frequency, the dates, and the amounts. It chains the first
|
|
11
|
+
payment, which the customer starts, to the later payments, which the merchant
|
|
12
|
+
starts. Mangopay still does not fire those payments.
|
|
8
13
|
|
|
9
|
-
For those, part of a subscription
|
|
10
|
-
in this module
|
|
14
|
+
For those providers, part of the state of a subscription can live with the
|
|
15
|
+
provider as well as in the database of this module. The extension point for it
|
|
16
|
+
is the `ProviderSchedule` interface in `src/schedule.ts`:
|
|
11
17
|
|
|
12
18
|
| Call | When | The default |
|
|
13
19
|
| ---------- | ---------------------------------------------- | ------------------------------ |
|
|
@@ -15,17 +21,20 @@ in this module's database. The seam for it is `ProviderSchedule`:
|
|
|
15
21
|
| `charge` | Each time a period is charged | An off-session `CreatePayment` |
|
|
16
22
|
| `release` | Once, when a subscription ends, for any reason | Does nothing |
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
`charge` and `release
|
|
20
|
-
throws for a decline
|
|
21
|
-
`CreatePayment` does.
|
|
24
|
+
The module stores what `register` returns with the subscription, and hands it
|
|
25
|
+
to every `charge` and `release` call. A schedule never decides when to charge.
|
|
26
|
+
It never throws for a decline either. A declined charge resolves with a
|
|
27
|
+
`failed` payment, as `CreatePayment` does.
|
|
22
28
|
|
|
23
|
-
`register` runs before the
|
|
24
|
-
key
|
|
25
|
-
registers anything real must tolerate that, or derive its
|
|
26
|
-
subscription
|
|
29
|
+
`register` runs before the module stores the subscription, and it receives no
|
|
30
|
+
idempotency key. Two creations that race on one key can therefore both call
|
|
31
|
+
it. A schedule that registers anything real must tolerate that, or derive its
|
|
32
|
+
own key from the subscription ID that it receives.
|
|
27
33
|
|
|
28
|
-
The
|
|
29
|
-
`payment-interface`, exists.
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
The `providerSchedule` setting chooses the schedule. Only the default,
|
|
35
|
+
`payment-interface`, exists. Any other name makes the module throw at
|
|
36
|
+
construction, with an error that lists the known names. A Mangopay schedule
|
|
37
|
+
would charge against the registration through an interface of the Mangopay
|
|
38
|
+
module itself. Everywhere else in AntelopeJS, provider-specific behaviour also
|
|
39
|
+
goes through the interface of the provider module, not through the portable
|
|
40
|
+
interfaces.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/payment-subscriptions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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",
|
|
@@ -42,23 +42,31 @@
|
|
|
42
42
|
"test:redis": "ANTELOPE_SUBSCRIPTIONS_TEST_CLOCK=redis ajs module test .",
|
|
43
43
|
"typecheck": "tsc --noEmit",
|
|
44
44
|
"format:check": "oxfmt --check .",
|
|
45
|
-
"knip": "knip"
|
|
45
|
+
"knip": "knip",
|
|
46
|
+
"prepare": "if git rev-parse --is-inside-work-tree >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1; then lefthook install; fi",
|
|
47
|
+
"checks": "antelopejs-checks",
|
|
48
|
+
"size": "antelopejs-check-size",
|
|
49
|
+
"sync": "antelopejs-sync",
|
|
50
|
+
"sync:check": "antelopejs-sync --check",
|
|
51
|
+
"suppressions": "antelopejs-suppressions",
|
|
52
|
+
"suppressions:update": "antelopejs-suppressions --update"
|
|
46
53
|
},
|
|
47
54
|
"dependencies": {
|
|
48
55
|
"@antelopejs/interface-core": ">=0.0.5 <1.0.0",
|
|
49
|
-
"@antelopejs/interface-database": "
|
|
56
|
+
"@antelopejs/interface-database": ">=0.2.0 <1.0.0",
|
|
50
57
|
"@antelopejs/interface-payment": ">=0.0.2 <1.0.0",
|
|
51
|
-
"@antelopejs/interface-subscriptions": ">=0.0
|
|
58
|
+
"@antelopejs/interface-subscriptions": ">=0.1.0 <0.2.0"
|
|
52
59
|
},
|
|
53
60
|
"devDependencies": {
|
|
54
61
|
"@antelopejs/core": "1.16.0",
|
|
55
|
-
"@antelopejs/mongodb": "^1.
|
|
62
|
+
"@antelopejs/mongodb": "^1.6.0",
|
|
56
63
|
"@antelopejs/redis": "^1.0.3",
|
|
57
|
-
"@antelopejs/tooling-configs": "^0.
|
|
64
|
+
"@antelopejs/tooling-configs": "^0.2.18",
|
|
58
65
|
"@types/mocha": "^10.0.10",
|
|
59
66
|
"@types/node": "^22.19.15",
|
|
60
67
|
"eslint-plugin-perfectionist": "^5.11.0",
|
|
61
68
|
"knip": "^6.34.0",
|
|
69
|
+
"lefthook": "^2.2.2",
|
|
62
70
|
"mongodb-memory-server-core": "^11.3.0",
|
|
63
71
|
"oxfmt": "^0.66.0",
|
|
64
72
|
"oxlint": "1.81.0",
|
|
@@ -71,7 +79,7 @@
|
|
|
71
79
|
},
|
|
72
80
|
"optionalDependencies": {
|
|
73
81
|
"@antelopejs/interface-redis": ">=0.0.6 <1.0.0",
|
|
74
|
-
"@antelopejs/interface-redis-scheduler": ">=0.0.
|
|
82
|
+
"@antelopejs/interface-redis-scheduler": ">=0.0.9 <1.0.0"
|
|
75
83
|
},
|
|
76
84
|
"packageManager": "pnpm@10.6.5",
|
|
77
85
|
"antelopeJs": {
|
|
@@ -82,6 +90,9 @@
|
|
|
82
90
|
"test": "src/test/antelope.test.ts",
|
|
83
91
|
"skills": [
|
|
84
92
|
"./skills"
|
|
85
|
-
]
|
|
93
|
+
],
|
|
94
|
+
"docs": {
|
|
95
|
+
"standard": true
|
|
96
|
+
}
|
|
86
97
|
}
|
|
87
98
|
}
|