@buffcore/payments 0.0.0-stage → 0.8.39
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +104 -2
- package/dist/admin/PaymentsLists.d.ts +12 -0
- package/dist/admin/PaymentsLists.js +93 -0
- package/dist/admin/PaymentsScreen.d.ts +1 -0
- package/dist/admin/PaymentsScreen.js +23 -0
- package/dist/admin/PaymentsView.d.ts +23 -0
- package/dist/admin/PaymentsView.js +32 -0
- package/dist/admin/i18n/en.d.ts +47 -0
- package/dist/admin/i18n/en.js +47 -0
- package/dist/admin/i18n/es.json +45 -0
- package/dist/admin/index.d.ts +96 -0
- package/dist/admin/index.js +31 -0
- package/dist/admin-routes.d.ts +2 -0
- package/dist/admin-routes.js +47 -0
- package/dist/app/BillingScreen.d.ts +9 -0
- package/dist/app/BillingScreen.js +85 -0
- package/dist/app/BillingView.d.ts +19 -0
- package/dist/app/BillingView.js +33 -0
- package/dist/app/CurrentPlan.d.ts +10 -0
- package/dist/app/CurrentPlan.js +35 -0
- package/dist/app/FailedPaymentNotice.d.ts +9 -0
- package/dist/app/FailedPaymentNotice.js +13 -0
- package/dist/app/i18n/en.d.ts +32 -0
- package/dist/app/i18n/en.js +34 -0
- package/dist/app/i18n/es.json +30 -0
- package/dist/app/index.d.ts +69 -0
- package/dist/app/index.js +16 -0
- package/dist/apply.d.ts +8 -0
- package/dist/apply.js +111 -0
- package/dist/billing.d.ts +20 -0
- package/dist/billing.js +20 -0
- package/dist/collected-lines.d.ts +7 -0
- package/dist/collected-lines.js +14 -0
- package/dist/contract.d.ts +422 -0
- package/dist/contract.js +169 -0
- package/dist/entity.d.ts +294 -0
- package/dist/entity.js +101 -0
- package/dist/items.d.ts +20 -0
- package/dist/items.js +75 -0
- package/dist/line-amount.d.ts +5 -0
- package/dist/line-amount.js +11 -0
- package/dist/line-events.d.ts +7 -0
- package/dist/line-events.js +39 -0
- package/dist/lines.d.ts +76 -0
- package/dist/lines.js +53 -0
- package/dist/locales/en.d.ts +35 -0
- package/dist/locales/en.js +37 -0
- package/dist/locales/es.json +33 -0
- package/dist/migrations/0001-init.d.ts +2 -0
- package/dist/migrations/0001-init.js +17 -0
- package/dist/migrations/0002-paid-lines.d.ts +2 -0
- package/dist/migrations/0002-paid-lines.js +9 -0
- package/dist/migrations/0003-subscription-items.d.ts +3 -0
- package/dist/migrations/0003-subscription-items.js +7 -0
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.js +4 -0
- package/dist/plans.d.ts +7 -0
- package/dist/plans.js +29 -0
- package/dist/price.d.ts +4 -0
- package/dist/price.js +8 -0
- package/dist/privacy.d.ts +74 -0
- package/dist/privacy.js +43 -0
- package/dist/provider.d.ts +119 -0
- package/dist/provider.js +25 -0
- package/dist/refund-split.d.ts +4 -0
- package/dist/refund-split.js +20 -0
- package/dist/routes.d.ts +4 -0
- package/dist/routes.js +116 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.js +59 -0
- package/dist/settings.d.ts +32 -0
- package/dist/settings.js +32 -0
- package/dist/status.d.ts +14 -0
- package/dist/status.js +80 -0
- package/dist/stripe-api.d.ts +21 -0
- package/dist/stripe-api.js +62 -0
- package/dist/stripe-items.d.ts +7 -0
- package/dist/stripe-items.js +40 -0
- package/dist/stripe-lines.d.ts +11 -0
- package/dist/stripe-lines.js +76 -0
- package/dist/stripe-portal.d.ts +5 -0
- package/dist/stripe-portal.js +47 -0
- package/dist/stripe.d.ts +3 -0
- package/dist/stripe.js +200 -0
- package/dist/subscription-items.d.ts +18 -0
- package/dist/subscription-items.js +28 -0
- package/dist/sync.d.ts +14 -0
- package/dist/sync.js +41 -0
- package/package.json +96 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,105 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @buffcore/payments
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An extension (docs/EXTENSIONS.md): the product's plans and one-off payments through Stripe Checkout, Stripe's customer portal to change plan, update the card or cancel, and failed payments in the console. Test mode by default. BuffApe's own billing is its first user; it moves onto F3's money ledger when that arrives.
|
|
4
|
+
|
|
5
|
+
- **Install:** `pnpm ape add @buffcore/payments` shows what it asks for (it holds `contact`, the address each customer gives Stripe, and calls `api.stripe.com` only) and writes its grant. **Remove:** `pnpm ape remove payments` (`--drop-tables` drops its tables first).
|
|
6
|
+
- **Its key:** `STRIPE_SECRET_KEY` in the server's environment (a restricted `rk_` key works too). Nothing else: Checkout and the portal are Stripe's pages, so no publishable key, and the webhook is never trusted, so no signing secret.
|
|
7
|
+
|
|
8
|
+
## Set it up
|
|
9
|
+
|
|
10
|
+
1. **The plans,** in the product's composition (`apps/api/src/app.ts`), with their names in the product's catalog:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
defineApp({
|
|
14
|
+
product,
|
|
15
|
+
modules,
|
|
16
|
+
settings: { payments: { plans: { plus: { name: 'myapp.plans.plus', description: 'myapp.plans.plusAbout' } } } },
|
|
17
|
+
catalogs: [{ en: { 'myapp.plans.plus': 'Plus', … }, es: { … } }],
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
A plan's key is its Stripe price's **lookup key**: give the test price and the live price the same one, and the setting works in both modes. A price that recurs is a subscription; one that doesn't is a one-off payment. Up to 10 plans. Set `quantity: true` to allow more than one of a plan, and `addOn: true` to let it sit beside other plans. Both are optional and default to false.
|
|
22
|
+
2. **In Stripe:** an active price with a fixed amount for each plan, its lookup key the plan's key, and the customer emails (receipts, failed payments) on. Nothing else: payments gives the portal its own configuration through the API (below). Make a price in the Dashboard (a product with a price; set the price's lookup key), or through the API; this one is a recurring plan `plus`, 5.00 USD a month, and a one-off plan leaves out `recurring[interval]`:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
curl https://api.stripe.com/v1/prices -u "$STRIPE_SECRET_KEY:" -d lookup_key=plus -d currency=usd \
|
|
26
|
+
-d unit_amount=500 -d "recurring[interval]=month" -d "product_data[name]=Plus"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Make the live price the same way with the live key. A lookup key belongs to one price in a Stripe account (test and live apart), so look before you make: if the key is taken (an earlier try, a shared sandbox), `curl -u "$STRIPE_SECRET_KEY:" -G https://api.stripe.com/v1/prices -d "lookup_keys[]=plus"` shows that price. Use it when its amount and interval are the plan's; else make the new one with `-d transfer_lookup_key=true`, which moves the key to it.
|
|
30
|
+
3. **The webhook,** on a server Stripe can reach: an endpoint at `<APE_API_URL>/v1/ext/payments/events` for `checkout.session.completed` and `checkout.session.async_payment_succeeded`, `customer.subscription.*`, `invoice.paid`, `invoice.payment_failed` and `invoice.voided`. Without one (`ape dev`, a server with no public address), the worker reads the events each minute anyway.
|
|
31
|
+
4. **Live:** a test key (`sk_test_…`) works anywhere; a live key only when `APE_ENV` is `production`. Development, tests and staging refuse it, and the console says so: they never charge a real card.
|
|
32
|
+
|
|
33
|
+
**The webhook is never trusted:** its body is never read (so it carries no signature to check); it only asks the worker to read Stripe's events now, from Stripe's API with the secret key, and a flood of calls makes one waiting read.
|
|
34
|
+
|
|
35
|
+
## Paying in test mode
|
|
36
|
+
|
|
37
|
+
In a browser, pay Checkout with Stripe's test card `4242 4242 4242 4242` (any future date, any CVC). Without one (an agent, a script), make what Checkout would for a subscription, with the test key; a one-off plan is recorded from Checkout's own event, so pay that one in a browser:
|
|
38
|
+
|
|
39
|
+
1. Start a checkout as the member once (the billing screen's button, or `payments.start_checkout`): it makes the account's Stripe customer, whose ID is `customer_id` in `payments_customers`. Subscribe that customer, not another, or payments can't tell whose it is.
|
|
40
|
+
2. Attach Stripe's test payment method and make it the customer's default (`$cus` is the customer's ID; `$pm` the `id` that the attach answers):
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
curl https://api.stripe.com/v1/payment_methods/pm_card_visa/attach -u "$STRIPE_SECRET_KEY:" -d customer=$cus
|
|
44
|
+
curl https://api.stripe.com/v1/customers/$cus -u "$STRIPE_SECRET_KEY:" -d "invoice_settings[default_payment_method]=$pm"
|
|
45
|
+
```
|
|
46
|
+
3. Subscribe it to the plan's price (`$price` is the `id` that `curl -u "$STRIPE_SECRET_KEY:" -G https://api.stripe.com/v1/prices -d "lookup_keys[]=plus"` gives):
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
curl https://api.stripe.com/v1/subscriptions -u "$STRIPE_SECRET_KEY:" -d customer=$cus -d "items[0][price]=$price"
|
|
50
|
+
```
|
|
51
|
+
4. Ask the worker to read Stripe's events now, rather than within the minute: `curl -X POST <APE_API_URL>/v1/ext/payments/events` (the address is in the product's `.env`). The billing screen then shows the plan active.
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
1. **The billing screen** reads `payments.get_billing` (`GET /v1/ext/payments/accounts/:accountId`): the plans with Stripe's prices (one call to Stripe), the account's subscription, a payment that failed, and the one-off plans it paid for.
|
|
56
|
+
2. **Paying** (`payments.start_checkout`, `POST …/accounts/:accountId/checkout`) takes `{ plan, returnTo? }` for one item of quantity 1 or `{ items: [{ plan, quantity }], returnTo? }`. A signed-in member needs the `payments.start_checkout` right on the account in the path. The server resolves the configured plan keys to active provider prices. Price IDs, amounts and currency come from the provider, which charges tax using its own settings. Checkout creates the account's customer once, returns the hosted payment page and audits the member and account IDs. A second recurring checkout while the account has a live subscription is refused.
|
|
57
|
+
|
|
58
|
+
`payments.returnPaths` in the app composition defaults to `['/payments']`. To send the member elsewhere after payment or cancellation, list the exact case-sensitive app paths, for example `['/payments', '/account/thanks']`, and pass one as `returnTo`. Entries start with `/` and use letters, digits, `/`, `.`, `_`, `~` or `-`, with no doubled slashes or dot segments. Omit `returnTo` for `/payments`. Checkout refuses unlisted paths and appends `?paid=<plan>` on success. The billing screen uses that marker to ask the worker to check the provider. A custom return page gets `?paid=<plan>`, and fulfilment waits for the minute sync unless the product calls `check_events` from that page. Fulfil a purchase from the provider-confirmed event.
|
|
59
|
+
|
|
60
|
+
In an app screen, use the `startCheckout` route from `@buffcore/payments/app` with the SDK. In an installed extension's handler, declare `uses: ['payments.start_checkout']` and call `useAction(ctx, 'payments.start_checkout', { params: { accountId }, body: { plan, returnTo } })`. The usual extension installation grant suffices. Both calls use the member's rights and checkout rules. A rule can hold the call for a person, in which case it returns `waiting` in place of the URL. The offer is available to extensions using a member session. API keys, MCP clients and agents cannot start checkout.
|
|
61
|
+
|
|
62
|
+
**Known limit.** `payments.start_checkout` is high-risk and always-human. With Automation enabled, an Owner's `approve` rule for people holds the call. The approved run does not return the hosted URL to the member, and a retry is held again. Leave checkout without an `approve` rule for people in this release.
|
|
63
|
+
|
|
64
|
+
**The portal** (`payments.open_portal`, `POST …/accounts/:accountId/portal`) returns the account's portal URL. Its configuration lists the recurring plans the member may switch between, with proration, and allows card updates, cancellation at the period's end and reading invoices. Payments rebuilds the configuration when the recurring price IDs change. The portal returns to `/payments`.
|
|
65
|
+
3. **Stripe's events:** the worker's `payments.sync` (each minute, and at once when `POST /v1/ext/payments/events` is called) lists the new events from Stripe's API with the secret key, oldest first, and applies each once: its ID is written in the transaction of its changes (`payments_events`, kept 29 days: Stripe keeps events 30). The webhook's body is never read, so a forged call can only make the worker look sooner. A subscription or an invoice is read again from Stripe, so its state is the newest whatever order the events came in. Each read that worked is noted in Redis, and Operations › Status's line "Stripe events" (`payments.events`) says when the last was: healthy within 5 minutes, then down; unknown before the first; down with a live key refused; off while payments are off.
|
|
66
|
+
4. **Receipts:** Stripe's own. It emails them (a dashboard setting), and the portal lists every invoice with its PDF; a one-off payment gets an invoice too. BuffCore records paid lines; receipts stay at Stripe.
|
|
67
|
+
5. **Failed payments:** Stripe retries them and emails the customer. A failed try is a row until the invoice is paid or voided; the account sees it with the way to update the card, the Owner in the console.
|
|
68
|
+
6. **The console's reads** (the Owner): `payments.get_overview` (the mode, the plans with their prices, the counts), and `payments.list_subscriptions` and `payments.list_failed_payments`, audited sensitive reads.
|
|
69
|
+
|
|
70
|
+
### Subscription items
|
|
71
|
+
|
|
72
|
+
Once any plan enables `quantity` or `addOn`, the portal keeps the card, cancellation and receipts while plan switching goes through `change_items`; products using neither setting keep the portal's plan switch.
|
|
73
|
+
|
|
74
|
+
**For the product's owner:** if someone swaps a subscriber's price in Stripe's dashboard to one Payments has never seen, the subscriber keeps the access they had on that subscription, and Operations › Status flags it until the price is set right in Stripe.
|
|
75
|
+
|
|
76
|
+
Dashboard edits are stored exactly as Stripe reports them, and `payments.items` on Operations › Status names the first live subscription with unnamed prices or a structural rule violation, without correcting Stripe; retired plans are normal, and checks read at most 1,000 live rows with “at least” counts when more exist (unknown if the unexamined rows may hold a problem).
|
|
77
|
+
|
|
78
|
+
Checkout accepts either `plan` or `items`, plus the optional `returnTo`. Extra checkout fields, including fields inside an item, are refused. Write quantities stay between 1 and 999; reads accept any non-negative integer reported by Stripe.
|
|
79
|
+
|
|
80
|
+
Subscribers keep their locked prices when a lookup key moves: Payments stores each item's price ID internally and names a keyless price only from that same stored ID; a legacy row's earlier plan can name one remaining keyless item when every other item is already named, including seats added before the first sync. Product IDs never name a price. Changing a retained item's quantity keeps its existing Stripe price; only removed or newly added plans delete or add items.
|
|
81
|
+
|
|
82
|
+
Migration `0003-subscription-items` adds one internal list for every reported price: `{ priceId, plan?, quantity }`, with `plan` absent while unnamed. Reads expose only named entries as `{ plan, quantity }`; while an unnamed price leaves no named base plan, the account keeps its earlier `plan` and access follows the subscription's status. A price swap alone then emits no subscription change. An unnamed price degrades Status and refuses `change_items` in English or Spanish, directing the person to Stripe's dashboard, including when a fresh Stripe read finds it before its event was synced. The privacy export's `items` list includes every entry's quantity and its plan when known, without internal price IDs.
|
|
83
|
+
|
|
84
|
+
A subscription has 1–10 items, each `{ plan, quantity }` (quantity 1–999). It holds at most one base plan (a plan without `addOn: true`); every plan appears once, and a quantity above 1 needs `quantity: true`. All prices must use the same currency and billing interval, including its interval count. A one-off price works alone, including with quantity, and cannot sit among several items. Unknown plans and plans without a Stripe price are refused.
|
|
85
|
+
|
|
86
|
+
`payments.change_items` (`PUT /v1/ext/payments/accounts/:accountId/items { items }`) replaces a live subscription's items. Its account Owner, or a member whose role has `payments.change_items`, may call it. It is closed to machines and agents and marked high risk, always human. Server code calls `changeItems(ctx, accountId, items)` from `@buffcore/payments`; it goes through the same action and rights checks. Checkout and changes share the same item rules; changes require recurring prices. Stripe prorates the change on the next invoice using its default behavior. Payments reads Stripe's item IDs for the change and never stores them.
|
|
87
|
+
|
|
88
|
+
The action writes no local subscription state. Stripe's next report rewrites the whole `items` column. `subscriptionOf`, `get_billing` and the console's subscription list return `items: [{ plan, quantity }]` beside `plan`. That compatibility field is the base plan, or the first item when all are add-ons. Rows from before migration `0003-subscription-items` read as one item `{ plan, quantity: 1 }` until Stripe reports them again.
|
|
89
|
+
|
|
90
|
+
`payments.item_changed` is about `payments_customer`, with props `{ plan, from, to }`: the old and new quantities, 0 when added or removed. Each named difference emits one event; unchanged reports emit none, and removals are not inferred while an unnamed price might be an earlier named item. Its allowed plan keys are declared once at composition from the settings. Provider items whose lookup keys are no longer configured remain in reads, but emit no item event for that undeclared key. `payments.subscription_changed` keeps its existing meaning (a status or base-plan change).
|
|
91
|
+
|
|
92
|
+
## Its parts
|
|
93
|
+
|
|
94
|
+
- **Its tables:** `payments_customers` (one per account, from its first Checkout: its Stripe customer, the address it gave Stripe, its subscription's base plan and items, state `active`, `past_due` or `canceled`, period end and whether it ends then), `payments_payments` (one-off payments, paid; failed subscription payments, until paid) and `payments_events` (the events applied).
|
|
95
|
+
- **Its events:** `payments.subscription_changed` (props: `status`), `payments.paid` and `payments.payment_failed`, about the customer row or the payment. `payments.line_paid` is a system event carrying `accountId`, the local `lineId`, `lineType`, tax-exclusive `amount` and `currency`. `payments.line_refunded` carries `lineId`, signed net `amount` and `currency`; read the original type with `paidLineOf`, including after configuration removes it. No address in them.
|
|
96
|
+
- **Paid lines:** `payments_payment_lines` holds each positive line's share of collected net (money collected minus charged tax), separate `tax`, and cumulative `refundedAmount` and `refundedTax`. Discounts, credit lines and customer credit balances reduce what earns; zero shares are skipped. Set `payments.lineTypes` beside `payments.plans` to map Stripe price lookup keys to types (for example `{ seats: 'seat', cloud: 'hosting' }`); unmapped prices use `plan`. Paid-event types are declared at composition. `paidLinesOf(em, accountId)` lists an account's lines, and `paidLineOf(em, lineId)` resolves a line event.
|
|
97
|
+
- **For the product's own code,** on the server (`@buffcore/payments`): `subscriptionOf(ctx, accountId)` gives `{ plan, items, status, periodEnd, ending }`, or `null` when the account has no subscription (none yet, or only a one-off payment). **Paid up is `status === 'active'`:** Stripe's `active` and `trialing`, and a subscription cancelled in the portal, which stays `active` (`ending` is true) until `periodEnd`. `past_due` is a payment Stripe is still retrying (its other unpaid states read this way too): the product decides whether that locks, or leaves the member in until it is `canceled`, which has ended. So a paid post opens when `sub?.plan === 'member' && sub.status === 'active'`. `paymentOf(ctx, id)` is for a subscriber to `payments.paid`. In the app (`@buffcore/payments/app`): `getBilling` (the plans with their prices and the account's subscription, read with `useRoute(getBilling, { params: { accountId } })`) and `priceText` (a price in the reader's words), to show a plan's price on the product's own screen.
|
|
98
|
+
- **In a product's test,** give an account a plan by writing its `payments_customers` row with SQL (`id`, `account_id`, `customer_id`, `plan` and `status`; the entity isn't exported).
|
|
99
|
+
- **Privacy:** an account's export holds `payments/billing.json`; deleting the account deletes its rows and its customer at Stripe (a job), which ends its subscription at once. Stripe keeps its invoices.
|
|
100
|
+
- **No vendor lock-in:** `PaymentProvider` (`provider.ts`) is the interface, with the calls payments make and no more; `stripe.ts` is its one implementation, its API version pinned.
|
|
101
|
+
- **Its screens** (approved provisionally, BC-D11): the app's `BillingScreen` ("Plan and billing", its views `BillingView` and `FailedPaymentNotice`, which a product may show anywhere) opens Stripe's pages in the same tab and, back from Checkout, waits for the plan to show; the console's Payments section (the Owner, `PaymentsScreen` and its view `PaymentsView`) only reads. The product's route, at `/payments`, is one line: `export { BillingScreen as default } from '@buffcore/payments/app';`.
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
Apache-2.0. Copyright © 2026 BuffApe. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FailedRow, Plan, SubscriptionRow } from '../contract.ts';
|
|
2
|
+
export declare function SubscriptionList(props: {
|
|
3
|
+
rows: readonly SubscriptionRow[];
|
|
4
|
+
plans: readonly Plan[];
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function FailedList(props: {
|
|
7
|
+
rows: readonly FailedRow[];
|
|
8
|
+
plans: readonly Plan[];
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export declare function PlanList({ plans }: {
|
|
11
|
+
plans: readonly Plan[];
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// The console's three lists: subscriptions with their state, failed payments, and the plans.
|
|
3
|
+
import { Badge, DataList, useFormat } from '@buffcore/admin-shell';
|
|
4
|
+
import { formatDate, formatMoney } from '@buffcore/i18n';
|
|
5
|
+
import { useLocale, useT } from '@buffcore/i18n/react';
|
|
6
|
+
import { priceText } from '../price.js';
|
|
7
|
+
const mono = { fontFamily: 'var(--font-mono)', fontSize: 'var(--font-size-caption)' };
|
|
8
|
+
const planName = (plans, key) => plans.find((p) => p.key === key)?.name ?? key;
|
|
9
|
+
function StateBadge({ row }) {
|
|
10
|
+
const t = useT();
|
|
11
|
+
if (row.status === 'past_due')
|
|
12
|
+
return (_jsx(Badge, { tone: "attention", icon: "triangle-alert", children: t('payments.admin.state.past_due') }));
|
|
13
|
+
if (row.status === 'canceled')
|
|
14
|
+
return _jsx(Badge, { children: t('payments.admin.state.canceled') });
|
|
15
|
+
if (row.ending)
|
|
16
|
+
return (_jsx(Badge, { tone: "neutral", icon: "clock", children: t('payments.admin.state.ending') }));
|
|
17
|
+
return (_jsx(Badge, { tone: "success", icon: "circle-check", children: t('payments.admin.state.active') }));
|
|
18
|
+
}
|
|
19
|
+
export function SubscriptionList(props) {
|
|
20
|
+
const t = useT();
|
|
21
|
+
const { locale } = useLocale();
|
|
22
|
+
const when = (row) => {
|
|
23
|
+
if (!row.periodEnd)
|
|
24
|
+
return '';
|
|
25
|
+
const date = formatDate(locale, row.periodEnd);
|
|
26
|
+
if (row.status === 'canceled')
|
|
27
|
+
return t('payments.admin.endedOn', { date });
|
|
28
|
+
return t(row.ending ? 'payments.admin.endsOn' : 'payments.admin.renewsOn', { date });
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(DataList, { label: t('payments.admin.tabs.subscriptions'), cols: [
|
|
31
|
+
{ k: t('payments.admin.cols.email'), w: 'minmax(0,2.2fr)' },
|
|
32
|
+
{ k: t('payments.admin.cols.plan'), w: 'minmax(0,1.2fr)' },
|
|
33
|
+
{ k: t('payments.admin.cols.state'), w: 'minmax(0,1.2fr)' },
|
|
34
|
+
{ k: t('payments.admin.cols.period'), w: 'minmax(0,1.6fr)' },
|
|
35
|
+
], rows: props.rows.map((row) => ({
|
|
36
|
+
id: row.id,
|
|
37
|
+
cells: [
|
|
38
|
+
{ v: row.email ?? t('payments.admin.noEmail') },
|
|
39
|
+
{ v: planName(props.plans, row.plan) },
|
|
40
|
+
{ v: row.status, el: _jsx(StateBadge, { row: row }) },
|
|
41
|
+
{ v: when(row), sort: row.periodEnd ?? '' },
|
|
42
|
+
],
|
|
43
|
+
})), empty: t('payments.admin.emptySubscriptions') }));
|
|
44
|
+
}
|
|
45
|
+
export function FailedList(props) {
|
|
46
|
+
const t = useT();
|
|
47
|
+
const f = useFormat();
|
|
48
|
+
const { locale } = useLocale();
|
|
49
|
+
return (_jsx(DataList, { label: t('payments.admin.tabs.failed'), cols: [
|
|
50
|
+
{ k: t('payments.admin.cols.email'), w: 'minmax(0,2.2fr)' },
|
|
51
|
+
{ k: t('payments.admin.cols.plan'), w: 'minmax(0,1.2fr)' },
|
|
52
|
+
{ k: t('payments.admin.cols.failedAt'), w: 'minmax(0,1.6fr)' },
|
|
53
|
+
// Last, at the row's end: an amount reads against its column, apart from the date.
|
|
54
|
+
{ k: t('payments.admin.cols.amount'), w: 'minmax(0,1fr)', end: true },
|
|
55
|
+
], rows: props.rows.map((row) => ({
|
|
56
|
+
id: row.id,
|
|
57
|
+
cells: [
|
|
58
|
+
{ v: row.email ?? t('payments.admin.noEmail') },
|
|
59
|
+
{ v: planName(props.plans, row.plan) },
|
|
60
|
+
{ v: f.dateTime(row.at), sort: row.at },
|
|
61
|
+
{ v: formatMoney(locale, row.amount, row.currency), sort: row.amount },
|
|
62
|
+
],
|
|
63
|
+
})), empty: t('payments.admin.emptyFailed') }));
|
|
64
|
+
}
|
|
65
|
+
export function PlanList({ plans }) {
|
|
66
|
+
const t = useT();
|
|
67
|
+
const { locale } = useLocale();
|
|
68
|
+
return (_jsx(DataList, { label: t('payments.admin.tabs.plans'), cols: [
|
|
69
|
+
{ k: t('payments.admin.cols.plan'), w: 'minmax(0,1.4fr)' },
|
|
70
|
+
{ k: t('payments.admin.cols.key'), w: 'minmax(0,1.2fr)' },
|
|
71
|
+
{ k: t('payments.admin.cols.price'), w: 'minmax(0,1.6fr)' },
|
|
72
|
+
{ k: t('payments.admin.cols.kind'), w: 'minmax(0,1fr)' },
|
|
73
|
+
], rows: plans.map((plan) => ({
|
|
74
|
+
id: plan.key,
|
|
75
|
+
cells: [
|
|
76
|
+
{ v: plan.name },
|
|
77
|
+
{ v: plan.key, el: _jsx("span", { style: mono, children: plan.key }) },
|
|
78
|
+
plan.price
|
|
79
|
+
? { v: priceText(t, locale, plan.price) }
|
|
80
|
+
: {
|
|
81
|
+
v: t('payments.admin.noPrice'),
|
|
82
|
+
el: (_jsx(Badge, { tone: "attention", icon: "triangle-alert", children: t('payments.admin.noPrice') })),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
v: t(!plan.price
|
|
86
|
+
? 'payments.admin.kind.unknown'
|
|
87
|
+
: plan.price.interval
|
|
88
|
+
? 'payments.admin.kind.subscription'
|
|
89
|
+
: 'payments.admin.kind.oneOff'),
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
})), empty: t('payments.admin.emptyPlans') }));
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PaymentsScreen(): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Payments in the console (the Owner): the approved view wired to its reads. It only reads:
|
|
3
|
+
// changing a plan, the card or cancelling is the customer's, in Stripe's portal.
|
|
4
|
+
import { ErrorState, Loading, useAdmin, usePagedRoute } from '@buffcore/admin-shell';
|
|
5
|
+
import { useRoute } from '@buffcore/sdk/react';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { getOverview, listFailedPayments, listSubscriptions } from '../contract.js';
|
|
8
|
+
import { PaymentsView } from './PaymentsView.js';
|
|
9
|
+
const NONE = { active: 0, pastDue: 0, canceled: 0, failed: 0 };
|
|
10
|
+
export function PaymentsScreen() {
|
|
11
|
+
const { api } = useAdmin();
|
|
12
|
+
const [tab, setTab] = useState('subscriptions');
|
|
13
|
+
const overview = useRoute(api, getOverview, {});
|
|
14
|
+
const subscriptions = usePagedRoute(api, listSubscriptions, { limit: 50 });
|
|
15
|
+
const failed = usePagedRoute(api, listFailedPayments, { limit: 50 });
|
|
16
|
+
const list = tab === 'failed' ? failed : subscriptions;
|
|
17
|
+
const error = overview.error ?? subscriptions.error ?? failed.error;
|
|
18
|
+
return (_jsx(PaymentsView, { mode: overview.data?.mode ?? 'off', counts: overview.data?.counts ?? NONE, plans: overview.data?.plans ?? [], tab: tab, onTab: setTab, subscriptions: subscriptions.items, failed: failed.items, hasMore: list.hasMore, loadingMore: list.loadingMore, onMore: list.more, state: error ? (_jsx(ErrorState, { error: error, onRetry: () => {
|
|
19
|
+
void overview.refetch();
|
|
20
|
+
subscriptions.refetch();
|
|
21
|
+
failed.refetch();
|
|
22
|
+
} })) : overview.isPending || subscriptions.isPending || failed.isPending ? (_jsx(Loading, {})) : undefined }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FailedRow, PaymentsMode, Plan, SubscriptionRow } from '../contract.ts';
|
|
3
|
+
export type PaymentsTab = 'subscriptions' | 'failed' | 'plans';
|
|
4
|
+
export interface PaymentsViewProps {
|
|
5
|
+
mode: PaymentsMode;
|
|
6
|
+
counts: {
|
|
7
|
+
active: number;
|
|
8
|
+
pastDue: number;
|
|
9
|
+
canceled: number;
|
|
10
|
+
failed: number;
|
|
11
|
+
};
|
|
12
|
+
plans: readonly Plan[];
|
|
13
|
+
tab: PaymentsTab;
|
|
14
|
+
onTab: (tab: PaymentsTab) => void;
|
|
15
|
+
subscriptions: readonly SubscriptionRow[];
|
|
16
|
+
failed: readonly FailedRow[];
|
|
17
|
+
hasMore?: boolean;
|
|
18
|
+
loadingMore?: boolean;
|
|
19
|
+
onMore?: () => void;
|
|
20
|
+
/** Loading or an error, shown instead of the page's content. */
|
|
21
|
+
state?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export declare function PaymentsView(props: PaymentsViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Payments in the console, as a view: props in, UI out (wired once the prototype is approved).
|
|
3
|
+
// The lists hold the addresses people gave Stripe, a named sensitive read: the page shows the
|
|
4
|
+
// audit line.
|
|
5
|
+
import { Badge, Banner, Button, KV, Page, Panel, Tabs, useFormat } from '@buffcore/admin-shell';
|
|
6
|
+
import { useT } from '@buffcore/i18n/react';
|
|
7
|
+
import { FailedList, PlanList, SubscriptionList } from './PaymentsLists.js';
|
|
8
|
+
/** Whether payments work, honestly: never green unless they take real payments. */
|
|
9
|
+
function ModeBadge({ mode }) {
|
|
10
|
+
const t = useT();
|
|
11
|
+
const label = t(`payments.admin.mode.${mode}`);
|
|
12
|
+
if (mode === 'live')
|
|
13
|
+
return _jsx(Badge, { status: "healthy", children: label });
|
|
14
|
+
if (mode === 'test')
|
|
15
|
+
return (_jsx(Badge, { tone: "attention", icon: "sliders-horizontal", children: label }));
|
|
16
|
+
return _jsx(Badge, { status: mode === 'off' ? 'unknown' : 'down', children: label });
|
|
17
|
+
}
|
|
18
|
+
export function PaymentsView(props) {
|
|
19
|
+
const { mode, counts, plans, tab, state } = props;
|
|
20
|
+
const t = useT();
|
|
21
|
+
const f = useFormat();
|
|
22
|
+
return (_jsx(Page, { title: t('payments.admin.title'), audit: true, actions: _jsx(ModeBadge, { mode: mode }), children: state ?? (_jsxs(_Fragment, { children: [mode === 'off' || mode === 'refused' ? (_jsx(Banner, { tone: mode === 'off' ? 'info' : 'error', icon: "circle-alert", children: t(`payments.admin.setup.${mode}`) })) : null, _jsx(Panel, { title: t('payments.admin.summary'), children: _jsx("div", { style: { padding: 'var(--space-4)' }, children: _jsx(KV, { cols: 4, items: [
|
|
23
|
+
[t('payments.admin.state.active'), f.number(counts.active)],
|
|
24
|
+
[t('payments.admin.state.past_due'), f.number(counts.pastDue)],
|
|
25
|
+
[t('payments.admin.state.canceled'), f.number(counts.canceled)],
|
|
26
|
+
[t('payments.admin.failedCount'), f.number(counts.failed)],
|
|
27
|
+
] }) }) }), _jsx(Tabs, { label: t('payments.admin.title'), tabs: [
|
|
28
|
+
['subscriptions', t('payments.admin.tabs.subscriptions')],
|
|
29
|
+
['failed', t('payments.admin.tabs.failed')],
|
|
30
|
+
['plans', t('payments.admin.tabs.plans')],
|
|
31
|
+
], value: tab, onChange: props.onTab }), tab === 'subscriptions' ? (_jsx(SubscriptionList, { rows: props.subscriptions, plans: plans })) : tab === 'failed' ? (_jsxs(_Fragment, { children: [_jsx("p", { style: { margin: 0, color: 'var(--text-muted)' }, children: t('payments.admin.failedHelp') }), _jsx(FailedList, { rows: props.failed, plans: plans })] })) : (_jsxs(_Fragment, { children: [_jsx("p", { style: { margin: 0, color: 'var(--text-muted)' }, children: t('payments.admin.plansHelp') }), _jsx(PlanList, { plans: plans })] })), tab !== 'plans' && props.hasMore && props.onMore ? (_jsx("div", { children: _jsx(Button, { variant: "secondary", loading: Boolean(props.loadingMore), onClick: props.onMore, children: t('admin.common.loadMore') }) })) : null] })) }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The payments extension's console strings: the English source. Spanish is in `es.json`. */
|
|
2
|
+
declare const _default: {
|
|
3
|
+
'payments.price.day': string;
|
|
4
|
+
'payments.price.week': string;
|
|
5
|
+
'payments.price.month': string;
|
|
6
|
+
'payments.price.year': string;
|
|
7
|
+
'payments.admin.rail': string;
|
|
8
|
+
'payments.admin.title': string;
|
|
9
|
+
'payments.admin.mode.off': string;
|
|
10
|
+
'payments.admin.mode.test': string;
|
|
11
|
+
'payments.admin.mode.live': string;
|
|
12
|
+
'payments.admin.mode.refused': string;
|
|
13
|
+
'payments.admin.setup.off': string;
|
|
14
|
+
'payments.admin.setup.refused': string;
|
|
15
|
+
'payments.admin.summary': string;
|
|
16
|
+
'payments.admin.state.active': string;
|
|
17
|
+
'payments.admin.state.past_due': string;
|
|
18
|
+
'payments.admin.state.canceled': string;
|
|
19
|
+
'payments.admin.state.ending': string;
|
|
20
|
+
'payments.admin.failedCount': string;
|
|
21
|
+
'payments.admin.tabs.subscriptions': string;
|
|
22
|
+
'payments.admin.tabs.failed': string;
|
|
23
|
+
'payments.admin.tabs.plans': string;
|
|
24
|
+
'payments.admin.cols.email': string;
|
|
25
|
+
'payments.admin.cols.plan': string;
|
|
26
|
+
'payments.admin.cols.state': string;
|
|
27
|
+
'payments.admin.cols.period': string;
|
|
28
|
+
'payments.admin.cols.amount': string;
|
|
29
|
+
'payments.admin.cols.failedAt': string;
|
|
30
|
+
'payments.admin.cols.key': string;
|
|
31
|
+
'payments.admin.cols.price': string;
|
|
32
|
+
'payments.admin.cols.kind': string;
|
|
33
|
+
'payments.admin.renewsOn': string;
|
|
34
|
+
'payments.admin.endsOn': string;
|
|
35
|
+
'payments.admin.endedOn': string;
|
|
36
|
+
'payments.admin.noEmail': string;
|
|
37
|
+
'payments.admin.noPrice': string;
|
|
38
|
+
'payments.admin.kind.subscription': string;
|
|
39
|
+
'payments.admin.kind.oneOff': string;
|
|
40
|
+
'payments.admin.kind.unknown': string;
|
|
41
|
+
'payments.admin.failedHelp': string;
|
|
42
|
+
'payments.admin.plansHelp': string;
|
|
43
|
+
'payments.admin.emptySubscriptions': string;
|
|
44
|
+
'payments.admin.emptyFailed': string;
|
|
45
|
+
'payments.admin.emptyPlans': string;
|
|
46
|
+
};
|
|
47
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The payments extension's console strings: the English source. Spanish is in `es.json`. */
|
|
2
|
+
export default {
|
|
3
|
+
// A price, by how often it is paid (the app has the same)
|
|
4
|
+
'payments.price.day': '{every, plural, one {{amount} a day} other {{amount} every # days}}',
|
|
5
|
+
'payments.price.week': '{every, plural, one {{amount} a week} other {{amount} every # weeks}}',
|
|
6
|
+
'payments.price.month': '{every, plural, one {{amount} a month} other {{amount} every # months}}',
|
|
7
|
+
'payments.price.year': '{every, plural, one {{amount} a year} other {{amount} every # years}}',
|
|
8
|
+
'payments.admin.rail': 'Payments',
|
|
9
|
+
'payments.admin.title': 'Payments',
|
|
10
|
+
'payments.admin.mode.off': 'Not set up',
|
|
11
|
+
'payments.admin.mode.test': 'Test mode',
|
|
12
|
+
'payments.admin.mode.live': 'Live',
|
|
13
|
+
'payments.admin.mode.refused': 'Live key refused',
|
|
14
|
+
'payments.admin.setup.off': 'Payments are off: set STRIPE_SECRET_KEY in the server’s environment. Start with a test key (sk_test_…): no real money moves.',
|
|
15
|
+
'payments.admin.setup.refused': 'The server has a live Stripe key, and live keys work only in production, so payments refuse it here and no real card is charged. Use a test key (sk_test_…).',
|
|
16
|
+
'payments.admin.summary': 'Subscriptions',
|
|
17
|
+
'payments.admin.state.active': 'Active',
|
|
18
|
+
'payments.admin.state.past_due': 'Payment due',
|
|
19
|
+
'payments.admin.state.canceled': 'Ended',
|
|
20
|
+
'payments.admin.state.ending': 'Ending',
|
|
21
|
+
'payments.admin.failedCount': 'Failed payments',
|
|
22
|
+
'payments.admin.tabs.subscriptions': 'Subscriptions',
|
|
23
|
+
'payments.admin.tabs.failed': 'Failed payments',
|
|
24
|
+
'payments.admin.tabs.plans': 'Plans',
|
|
25
|
+
'payments.admin.cols.email': 'Email',
|
|
26
|
+
'payments.admin.cols.plan': 'Plan',
|
|
27
|
+
'payments.admin.cols.state': 'State',
|
|
28
|
+
'payments.admin.cols.period': 'Renews or ends',
|
|
29
|
+
'payments.admin.cols.amount': 'Amount',
|
|
30
|
+
'payments.admin.cols.failedAt': 'Failed on',
|
|
31
|
+
'payments.admin.cols.key': 'Lookup key',
|
|
32
|
+
'payments.admin.cols.price': 'Price in Stripe',
|
|
33
|
+
'payments.admin.cols.kind': 'Kind',
|
|
34
|
+
'payments.admin.renewsOn': 'Renews on {date}',
|
|
35
|
+
'payments.admin.endsOn': 'Ends on {date}',
|
|
36
|
+
'payments.admin.endedOn': 'Ended on {date}',
|
|
37
|
+
'payments.admin.noEmail': 'No address yet',
|
|
38
|
+
'payments.admin.noPrice': 'No price in Stripe',
|
|
39
|
+
'payments.admin.kind.subscription': 'Subscription',
|
|
40
|
+
'payments.admin.kind.oneOff': 'One-off',
|
|
41
|
+
'payments.admin.kind.unknown': '—',
|
|
42
|
+
'payments.admin.failedHelp': 'Stripe retries a failed payment and emails the customer; the row leaves this list once it is paid or voided.',
|
|
43
|
+
'payments.admin.plansHelp': 'The product’s plans. A plan’s key is its price’s lookup key in Stripe: give the test price and the live price the same key.',
|
|
44
|
+
'payments.admin.emptySubscriptions': 'No subscriptions yet.',
|
|
45
|
+
'payments.admin.emptyFailed': 'No failed payments.',
|
|
46
|
+
'payments.admin.emptyPlans': 'The product has no plans yet.',
|
|
47
|
+
};
|