@adonis-agora/payments 0.2.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 +27 -0
- package/dist/commands/main.d.ts +16 -0
- package/dist/commands/main.d.ts.map +1 -0
- package/dist/commands/main.js +17 -0
- package/dist/commands/main.js.map +1 -0
- package/dist/commands/make_billable.d.ts +16 -0
- package/dist/commands/make_billable.d.ts.map +1 -0
- package/dist/commands/make_billable.js +30 -0
- package/dist/commands/make_billable.js.map +1 -0
- package/dist/commands/make_webhook_handler.d.ts +20 -0
- package/dist/commands/make_webhook_handler.d.ts.map +1 -0
- package/dist/commands/make_webhook_handler.js +34 -0
- package/dist/commands/make_webhook_handler.js.map +1 -0
- package/dist/commands/payments_sync.d.ts +20 -0
- package/dist/commands/payments_sync.d.ts.map +1 -0
- package/dist/commands/payments_sync.js +95 -0
- package/dist/commands/payments_sync.js.map +1 -0
- package/dist/commands/payments_webhook.d.ts +19 -0
- package/dist/commands/payments_webhook.d.ts.map +1 -0
- package/dist/commands/payments_webhook.js +123 -0
- package/dist/commands/payments_webhook.js.map +1 -0
- package/dist/configure.d.ts +12 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +34 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/payments_provider.d.ts +15 -0
- package/dist/providers/payments_provider.d.ts.map +1 -0
- package/dist/providers/payments_provider.js +155 -0
- package/dist/providers/payments_provider.js.map +1 -0
- package/dist/src/billing/billing_overview.d.ts +26 -0
- package/dist/src/billing/billing_overview.d.ts.map +1 -0
- package/dist/src/billing/billing_overview.js +27 -0
- package/dist/src/billing/billing_overview.js.map +1 -0
- package/dist/src/billing/billing_store.d.ts +73 -0
- package/dist/src/billing/billing_store.d.ts.map +1 -0
- package/dist/src/billing/billing_store.js +2 -0
- package/dist/src/billing/billing_store.js.map +1 -0
- package/dist/src/billing/index.d.ts +8 -0
- package/dist/src/billing/index.d.ts.map +1 -0
- package/dist/src/billing/index.js +6 -0
- package/dist/src/billing/index.js.map +1 -0
- package/dist/src/billing/lucid_billing_store.d.ts +84 -0
- package/dist/src/billing/lucid_billing_store.d.ts.map +1 -0
- package/dist/src/billing/lucid_billing_store.js +143 -0
- package/dist/src/billing/lucid_billing_store.js.map +1 -0
- package/dist/src/billing/metered_bill.d.ts +60 -0
- package/dist/src/billing/metered_bill.d.ts.map +1 -0
- package/dist/src/billing/metered_bill.js +46 -0
- package/dist/src/billing/metered_bill.js.map +1 -0
- package/dist/src/billing/mixins/index.d.ts +6 -0
- package/dist/src/billing/mixins/index.d.ts.map +1 -0
- package/dist/src/billing/mixins/index.js +6 -0
- package/dist/src/billing/mixins/index.js.map +1 -0
- package/dist/src/billing/mixins/with_billable.d.ts +23 -0
- package/dist/src/billing/mixins/with_billable.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_billable.js +33 -0
- package/dist/src/billing/mixins/with_billable.js.map +1 -0
- package/dist/src/billing/mixins/with_payment.d.ts +45 -0
- package/dist/src/billing/mixins/with_payment.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_payment.js +94 -0
- package/dist/src/billing/mixins/with_payment.js.map +1 -0
- package/dist/src/billing/mixins/with_subscription.d.ts +50 -0
- package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_subscription.js +95 -0
- package/dist/src/billing/mixins/with_subscription.js.map +1 -0
- package/dist/src/billing/mixins/with_usage_event.d.ts +22 -0
- package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_usage_event.js +39 -0
- package/dist/src/billing/mixins/with_usage_event.js.map +1 -0
- package/dist/src/billing/mixins/with_webhook_event.d.ts +21 -0
- package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_webhook_event.js +42 -0
- package/dist/src/billing/mixins/with_webhook_event.js.map +1 -0
- package/dist/src/billing/webhook_dispatcher.d.ts +79 -0
- package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -0
- package/dist/src/billing/webhook_dispatcher.js +125 -0
- package/dist/src/billing/webhook_dispatcher.js.map +1 -0
- package/dist/src/billing/webhook_events.d.ts +49 -0
- package/dist/src/billing/webhook_events.d.ts.map +1 -0
- package/dist/src/billing/webhook_events.js +44 -0
- package/dist/src/billing/webhook_events.js.map +1 -0
- package/dist/src/billing/webhook_processor.d.ts +39 -0
- package/dist/src/billing/webhook_processor.d.ts.map +1 -0
- package/dist/src/billing/webhook_processor.js +209 -0
- package/dist/src/billing/webhook_processor.js.map +1 -0
- package/dist/src/define_config.d.ts +251 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +67 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/diagnostics.d.ts +155 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +153 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/driver.d.ts +222 -0
- package/dist/src/driver.d.ts.map +1 -0
- package/dist/src/driver.js +2 -0
- package/dist/src/driver.js.map +1 -0
- package/dist/src/drivers/abacate.d.ts +35 -0
- package/dist/src/drivers/abacate.d.ts.map +1 -0
- package/dist/src/drivers/abacate.js +381 -0
- package/dist/src/drivers/abacate.js.map +1 -0
- package/dist/src/drivers/asaas.d.ts +36 -0
- package/dist/src/drivers/asaas.d.ts.map +1 -0
- package/dist/src/drivers/asaas.js +455 -0
- package/dist/src/drivers/asaas.js.map +1 -0
- package/dist/src/drivers/stripe.d.ts +36 -0
- package/dist/src/drivers/stripe.d.ts.map +1 -0
- package/dist/src/drivers/stripe.js +392 -0
- package/dist/src/drivers/stripe.js.map +1 -0
- package/dist/src/drivers/woovi.d.ts +49 -0
- package/dist/src/drivers/woovi.d.ts.map +1 -0
- package/dist/src/drivers/woovi.js +339 -0
- package/dist/src/drivers/woovi.js.map +1 -0
- package/dist/src/ensure_customer.d.ts +23 -0
- package/dist/src/ensure_customer.d.ts.map +1 -0
- package/dist/src/ensure_customer.js +25 -0
- package/dist/src/ensure_customer.js.map +1 -0
- package/dist/src/hooks/webhook_handlers.d.ts +50 -0
- package/dist/src/hooks/webhook_handlers.d.ts.map +1 -0
- package/dist/src/hooks/webhook_handlers.js +53 -0
- package/dist/src/hooks/webhook_handlers.js.map +1 -0
- package/dist/src/http.d.ts +24 -0
- package/dist/src/http.d.ts.map +1 -0
- package/dist/src/http.js +52 -0
- package/dist/src/http.js.map +1 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/invoice/drivers/asaas.d.ts +23 -0
- package/dist/src/invoice/drivers/asaas.d.ts.map +1 -0
- package/dist/src/invoice/drivers/asaas.js +85 -0
- package/dist/src/invoice/drivers/asaas.js.map +1 -0
- package/dist/src/invoice/drivers/enotas.d.ts +23 -0
- package/dist/src/invoice/drivers/enotas.d.ts.map +1 -0
- package/dist/src/invoice/drivers/enotas.js +83 -0
- package/dist/src/invoice/drivers/enotas.js.map +1 -0
- package/dist/src/invoice/drivers/focus.d.ts +23 -0
- package/dist/src/invoice/drivers/focus.d.ts.map +1 -0
- package/dist/src/invoice/drivers/focus.js +90 -0
- package/dist/src/invoice/drivers/focus.js.map +1 -0
- package/dist/src/invoice/drivers/plugnotas.d.ts +22 -0
- package/dist/src/invoice/drivers/plugnotas.d.ts.map +1 -0
- package/dist/src/invoice/drivers/plugnotas.js +81 -0
- package/dist/src/invoice/drivers/plugnotas.js.map +1 -0
- package/dist/src/invoice/drivers/tecnospeed.d.ts +29 -0
- package/dist/src/invoice/drivers/tecnospeed.d.ts.map +1 -0
- package/dist/src/invoice/drivers/tecnospeed.js +87 -0
- package/dist/src/invoice/drivers/tecnospeed.js.map +1 -0
- package/dist/src/invoice/emit_invoice.d.ts +45 -0
- package/dist/src/invoice/emit_invoice.d.ts.map +1 -0
- package/dist/src/invoice/emit_invoice.js +72 -0
- package/dist/src/invoice/emit_invoice.js.map +1 -0
- package/dist/src/invoice/invoice_manager.d.ts +12 -0
- package/dist/src/invoice/invoice_manager.d.ts.map +1 -0
- package/dist/src/invoice/invoice_manager.js +35 -0
- package/dist/src/invoice/invoice_manager.js.map +1 -0
- package/dist/src/invoice/invoice_provider.d.ts +48 -0
- package/dist/src/invoice/invoice_provider.d.ts.map +1 -0
- package/dist/src/invoice/invoice_provider.js +2 -0
- package/dist/src/invoice/invoice_provider.js.map +1 -0
- package/dist/src/money.d.ts +11 -0
- package/dist/src/money.d.ts.map +1 -0
- package/dist/src/money.js +14 -0
- package/dist/src/money.js.map +1 -0
- package/dist/src/payments_manager.d.ts +40 -0
- package/dist/src/payments_manager.d.ts.map +1 -0
- package/dist/src/payments_manager.js +94 -0
- package/dist/src/payments_manager.js.map +1 -0
- package/dist/src/services/main.d.ts +6 -0
- package/dist/src/services/main.d.ts.map +1 -0
- package/dist/src/services/main.js +17 -0
- package/dist/src/services/main.js.map +1 -0
- package/dist/src/telescope/index.d.ts +3 -0
- package/dist/src/telescope/index.d.ts.map +1 -0
- package/dist/src/telescope/index.js +2 -0
- package/dist/src/telescope/index.js.map +1 -0
- package/dist/src/telescope/payments_watcher.d.ts +27 -0
- package/dist/src/telescope/payments_watcher.d.ts.map +1 -0
- package/dist/src/telescope/payments_watcher.js +58 -0
- package/dist/src/telescope/payments_watcher.js.map +1 -0
- package/dist/src/telescope/telescope-sdk.d.ts +21 -0
- package/dist/src/telescope/telescope-sdk.d.ts.map +1 -0
- package/dist/src/telescope/telescope-sdk.js +11 -0
- package/dist/src/telescope/telescope-sdk.js.map +1 -0
- package/dist/src/testing/fake_payments_driver.d.ts +64 -0
- package/dist/src/testing/fake_payments_driver.d.ts.map +1 -0
- package/dist/src/testing/fake_payments_driver.js +171 -0
- package/dist/src/testing/fake_payments_driver.js.map +1 -0
- package/dist/src/testing/in_memory_billing_store.d.ts +110 -0
- package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -0
- package/dist/src/testing/in_memory_billing_store.js +136 -0
- package/dist/src/testing/in_memory_billing_store.js.map +1 -0
- package/dist/src/testing/index.d.ts +6 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +4 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/mutable_clock.d.ts +12 -0
- package/dist/src/testing/mutable_clock.d.ts.map +1 -0
- package/dist/src/testing/mutable_clock.js +20 -0
- package/dist/src/testing/mutable_clock.js.map +1 -0
- package/dist/src/types.d.ts +178 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +9 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/webhook_handlers.d.ts +76 -0
- package/dist/src/webhook_handlers.d.ts.map +1 -0
- package/dist/src/webhook_handlers.js +128 -0
- package/dist/src/webhook_handlers.js.map +1 -0
- package/dist/src/webhook_security.d.ts +29 -0
- package/dist/src/webhook_security.d.ts.map +1 -0
- package/dist/src/webhook_security.js +53 -0
- package/dist/src/webhook_security.js.map +1 -0
- package/dist/stubs/config/payments.stub +101 -0
- package/dist/stubs/database/migrations/create_billing_tables.stub +90 -0
- package/dist/stubs/main.d.ts +9 -0
- package/dist/stubs/main.d.ts.map +1 -0
- package/dist/stubs/main.js +16 -0
- package/dist/stubs/main.js.map +1 -0
- package/dist/stubs/make/billable/main.stub +28 -0
- package/dist/stubs/make/webhook_handler/main.stub +29 -0
- package/package.json +150 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.migrationsPath(`${new Date().getTime()}_create_billing_tables.ts`) })
|
|
3
|
+
}}}
|
|
4
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
5
|
+
|
|
6
|
+
export default class extends BaseSchema {
|
|
7
|
+
protected tableName = 'billing_customers'
|
|
8
|
+
|
|
9
|
+
async up() {
|
|
10
|
+
this.schema.createTable('billing_customers', (table) => {
|
|
11
|
+
table.uuid('id').primary()
|
|
12
|
+
table.string('owner_type')
|
|
13
|
+
table.string('owner_id')
|
|
14
|
+
table.string('gateway_id').unique()
|
|
15
|
+
table.string('provider')
|
|
16
|
+
table.string('email').nullable()
|
|
17
|
+
table.string('name').nullable()
|
|
18
|
+
table.string('tax_id').nullable()
|
|
19
|
+
table.jsonb('metadata').nullable()
|
|
20
|
+
table.timestamp('created_at', { useTz: true }).notNullable()
|
|
21
|
+
table.timestamp('updated_at', { useTz: true }).notNullable()
|
|
22
|
+
table.index(['owner_type', 'owner_id'], 'billing_customers_owner_idx')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
this.schema.createTable('billing_subscriptions', (table) => {
|
|
26
|
+
table.uuid('id').primary()
|
|
27
|
+
table.string('gateway_id').unique()
|
|
28
|
+
table.string('provider')
|
|
29
|
+
table.string('status')
|
|
30
|
+
table.string('plan_id')
|
|
31
|
+
table.string('customer_id').nullable()
|
|
32
|
+
table.timestamp('trial_ends_at', { useTz: true }).nullable()
|
|
33
|
+
table.timestamp('ends_at', { useTz: true }).nullable()
|
|
34
|
+
table.jsonb('payload').nullable()
|
|
35
|
+
table.timestamp('created_at', { useTz: true }).notNullable()
|
|
36
|
+
table.timestamp('updated_at', { useTz: true }).notNullable()
|
|
37
|
+
table.index(['customer_id'], 'billing_subscriptions_customer_idx')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
this.schema.createTable('billing_payments', (table) => {
|
|
41
|
+
table.uuid('id').primary()
|
|
42
|
+
table.string('gateway_id').unique()
|
|
43
|
+
table.string('provider')
|
|
44
|
+
table.string('status')
|
|
45
|
+
table.bigInteger('amount')
|
|
46
|
+
table.string('currency', 3)
|
|
47
|
+
table.string('customer_id').nullable()
|
|
48
|
+
table.string('subscription_id').nullable()
|
|
49
|
+
table.jsonb('payload').nullable()
|
|
50
|
+
table.timestamp('paid_at', { useTz: true }).nullable()
|
|
51
|
+
table.timestamp('created_at', { useTz: true }).notNullable()
|
|
52
|
+
table.timestamp('updated_at', { useTz: true }).notNullable()
|
|
53
|
+
table.index(['customer_id'], 'billing_payments_customer_idx')
|
|
54
|
+
table.index(['subscription_id'], 'billing_payments_subscription_idx')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
this.schema.createTable('billing_webhook_events', (table) => {
|
|
58
|
+
table.uuid('id').primary()
|
|
59
|
+
table.string('gateway_event_id').unique()
|
|
60
|
+
table.string('provider')
|
|
61
|
+
table.string('type')
|
|
62
|
+
table.string('status')
|
|
63
|
+
table.jsonb('payload').nullable()
|
|
64
|
+
table.text('error').nullable()
|
|
65
|
+
table.timestamp('created_at', { useTz: true }).notNullable()
|
|
66
|
+
table.timestamp('updated_at', { useTz: true }).notNullable()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
this.schema.createTable('billing_usage_events', (table) => {
|
|
70
|
+
table.uuid('id').primary()
|
|
71
|
+
table.string('subscription_id').nullable()
|
|
72
|
+
table.string('customer_id').nullable()
|
|
73
|
+
table.string('meter')
|
|
74
|
+
table.integer('quantity').defaultTo(1)
|
|
75
|
+
table.jsonb('metadata').nullable()
|
|
76
|
+
table.timestamp('recorded_at', { useTz: true }).notNullable()
|
|
77
|
+
table.timestamp('updated_at', { useTz: true }).notNullable()
|
|
78
|
+
table.index(['subscription_id', 'meter'], 'billing_usage_subscription_meter_idx')
|
|
79
|
+
table.index(['customer_id', 'meter'], 'billing_usage_customer_meter_idx')
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async down() {
|
|
84
|
+
this.schema.dropTable('billing_customers')
|
|
85
|
+
this.schema.dropTable('billing_subscriptions')
|
|
86
|
+
this.schema.dropTable('billing_payments')
|
|
87
|
+
this.schema.dropTable('billing_webhook_events')
|
|
88
|
+
this.schema.dropTable('billing_usage_events')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Absolute path to the published stubs directory (`dist/stubs/`).
|
|
3
|
+
*
|
|
4
|
+
* Computed lazily on first call — NOT at module import — and memoized, so importing this
|
|
5
|
+
* package never evaluates `fileURLToPath(new URL('./', import.meta.url))` at load time
|
|
6
|
+
* (see the same hazard fix in `@adonis-agora/media`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function stubsRoot(): string;
|
|
9
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../stubs/main.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAKlC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
let cached;
|
|
3
|
+
/**
|
|
4
|
+
* Absolute path to the published stubs directory (`dist/stubs/`).
|
|
5
|
+
*
|
|
6
|
+
* Computed lazily on first call — NOT at module import — and memoized, so importing this
|
|
7
|
+
* package never evaluates `fileURLToPath(new URL('./', import.meta.url))` at load time
|
|
8
|
+
* (see the same hazard fix in `@adonis-agora/media`).
|
|
9
|
+
*/
|
|
10
|
+
export function stubsRoot() {
|
|
11
|
+
if (cached === undefined) {
|
|
12
|
+
cached = fileURLToPath(new URL('./', import.meta.url));
|
|
13
|
+
}
|
|
14
|
+
return cached;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../stubs/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,IAAI,MAA0B,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,SAAS;IACvB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{{#var billableName = string(entity.name).pascalCase().toString()}}
|
|
2
|
+
{{#var billableFileName = string(entity.name).snakeCase().removeSuffix('model').toString() + '_model'}}
|
|
3
|
+
{{{
|
|
4
|
+
exports({
|
|
5
|
+
to: app.makePath('app/models', entity.path, billableFileName + '.ts')
|
|
6
|
+
})
|
|
7
|
+
}}}
|
|
8
|
+
import { BaseModel, compose } from '@adonisjs/lucid/orm'
|
|
9
|
+
import { column } from '@adonisjs/lucid/orm'
|
|
10
|
+
import { withBillable } from '@adonis-agora/payments'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* {{ billableName }} — the billable model. Compose `withBillable()` to add the billing
|
|
14
|
+
* customer columns (billingCustomerId, billingProvider) and use the payments service
|
|
15
|
+
* to charge, subscribe and manage payment methods.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const payments = await app.container.make(PaymentsManager)
|
|
19
|
+
* const driver = payments.driver('pix')
|
|
20
|
+
* const customer = await driver.createCustomer({ name: user.name, email: user.email })
|
|
21
|
+
* user.billingCustomerId = customer.id
|
|
22
|
+
* await user.save()
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export default class {{ billableName }} extends compose(BaseModel, withBillable()) {
|
|
26
|
+
@column({ isPrimary: true })
|
|
27
|
+
declare id: string
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{{#var handlerName = string(entity.name).pascalCase().toString()}}
|
|
2
|
+
{{#var fileName = string(entity.name).snakeCase().toString()}}
|
|
3
|
+
{{{
|
|
4
|
+
exports({
|
|
5
|
+
to: app.makePath('app/payment_handlers', entity.path, fileName + '.ts')
|
|
6
|
+
})
|
|
7
|
+
}}}
|
|
8
|
+
import { inject } from '@adonisjs/core'
|
|
9
|
+
import type { WebhookEvent } from '@adonis-agora/payments'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Webhook handler para `{{ entity.name }}` — rodado pela rota da própria lib
|
|
13
|
+
* (`/payments/webhook/:provider`) dentro do WebhookProcessor. Um throw marca o evento
|
|
14
|
+
* como failed no ledger e o dispatcher re-tenta (durable/in-process).
|
|
15
|
+
*
|
|
16
|
+
* Faça a lógica pesada rodar numa fila/workflow durable e dispatch aqui:
|
|
17
|
+
*
|
|
18
|
+
* const engine = await app.container.make(WorkflowEngine)
|
|
19
|
+
* await engine.start(MyWorkflow, { ... }, randomUUID())
|
|
20
|
+
*/
|
|
21
|
+
@inject()
|
|
22
|
+
export default class {{ handlerName }}Handler {
|
|
23
|
+
static readonly eventType = '{{ entity.name }}'
|
|
24
|
+
|
|
25
|
+
async handle(event: WebhookEvent): Promise<void> {
|
|
26
|
+
// Sua lógica de negócio (ou dispatch pra um workflow durable / job da fila)...
|
|
27
|
+
void event
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adonis-agora/payments",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Billing library for AdonisJS — multi-gateway payments (Stripe, AbacatePay, Asaas, Woovi) with a Cashier-style subscription billing layer: Billable mixin, Lucid stores, idempotent webhook processing and an optional Durable-backed dispatcher. Part of the Agora ecosystem.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/DavideCarvalho/adonis-agora-payments.git",
|
|
9
|
+
"directory": "packages/adonis"
|
|
10
|
+
},
|
|
11
|
+
"author": "Davi Carvalho <davi@goflip.ai>",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/src/index.js",
|
|
14
|
+
"types": "./dist/src/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/src/index.d.ts",
|
|
18
|
+
"import": "./dist/src/index.js",
|
|
19
|
+
"default": "./dist/src/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./services/main": {
|
|
22
|
+
"types": "./dist/src/services/main.d.ts",
|
|
23
|
+
"import": "./dist/src/services/main.js",
|
|
24
|
+
"default": "./dist/src/services/main.js"
|
|
25
|
+
},
|
|
26
|
+
"./payments_provider": {
|
|
27
|
+
"types": "./dist/providers/payments_provider.d.ts",
|
|
28
|
+
"import": "./dist/providers/payments_provider.js",
|
|
29
|
+
"default": "./dist/providers/payments_provider.js"
|
|
30
|
+
},
|
|
31
|
+
"./configure": {
|
|
32
|
+
"types": "./dist/configure.d.ts",
|
|
33
|
+
"import": "./dist/configure.js",
|
|
34
|
+
"default": "./dist/configure.js"
|
|
35
|
+
},
|
|
36
|
+
"./commands": {
|
|
37
|
+
"types": "./dist/commands/main.d.ts",
|
|
38
|
+
"import": "./dist/commands/main.js",
|
|
39
|
+
"default": "./dist/commands/main.js"
|
|
40
|
+
},
|
|
41
|
+
"./commands/*": {
|
|
42
|
+
"types": "./dist/commands/*.d.ts",
|
|
43
|
+
"import": "./dist/commands/*.js",
|
|
44
|
+
"default": "./dist/commands/*.js"
|
|
45
|
+
},
|
|
46
|
+
"./hooks/webhook_handlers": {
|
|
47
|
+
"types": "./dist/src/hooks/webhook_handlers.d.ts",
|
|
48
|
+
"import": "./dist/src/hooks/webhook_handlers.js",
|
|
49
|
+
"default": "./dist/src/hooks/webhook_handlers.js"
|
|
50
|
+
},
|
|
51
|
+
"./testing": {
|
|
52
|
+
"types": "./dist/src/testing/index.d.ts",
|
|
53
|
+
"import": "./dist/src/testing/index.js",
|
|
54
|
+
"default": "./dist/src/testing/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./telescope": {
|
|
57
|
+
"types": "./dist/src/telescope/index.d.ts",
|
|
58
|
+
"import": "./dist/src/telescope/index.js",
|
|
59
|
+
"default": "./dist/src/telescope/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./drivers/asaas": {
|
|
62
|
+
"types": "./dist/src/drivers/asaas.d.ts",
|
|
63
|
+
"import": "./dist/src/drivers/asaas.js",
|
|
64
|
+
"default": "./dist/src/drivers/asaas.js"
|
|
65
|
+
},
|
|
66
|
+
"./drivers/stripe": {
|
|
67
|
+
"types": "./dist/src/drivers/stripe.d.ts",
|
|
68
|
+
"import": "./dist/src/drivers/stripe.js",
|
|
69
|
+
"default": "./dist/src/drivers/stripe.js"
|
|
70
|
+
},
|
|
71
|
+
"./drivers/abacate": {
|
|
72
|
+
"types": "./dist/src/drivers/abacate.d.ts",
|
|
73
|
+
"import": "./dist/src/drivers/abacate.js",
|
|
74
|
+
"default": "./dist/src/drivers/abacate.js"
|
|
75
|
+
},
|
|
76
|
+
"./drivers/woovi": {
|
|
77
|
+
"types": "./dist/src/drivers/woovi.d.ts",
|
|
78
|
+
"import": "./dist/src/drivers/woovi.js",
|
|
79
|
+
"default": "./dist/src/drivers/woovi.js"
|
|
80
|
+
},
|
|
81
|
+
"./types": {
|
|
82
|
+
"types": "./dist/src/types.d.ts",
|
|
83
|
+
"import": "./dist/src/types.js",
|
|
84
|
+
"default": "./dist/src/types.js"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"files": [
|
|
88
|
+
"dist/",
|
|
89
|
+
"README.md",
|
|
90
|
+
"CHANGELOG.md"
|
|
91
|
+
],
|
|
92
|
+
"sideEffects": false,
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"@adonis-agora/durable": ">=0.1.0 <1.0.0",
|
|
95
|
+
"@adonisjs/core": "^7.3.0",
|
|
96
|
+
"@adonisjs/lucid": "^22.4.0",
|
|
97
|
+
"@woovi/node-sdk": "^1.0.0",
|
|
98
|
+
"stripe": "^17.0.0 || ^18.0.0"
|
|
99
|
+
},
|
|
100
|
+
"peerDependenciesMeta": {
|
|
101
|
+
"@adonis-agora/durable": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"@adonisjs/lucid": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"@woovi/node-sdk": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"stripe": {
|
|
111
|
+
"optional": true
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"devDependencies": {
|
|
115
|
+
"@adonisjs/assembler": "^8.5.0",
|
|
116
|
+
"@adonisjs/core": "7.4.0",
|
|
117
|
+
"@adonisjs/lucid": "^22.4.0",
|
|
118
|
+
"@types/luxon": "^3.7.5",
|
|
119
|
+
"@types/node": "^20.0.0",
|
|
120
|
+
"@woovi/node-sdk": "^1.0.0",
|
|
121
|
+
"luxon": "^3.7.2",
|
|
122
|
+
"stripe": "^18.0.0",
|
|
123
|
+
"typescript": "^5.4.0",
|
|
124
|
+
"vitest": "3.2.7"
|
|
125
|
+
},
|
|
126
|
+
"engines": {
|
|
127
|
+
"node": ">=20.6.0"
|
|
128
|
+
},
|
|
129
|
+
"keywords": [
|
|
130
|
+
"adonisjs",
|
|
131
|
+
"adonis",
|
|
132
|
+
"payments",
|
|
133
|
+
"billing",
|
|
134
|
+
"subscriptions",
|
|
135
|
+
"stripe",
|
|
136
|
+
"abacatepay",
|
|
137
|
+
"asaas",
|
|
138
|
+
"woovi",
|
|
139
|
+
"openpix",
|
|
140
|
+
"pix",
|
|
141
|
+
"agora"
|
|
142
|
+
],
|
|
143
|
+
"scripts": {
|
|
144
|
+
"build": "tsc -p tsconfig.json && pnpm run copy:stubs",
|
|
145
|
+
"copy:stubs": "mkdir -p dist/stubs/config dist/stubs/database/migrations dist/stubs/make/billable dist/stubs/make/webhook_handler && cp -r stubs/config/. dist/stubs/config/ && cp -r stubs/database/migrations/. dist/stubs/database/migrations/ && cp -r stubs/make/billable/. dist/stubs/make/billable/ && cp -r stubs/make/webhook_handler/. dist/stubs/make/webhook_handler/",
|
|
146
|
+
"test": "vitest run --passWithNoTests",
|
|
147
|
+
"test:watch": "vitest",
|
|
148
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
149
|
+
}
|
|
150
|
+
}
|