@adonis-agora/payments 0.2.0 → 0.3.0
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/CHANGELOG.md +2347 -0
- package/dist/assets/spa/assets/index-CT5Zon6P.css +1 -0
- package/dist/assets/spa/assets/index-CvEbJEnq.js +41 -0
- package/dist/assets/spa/assets/index-CvEbJEnq.js.map +1 -0
- package/dist/assets/spa/index.html +20 -0
- package/dist/commands/main.d.ts +4 -3
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +9 -2
- package/dist/commands/main.js.map +1 -1
- package/dist/commands/payments_health.d.ts +31 -0
- package/dist/commands/payments_health.d.ts.map +1 -0
- package/dist/commands/payments_health.js +113 -0
- package/dist/commands/payments_health.js.map +1 -0
- package/dist/commands/payments_sync.d.ts +18 -4
- package/dist/commands/payments_sync.d.ts.map +1 -1
- package/dist/commands/payments_sync.js +136 -40
- package/dist/commands/payments_sync.js.map +1 -1
- package/dist/configure.d.ts +12 -5
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +18 -5
- package/dist/configure.js.map +1 -1
- package/dist/providers/dashboard_provider.d.ts +97 -0
- package/dist/providers/dashboard_provider.d.ts.map +1 -0
- package/dist/providers/dashboard_provider.js +430 -0
- package/dist/providers/dashboard_provider.js.map +1 -0
- package/dist/providers/payments_client_provider.d.ts +41 -0
- package/dist/providers/payments_client_provider.d.ts.map +1 -0
- package/dist/providers/payments_client_provider.js +95 -0
- package/dist/providers/payments_client_provider.js.map +1 -0
- package/dist/providers/payments_provider.d.ts +35 -0
- package/dist/providers/payments_provider.d.ts.map +1 -1
- package/dist/providers/payments_provider.js +250 -36
- package/dist/providers/payments_provider.js.map +1 -1
- package/dist/src/billing/billing_health.d.ts +85 -0
- package/dist/src/billing/billing_health.d.ts.map +1 -0
- package/dist/src/billing/billing_health.js +155 -0
- package/dist/src/billing/billing_health.js.map +1 -0
- package/dist/src/billing/billing_overview.d.ts +4 -3
- package/dist/src/billing/billing_overview.d.ts.map +1 -1
- package/dist/src/billing/billing_overview.js +14 -5
- package/dist/src/billing/billing_overview.js.map +1 -1
- package/dist/src/billing/billing_store.d.ts +634 -5
- package/dist/src/billing/billing_store.d.ts.map +1 -1
- package/dist/src/billing/billing_store.js +18 -1
- package/dist/src/billing/billing_store.js.map +1 -1
- package/dist/src/billing/index.d.ts +2 -1
- package/dist/src/billing/index.d.ts.map +1 -1
- package/dist/src/billing/index.js +1 -0
- package/dist/src/billing/index.js.map +1 -1
- package/dist/src/billing/list_query.d.ts +16 -0
- package/dist/src/billing/list_query.d.ts.map +1 -0
- package/dist/src/billing/list_query.js +28 -0
- package/dist/src/billing/list_query.js.map +1 -0
- package/dist/src/billing/lucid_billing_store.d.ts +122 -4
- package/dist/src/billing/lucid_billing_store.d.ts.map +1 -1
- package/dist/src/billing/lucid_billing_store.js +811 -13
- package/dist/src/billing/lucid_billing_store.js.map +1 -1
- package/dist/src/billing/mixins/index.d.ts +3 -0
- package/dist/src/billing/mixins/index.d.ts.map +1 -1
- package/dist/src/billing/mixins/index.js +3 -0
- package/dist/src/billing/mixins/index.js.map +1 -1
- package/dist/src/billing/mixins/with_audit_event.d.ts +48 -0
- package/dist/src/billing/mixins/with_audit_event.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_audit_event.js +77 -0
- package/dist/src/billing/mixins/with_audit_event.js.map +1 -0
- package/dist/src/billing/mixins/with_customer.d.ts +39 -0
- package/dist/src/billing/mixins/with_customer.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_customer.js +68 -0
- package/dist/src/billing/mixins/with_customer.js.map +1 -0
- package/dist/src/billing/mixins/with_dispute.d.ts +68 -0
- package/dist/src/billing/mixins/with_dispute.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_dispute.js +83 -0
- package/dist/src/billing/mixins/with_dispute.js.map +1 -0
- package/dist/src/billing/mixins/with_payment.d.ts +42 -0
- package/dist/src/billing/mixins/with_payment.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_payment.js +29 -3
- package/dist/src/billing/mixins/with_payment.js.map +1 -1
- package/dist/src/billing/mixins/with_subscription.d.ts +7 -0
- package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_subscription.js +15 -1
- package/dist/src/billing/mixins/with_subscription.js.map +1 -1
- package/dist/src/billing/mixins/with_usage_event.d.ts +7 -0
- package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_usage_event.js +15 -1
- package/dist/src/billing/mixins/with_usage_event.js.map +1 -1
- package/dist/src/billing/mixins/with_webhook_event.d.ts +18 -0
- package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_webhook_event.js +18 -1
- package/dist/src/billing/mixins/with_webhook_event.js.map +1 -1
- package/dist/src/billing/resolve_dispatch.d.ts +22 -0
- package/dist/src/billing/resolve_dispatch.d.ts.map +1 -0
- package/dist/src/billing/resolve_dispatch.js +44 -0
- package/dist/src/billing/resolve_dispatch.js.map +1 -0
- package/dist/src/billing/resolve_store.d.ts +18 -0
- package/dist/src/billing/resolve_store.d.ts.map +1 -0
- package/dist/src/billing/resolve_store.js +35 -0
- package/dist/src/billing/resolve_store.js.map +1 -0
- package/dist/src/billing/schema.d.ts +108 -0
- package/dist/src/billing/schema.d.ts.map +1 -0
- package/dist/src/billing/schema.js +350 -0
- package/dist/src/billing/schema.js.map +1 -0
- package/dist/src/billing/webhook_dispatcher.d.ts +95 -16
- package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -1
- package/dist/src/billing/webhook_dispatcher.js +186 -33
- package/dist/src/billing/webhook_dispatcher.js.map +1 -1
- package/dist/src/billing/webhook_events.d.ts +67 -1
- package/dist/src/billing/webhook_events.d.ts.map +1 -1
- package/dist/src/billing/webhook_events.js +15 -0
- package/dist/src/billing/webhook_events.js.map +1 -1
- package/dist/src/billing/webhook_processor.d.ts.map +1 -1
- package/dist/src/billing/webhook_processor.js +325 -5
- package/dist/src/billing/webhook_processor.js.map +1 -1
- package/dist/src/client/define_config.d.ts +150 -0
- package/dist/src/client/define_config.d.ts.map +1 -0
- package/dist/src/client/define_config.js +98 -0
- package/dist/src/client/define_config.js.map +1 -0
- package/dist/src/client/handlers.d.ts +71 -0
- package/dist/src/client/handlers.d.ts.map +1 -0
- package/dist/src/client/handlers.js +119 -0
- package/dist/src/client/handlers.js.map +1 -0
- package/dist/src/client/index.d.ts +16 -0
- package/dist/src/client/index.d.ts.map +1 -0
- package/dist/src/client/index.js +13 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/statuses.d.ts +38 -0
- package/dist/src/client/statuses.d.ts.map +1 -0
- package/dist/src/client/statuses.js +42 -0
- package/dist/src/client/statuses.js.map +1 -0
- package/dist/src/dashboard/actions.d.ts +143 -0
- package/dist/src/dashboard/actions.d.ts.map +1 -0
- package/dist/src/dashboard/actions.js +112 -0
- package/dist/src/dashboard/actions.js.map +1 -0
- package/dist/src/dashboard/auth.d.ts +136 -0
- package/dist/src/dashboard/auth.d.ts.map +1 -0
- package/dist/src/dashboard/auth.js +152 -0
- package/dist/src/dashboard/auth.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +80 -0
- package/dist/src/dashboard/define_config.d.ts.map +1 -0
- package/dist/src/dashboard/define_config.js +83 -0
- package/dist/src/dashboard/define_config.js.map +1 -0
- package/dist/src/dashboard/handlers.d.ts +281 -0
- package/dist/src/dashboard/handlers.d.ts.map +1 -0
- package/dist/src/dashboard/handlers.js +960 -0
- package/dist/src/dashboard/handlers.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +18 -0
- package/dist/src/dashboard/index.d.ts.map +1 -0
- package/dist/src/dashboard/index.js +14 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/dashboard/login_page.d.ts +23 -0
- package/dist/src/dashboard/login_page.d.ts.map +1 -0
- package/dist/src/dashboard/login_page.js +170 -0
- package/dist/src/dashboard/login_page.js.map +1 -0
- package/dist/src/dashboard/period.d.ts +31 -0
- package/dist/src/dashboard/period.d.ts.map +1 -0
- package/dist/src/dashboard/period.js +44 -0
- package/dist/src/dashboard/period.js.map +1 -0
- package/dist/src/dashboard/session_cookie.d.ts +42 -0
- package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
- package/dist/src/dashboard/session_cookie.js +97 -0
- package/dist/src/dashboard/session_cookie.js.map +1 -0
- package/dist/src/dashboard/spa.d.ts +24 -0
- package/dist/src/dashboard/spa.d.ts.map +1 -0
- package/dist/src/dashboard/spa.js +52 -0
- package/dist/src/dashboard/spa.js.map +1 -0
- package/dist/src/define_config.d.ts +244 -9
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js +97 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/diagnostics.d.ts +287 -7
- package/dist/src/diagnostics.d.ts.map +1 -1
- package/dist/src/diagnostics.js +317 -1
- package/dist/src/diagnostics.js.map +1 -1
- package/dist/src/driver.d.ts +139 -5
- package/dist/src/driver.d.ts.map +1 -1
- package/dist/src/drivers/abacate.d.ts +12 -2
- package/dist/src/drivers/abacate.d.ts.map +1 -1
- package/dist/src/drivers/abacate.js +112 -19
- package/dist/src/drivers/abacate.js.map +1 -1
- package/dist/src/drivers/adyen.d.ts +164 -0
- package/dist/src/drivers/adyen.d.ts.map +1 -0
- package/dist/src/drivers/adyen.js +678 -0
- package/dist/src/drivers/adyen.js.map +1 -0
- package/dist/src/drivers/asaas.d.ts +52 -2
- package/dist/src/drivers/asaas.d.ts.map +1 -1
- package/dist/src/drivers/asaas.js +364 -29
- package/dist/src/drivers/asaas.js.map +1 -1
- package/dist/src/drivers/dodo.d.ts +135 -0
- package/dist/src/drivers/dodo.d.ts.map +1 -0
- package/dist/src/drivers/dodo.js +864 -0
- package/dist/src/drivers/dodo.js.map +1 -0
- package/dist/src/drivers/efi.d.ts +98 -0
- package/dist/src/drivers/efi.d.ts.map +1 -0
- package/dist/src/drivers/efi.js +628 -0
- package/dist/src/drivers/efi.js.map +1 -0
- package/dist/src/drivers/infinitepay.d.ts +156 -0
- package/dist/src/drivers/infinitepay.d.ts.map +1 -0
- package/dist/src/drivers/infinitepay.js +321 -0
- package/dist/src/drivers/infinitepay.js.map +1 -0
- package/dist/src/drivers/lemonsqueezy.d.ts +125 -0
- package/dist/src/drivers/lemonsqueezy.d.ts.map +1 -0
- package/dist/src/drivers/lemonsqueezy.js +632 -0
- package/dist/src/drivers/lemonsqueezy.js.map +1 -0
- package/dist/src/drivers/mercadopago.d.ts +97 -0
- package/dist/src/drivers/mercadopago.d.ts.map +1 -0
- package/dist/src/drivers/mercadopago.js +844 -0
- package/dist/src/drivers/mercadopago.js.map +1 -0
- package/dist/src/drivers/mollie.d.ts +125 -0
- package/dist/src/drivers/mollie.d.ts.map +1 -0
- package/dist/src/drivers/mollie.js +812 -0
- package/dist/src/drivers/mollie.js.map +1 -0
- package/dist/src/drivers/paddle.d.ts +148 -0
- package/dist/src/drivers/paddle.d.ts.map +1 -0
- package/dist/src/drivers/paddle.js +738 -0
- package/dist/src/drivers/paddle.js.map +1 -0
- package/dist/src/drivers/pagarme.d.ts +97 -0
- package/dist/src/drivers/pagarme.d.ts.map +1 -0
- package/dist/src/drivers/pagarme.js +829 -0
- package/dist/src/drivers/pagarme.js.map +1 -0
- package/dist/src/drivers/pagbank.d.ts +57 -0
- package/dist/src/drivers/pagbank.d.ts.map +1 -0
- package/dist/src/drivers/pagbank.js +499 -0
- package/dist/src/drivers/pagbank.js.map +1 -0
- package/dist/src/drivers/paypal.d.ts +120 -0
- package/dist/src/drivers/paypal.d.ts.map +1 -0
- package/dist/src/drivers/paypal.js +891 -0
- package/dist/src/drivers/paypal.js.map +1 -0
- package/dist/src/drivers/polar.d.ts +118 -0
- package/dist/src/drivers/polar.d.ts.map +1 -0
- package/dist/src/drivers/polar.js +604 -0
- package/dist/src/drivers/polar.js.map +1 -0
- package/dist/src/drivers/razorpay.d.ts +103 -0
- package/dist/src/drivers/razorpay.d.ts.map +1 -0
- package/dist/src/drivers/razorpay.js +867 -0
- package/dist/src/drivers/razorpay.js.map +1 -0
- package/dist/src/drivers/shared.d.ts +33 -0
- package/dist/src/drivers/shared.d.ts.map +1 -0
- package/dist/src/drivers/shared.js +37 -0
- package/dist/src/drivers/shared.js.map +1 -0
- package/dist/src/drivers/square.d.ts +133 -0
- package/dist/src/drivers/square.d.ts.map +1 -0
- package/dist/src/drivers/square.js +905 -0
- package/dist/src/drivers/square.js.map +1 -0
- package/dist/src/drivers/stripe.d.ts +40 -3
- package/dist/src/drivers/stripe.d.ts.map +1 -1
- package/dist/src/drivers/stripe.js +806 -25
- package/dist/src/drivers/stripe.js.map +1 -1
- package/dist/src/drivers/woovi.d.ts +10 -3
- package/dist/src/drivers/woovi.d.ts.map +1 -1
- package/dist/src/drivers/woovi.js +162 -29
- package/dist/src/drivers/woovi.js.map +1 -1
- package/dist/src/ensure_customer.d.ts +34 -1
- package/dist/src/ensure_customer.d.ts.map +1 -1
- package/dist/src/ensure_customer.js +29 -4
- package/dist/src/ensure_customer.js.map +1 -1
- package/dist/src/http.d.ts +37 -3
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +69 -5
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +40 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +22 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/invoice/emit_invoice.d.ts.map +1 -1
- package/dist/src/invoice/emit_invoice.js +31 -11
- package/dist/src/invoice/emit_invoice.js.map +1 -1
- package/dist/src/money.d.ts +23 -5
- package/dist/src/money.d.ts.map +1 -1
- package/dist/src/money.js +72 -7
- package/dist/src/money.js.map +1 -1
- package/dist/src/payments_manager.d.ts +8 -1
- package/dist/src/payments_manager.d.ts.map +1 -1
- package/dist/src/payments_manager.js +168 -6
- package/dist/src/payments_manager.js.map +1 -1
- package/dist/src/services/main.d.ts +38 -0
- package/dist/src/services/main.d.ts.map +1 -1
- package/dist/src/services/main.js +130 -0
- package/dist/src/services/main.js.map +1 -1
- package/dist/src/telescope/index.d.ts +2 -0
- package/dist/src/telescope/index.d.ts.map +1 -1
- package/dist/src/telescope/index.js +1 -0
- package/dist/src/telescope/index.js.map +1 -1
- package/dist/src/telescope/payments_watcher.d.ts +10 -4
- package/dist/src/telescope/payments_watcher.d.ts.map +1 -1
- package/dist/src/telescope/payments_watcher.js +65 -13
- package/dist/src/telescope/payments_watcher.js.map +1 -1
- package/dist/src/telescope/register.d.ts +62 -0
- package/dist/src/telescope/register.d.ts.map +1 -0
- package/dist/src/telescope/register.js +48 -0
- package/dist/src/telescope/register.js.map +1 -0
- package/dist/src/testing/fake_payments.d.ts +62 -0
- package/dist/src/testing/fake_payments.d.ts.map +1 -0
- package/dist/src/testing/fake_payments.js +82 -0
- package/dist/src/testing/fake_payments.js.map +1 -0
- package/dist/src/testing/in_memory_billing_store.d.ts +151 -2
- package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -1
- package/dist/src/testing/in_memory_billing_store.js +517 -4
- package/dist/src/testing/in_memory_billing_store.js.map +1 -1
- package/dist/src/testing/index.d.ts +2 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/types.d.ts +161 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +30 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/webhook_handlers.d.ts +96 -2
- package/dist/src/webhook_handlers.d.ts.map +1 -1
- package/dist/src/webhook_handlers.js +91 -10
- package/dist/src/webhook_handlers.js.map +1 -1
- package/dist/src/webhook_security.d.ts +94 -3
- package/dist/src/webhook_security.d.ts.map +1 -1
- package/dist/src/webhook_security.js +173 -9
- package/dist/src/webhook_security.js.map +1 -1
- package/dist/stubs/config/payments.stub +13 -0
- package/dist/stubs/config/payments_client.stub +42 -0
- package/dist/stubs/config/payments_dashboard.stub +38 -0
- package/dist/stubs/database/migrations/create_billing_tables.stub +35 -77
- package/dist/stubs/make/webhook_handler/main.stub +29 -11
- package/package.json +60 -25
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="robots" content="noindex, nofollow" />
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
|
+
<link
|
|
10
|
+
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Space+Grotesk:wght@400;500;600;700&display=swap"
|
|
11
|
+
rel="stylesheet"
|
|
12
|
+
/>
|
|
13
|
+
<title>payments · billing console</title>
|
|
14
|
+
<script type="module" crossorigin src="/__PAYMENTS_DASHBOARD__/assets/index-CvEbJEnq.js"></script>
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/__PAYMENTS_DASHBOARD__/assets/index-CT5Zon6P.css">
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
package/dist/commands/main.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ListLoader } from '@adonisjs/core/ace';
|
|
2
2
|
import MakeBillable from './make_billable.js';
|
|
3
|
+
import PaymentsHealth from './payments_health.js';
|
|
3
4
|
import PaymentsSync from './payments_sync.js';
|
|
4
5
|
import PaymentsWebhook from './payments_webhook.js';
|
|
5
6
|
/**
|
|
@@ -7,10 +8,10 @@ import PaymentsWebhook from './payments_webhook.js';
|
|
|
7
8
|
* `rcFile.addCommand('@adonis-agora/payments/commands')` (done by this package's
|
|
8
9
|
* `configure`). The ace kernel imports this module and treats it as a commands loader: a
|
|
9
10
|
* {@link ListLoader} over the payments commands (`make:billable`, `make:webhook-handler`,
|
|
10
|
-
* `payments:webhook`, `payments:sync`) provides their metadata and constructors.
|
|
11
|
+
* `payments:webhook`, `payments:sync`, `payments:health`) provides their metadata and constructors.
|
|
11
12
|
*/
|
|
12
|
-
declare const loader: ListLoader<typeof MakeBillable | typeof PaymentsSync | typeof PaymentsWebhook>;
|
|
13
|
+
declare const loader: ListLoader<typeof MakeBillable | typeof PaymentsHealth | typeof PaymentsSync | typeof PaymentsWebhook>;
|
|
13
14
|
export declare const getMetaData: () => Promise<import("@adonisjs/core/types/ace").CommandMetaData[]>;
|
|
14
|
-
export declare const getCommand: (metaData: import("@adonisjs/core/types/ace").CommandMetaData) => Promise<typeof MakeBillable | typeof PaymentsSync | typeof PaymentsWebhook | null>;
|
|
15
|
+
export declare const getCommand: (metaData: import("@adonisjs/core/types/ace").CommandMetaData) => Promise<typeof MakeBillable | typeof PaymentsHealth | typeof PaymentsSync | typeof PaymentsWebhook | null>;
|
|
15
16
|
export default loader;
|
|
16
17
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD;;;;;;GAMG;AACH,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD;;;;;;GAMG;AACH,QAAA,MAAM,MAAM,wGAMV,CAAC;AAEH,eAAO,MAAM,WAAW,qEAAkC,CAAC;AAC3D,eAAO,MAAM,UAAU,8KAAiC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
|
package/dist/commands/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ListLoader } from '@adonisjs/core/ace';
|
|
2
2
|
import MakeBillable from './make_billable.js';
|
|
3
3
|
import MakeWebhookHandler from './make_webhook_handler.js';
|
|
4
|
+
import PaymentsHealth from './payments_health.js';
|
|
4
5
|
import PaymentsSync from './payments_sync.js';
|
|
5
6
|
import PaymentsWebhook from './payments_webhook.js';
|
|
6
7
|
/**
|
|
@@ -8,9 +9,15 @@ import PaymentsWebhook from './payments_webhook.js';
|
|
|
8
9
|
* `rcFile.addCommand('@adonis-agora/payments/commands')` (done by this package's
|
|
9
10
|
* `configure`). The ace kernel imports this module and treats it as a commands loader: a
|
|
10
11
|
* {@link ListLoader} over the payments commands (`make:billable`, `make:webhook-handler`,
|
|
11
|
-
* `payments:webhook`, `payments:sync`) provides their metadata and constructors.
|
|
12
|
+
* `payments:webhook`, `payments:sync`, `payments:health`) provides their metadata and constructors.
|
|
12
13
|
*/
|
|
13
|
-
const loader = new ListLoader([
|
|
14
|
+
const loader = new ListLoader([
|
|
15
|
+
MakeBillable,
|
|
16
|
+
MakeWebhookHandler,
|
|
17
|
+
PaymentsWebhook,
|
|
18
|
+
PaymentsSync,
|
|
19
|
+
PaymentsHealth,
|
|
20
|
+
]);
|
|
14
21
|
export const getMetaData = loader.getMetaData.bind(loader);
|
|
15
22
|
export const getCommand = loader.getCommand.bind(loader);
|
|
16
23
|
export default loader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../commands/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;IAC5B,YAAY;IACZ,kBAAkB;IAClB,eAAe;IACf,YAAY;IACZ,cAAc;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
import type { CommandOptions } from '@adonisjs/core/types/ace';
|
|
3
|
+
/**
|
|
4
|
+
* `node ace payments:health` — the scheduled check for the six silent failures of a billing
|
|
5
|
+
* install: events claimed and never finished, events the dispatcher gave up on, charges
|
|
6
|
+
* created that never confirmed, a chargeback whose evidence window is about to close, a
|
|
7
|
+
* chargeback that is simply open, and deliveries the endpoint refused.
|
|
8
|
+
*
|
|
9
|
+
* Two of those are the reason to run this on a cron rather than when something looks wrong.
|
|
10
|
+
* A closing evidence window is not a failure at all — nothing is broken, and the money goes
|
|
11
|
+
* anyway if nobody answers in time. A refused delivery leaves no ledger row (it is rejected
|
|
12
|
+
* before an event exists), so a rotated webhook credential looks exactly like a quiet
|
|
13
|
+
* gateway from the inside: no events, no failures, and revenue that simply stops.
|
|
14
|
+
*
|
|
15
|
+
* Exits non-zero when anything is wrong, so a cron entry or a container healthcheck can
|
|
16
|
+
* page on it without parsing the output. `--json` prints the machine-readable form for a
|
|
17
|
+
* metrics shipper.
|
|
18
|
+
*/
|
|
19
|
+
export default class PaymentsHealth extends BaseCommand {
|
|
20
|
+
static commandName: string;
|
|
21
|
+
static description: string;
|
|
22
|
+
static options: CommandOptions;
|
|
23
|
+
stuckAfter?: number;
|
|
24
|
+
unconfirmedAfter?: number;
|
|
25
|
+
window?: number;
|
|
26
|
+
disputeWindow?: number;
|
|
27
|
+
rejectedWindow?: number;
|
|
28
|
+
json?: boolean;
|
|
29
|
+
run(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=payments_health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments_health.d.ts","sourceRoot":"","sources":["../../commands/payments_health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW;IACrD,OAAgB,WAAW,SAAqB;IAChD,OAAgB,WAAW,SACkF;IAC7G,OAAgB,OAAO,EAAE,cAAc,CAAsB;IAKrD,UAAU,CAAC,EAAE,MAAM,CAAC;IAKpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,aAAa,CAAC,EAAE,MAAM,CAAC;IAKvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,IAAI,CAAC,EAAE,OAAO,CAAC;IAER,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4DpC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
+
import { billingHealth } from '../src/billing/billing_health.js';
|
|
9
|
+
import { resolveBillingStore } from '../src/billing/resolve_store.js';
|
|
10
|
+
/**
|
|
11
|
+
* `node ace payments:health` — the scheduled check for the six silent failures of a billing
|
|
12
|
+
* install: events claimed and never finished, events the dispatcher gave up on, charges
|
|
13
|
+
* created that never confirmed, a chargeback whose evidence window is about to close, a
|
|
14
|
+
* chargeback that is simply open, and deliveries the endpoint refused.
|
|
15
|
+
*
|
|
16
|
+
* Two of those are the reason to run this on a cron rather than when something looks wrong.
|
|
17
|
+
* A closing evidence window is not a failure at all — nothing is broken, and the money goes
|
|
18
|
+
* anyway if nobody answers in time. A refused delivery leaves no ledger row (it is rejected
|
|
19
|
+
* before an event exists), so a rotated webhook credential looks exactly like a quiet
|
|
20
|
+
* gateway from the inside: no events, no failures, and revenue that simply stops.
|
|
21
|
+
*
|
|
22
|
+
* Exits non-zero when anything is wrong, so a cron entry or a container healthcheck can
|
|
23
|
+
* page on it without parsing the output. `--json` prints the machine-readable form for a
|
|
24
|
+
* metrics shipper.
|
|
25
|
+
*/
|
|
26
|
+
export default class PaymentsHealth extends BaseCommand {
|
|
27
|
+
static commandName = 'payments:health';
|
|
28
|
+
static description = 'Report stuck and failed webhooks, unconfirmed charges, open and closing disputes, and refused deliveries';
|
|
29
|
+
static options = { startApp: true };
|
|
30
|
+
async run() {
|
|
31
|
+
const config = this.app.config.get('payments', {});
|
|
32
|
+
if (config.billing?.enabled === false) {
|
|
33
|
+
this.logger.error('The billing layer is disabled (billing.enabled = false). Nothing to check.');
|
|
34
|
+
this.exitCode = 1;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const store = await resolveBillingStore(config);
|
|
38
|
+
const report = await billingHealth(store, {
|
|
39
|
+
...(this.stuckAfter !== undefined ? { stuckAfter: this.stuckAfter * 60_000 } : {}),
|
|
40
|
+
...(this.unconfirmedAfter !== undefined
|
|
41
|
+
? { unconfirmedAfter: this.unconfirmedAfter * 60_000 }
|
|
42
|
+
: {}),
|
|
43
|
+
...(this.window !== undefined ? { failedWithin: this.window * 3_600_000 } : {}),
|
|
44
|
+
...(this.disputeWindow !== undefined
|
|
45
|
+
? { disputeDueWithin: this.disputeWindow * 3_600_000 }
|
|
46
|
+
: {}),
|
|
47
|
+
...(this.rejectedWindow !== undefined
|
|
48
|
+
? { rejectedWithin: this.rejectedWindow * 3_600_000 }
|
|
49
|
+
: {}),
|
|
50
|
+
});
|
|
51
|
+
if (this.json) {
|
|
52
|
+
this.logger.log(JSON.stringify(report, null, 2));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
for (const check of report.checks) {
|
|
56
|
+
const line = `${check.count} ${check.label}`;
|
|
57
|
+
if (check.healthy)
|
|
58
|
+
this.logger.success(line);
|
|
59
|
+
else
|
|
60
|
+
this.logger.error(`${line}\n ${check.hint}`);
|
|
61
|
+
}
|
|
62
|
+
for (const failure of report.failures) {
|
|
63
|
+
this.logger.info(` ${failure.provider} ${failure.type}: ${failure.count} failed`);
|
|
64
|
+
}
|
|
65
|
+
// WHICH windows are closing, soonest first — a count names nobody to email and no
|
|
66
|
+
// gateway dashboard to open. The list is capped; the check's count is not, so a
|
|
67
|
+
// report can name twenty of fifty without pretending it named all of them.
|
|
68
|
+
for (const dispute of report.deadlines) {
|
|
69
|
+
const due = dispute.evidenceDueBy?.toISOString() ?? 'unknown';
|
|
70
|
+
this.logger.info(` ${dispute.provider} ${dispute.gatewayId} (payment ${dispute.paymentGatewayId}): evidence due ${due}`);
|
|
71
|
+
}
|
|
72
|
+
// The open-dispute check exists BECAUSE a deadline is usually absent — Asaas' own
|
|
73
|
+
// webhook examples never carry one — so printing only `deadlines` would fire a count
|
|
74
|
+
// that names nobody, on precisely the installs the check was added for.
|
|
75
|
+
const named = new Set(report.deadlines.map((dispute) => dispute.gatewayId));
|
|
76
|
+
for (const dispute of report.openDisputes) {
|
|
77
|
+
if (named.has(dispute.gatewayId))
|
|
78
|
+
continue;
|
|
79
|
+
this.logger.info(` ${dispute.provider} ${dispute.gatewayId} (payment ${dispute.paymentGatewayId}): open, no deadline given`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Non-zero so a scheduler notices without reading the output.
|
|
83
|
+
if (!report.healthy)
|
|
84
|
+
this.exitCode = 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
__decorate([
|
|
88
|
+
flags.number({
|
|
89
|
+
description: 'Minutes an event may sit unfinished before it counts as stuck (default 15)',
|
|
90
|
+
})
|
|
91
|
+
], PaymentsHealth.prototype, "stuckAfter", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
flags.number({
|
|
94
|
+
description: 'Minutes a charge may stay pending before it counts as unconfirmed (default 120)',
|
|
95
|
+
})
|
|
96
|
+
], PaymentsHealth.prototype, "unconfirmedAfter", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
flags.number({ description: 'Window in hours that failures are counted over (default 24)' })
|
|
99
|
+
], PaymentsHealth.prototype, "window", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
flags.number({
|
|
102
|
+
description: 'Hours ahead to look for a dispute whose evidence window closes (default 72). Windows already past are always counted',
|
|
103
|
+
})
|
|
104
|
+
], PaymentsHealth.prototype, "disputeWindow", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
flags.number({
|
|
107
|
+
description: 'Window in hours that refused deliveries are counted over (default 24)',
|
|
108
|
+
})
|
|
109
|
+
], PaymentsHealth.prototype, "rejectedWindow", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
flags.boolean({ description: 'Print the report as JSON' })
|
|
112
|
+
], PaymentsHealth.prototype, "json", void 0);
|
|
113
|
+
//# sourceMappingURL=payments_health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments_health.js","sourceRoot":"","sources":["../../commands/payments_health.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW;IACrD,MAAM,CAAU,WAAW,GAAG,iBAAiB,CAAC;IAChD,MAAM,CAAU,WAAW,GACzB,0GAA0G,CAAC;IAC7G,MAAM,CAAU,OAAO,GAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IA6BpD,KAAK,CAAC,GAAG;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAiB,UAAU,EAAE,EAAE,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,4EAA4E,CAC7E,CAAC;YACF,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;Q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AAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzC,CAAC;;AAnFO;IAHP,KAAK,CAAC,MAAM,CAAC;QACZ,WAAW,EAAE,4EAA4E;KAC1F,CAAC;kDAC0B;AAKpB;IAHP,KAAK,CAAC,MAAM,CAAC;QACZ,WAAW,EAAE,iFAAiF;KAC/F,CAAC;wDACgC;AAG1B;IADP,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC;8CACrE;AAMhB;IAJP,KAAK,CAAC,MAAM,CAAC;QACZ,WAAW,EACT,sHAAsH;KACzH,CAAC;qDAC6B;AAKvB;IAHP,KAAK,CAAC,MAAM,CAAC;QACZ,WAAW,EAAE,uEAAuE;KACrF,CAAC;sDAC8B;AAGxB;IADP,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;4CACpC"}
|
|
@@ -2,10 +2,24 @@ import { BaseCommand } from '@adonisjs/core/ace';
|
|
|
2
2
|
import type { CommandOptions } from '@adonisjs/core/types/ace';
|
|
3
3
|
/**
|
|
4
4
|
* `node ace payments:sync [--provider=stripe] [--customer=cus_123 | --all]` — reconcile
|
|
5
|
-
* local billing records with the gateway. Useful after missed webhooks or manual
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the billing tables converge with the gateway.
|
|
5
|
+
* local billing records with the gateway. Useful after missed webhooks or manual dashboard
|
|
6
|
+
* changes: pages through every invoice for a customer (or for every recorded customer with
|
|
7
|
+
* `--all`), asks the gateway what each charge's payment actually says, and writes that into
|
|
8
|
+
* the local store — so the billing tables converge with the gateway.
|
|
9
|
+
*
|
|
10
|
+
* Three properties this command has to have, and did not:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Every invoice, not the first page.** It read one unpaginated listing and reported the
|
|
13
|
+
* total as if it were the whole customer.
|
|
14
|
+
* 2. **Both directions.** It wrote `status: 'paid'` and nothing else, counting everything
|
|
15
|
+
* that was not paid as "skipped (non-paid)" — so a local row saying `paid` while the
|
|
16
|
+
* gateway said refunded or charged back could never be corrected, which is precisely the
|
|
17
|
+
* drift a gateway-is-truth reconcile exists for.
|
|
18
|
+
* 3. **The gateway's settlement date, or none.** It stamped `paidAt: new Date()`, which moved
|
|
19
|
+
* historic revenue into the month the reconcile ran.
|
|
20
|
+
*
|
|
21
|
+
* One local state is deliberately NOT reconcilable from the gateway: `disputed`. See the
|
|
22
|
+
* comment on it below.
|
|
9
23
|
*/
|
|
10
24
|
export default class PaymentsSync extends BaseCommand {
|
|
11
25
|
#private;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments_sync.d.ts","sourceRoot":"","sources":["../../commands/payments_sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"payments_sync.d.ts","sourceRoot":"","sources":["../../commands/payments_sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAS,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAsB/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;;IACnD,OAAgB,WAAW,SAAmB;IAC9C,OAAgB,WAAW,SAA6D;IACxF,OAAgB,OAAO,EAAE,cAAc,CAA+B;IAG9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,GAAG,CAAC,EAAE,OAAO,CAAC;IAEP,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2JpC"}
|
|
@@ -5,15 +5,43 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
-
import
|
|
9
|
-
import { LucidBillingStore } from '../src/billing/lucid_billing_store.js';
|
|
8
|
+
import { resolveBillingStore } from '../src/billing/resolve_store.js';
|
|
10
9
|
import { PaymentsManager } from '../src/payments_manager.js';
|
|
10
|
+
/** Customers pulled per page while iterating `--all`. */
|
|
11
|
+
const PAGE = 100;
|
|
12
|
+
/**
|
|
13
|
+
* A gateway-sent settlement date as a `Date`, or `undefined` when there is nothing usable.
|
|
14
|
+
*
|
|
15
|
+
* Never a fallback to "now". `revenue()` windows on `paid_at`, so a manufactured date files
|
|
16
|
+
* money in the month the reconcile ran rather than the month it was earned — and running the
|
|
17
|
+
* reconcile twice, in two months, counted the same charge in both.
|
|
18
|
+
*/
|
|
19
|
+
function parseInstant(value) {
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
const parsed = new Date(value);
|
|
23
|
+
return Number.isNaN(parsed.getTime()) ? undefined : parsed;
|
|
24
|
+
}
|
|
11
25
|
/**
|
|
12
26
|
* `node ace payments:sync [--provider=stripe] [--customer=cus_123 | --all]` — reconcile
|
|
13
|
-
* local billing records with the gateway. Useful after missed webhooks or manual
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the billing tables converge with the gateway.
|
|
27
|
+
* local billing records with the gateway. Useful after missed webhooks or manual dashboard
|
|
28
|
+
* changes: pages through every invoice for a customer (or for every recorded customer with
|
|
29
|
+
* `--all`), asks the gateway what each charge's payment actually says, and writes that into
|
|
30
|
+
* the local store — so the billing tables converge with the gateway.
|
|
31
|
+
*
|
|
32
|
+
* Three properties this command has to have, and did not:
|
|
33
|
+
*
|
|
34
|
+
* 1. **Every invoice, not the first page.** It read one unpaginated listing and reported the
|
|
35
|
+
* total as if it were the whole customer.
|
|
36
|
+
* 2. **Both directions.** It wrote `status: 'paid'` and nothing else, counting everything
|
|
37
|
+
* that was not paid as "skipped (non-paid)" — so a local row saying `paid` while the
|
|
38
|
+
* gateway said refunded or charged back could never be corrected, which is precisely the
|
|
39
|
+
* drift a gateway-is-truth reconcile exists for.
|
|
40
|
+
* 3. **The gateway's settlement date, or none.** It stamped `paidAt: new Date()`, which moved
|
|
41
|
+
* historic revenue into the month the reconcile ran.
|
|
42
|
+
*
|
|
43
|
+
* One local state is deliberately NOT reconcilable from the gateway: `disputed`. See the
|
|
44
|
+
* comment on it below.
|
|
17
45
|
*/
|
|
18
46
|
export default class PaymentsSync extends BaseCommand {
|
|
19
47
|
static commandName = 'payments:sync';
|
|
@@ -26,7 +54,7 @@ export default class PaymentsSync extends BaseCommand {
|
|
|
26
54
|
return;
|
|
27
55
|
}
|
|
28
56
|
if (!this.customer && !this.all) {
|
|
29
|
-
this.logger.error('Pass --customer=<gateway customer id> to sync one customer, or --all to sync every
|
|
57
|
+
this.logger.error('Pass --customer=<gateway customer id> to sync one customer, or --all to sync every recorded gateway customer.');
|
|
30
58
|
return;
|
|
31
59
|
}
|
|
32
60
|
const manager = await this.app.container.make(PaymentsManager);
|
|
@@ -34,50 +62,118 @@ export default class PaymentsSync extends BaseCommand {
|
|
|
34
62
|
// Some gateways (Woovi/OpenPix) have no invoice concept — fail early with a clear
|
|
35
63
|
// message instead of listing nothing.
|
|
36
64
|
manager.assertCapability(driver, 'invoices');
|
|
37
|
-
|
|
38
|
-
|
|
65
|
+
// The CONFIGURED store, not a fresh Lucid one: an app that pointed `billing.store`
|
|
66
|
+
// somewhere else would otherwise have its reconcile write to a database the rest of
|
|
67
|
+
// the billing layer never reads.
|
|
68
|
+
const store = await resolveBillingStore(config);
|
|
69
|
+
const customers = this.customer
|
|
70
|
+
? [this.customer]
|
|
71
|
+
: await this.#listCustomers(store, this.provider);
|
|
39
72
|
if (customers.length === 0) {
|
|
40
|
-
this.logger.info('No customers to sync (
|
|
73
|
+
this.logger.info('No customers recorded to sync. `--all` iterates the mappings written by ensureCustomer({ store }) / store.saveCustomer() — see the billing docs.');
|
|
41
74
|
return;
|
|
42
75
|
}
|
|
43
76
|
let synced = 0;
|
|
77
|
+
let protectedRows = 0;
|
|
44
78
|
for (const customerId of customers) {
|
|
45
79
|
const invoices = await driver.listInvoices(customerId);
|
|
46
|
-
let
|
|
80
|
+
let changed = 0;
|
|
81
|
+
let unchanged = 0;
|
|
82
|
+
let undecided = 0;
|
|
47
83
|
for (const invoice of invoices) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
? { subscriptionId: invoice.subscriptionId }
|
|
59
|
-
: {}),
|
|
60
|
-
paidAt: new Date(),
|
|
61
|
-
payload: invoice.payload,
|
|
62
|
-
});
|
|
63
|
-
synced += 1;
|
|
84
|
+
const local = await store.findPaymentByGatewayId(invoice.gatewayId);
|
|
85
|
+
// The converged case, and the reason a second run of this command is cheap: the
|
|
86
|
+
// gateway says paid, the local row says paid, and it already carries a settlement
|
|
87
|
+
// date. There is nothing a `findPayment` could tell us, so it is not asked.
|
|
88
|
+
if (local !== null &&
|
|
89
|
+
local.status === 'paid' &&
|
|
90
|
+
local.paidAt &&
|
|
91
|
+
invoice.status === 'paid') {
|
|
92
|
+
unchanged += 1;
|
|
93
|
+
continue;
|
|
64
94
|
}
|
|
65
|
-
|
|
66
|
-
|
|
95
|
+
// `Invoice.status` cannot say `refunded` or `disputed` — its vocabulary has no
|
|
96
|
+
// members for them, so a reversed charge arrives here as `draft`. That is the exact
|
|
97
|
+
// drift a gateway-is-truth reconcile exists to correct, so the authority is the
|
|
98
|
+
// PAYMENT resource, which speaks `BillingStatus`: the listing enumerates, the payment
|
|
99
|
+
// decides.
|
|
100
|
+
const remote = await driver.findPayment(invoice.gatewayId);
|
|
101
|
+
if (remote === null) {
|
|
102
|
+
undecided += 1;
|
|
103
|
+
continue;
|
|
67
104
|
}
|
|
105
|
+
// The one local state the gateway does not get to overwrite. A chargeback is money
|
|
106
|
+
// the bank has pulled back, it lives in `billing_disputes` with a deadline, and the
|
|
107
|
+
// gateway's payment resource frequently goes on reporting the charge as received
|
|
108
|
+
// while the dispute is open — so reconciling `disputed` back to `paid` here would
|
|
109
|
+
// re-count money that is gone and silence the dispute at the same time. Only
|
|
110
|
+
// `payment.dispute_closed`, which carries an outcome, resolves one.
|
|
111
|
+
if (local !== null && local.status === 'disputed' && remote.status !== 'disputed') {
|
|
112
|
+
protectedRows += 1;
|
|
113
|
+
this.logger.warning(` ${invoice.gatewayId}: local row is disputed, gateway says ${remote.status} — left alone. A dispute is resolved by its close event, not by a reconcile.`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// Already agreed, with nothing left to add: same status, and either the settlement
|
|
117
|
+
// date is recorded or the gateway has none to give. Skipped so a reconcile over a
|
|
118
|
+
// stable install writes nothing at all rather than churning every row's `updated_at`.
|
|
119
|
+
if (local !== null &&
|
|
120
|
+
local.status === remote.status &&
|
|
121
|
+
(local.paidAt || remote.paidAt === undefined)) {
|
|
122
|
+
unchanged += 1;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
// The gateway's OWN settlement date, and never a substitute for it. Stamping
|
|
126
|
+
// `new Date()` here — which is what this did — relocated historic revenue into the
|
|
127
|
+
// month the reconcile ran, so running it twice in different months counted the same
|
|
128
|
+
// charge in both. An already-recorded `paid_at` is never overwritten, and an invoice
|
|
129
|
+
// that carries none records none: absent means "not stated" to `savePayment`, which
|
|
130
|
+
// leaves whatever is there alone.
|
|
131
|
+
const settledAt = local?.paidAt ? undefined : parseInstant(remote.paidAt);
|
|
132
|
+
await store.savePayment({
|
|
133
|
+
gatewayId: invoice.gatewayId,
|
|
134
|
+
provider: invoice.provider,
|
|
135
|
+
// Both directions. Writing only `paid` meant a local row saying `paid` while the
|
|
136
|
+
// gateway said refunded or charged back could never be corrected — and every such
|
|
137
|
+
// row was counted as "skipped (non-paid)", which read like nothing was wrong.
|
|
138
|
+
status: remote.status,
|
|
139
|
+
amount: remote.amount.amount,
|
|
140
|
+
currency: remote.amount.currency,
|
|
141
|
+
...(invoice.customerId !== undefined ? { customerId: invoice.customerId } : {}),
|
|
142
|
+
...(invoice.subscriptionId !== undefined
|
|
143
|
+
? { subscriptionId: invoice.subscriptionId }
|
|
144
|
+
: {}),
|
|
145
|
+
...(settledAt !== undefined ? { paidAt: settledAt } : {}),
|
|
146
|
+
payload: invoice.payload,
|
|
147
|
+
});
|
|
148
|
+
changed += 1;
|
|
149
|
+
synced += 1;
|
|
68
150
|
}
|
|
69
|
-
this.logger.info(` ${customerId}: ${invoices.length} invoice(s), ${
|
|
151
|
+
this.logger.info(` ${customerId}: ${invoices.length} invoice(s), ${changed} reconciled, ${unchanged} already current, ${undecided} undecidable (gateway had no payment)`);
|
|
70
152
|
}
|
|
71
|
-
this.logger.success(`
|
|
153
|
+
this.logger.success(`Reconciled ${synced} payment(s) across ${customers.length} customer(s)${protectedRows > 0 ? `; ${protectedRows} disputed row(s) left alone` : ''}.`);
|
|
72
154
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Gateway customer ids from the recorded customer mappings.
|
|
157
|
+
*
|
|
158
|
+
* Read through the STORE rather than the table: `billing.store` is a configured seam, and
|
|
159
|
+
* a reconcile that queried `billing_customers` directly would iterate a table the rest of
|
|
160
|
+
* the billing layer no longer uses the moment an app points that seam elsewhere.
|
|
161
|
+
*
|
|
162
|
+
* Paged, because `--all` on a large install would otherwise select the whole table into
|
|
163
|
+
* memory before the first invoice is fetched.
|
|
164
|
+
*/
|
|
165
|
+
async #listCustomers(store, provider) {
|
|
166
|
+
const ids = [];
|
|
167
|
+
for (let offset = 0;; offset += PAGE) {
|
|
168
|
+
const page = await store.listCustomers({
|
|
169
|
+
limit: PAGE,
|
|
170
|
+
offset,
|
|
171
|
+
...(provider !== undefined ? { provider } : {}),
|
|
172
|
+
});
|
|
173
|
+
for (const row of page)
|
|
174
|
+
ids.push(row.gatewayId);
|
|
175
|
+
if (page.length < PAGE)
|
|
176
|
+
return ids;
|
|
81
177
|
}
|
|
82
178
|
}
|
|
83
179
|
}
|
|
@@ -89,7 +185,7 @@ __decorate([
|
|
|
89
185
|
], PaymentsSync.prototype, "customer", void 0);
|
|
90
186
|
__decorate([
|
|
91
187
|
flags.boolean({
|
|
92
|
-
description: 'Sync invoices for every
|
|
188
|
+
description: 'Sync invoices for every recorded gateway customer',
|
|
93
189
|
})
|
|
94
190
|
], PaymentsSync.prototype, "all", void 0);
|
|
95
191
|
//# sourceMappingURL=payments_sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments_sync.js","sourceRoot":"","sources":["../../commands/payments_sync.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"payments_sync.js","sourceRoot":"","sources":["../../commands/payments_sync.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,yDAAyD;AACzD,MAAM,IAAI,GAAG,GAAG,CAAC;AAEjB;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAyB;IAC7C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH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AK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;8CACpD;AAGlB;IADP,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;8CAChD;AAKlB;IAHP,KAAK,CAAC,OAAO,CAAC;QACb,WAAW,EAAE,mDAAmD;KACjE,CAAC;yCACoB"}
|
package/dist/configure.d.ts
CHANGED
|
@@ -2,11 +2,18 @@ import type Configure from '@adonisjs/core/commands/configure';
|
|
|
2
2
|
/**
|
|
3
3
|
* `node ace configure @adonis-agora/payments` — auto-wires the package:
|
|
4
4
|
*
|
|
5
|
-
* 1. registers the payments service provider in `adonisrc.ts
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* 1. registers the payments service provider in `adonisrc.ts`, plus the optional
|
|
6
|
+
* dashboard provider;
|
|
7
|
+
* 2. registers the Assembler `init` hook that generates the `app/payment_handlers/`
|
|
8
|
+
* barrel (discovery works without it — the provider falls back to a runtime scan —
|
|
9
|
+
* but the barrel removes that scan from boot);
|
|
10
|
+
* 3. publishes `config/payments.ts`, `config/payments_dashboard.ts` and
|
|
11
|
+
* `config/payments_client.ts` (the browser status endpoint — off unless enabled);
|
|
12
|
+
* 4. publishes ONE Lucid migration for the billing tables, which most apps can delete: the
|
|
13
|
+
* library creates its own schema on first use (`billing.autoCreateSchema`, on by
|
|
14
|
+
* default), so the file is there for apps that would rather run the DDL explicitly. Both
|
|
15
|
+
* paths call the same `createBillingTables`;
|
|
16
|
+
* 5. registers the env validations for the payment providers.
|
|
10
17
|
*/
|
|
11
18
|
export declare function configure(command: Configure): Promise<void>;
|
|
12
19
|
//# sourceMappingURL=configure.d.ts.map
|
package/dist/configure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAG/D
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAG/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,iBA+BjD"}
|
package/dist/configure.js
CHANGED
|
@@ -2,21 +2,33 @@ import { stubsRoot } from './stubs/main.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* `node ace configure @adonis-agora/payments` — auto-wires the package:
|
|
4
4
|
*
|
|
5
|
-
* 1. registers the payments service provider in `adonisrc.ts
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* 1. registers the payments service provider in `adonisrc.ts`, plus the optional
|
|
6
|
+
* dashboard provider;
|
|
7
|
+
* 2. registers the Assembler `init` hook that generates the `app/payment_handlers/`
|
|
8
|
+
* barrel (discovery works without it — the provider falls back to a runtime scan —
|
|
9
|
+
* but the barrel removes that scan from boot);
|
|
10
|
+
* 3. publishes `config/payments.ts`, `config/payments_dashboard.ts` and
|
|
11
|
+
* `config/payments_client.ts` (the browser status endpoint — off unless enabled);
|
|
12
|
+
* 4. publishes ONE Lucid migration for the billing tables, which most apps can delete: the
|
|
13
|
+
* library creates its own schema on first use (`billing.autoCreateSchema`, on by
|
|
14
|
+
* default), so the file is there for apps that would rather run the DDL explicitly. Both
|
|
15
|
+
* paths call the same `createBillingTables`;
|
|
16
|
+
* 5. registers the env validations for the payment providers.
|
|
10
17
|
*/
|
|
11
18
|
export async function configure(command) {
|
|
12
19
|
const codemods = await command.createCodemods();
|
|
13
20
|
// biome-ignore lint/suspicious/noExplicitAny: `createCodemods` types the callback; matching media.
|
|
14
21
|
await codemods.updateRcFile((rcFile) => {
|
|
15
22
|
rcFile.addProvider('@adonis-agora/payments/payments_provider');
|
|
23
|
+
rcFile.addProvider('@adonis-agora/payments/dashboard_provider');
|
|
24
|
+
rcFile.addProvider('@adonis-agora/payments/payments_client_provider');
|
|
16
25
|
rcFile.addCommand('@adonis-agora/payments/commands');
|
|
26
|
+
rcFile.addAssemblerHook('init', '@adonis-agora/payments/hooks/webhook_handlers');
|
|
17
27
|
});
|
|
18
28
|
const stubs = stubsRoot();
|
|
19
29
|
await codemods.makeUsingStub(stubs, 'config/payments.stub', {});
|
|
30
|
+
await codemods.makeUsingStub(stubs, 'config/payments_dashboard.stub', {});
|
|
31
|
+
await codemods.makeUsingStub(stubs, 'config/payments_client.stub', {});
|
|
20
32
|
await codemods.makeUsingStub(stubs, 'database/migrations/create_billing_tables.stub', {});
|
|
21
33
|
await codemods.defineEnvValidations({
|
|
22
34
|
leadingComment: 'PAYMENTS_',
|
|
@@ -28,6 +40,7 @@ export async function configure(command) {
|
|
|
28
40
|
ASAAS_API_KEY: 'Env.schema.string.optional()',
|
|
29
41
|
WOOVI_APP_ID: 'Env.schema.string.optional()',
|
|
30
42
|
FOCUS_NFE_TOKEN: 'Env.schema.string.optional()',
|
|
43
|
+
PAYMENTS_DASHBOARD_TOKEN: 'Env.schema.string.optional()',
|
|
31
44
|
},
|
|
32
45
|
});
|
|
33
46
|
}
|
package/dist/configure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAkB;IAChD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC;IAEhD,mGAAmG;IACnG,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,MA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