@antelopejs/dms-saas 0.7.0 → 0.7.2
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 +3 -3
- package/dist/auth/subscription-access-gate.d.ts +1 -0
- package/dist/auth/subscription-access-gate.js +19 -4
- package/dist/auth/subscription-access-gate.js.map +1 -1
- package/dist/config/runtime.d.ts +2 -0
- package/dist/config/runtime.js +12 -0
- package/dist/config/runtime.js.map +1 -1
- package/dist/crons/reconcile-guarded-downgrades.d.ts +3 -0
- package/dist/crons/reconcile-guarded-downgrades.js +39 -0
- package/dist/crons/reconcile-guarded-downgrades.js.map +1 -0
- package/dist/crons/reconcile-invoice-line-injections.d.ts +2 -0
- package/dist/crons/reconcile-invoice-line-injections.js +19 -0
- package/dist/crons/reconcile-invoice-line-injections.js.map +1 -0
- package/dist/crons/register.js +4 -0
- package/dist/crons/register.js.map +1 -1
- package/dist/implementations/dms-saas/plan-changes.d.ts +14 -0
- package/dist/implementations/dms-saas/plan-changes.js +118 -0
- package/dist/implementations/dms-saas/plan-changes.js.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/invoice-line-items/billing-window.js +6 -1
- package/dist/invoice-line-items/billing-window.js.map +1 -1
- package/dist/invoice-line-items/index.d.ts +1 -0
- package/dist/invoice-line-items/index.js +1 -0
- package/dist/invoice-line-items/index.js.map +1 -1
- package/dist/invoice-line-items/injection.d.ts +8 -1
- package/dist/invoice-line-items/injection.js +11 -59
- package/dist/invoice-line-items/injection.js.map +1 -1
- package/dist/invoice-line-items/recovery/admission.d.ts +11 -0
- package/dist/invoice-line-items/recovery/admission.js +54 -0
- package/dist/invoice-line-items/recovery/admission.js.map +1 -0
- package/dist/invoice-line-items/recovery/discovery.d.ts +1 -0
- package/dist/invoice-line-items/recovery/discovery.js +77 -0
- package/dist/invoice-line-items/recovery/discovery.js.map +1 -0
- package/dist/invoice-line-items/recovery/index.d.ts +6 -0
- package/dist/invoice-line-items/recovery/index.js +23 -0
- package/dist/invoice-line-items/recovery/index.js.map +1 -0
- package/dist/invoice-line-items/recovery/managed-lines.d.ts +25 -0
- package/dist/invoice-line-items/recovery/managed-lines.js +113 -0
- package/dist/invoice-line-items/recovery/managed-lines.js.map +1 -0
- package/dist/invoice-line-items/recovery/process.d.ts +3 -0
- package/dist/invoice-line-items/recovery/process.js +271 -0
- package/dist/invoice-line-items/recovery/process.js.map +1 -0
- package/dist/invoice-line-items/recovery/reconcile.d.ts +1 -0
- package/dist/invoice-line-items/recovery/reconcile.js +23 -0
- package/dist/invoice-line-items/recovery/reconcile.js.map +1 -0
- package/dist/invoice-line-items/recovery/task.model.d.ts +36 -0
- package/dist/invoice-line-items/recovery/task.model.js +108 -0
- package/dist/invoice-line-items/recovery/task.model.js.map +1 -0
- package/dist/invoice-line-items/recovery/task.table.d.ts +29 -0
- package/dist/invoice-line-items/recovery/task.table.js +119 -0
- package/dist/invoice-line-items/recovery/task.table.js.map +1 -0
- package/dist/operator-actions/db/lifecycle-delivery.table.d.ts +1 -0
- package/dist/operator-actions/db/lifecycle-delivery.table.js +4 -0
- package/dist/operator-actions/db/lifecycle-delivery.table.js.map +1 -1
- package/dist/operator-actions/lifecycle-outbox.d.ts +1 -0
- package/dist/operator-actions/lifecycle-outbox.js +7 -1
- package/dist/operator-actions/lifecycle-outbox.js.map +1 -1
- package/dist/plan-changes/deferred.js +17 -0
- package/dist/plan-changes/deferred.js.map +1 -1
- package/dist/plan-changes/guarded-free.d.ts +9 -0
- package/dist/plan-changes/guarded-free.js +152 -0
- package/dist/plan-changes/guarded-free.js.map +1 -0
- package/dist/plan-changes/guarded-landing.d.ts +1 -0
- package/dist/plan-changes/guarded-landing.js +233 -0
- package/dist/plan-changes/guarded-landing.js.map +1 -0
- package/dist/plan-changes/guarded-state.d.ts +9 -0
- package/dist/plan-changes/guarded-state.js +110 -0
- package/dist/plan-changes/guarded-state.js.map +1 -0
- package/dist/plan-changes/inventory-barrier.d.ts +3 -0
- package/dist/plan-changes/inventory-barrier.js +38 -0
- package/dist/plan-changes/inventory-barrier.js.map +1 -0
- package/dist/plans/seat-hooks.js +28 -3
- package/dist/plans/seat-hooks.js.map +1 -1
- package/dist/routes/tenant/tenant-plan-ops.d.ts +1 -0
- package/dist/routes/tenant/tenant-plan-ops.js +16 -0
- package/dist/routes/tenant/tenant-plan-ops.js.map +1 -1
- package/dist/routes/tenant/tenant-plan.js +13 -3
- package/dist/routes/tenant/tenant-plan.js.map +1 -1
- package/dist/stripe/webhook-handlers.js +7 -1
- package/dist/stripe/webhook-handlers.js.map +1 -1
- package/dist/stripe/webhook-shared.js +5 -0
- package/dist/stripe/webhook-shared.js.map +1 -1
- package/dist/types/config.d.ts +3 -0
- package/frontend-vue/app/build/PlanChangeReview.vue +53 -7
- package/frontend-vue/app/build/public/routes.ts +3 -1
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +23 -5
- package/frontend-vue/app/composables/usePlanChangeReview.ts +25 -0
- package/frontend-vue/app/composables/useSaasRegistration.ts +25 -6
- package/frontend-vue/app/composables/useStripePaymentElement.ts +28 -12
- package/frontend-vue/app/custom-pages/auth/no-workspace.vue +23 -4
- package/frontend-vue/i18n/locales/saas-tenant-billing-en-GB.json +436 -432
- package/frontend-vue/i18n/locales/saas-tenant-billing-fr-FR.json +436 -432
- package/package.json +4 -4
|
@@ -54,6 +54,12 @@ interface SetupConfirmation {
|
|
|
54
54
|
|
|
55
55
|
interface StripePaymentElementHandle {
|
|
56
56
|
confirmAndGetPaymentMethod: () => Promise<ConfirmResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Swap in a fresh SetupIntent. A confirmed SetupIntent is spent: Stripe
|
|
59
|
+
* refuses to confirm it again with another card, so a form that keeps the
|
|
60
|
+
* visitor after a confirmed card was refused must call this first.
|
|
61
|
+
*/
|
|
62
|
+
renew: (clientSecret: string) => Promise<void>;
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
const UNKNOWN_STRIPE_ERROR = "Stripe could not confirm the card";
|
|
@@ -99,20 +105,15 @@ export function useStripePaymentElement(
|
|
|
99
105
|
): StripePaymentElementHandle {
|
|
100
106
|
let stripeInstance: any = null;
|
|
101
107
|
let elementsInstance: any = null;
|
|
108
|
+
let paymentElement: any = null;
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
stripeInstance = await loadStripe(options.publishableKey);
|
|
106
|
-
if (!stripeInstance) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
110
|
+
function mountPaymentElement(clientSecret: string): void {
|
|
111
|
+
paymentElement?.destroy();
|
|
109
112
|
// Payment method types are fixed server-side on the SetupIntent: Stripe
|
|
110
113
|
// rejects `paymentMethodTypes` next to a `clientSecret`, since it only
|
|
111
114
|
// applies to an Elements instance created in deferred-intent `mode`.
|
|
112
|
-
elementsInstance = stripeInstance.elements({
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
const paymentElement = elementsInstance.create("payment", {
|
|
115
|
+
elementsInstance = stripeInstance.elements({ clientSecret });
|
|
116
|
+
paymentElement = elementsInstance.create("payment", {
|
|
116
117
|
wallets: { applePay: "never", googlePay: "never" },
|
|
117
118
|
fields: {
|
|
118
119
|
billingDetails: { address: "auto", name: "auto", email: "never" },
|
|
@@ -121,6 +122,20 @@ export function useStripePaymentElement(
|
|
|
121
122
|
paymentElement.mount(`#${options.containerId}`);
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
async function init(): Promise<void> {
|
|
126
|
+
const { loadStripe } = await import("@stripe/stripe-js");
|
|
127
|
+
stripeInstance = await loadStripe(options.publishableKey);
|
|
128
|
+
if (!stripeInstance) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
mountPaymentElement(options.clientSecret);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function renew(clientSecret: string): Promise<void> {
|
|
135
|
+
await ready;
|
|
136
|
+
if (stripeInstance) mountPaymentElement(clientSecret);
|
|
137
|
+
}
|
|
138
|
+
|
|
124
139
|
async function confirmAndGetPaymentMethod(): Promise<ConfirmResult> {
|
|
125
140
|
if (!stripeInstance || !elementsInstance) {
|
|
126
141
|
return { error: { message: "Stripe not initialized" } };
|
|
@@ -139,11 +154,12 @@ export function useStripePaymentElement(
|
|
|
139
154
|
}
|
|
140
155
|
|
|
141
156
|
onUnmounted(() => {
|
|
157
|
+
paymentElement = null;
|
|
142
158
|
elementsInstance = null;
|
|
143
159
|
stripeInstance = null;
|
|
144
160
|
});
|
|
145
161
|
|
|
146
|
-
|
|
162
|
+
const ready = init();
|
|
147
163
|
|
|
148
|
-
return { confirmAndGetPaymentMethod };
|
|
164
|
+
return { confirmAndGetPaymentMethod, renew };
|
|
149
165
|
}
|
|
@@ -178,15 +178,20 @@ async function loadPendingRegistration(): Promise<void> {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
async function createSetupIntent(): Promise<string | undefined> {
|
|
182
|
+
const setup = await publicFetch<SetupIntentResponse>(SETUP_INTENT_ENDPOINT)
|
|
183
|
+
return setup.clientSecret || undefined
|
|
184
|
+
}
|
|
185
|
+
|
|
181
186
|
async function mountPaymentElement(): Promise<void> {
|
|
182
187
|
const publishableKey = saasConfig?.stripePublishableKey
|
|
183
188
|
if (!publishableKey || paymentMethodPolicy === 'none') return
|
|
184
189
|
try {
|
|
185
|
-
const
|
|
186
|
-
if (!
|
|
190
|
+
const clientSecret = await createSetupIntent()
|
|
191
|
+
if (!clientSecret) return
|
|
187
192
|
stripeHandle.value = useStripePaymentElement({
|
|
188
193
|
publishableKey,
|
|
189
|
-
clientSecret
|
|
194
|
+
clientSecret,
|
|
190
195
|
containerId: PAYMENT_ELEMENT_ID,
|
|
191
196
|
billingEmail: () => pending.value?.email ?? '',
|
|
192
197
|
})
|
|
@@ -195,6 +200,18 @@ async function mountPaymentElement(): Promise<void> {
|
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
|
|
203
|
+
// A refusal after the card was confirmed leaves its SetupIntent spent: the
|
|
204
|
+
// next card must go through a fresh one, or Stripe refuses it with a bare
|
|
205
|
+
// processing error.
|
|
206
|
+
async function renewCard(): Promise<void> {
|
|
207
|
+
try {
|
|
208
|
+
const clientSecret = await createSetupIntent()
|
|
209
|
+
if (clientSecret) await stripeHandle.value?.renew(clientSecret)
|
|
210
|
+
} catch (error) {
|
|
211
|
+
cardError.value = resolveApiError(error, 'saas.public.register.error.load')
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
198
215
|
/** The confirmed card, undefined when none is collected, null on failure. */
|
|
199
216
|
async function confirmPaymentMethod(): Promise<string | undefined | null> {
|
|
200
217
|
if (!isPaymentStepVisible.value) return undefined
|
|
@@ -219,8 +236,9 @@ function validate(): boolean {
|
|
|
219
236
|
async function submit(): Promise<void> {
|
|
220
237
|
if (isSubmitting.value || !validate()) return
|
|
221
238
|
isSubmitting.value = true
|
|
239
|
+
let paymentMethodId: string | undefined | null
|
|
222
240
|
try {
|
|
223
|
-
|
|
241
|
+
paymentMethodId = await confirmPaymentMethod()
|
|
224
242
|
if (paymentMethodId === null) return
|
|
225
243
|
await $fetch(SESSION_ESTABLISH_ENDPOINT, {
|
|
226
244
|
method: 'POST',
|
|
@@ -241,6 +259,7 @@ async function submit(): Promise<void> {
|
|
|
241
259
|
error,
|
|
242
260
|
'saas.public.register.error.failed',
|
|
243
261
|
)
|
|
262
|
+
if (paymentMethodId) await renewCard()
|
|
244
263
|
} finally {
|
|
245
264
|
isSubmitting.value = false
|
|
246
265
|
}
|