@dodopayments/better-auth 1.5.0 → 1.6.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 +75 -5
- package/dist/{chunk-R5TTSJK4.js → chunk-527Y7FSE.js} +28 -19
- package/dist/chunk-527Y7FSE.js.map +1 -0
- package/dist/{chunk-65YIVTFE.js → chunk-6VDYFSNJ.js} +6 -6
- package/dist/chunk-6VDYFSNJ.js.map +1 -0
- package/dist/{chunk-TOPOAYYO.js → chunk-EGRIWRWP.js} +6 -3
- package/dist/chunk-EGRIWRWP.js.map +1 -0
- package/dist/{chunk-HHIXOUFD.js → chunk-XXIDSJPK.js} +4 -4
- package/dist/chunk-XXIDSJPK.js.map +1 -0
- package/dist/{chunk-DTOB4IQZ.js → chunk-YCUWFLKK.js} +15 -12
- package/dist/chunk-YCUWFLKK.js.map +1 -0
- package/dist/{chunk-ARA27DRZ.js → chunk-ZA3TNX5K.js} +11 -9
- package/dist/chunk-ZA3TNX5K.js.map +1 -0
- package/dist/client.d.cts +1 -2
- package/dist/client.d.ts +1 -2
- package/dist/hooks/customer.cjs +27 -18
- package/dist/hooks/customer.cjs.map +1 -1
- package/dist/hooks/customer.d.cts +1 -2
- package/dist/hooks/customer.d.ts +1 -2
- package/dist/hooks/customer.js +1 -1
- package/dist/index.cjs +63 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/plugins/checkout.cjs +5 -5
- package/dist/plugins/checkout.cjs.map +1 -1
- package/dist/plugins/checkout.d.cts +2 -3
- package/dist/plugins/checkout.d.ts +2 -3
- package/dist/plugins/checkout.js +1 -1
- package/dist/plugins/portal.cjs +18 -12
- package/dist/plugins/portal.cjs.map +1 -1
- package/dist/plugins/portal.d.cts +2 -3
- package/dist/plugins/portal.d.ts +2 -3
- package/dist/plugins/portal.js +2 -2
- package/dist/plugins/usage.cjs +14 -9
- package/dist/plugins/usage.cjs.map +1 -1
- package/dist/plugins/usage.d.cts +6 -107
- package/dist/plugins/usage.d.ts +6 -107
- package/dist/plugins/usage.js +2 -2
- package/dist/plugins/webhooks.cjs +3 -3
- package/dist/plugins/webhooks.cjs.map +1 -1
- package/dist/plugins/webhooks.d.cts +2 -3
- package/dist/plugins/webhooks.d.ts +2 -3
- package/dist/plugins/webhooks.js +1 -1
- package/dist/{types-4JE4OwKb.d.cts → types-D0tVSLaf.d.cts} +122 -10
- package/dist/{types-B9rx1bt7.d.ts → types-D0tVSLaf.d.ts} +122 -10
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/utils.cjs +5 -2
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +8 -1
- package/dist/utils.d.ts +8 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-65YIVTFE.js.map +0 -1
- package/dist/chunk-ARA27DRZ.js.map +0 -1
- package/dist/chunk-DTOB4IQZ.js.map +0 -1
- package/dist/chunk-HHIXOUFD.js.map +0 -1
- package/dist/chunk-R5TTSJK4.js.map +0 -1
- package/dist/chunk-TOPOAYYO.js.map +0 -1
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(webhooks_exports);
|
|
|
26
26
|
var import_webhook = require("@dodopayments/core/webhook");
|
|
27
27
|
var import_api = require("better-auth/api");
|
|
28
28
|
var import_webhook2 = require("@dodopayments/core/webhook");
|
|
29
|
-
var webhooks = (
|
|
29
|
+
var webhooks = (webhookOptions) => (_options) => {
|
|
30
30
|
return {
|
|
31
31
|
dodopaymentsWebhooks: (0, import_api.createAuthEndpoint)(
|
|
32
32
|
"/dodopayments/webhooks",
|
|
@@ -38,7 +38,7 @@ var webhooks = (options) => (_dodopayments) => {
|
|
|
38
38
|
cloneRequest: true
|
|
39
39
|
},
|
|
40
40
|
async (ctx) => {
|
|
41
|
-
const { webhookKey } =
|
|
41
|
+
const { webhookKey } = webhookOptions;
|
|
42
42
|
if (!ctx.request?.body) {
|
|
43
43
|
throw new import_api.APIError("INTERNAL_SERVER_ERROR");
|
|
44
44
|
}
|
|
@@ -76,7 +76,7 @@ var webhooks = (options) => (_dodopayments) => {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
|
-
await (0, import_webhook.handleWebhookPayload)(event,
|
|
79
|
+
await (0, import_webhook.handleWebhookPayload)(event, webhookOptions);
|
|
80
80
|
} catch (e) {
|
|
81
81
|
if (e instanceof Error) {
|
|
82
82
|
ctx.context.logger.error(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/webhooks.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/webhooks.ts"],"sourcesContent":["import type { DodoPaymentsOptions } from \"../types\";\nimport {\n handleWebhookPayload,\n WebhookHandlerConfig,\n} from \"@dodopayments/core/webhook\";\nimport { APIError, createAuthEndpoint } from \"better-auth/api\";\nimport { WebhookPayload } from \"@dodopayments/core/schemas\";\nimport { verifyWebhookPayload } from \"@dodopayments/core/webhook\";\nimport type { WebhookResponse } from \"../types\";\n\nexport const webhooks =\n (webhookOptions: WebhookHandlerConfig) => (_options: DodoPaymentsOptions) => {\n return {\n dodopaymentsWebhooks: createAuthEndpoint(\n \"/dodopayments/webhooks\",\n {\n method: \"POST\",\n metadata: {\n isAction: false,\n },\n cloneRequest: true,\n },\n async (ctx): Promise<WebhookResponse> => {\n const { webhookKey } = webhookOptions;\n\n if (!ctx.request?.body) {\n throw new APIError(\"INTERNAL_SERVER_ERROR\");\n }\n const buf = await ctx.request.text();\n let event: WebhookPayload;\n try {\n if (!webhookKey) {\n throw new APIError(\"INTERNAL_SERVER_ERROR\", {\n message: \"DodoPayments webhook webhookKey not found\",\n });\n }\n\n const headers = {\n \"webhook-id\": ctx.request.headers.get(\"webhook-id\") as string,\n \"webhook-timestamp\": ctx.request.headers.get(\n \"webhook-timestamp\",\n ) as string,\n \"webhook-signature\": ctx.request.headers.get(\n \"webhook-signature\",\n ) as string,\n };\n\n event = await verifyWebhookPayload({\n webhookKey,\n headers,\n body: buf,\n });\n } catch (err: unknown) {\n if (err instanceof Error) {\n ctx.context.logger.error(`Webhook Error: ${err.message}`);\n throw new APIError(\"BAD_REQUEST\", {\n message: `Webhook Error: ${err.message}`,\n });\n }\n\n throw new APIError(\"BAD_REQUEST\", {\n message: `Webhook Error: ${err}`,\n });\n }\n\n try {\n await handleWebhookPayload(event, webhookOptions);\n } catch (e: unknown) {\n if (e instanceof Error) {\n ctx.context.logger.error(\n `DodoPayments webhook failed. Error: ${e.message}`,\n );\n }\n\n ctx.context.logger.error(\n `DodoPayments webhook failed. Error: ${e}`,\n );\n\n throw new APIError(\"BAD_REQUEST\", {\n message: \"Webhook error: See server logs for more information.\",\n });\n }\n\n return ctx.json({ received: true });\n },\n ),\n };\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAGO;AACP,iBAA6C;AAE7C,IAAAA,kBAAqC;AAG9B,IAAM,WACX,CAAC,mBAAyC,CAAC,aAAkC;AAC3E,SAAO;AAAA,IACL,0BAAsB;AAAA,MACpB;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,UAAU;AAAA,UACR,UAAU;AAAA,QACZ;AAAA,QACA,cAAc;AAAA,MAChB;AAAA,MACA,OAAO,QAAkC;AACvC,cAAM,EAAE,WAAW,IAAI;AAEvB,YAAI,CAAC,IAAI,SAAS,MAAM;AACtB,gBAAM,IAAI,oBAAS,uBAAuB;AAAA,QAC5C;AACA,cAAM,MAAM,MAAM,IAAI,QAAQ,KAAK;AACnC,YAAI;AACJ,YAAI;AACF,cAAI,CAAC,YAAY;AACf,kBAAM,IAAI,oBAAS,yBAAyB;AAAA,cAC1C,SAAS;AAAA,YACX,CAAC;AAAA,UACH;AAEA,gBAAM,UAAU;AAAA,YACd,cAAc,IAAI,QAAQ,QAAQ,IAAI,YAAY;AAAA,YAClD,qBAAqB,IAAI,QAAQ,QAAQ;AAAA,cACvC;AAAA,YACF;AAAA,YACA,qBAAqB,IAAI,QAAQ,QAAQ;AAAA,cACvC;AAAA,YACF;AAAA,UACF;AAEA,kBAAQ,UAAM,sCAAqB;AAAA,YACjC;AAAA,YACA;AAAA,YACA,MAAM;AAAA,UACR,CAAC;AAAA,QACH,SAAS,KAAc;AACrB,cAAI,eAAe,OAAO;AACxB,gBAAI,QAAQ,OAAO,MAAM,kBAAkB,IAAI,OAAO,EAAE;AACxD,kBAAM,IAAI,oBAAS,eAAe;AAAA,cAChC,SAAS,kBAAkB,IAAI,OAAO;AAAA,YACxC,CAAC;AAAA,UACH;AAEA,gBAAM,IAAI,oBAAS,eAAe;AAAA,YAChC,SAAS,kBAAkB,GAAG;AAAA,UAChC,CAAC;AAAA,QACH;AAEA,YAAI;AACF,oBAAM,qCAAqB,OAAO,cAAc;AAAA,QAClD,SAAS,GAAY;AACnB,cAAI,aAAa,OAAO;AACtB,gBAAI,QAAQ,OAAO;AAAA,cACjB,uCAAuC,EAAE,OAAO;AAAA,YAClD;AAAA,UACF;AAEA,cAAI,QAAQ,OAAO;AAAA,YACjB,uCAAuC,CAAC;AAAA,UAC1C;AAEA,gBAAM,IAAI,oBAAS,eAAe;AAAA,YAChC,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAEA,eAAO,IAAI,KAAK,EAAE,UAAU,KAAK,CAAC;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACF;","names":["import_webhook"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'better-auth';
|
|
2
|
-
|
|
2
|
+
export { w as webhooks } from '../types-D0tVSLaf.cjs';
|
|
3
3
|
import '@dodopayments/core/webhook';
|
|
4
|
-
|
|
4
|
+
import 'dodopayments';
|
|
5
5
|
import 'zod/v3';
|
|
6
|
-
import './usage.cjs';
|
|
7
6
|
import 'dodopayments/resources/usage-events.mjs';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'better-auth';
|
|
2
|
-
|
|
2
|
+
export { w as webhooks } from '../types-D0tVSLaf.js';
|
|
3
3
|
import '@dodopayments/core/webhook';
|
|
4
|
-
|
|
4
|
+
import 'dodopayments';
|
|
5
5
|
import 'zod/v3';
|
|
6
|
-
import './usage.js';
|
|
7
6
|
import 'dodopayments/resources/usage-events.mjs';
|
package/dist/plugins/webhooks.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DodoPayments } from 'dodopayments';
|
|
2
2
|
import * as better_auth from 'better-auth';
|
|
3
|
-
import { UnionToIntersection } from 'better-auth';
|
|
3
|
+
import { User, UnionToIntersection } from 'better-auth';
|
|
4
4
|
import { z } from 'zod/v3';
|
|
5
5
|
import { WebhookHandlerConfig } from '@dodopayments/core/webhook';
|
|
6
|
-
import {
|
|
6
|
+
import { Event } from 'dodopayments/resources/usage-events.mjs';
|
|
7
7
|
|
|
8
8
|
interface CheckoutOptions {
|
|
9
9
|
/**
|
|
@@ -19,7 +19,7 @@ interface CheckoutOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
authenticatedUsersOnly?: boolean;
|
|
21
21
|
}
|
|
22
|
-
declare const checkout: (checkoutOptions?: CheckoutOptions) => (
|
|
22
|
+
declare const checkout: (checkoutOptions?: CheckoutOptions) => (options: DodoPaymentsOptions) => {
|
|
23
23
|
/**
|
|
24
24
|
* @deprecated
|
|
25
25
|
*/
|
|
@@ -526,7 +526,7 @@ declare const checkout: (checkoutOptions?: CheckoutOptions) => (dodopayments: Do
|
|
|
526
526
|
}, CreateCheckoutResponse>;
|
|
527
527
|
};
|
|
528
528
|
|
|
529
|
-
declare const portal: () => (
|
|
529
|
+
declare const portal: () => (options: DodoPaymentsOptions) => {
|
|
530
530
|
dodoPortal: better_auth.StrictEndpoint<"/dodopayments/customer/portal", {
|
|
531
531
|
method: "GET";
|
|
532
532
|
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -639,7 +639,7 @@ declare const portal: () => (dodopayments: DodoPayments$1) => {
|
|
|
639
639
|
}, PaymentItems>;
|
|
640
640
|
};
|
|
641
641
|
|
|
642
|
-
declare const webhooks: (
|
|
642
|
+
declare const webhooks: (webhookOptions: WebhookHandlerConfig) => (_options: DodoPaymentsOptions) => {
|
|
643
643
|
dodopaymentsWebhooks: better_auth.StrictEndpoint<"/dodopayments/webhooks", {
|
|
644
644
|
method: "POST";
|
|
645
645
|
metadata: {
|
|
@@ -651,6 +651,107 @@ declare const webhooks: (options: WebhookHandlerConfig) => (_dodopayments: DodoP
|
|
|
651
651
|
}, WebhookResponse>;
|
|
652
652
|
};
|
|
653
653
|
|
|
654
|
+
declare const usage: () => (options: DodoPaymentsOptions) => {
|
|
655
|
+
dodoUsageIngest: better_auth.StrictEndpoint<"/dodopayments/usage/ingest", {
|
|
656
|
+
method: "POST";
|
|
657
|
+
body: z.ZodObject<{
|
|
658
|
+
event_id: z.ZodString;
|
|
659
|
+
event_name: z.ZodString;
|
|
660
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
|
|
661
|
+
timestamp: z.ZodOptional<z.ZodEffects<z.ZodDate, string, Date>>;
|
|
662
|
+
}, "strip", z.ZodTypeAny, {
|
|
663
|
+
event_id: string;
|
|
664
|
+
event_name: string;
|
|
665
|
+
metadata?: Record<string, string | number | boolean> | null | undefined;
|
|
666
|
+
timestamp?: string | undefined;
|
|
667
|
+
}, {
|
|
668
|
+
event_id: string;
|
|
669
|
+
event_name: string;
|
|
670
|
+
metadata?: Record<string, string | number | boolean> | null | undefined;
|
|
671
|
+
timestamp?: Date | undefined;
|
|
672
|
+
}>;
|
|
673
|
+
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
674
|
+
session: {
|
|
675
|
+
session: Record<string, any> & {
|
|
676
|
+
id: string;
|
|
677
|
+
createdAt: Date;
|
|
678
|
+
updatedAt: Date;
|
|
679
|
+
userId: string;
|
|
680
|
+
expiresAt: Date;
|
|
681
|
+
token: string;
|
|
682
|
+
ipAddress?: string | null | undefined;
|
|
683
|
+
userAgent?: string | null | undefined;
|
|
684
|
+
};
|
|
685
|
+
user: Record<string, any> & {
|
|
686
|
+
id: string;
|
|
687
|
+
createdAt: Date;
|
|
688
|
+
updatedAt: Date;
|
|
689
|
+
email: string;
|
|
690
|
+
emailVerified: boolean;
|
|
691
|
+
name: string;
|
|
692
|
+
image?: string | null | undefined;
|
|
693
|
+
};
|
|
694
|
+
};
|
|
695
|
+
}>)[];
|
|
696
|
+
} & {
|
|
697
|
+
use: any[];
|
|
698
|
+
}, {
|
|
699
|
+
ingested_count: number;
|
|
700
|
+
}>;
|
|
701
|
+
dodoUsageMetersList: better_auth.StrictEndpoint<"/dodopayments/usage/meters/list", {
|
|
702
|
+
method: "GET";
|
|
703
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
704
|
+
page_number: z.ZodOptional<z.ZodNumber>;
|
|
705
|
+
page_size: z.ZodOptional<z.ZodNumber>;
|
|
706
|
+
event_name: z.ZodOptional<z.ZodString>;
|
|
707
|
+
meter_id: z.ZodOptional<z.ZodString>;
|
|
708
|
+
start: z.ZodOptional<z.ZodString>;
|
|
709
|
+
end: z.ZodOptional<z.ZodString>;
|
|
710
|
+
}, "strip", z.ZodTypeAny, {
|
|
711
|
+
event_name?: string | undefined;
|
|
712
|
+
page_number?: number | undefined;
|
|
713
|
+
page_size?: number | undefined;
|
|
714
|
+
meter_id?: string | undefined;
|
|
715
|
+
start?: string | undefined;
|
|
716
|
+
end?: string | undefined;
|
|
717
|
+
}, {
|
|
718
|
+
event_name?: string | undefined;
|
|
719
|
+
page_number?: number | undefined;
|
|
720
|
+
page_size?: number | undefined;
|
|
721
|
+
meter_id?: string | undefined;
|
|
722
|
+
start?: string | undefined;
|
|
723
|
+
end?: string | undefined;
|
|
724
|
+
}>>;
|
|
725
|
+
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
726
|
+
session: {
|
|
727
|
+
session: Record<string, any> & {
|
|
728
|
+
id: string;
|
|
729
|
+
createdAt: Date;
|
|
730
|
+
updatedAt: Date;
|
|
731
|
+
userId: string;
|
|
732
|
+
expiresAt: Date;
|
|
733
|
+
token: string;
|
|
734
|
+
ipAddress?: string | null | undefined;
|
|
735
|
+
userAgent?: string | null | undefined;
|
|
736
|
+
};
|
|
737
|
+
user: Record<string, any> & {
|
|
738
|
+
id: string;
|
|
739
|
+
createdAt: Date;
|
|
740
|
+
updatedAt: Date;
|
|
741
|
+
email: string;
|
|
742
|
+
emailVerified: boolean;
|
|
743
|
+
name: string;
|
|
744
|
+
image?: string | null | undefined;
|
|
745
|
+
};
|
|
746
|
+
};
|
|
747
|
+
}>)[];
|
|
748
|
+
} & {
|
|
749
|
+
use: any[];
|
|
750
|
+
}, {
|
|
751
|
+
items: Event[];
|
|
752
|
+
}>;
|
|
753
|
+
};
|
|
754
|
+
|
|
654
755
|
type Product = {
|
|
655
756
|
/**
|
|
656
757
|
* Product Id from DodoPayments Product
|
|
@@ -668,7 +769,7 @@ interface DodoPaymentsOptions {
|
|
|
668
769
|
/**
|
|
669
770
|
* DodoPayments Client
|
|
670
771
|
*/
|
|
671
|
-
client: DodoPayments
|
|
772
|
+
client: DodoPayments;
|
|
672
773
|
/**
|
|
673
774
|
* Enable customer creation when a user signs up
|
|
674
775
|
*/
|
|
@@ -677,9 +778,20 @@ interface DodoPaymentsOptions {
|
|
|
677
778
|
* Use DodoPayments plugins
|
|
678
779
|
*/
|
|
679
780
|
use: DodoPaymentsPlugins;
|
|
781
|
+
/**
|
|
782
|
+
* Optionally provide additional fields (e.g. metadata, phone_number) to include when creating
|
|
783
|
+
* or updating a DodoPayments customer.
|
|
784
|
+
*/
|
|
785
|
+
getCustomerParams?: (user: User) => {
|
|
786
|
+
metadata?: Record<string, string>;
|
|
787
|
+
phone_number?: string | null;
|
|
788
|
+
} | Promise<{
|
|
789
|
+
metadata?: Record<string, string>;
|
|
790
|
+
phone_number?: string | null;
|
|
791
|
+
}>;
|
|
680
792
|
}
|
|
681
|
-
type PaymentsList = Awaited<ReturnType<DodoPayments
|
|
682
|
-
type SubscriptionsList = Awaited<ReturnType<DodoPayments
|
|
793
|
+
type PaymentsList = Awaited<ReturnType<DodoPayments["payments"]["list"]>>;
|
|
794
|
+
type SubscriptionsList = Awaited<ReturnType<DodoPayments["subscriptions"]["list"]>>;
|
|
683
795
|
type PaymentItems = {
|
|
684
796
|
items: PaymentsList["items"];
|
|
685
797
|
};
|
|
@@ -698,4 +810,4 @@ type WebhookResponse = {
|
|
|
698
810
|
received: boolean;
|
|
699
811
|
};
|
|
700
812
|
|
|
701
|
-
export { type CreateCheckoutResponse as C, type DodoPaymentsOptions as D, type PaymentItems as P, type SubscriptionItems as S, type WebhookResponse as W, type CustomerPortalResponse as a, type Product as b, type DodoPaymentsPlugin as c, type DodoPaymentsPlugins as d, type DodoPaymentsEndpoints as e, checkout as f, type CheckoutOptions as g, portal as p, webhooks as w };
|
|
813
|
+
export { type CreateCheckoutResponse as C, type DodoPaymentsOptions as D, type PaymentItems as P, type SubscriptionItems as S, type WebhookResponse as W, type CustomerPortalResponse as a, type Product as b, type DodoPaymentsPlugin as c, type DodoPaymentsPlugins as d, type DodoPaymentsEndpoints as e, checkout as f, type CheckoutOptions as g, portal as p, usage as u, webhooks as w };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DodoPayments } from 'dodopayments';
|
|
2
2
|
import * as better_auth from 'better-auth';
|
|
3
|
-
import { UnionToIntersection } from 'better-auth';
|
|
3
|
+
import { User, UnionToIntersection } from 'better-auth';
|
|
4
4
|
import { z } from 'zod/v3';
|
|
5
5
|
import { WebhookHandlerConfig } from '@dodopayments/core/webhook';
|
|
6
|
-
import {
|
|
6
|
+
import { Event } from 'dodopayments/resources/usage-events.mjs';
|
|
7
7
|
|
|
8
8
|
interface CheckoutOptions {
|
|
9
9
|
/**
|
|
@@ -19,7 +19,7 @@ interface CheckoutOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
authenticatedUsersOnly?: boolean;
|
|
21
21
|
}
|
|
22
|
-
declare const checkout: (checkoutOptions?: CheckoutOptions) => (
|
|
22
|
+
declare const checkout: (checkoutOptions?: CheckoutOptions) => (options: DodoPaymentsOptions) => {
|
|
23
23
|
/**
|
|
24
24
|
* @deprecated
|
|
25
25
|
*/
|
|
@@ -526,7 +526,7 @@ declare const checkout: (checkoutOptions?: CheckoutOptions) => (dodopayments: Do
|
|
|
526
526
|
}, CreateCheckoutResponse>;
|
|
527
527
|
};
|
|
528
528
|
|
|
529
|
-
declare const portal: () => (
|
|
529
|
+
declare const portal: () => (options: DodoPaymentsOptions) => {
|
|
530
530
|
dodoPortal: better_auth.StrictEndpoint<"/dodopayments/customer/portal", {
|
|
531
531
|
method: "GET";
|
|
532
532
|
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -639,7 +639,7 @@ declare const portal: () => (dodopayments: DodoPayments$1) => {
|
|
|
639
639
|
}, PaymentItems>;
|
|
640
640
|
};
|
|
641
641
|
|
|
642
|
-
declare const webhooks: (
|
|
642
|
+
declare const webhooks: (webhookOptions: WebhookHandlerConfig) => (_options: DodoPaymentsOptions) => {
|
|
643
643
|
dodopaymentsWebhooks: better_auth.StrictEndpoint<"/dodopayments/webhooks", {
|
|
644
644
|
method: "POST";
|
|
645
645
|
metadata: {
|
|
@@ -651,6 +651,107 @@ declare const webhooks: (options: WebhookHandlerConfig) => (_dodopayments: DodoP
|
|
|
651
651
|
}, WebhookResponse>;
|
|
652
652
|
};
|
|
653
653
|
|
|
654
|
+
declare const usage: () => (options: DodoPaymentsOptions) => {
|
|
655
|
+
dodoUsageIngest: better_auth.StrictEndpoint<"/dodopayments/usage/ingest", {
|
|
656
|
+
method: "POST";
|
|
657
|
+
body: z.ZodObject<{
|
|
658
|
+
event_id: z.ZodString;
|
|
659
|
+
event_name: z.ZodString;
|
|
660
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
|
|
661
|
+
timestamp: z.ZodOptional<z.ZodEffects<z.ZodDate, string, Date>>;
|
|
662
|
+
}, "strip", z.ZodTypeAny, {
|
|
663
|
+
event_id: string;
|
|
664
|
+
event_name: string;
|
|
665
|
+
metadata?: Record<string, string | number | boolean> | null | undefined;
|
|
666
|
+
timestamp?: string | undefined;
|
|
667
|
+
}, {
|
|
668
|
+
event_id: string;
|
|
669
|
+
event_name: string;
|
|
670
|
+
metadata?: Record<string, string | number | boolean> | null | undefined;
|
|
671
|
+
timestamp?: Date | undefined;
|
|
672
|
+
}>;
|
|
673
|
+
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
674
|
+
session: {
|
|
675
|
+
session: Record<string, any> & {
|
|
676
|
+
id: string;
|
|
677
|
+
createdAt: Date;
|
|
678
|
+
updatedAt: Date;
|
|
679
|
+
userId: string;
|
|
680
|
+
expiresAt: Date;
|
|
681
|
+
token: string;
|
|
682
|
+
ipAddress?: string | null | undefined;
|
|
683
|
+
userAgent?: string | null | undefined;
|
|
684
|
+
};
|
|
685
|
+
user: Record<string, any> & {
|
|
686
|
+
id: string;
|
|
687
|
+
createdAt: Date;
|
|
688
|
+
updatedAt: Date;
|
|
689
|
+
email: string;
|
|
690
|
+
emailVerified: boolean;
|
|
691
|
+
name: string;
|
|
692
|
+
image?: string | null | undefined;
|
|
693
|
+
};
|
|
694
|
+
};
|
|
695
|
+
}>)[];
|
|
696
|
+
} & {
|
|
697
|
+
use: any[];
|
|
698
|
+
}, {
|
|
699
|
+
ingested_count: number;
|
|
700
|
+
}>;
|
|
701
|
+
dodoUsageMetersList: better_auth.StrictEndpoint<"/dodopayments/usage/meters/list", {
|
|
702
|
+
method: "GET";
|
|
703
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
704
|
+
page_number: z.ZodOptional<z.ZodNumber>;
|
|
705
|
+
page_size: z.ZodOptional<z.ZodNumber>;
|
|
706
|
+
event_name: z.ZodOptional<z.ZodString>;
|
|
707
|
+
meter_id: z.ZodOptional<z.ZodString>;
|
|
708
|
+
start: z.ZodOptional<z.ZodString>;
|
|
709
|
+
end: z.ZodOptional<z.ZodString>;
|
|
710
|
+
}, "strip", z.ZodTypeAny, {
|
|
711
|
+
event_name?: string | undefined;
|
|
712
|
+
page_number?: number | undefined;
|
|
713
|
+
page_size?: number | undefined;
|
|
714
|
+
meter_id?: string | undefined;
|
|
715
|
+
start?: string | undefined;
|
|
716
|
+
end?: string | undefined;
|
|
717
|
+
}, {
|
|
718
|
+
event_name?: string | undefined;
|
|
719
|
+
page_number?: number | undefined;
|
|
720
|
+
page_size?: number | undefined;
|
|
721
|
+
meter_id?: string | undefined;
|
|
722
|
+
start?: string | undefined;
|
|
723
|
+
end?: string | undefined;
|
|
724
|
+
}>>;
|
|
725
|
+
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
726
|
+
session: {
|
|
727
|
+
session: Record<string, any> & {
|
|
728
|
+
id: string;
|
|
729
|
+
createdAt: Date;
|
|
730
|
+
updatedAt: Date;
|
|
731
|
+
userId: string;
|
|
732
|
+
expiresAt: Date;
|
|
733
|
+
token: string;
|
|
734
|
+
ipAddress?: string | null | undefined;
|
|
735
|
+
userAgent?: string | null | undefined;
|
|
736
|
+
};
|
|
737
|
+
user: Record<string, any> & {
|
|
738
|
+
id: string;
|
|
739
|
+
createdAt: Date;
|
|
740
|
+
updatedAt: Date;
|
|
741
|
+
email: string;
|
|
742
|
+
emailVerified: boolean;
|
|
743
|
+
name: string;
|
|
744
|
+
image?: string | null | undefined;
|
|
745
|
+
};
|
|
746
|
+
};
|
|
747
|
+
}>)[];
|
|
748
|
+
} & {
|
|
749
|
+
use: any[];
|
|
750
|
+
}, {
|
|
751
|
+
items: Event[];
|
|
752
|
+
}>;
|
|
753
|
+
};
|
|
754
|
+
|
|
654
755
|
type Product = {
|
|
655
756
|
/**
|
|
656
757
|
* Product Id from DodoPayments Product
|
|
@@ -668,7 +769,7 @@ interface DodoPaymentsOptions {
|
|
|
668
769
|
/**
|
|
669
770
|
* DodoPayments Client
|
|
670
771
|
*/
|
|
671
|
-
client: DodoPayments
|
|
772
|
+
client: DodoPayments;
|
|
672
773
|
/**
|
|
673
774
|
* Enable customer creation when a user signs up
|
|
674
775
|
*/
|
|
@@ -677,9 +778,20 @@ interface DodoPaymentsOptions {
|
|
|
677
778
|
* Use DodoPayments plugins
|
|
678
779
|
*/
|
|
679
780
|
use: DodoPaymentsPlugins;
|
|
781
|
+
/**
|
|
782
|
+
* Optionally provide additional fields (e.g. metadata, phone_number) to include when creating
|
|
783
|
+
* or updating a DodoPayments customer.
|
|
784
|
+
*/
|
|
785
|
+
getCustomerParams?: (user: User) => {
|
|
786
|
+
metadata?: Record<string, string>;
|
|
787
|
+
phone_number?: string | null;
|
|
788
|
+
} | Promise<{
|
|
789
|
+
metadata?: Record<string, string>;
|
|
790
|
+
phone_number?: string | null;
|
|
791
|
+
}>;
|
|
680
792
|
}
|
|
681
|
-
type PaymentsList = Awaited<ReturnType<DodoPayments
|
|
682
|
-
type SubscriptionsList = Awaited<ReturnType<DodoPayments
|
|
793
|
+
type PaymentsList = Awaited<ReturnType<DodoPayments["payments"]["list"]>>;
|
|
794
|
+
type SubscriptionsList = Awaited<ReturnType<DodoPayments["subscriptions"]["list"]>>;
|
|
683
795
|
type PaymentItems = {
|
|
684
796
|
items: PaymentsList["items"];
|
|
685
797
|
};
|
|
@@ -698,4 +810,4 @@ type WebhookResponse = {
|
|
|
698
810
|
received: boolean;
|
|
699
811
|
};
|
|
700
812
|
|
|
701
|
-
export { type CreateCheckoutResponse as C, type DodoPaymentsOptions as D, type PaymentItems as P, type SubscriptionItems as S, type WebhookResponse as W, type CustomerPortalResponse as a, type Product as b, type DodoPaymentsPlugin as c, type DodoPaymentsPlugins as d, type DodoPaymentsEndpoints as e, checkout as f, type CheckoutOptions as g, portal as p, webhooks as w };
|
|
813
|
+
export { type CreateCheckoutResponse as C, type DodoPaymentsOptions as D, type PaymentItems as P, type SubscriptionItems as S, type WebhookResponse as W, type CustomerPortalResponse as a, type Product as b, type DodoPaymentsPlugin as c, type DodoPaymentsPlugins as d, type DodoPaymentsEndpoints as e, checkout as f, type CheckoutOptions as g, portal as p, usage as u, webhooks as w };
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DodoPayments } from \"dodopayments\";\n\nimport type { UnionToIntersection } from \"better-auth\";\nimport type { checkout } from \"./plugins/checkout\";\nimport type { portal } from \"./plugins/portal\";\nimport type { webhooks } from \"./plugins/webhooks\";\nimport { usage } from \"./plugins/usage\";\n\nexport type Product = {\n /**\n * Product Id from DodoPayments Product\n */\n productId: string;\n /**\n * Easily identifiable slug for the product\n */\n slug: string;\n};\n\nexport type DodoPaymentsPlugin =\n | ReturnType<typeof checkout>\n | ReturnType<typeof portal>\n | ReturnType<typeof webhooks>\n | ReturnType<typeof usage>;\n\nexport type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];\n\nexport type DodoPaymentsEndpoints = UnionToIntersection<\n ReturnType<DodoPaymentsPlugin>\n>;\n\nexport interface DodoPaymentsOptions {\n /**\n * DodoPayments Client\n */\n client: DodoPayments;\n /**\n * Enable customer creation when a user signs up\n */\n createCustomerOnSignUp?: boolean;\n /**\n * Use DodoPayments plugins\n */\n use: DodoPaymentsPlugins;\n}\n\ntype PaymentsList = Awaited<ReturnType<DodoPayments[\"payments\"][\"list\"]>>;\ntype SubscriptionsList = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"list\"]>\n>;\nexport type PaymentItems = { items: PaymentsList[\"items\"] };\nexport type SubscriptionItems = { items: SubscriptionsList[\"items\"] };\nexport type CustomerPortalResponse = { url: string; redirect: boolean };\nexport type CreateCheckoutResponse = { url: string; redirect: boolean };\nexport type WebhookResponse = { received: boolean };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { DodoPayments } from \"dodopayments\";\n\nimport type { UnionToIntersection, User } from \"better-auth\";\nimport type { checkout } from \"./plugins/checkout\";\nimport type { portal } from \"./plugins/portal\";\nimport type { webhooks } from \"./plugins/webhooks\";\nimport { usage } from \"./plugins/usage\";\n\nexport type Product = {\n /**\n * Product Id from DodoPayments Product\n */\n productId: string;\n /**\n * Easily identifiable slug for the product\n */\n slug: string;\n};\n\nexport type DodoPaymentsPlugin =\n | ReturnType<typeof checkout>\n | ReturnType<typeof portal>\n | ReturnType<typeof webhooks>\n | ReturnType<typeof usage>;\n\nexport type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];\n\nexport type DodoPaymentsEndpoints = UnionToIntersection<\n ReturnType<DodoPaymentsPlugin>\n>;\n\nexport interface DodoPaymentsOptions {\n /**\n * DodoPayments Client\n */\n client: DodoPayments;\n /**\n * Enable customer creation when a user signs up\n */\n createCustomerOnSignUp?: boolean;\n /**\n * Use DodoPayments plugins\n */\n use: DodoPaymentsPlugins;\n /**\n * Optionally provide additional fields (e.g. metadata, phone_number) to include when creating\n * or updating a DodoPayments customer.\n */\n getCustomerParams?: (user: User) => { metadata?: Record<string, string>; phone_number?: string | null } | Promise<{ metadata?: Record<string, string>; phone_number?: string | null }>;\n}\n\ntype PaymentsList = Awaited<ReturnType<DodoPayments[\"payments\"][\"list\"]>>;\ntype SubscriptionsList = Awaited<\n ReturnType<DodoPayments[\"subscriptions\"][\"list\"]>\n>;\nexport type PaymentItems = { items: PaymentsList[\"items\"] };\nexport type SubscriptionItems = { items: SubscriptionsList[\"items\"] };\nexport type CustomerPortalResponse = { url: string; redirect: boolean };\nexport type CreateCheckoutResponse = { url: string; redirect: boolean };\nexport type WebhookResponse = { received: boolean };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'dodopayments';
|
|
2
2
|
import 'better-auth';
|
|
3
|
-
export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-
|
|
4
|
-
import './plugins/usage.cjs';
|
|
3
|
+
export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-D0tVSLaf.cjs';
|
|
5
4
|
import 'zod/v3';
|
|
6
5
|
import '@dodopayments/core/webhook';
|
|
7
6
|
import 'dodopayments/resources/usage-events.mjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'dodopayments';
|
|
2
2
|
import 'better-auth';
|
|
3
|
-
export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-
|
|
4
|
-
import './plugins/usage.js';
|
|
3
|
+
export { C as CreateCheckoutResponse, a as CustomerPortalResponse, e as DodoPaymentsEndpoints, D as DodoPaymentsOptions, c as DodoPaymentsPlugin, d as DodoPaymentsPlugins, P as PaymentItems, b as Product, S as SubscriptionItems, W as WebhookResponse } from './types-D0tVSLaf.js';
|
|
5
4
|
import 'zod/v3';
|
|
6
5
|
import '@dodopayments/core/webhook';
|
|
7
6
|
import 'dodopayments/resources/usage-events.mjs';
|
package/dist/utils.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(utils_exports, {
|
|
|
23
23
|
getOrCreateCustomerId: () => getOrCreateCustomerId
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(utils_exports);
|
|
26
|
-
async function getOrCreateCustomerId(dodopayments, session, internalAdapter) {
|
|
26
|
+
async function getOrCreateCustomerId(dodopayments, session, internalAdapter, getCustomerParams) {
|
|
27
27
|
const dodoCustomerId = session.user["dodoCustomerId"];
|
|
28
28
|
if (dodoCustomerId) return dodoCustomerId;
|
|
29
29
|
const customers = await dodopayments.customers.list({
|
|
@@ -31,9 +31,12 @@ async function getOrCreateCustomerId(dodopayments, session, internalAdapter) {
|
|
|
31
31
|
});
|
|
32
32
|
let customer = customers.items[0];
|
|
33
33
|
if (!customer) {
|
|
34
|
+
const additionalParams = getCustomerParams ? await getCustomerParams(session.user) : void 0;
|
|
34
35
|
customer = await dodopayments.customers.create({
|
|
35
36
|
email: session.user.email,
|
|
36
|
-
name: session.user.name
|
|
37
|
+
name: session.user.name,
|
|
38
|
+
metadata: additionalParams?.metadata,
|
|
39
|
+
phone_number: additionalParams?.phone_number
|
|
37
40
|
}, { idempotencyKey: session.user.id });
|
|
38
41
|
}
|
|
39
42
|
internalAdapter.updateUser(session.user.id, { dodoCustomerId: customer.customer_id }).catch(() => {
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import type { DodoPayments } from \"dodopayments\";\n\nexport async function getOrCreateCustomerId(\n dodopayments: DodoPayments,\n session: { user: { id: string; email: string; name: string } & Record<string, unknown> },\n internalAdapter: { updateUser: (id: string, data: Record<string, unknown>) => Promise<unknown> },\n): Promise<string> {\n const dodoCustomerId = session.user[\"dodoCustomerId\"] as string | undefined;\n if (dodoCustomerId) return dodoCustomerId;\n\n // Fallback to get customer from email if dodoCustomerId doesn't exist\n const customers = await dodopayments.customers.list({\n email: session.user.email,\n });\n let customer = customers.items[0];\n\n if (!customer) {\n customer = await dodopayments.customers.create({\n email: session.user.email,\n name: session.user.name,\n }, { idempotencyKey: session.user.id });\n }\n\n internalAdapter\n .updateUser(session.user.id, { dodoCustomerId: customer.customer_id })\n .catch(() => {});\n\n return customer.customer_id;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import type { DodoPayments } from \"dodopayments\";\nimport type { User } from \"better-auth\";\n\nexport async function getOrCreateCustomerId(\n dodopayments: DodoPayments,\n session: { user: { id: string; email: string; name: string } & Record<string, unknown> },\n internalAdapter: { updateUser: (id: string, data: Record<string, unknown>) => Promise<unknown> },\n getCustomerParams?: (user: User) => { metadata?: Record<string, string>; phone_number?: string | null } | Promise<{ metadata?: Record<string, string>; phone_number?: string | null }>,\n): Promise<string> {\n const dodoCustomerId = session.user[\"dodoCustomerId\"] as string | undefined;\n if (dodoCustomerId) return dodoCustomerId;\n\n // Fallback to get customer from email if dodoCustomerId doesn't exist\n const customers = await dodopayments.customers.list({\n email: session.user.email,\n });\n let customer = customers.items[0];\n\n if (!customer) {\n const additionalParams = getCustomerParams\n ? await getCustomerParams(session.user as User)\n : undefined;\n\n customer = await dodopayments.customers.create({\n email: session.user.email,\n name: session.user.name,\n metadata: additionalParams?.metadata,\n phone_number: additionalParams?.phone_number,\n }, { idempotencyKey: session.user.id });\n }\n\n internalAdapter\n .updateUser(session.user.id, { dodoCustomerId: customer.customer_id })\n .catch(() => {});\n\n return customer.customer_id;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,eAAsB,sBACpB,cACA,SACA,iBACA,mBACiB;AACjB,QAAM,iBAAiB,QAAQ,KAAK,gBAAgB;AACpD,MAAI,eAAgB,QAAO;AAG3B,QAAM,YAAY,MAAM,aAAa,UAAU,KAAK;AAAA,IAClD,OAAO,QAAQ,KAAK;AAAA,EACtB,CAAC;AACD,MAAI,WAAW,UAAU,MAAM,CAAC;AAEhC,MAAI,CAAC,UAAU;AACb,UAAM,mBAAmB,oBACrB,MAAM,kBAAkB,QAAQ,IAAY,IAC5C;AAEJ,eAAW,MAAM,aAAa,UAAU,OAAO;AAAA,MAC7C,OAAO,QAAQ,KAAK;AAAA,MACpB,MAAM,QAAQ,KAAK;AAAA,MACnB,UAAU,kBAAkB;AAAA,MAC5B,cAAc,kBAAkB;AAAA,IAClC,GAAG,EAAE,gBAAgB,QAAQ,KAAK,GAAG,CAAC;AAAA,EACxC;AAEA,kBACG,WAAW,QAAQ,KAAK,IAAI,EAAE,gBAAgB,SAAS,YAAY,CAAC,EACpE,MAAM,MAAM;AAAA,EAAC,CAAC;AAEjB,SAAO,SAAS;AAClB;","names":[]}
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DodoPayments } from 'dodopayments';
|
|
2
|
+
import { User } from 'better-auth';
|
|
2
3
|
|
|
3
4
|
declare function getOrCreateCustomerId(dodopayments: DodoPayments, session: {
|
|
4
5
|
user: {
|
|
@@ -8,6 +9,12 @@ declare function getOrCreateCustomerId(dodopayments: DodoPayments, session: {
|
|
|
8
9
|
} & Record<string, unknown>;
|
|
9
10
|
}, internalAdapter: {
|
|
10
11
|
updateUser: (id: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
11
|
-
}
|
|
12
|
+
}, getCustomerParams?: (user: User) => {
|
|
13
|
+
metadata?: Record<string, string>;
|
|
14
|
+
phone_number?: string | null;
|
|
15
|
+
} | Promise<{
|
|
16
|
+
metadata?: Record<string, string>;
|
|
17
|
+
phone_number?: string | null;
|
|
18
|
+
}>): Promise<string>;
|
|
12
19
|
|
|
13
20
|
export { getOrCreateCustomerId };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DodoPayments } from 'dodopayments';
|
|
2
|
+
import { User } from 'better-auth';
|
|
2
3
|
|
|
3
4
|
declare function getOrCreateCustomerId(dodopayments: DodoPayments, session: {
|
|
4
5
|
user: {
|
|
@@ -8,6 +9,12 @@ declare function getOrCreateCustomerId(dodopayments: DodoPayments, session: {
|
|
|
8
9
|
} & Record<string, unknown>;
|
|
9
10
|
}, internalAdapter: {
|
|
10
11
|
updateUser: (id: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
11
|
-
}
|
|
12
|
+
}, getCustomerParams?: (user: User) => {
|
|
13
|
+
metadata?: Record<string, string>;
|
|
14
|
+
phone_number?: string | null;
|
|
15
|
+
} | Promise<{
|
|
16
|
+
metadata?: Record<string, string>;
|
|
17
|
+
phone_number?: string | null;
|
|
18
|
+
}>): Promise<string>;
|
|
12
19
|
|
|
13
20
|
export { getOrCreateCustomerId };
|
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/checkout.ts"],"sourcesContent":["import type DodoPayments from \"dodopayments\";\nimport { APIError, createAuthEndpoint, getSessionFromCtx } from \"better-auth/api\";\nimport { z } from \"zod/v3\";\nimport type { CreateCheckoutResponse, Product } from \"../types\";\nimport {\n buildCheckoutUrl,\n checkoutSessionPayloadSchema,\n dynamicCheckoutBodySchema,\n} from \"@dodopayments/core/checkout\";\n\nexport interface CheckoutOptions {\n /**\n * Optional list of slug -> productId mappings for easy slug checkouts\n */\n products?: Product[] | (() => Promise<Product[]>);\n /**\n * Checkout Success URL\n */\n successUrl?: string;\n /**\n * Only allow authenticated customers to checkout\n */\n authenticatedUsersOnly?: boolean;\n}\n\nexport const checkout =\n (checkoutOptions: CheckoutOptions = {}) =>\n (dodopayments: DodoPayments) => {\n return {\n /**\n * @deprecated\n */\n dodoCheckout: createAuthEndpoint(\n \"/dodopayments/checkout\",\n {\n method: \"POST\",\n body: dynamicCheckoutBodySchema.extend({\n slug: z.string().optional(),\n referenceId: z.string().optional(),\n }),\n requireRequest: true,\n },\n async (ctx): Promise<CreateCheckoutResponse> => {\n const session = await getSessionFromCtx(ctx);\n\n let dodoPaymentsProductId: string | undefined;\n\n if (ctx.body?.slug) {\n const resolvedProducts =\n typeof checkoutOptions.products === \"function\"\n ? await checkoutOptions.products()\n : checkoutOptions.products;\n\n const productId = resolvedProducts?.find(\n (product) => product.slug === ctx.body.slug,\n )?.productId;\n\n if (!productId) {\n throw new APIError(\"BAD_REQUEST\", {\n message: \"Product not found\",\n });\n }\n\n dodoPaymentsProductId = productId;\n } else {\n dodoPaymentsProductId = ctx.body.product_id;\n }\n\n if (checkoutOptions.authenticatedUsersOnly && !session?.user.id) {\n throw new APIError(\"UNAUTHORIZED\", {\n message: \"You must be logged in to checkout\",\n });\n }\n\n try {\n const checkoutUrl = await buildCheckoutUrl({\n body: {\n ...ctx.body,\n product_id: dodoPaymentsProductId,\n customer: {\n email: session?.user.email,\n name: session?.user.name,\n ...ctx.body.customer,\n },\n product_cart: dodoPaymentsProductId\n ? [\n {\n product_id: dodoPaymentsProductId,\n quantity: 1,\n },\n ]\n : undefined,\n metadata: ctx.body.referenceId\n ? {\n referenceId: ctx.body.referenceId,\n ...ctx.body.metadata,\n }\n : ctx.body.metadata,\n },\n bearerToken: dodopayments.bearerToken,\n environment: dodopayments.baseURL.includes(\"test\")\n ? \"test_mode\"\n : \"live_mode\",\n returnUrl: checkoutOptions.successUrl\n ? new URL(\n checkoutOptions.successUrl,\n ctx.request?.url,\n ).toString()\n : undefined,\n type: \"dynamic\",\n });\n\n const redirectUrl = new URL(checkoutUrl);\n\n return ctx.json({\n url: redirectUrl.toString(),\n redirect: true,\n });\n } catch (e: unknown) {\n if (e instanceof Error) {\n ctx.context.logger.error(\n `DodoPayments checkout creation failed. Error: ${e.message}`,\n );\n }\n\n throw new APIError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Checkout creation failed\",\n });\n }\n },\n ),\n dodoCheckoutSession: createAuthEndpoint(\n \"/dodopayments/checkout-session\",\n {\n method: \"POST\",\n body: checkoutSessionPayloadSchema\n .extend({\n slug: z.string().optional(),\n referenceId: z.string().optional(),\n })\n .partial({\n product_cart: true,\n }),\n requireRequest: true,\n },\n async (ctx): Promise<CreateCheckoutResponse> => {\n const session = await getSessionFromCtx(ctx);\n\n let dodoPaymentsProductId: string | undefined;\n\n if (ctx.body?.slug) {\n const resolvedProducts =\n typeof checkoutOptions.products === \"function\"\n ? await checkoutOptions.products()\n : checkoutOptions.products;\n\n const productId = resolvedProducts?.find(\n (product) => product.slug === ctx.body.slug,\n )?.productId;\n\n if (!productId) {\n throw new APIError(\"BAD_REQUEST\", {\n message: \"Product not found\",\n });\n }\n\n dodoPaymentsProductId = productId;\n }\n\n if (checkoutOptions.authenticatedUsersOnly && !session?.user.id) {\n throw new APIError(\"UNAUTHORIZED\", {\n message: \"You must be logged in to checkout\",\n });\n }\n\n // Ensure we have a product_cart\n const product_cart = dodoPaymentsProductId\n ? [{ product_id: dodoPaymentsProductId, quantity: 1 }]\n : ctx.body.product_cart;\n\n if (!product_cart || product_cart.length === 0) {\n throw new APIError(\"BAD_REQUEST\", {\n message: \"Neither product_cart nor slug was provided\",\n });\n }\n\n try {\n const checkoutUrl = await buildCheckoutUrl({\n sessionPayload: {\n ...ctx.body,\n product_cart,\n customer: session?.user.email\n ? {\n email: session?.user.email,\n name: session?.user.name,\n }\n : ctx.body.customer,\n metadata: ctx.body.referenceId\n ? {\n referenceId: ctx.body.referenceId,\n ...ctx.body.metadata,\n }\n : ctx.body.metadata,\n return_url: checkoutOptions.successUrl\n ? new URL(\n checkoutOptions.successUrl,\n ctx.request?.url,\n ).toString()\n : undefined,\n },\n bearerToken: dodopayments.bearerToken,\n environment: dodopayments.baseURL.includes(\"test\")\n ? \"test_mode\"\n : \"live_mode\",\n type: \"session\",\n });\n\n const redirectUrl = new URL(checkoutUrl);\n\n return ctx.json({\n url: redirectUrl.toString(),\n redirect: true,\n });\n } catch (e: unknown) {\n if (e instanceof Error) {\n ctx.context.logger.error(\n `DodoPayments checkout creation failed. Error: ${e.message}`,\n );\n }\n\n throw new APIError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Checkout session creation failed\",\n });\n }\n },\n ),\n };\n };\n"],"mappings":";AACA,SAAS,UAAU,oBAAoB,yBAAyB;AAChE,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAiBA,IAAM,WACX,CAAC,kBAAmC,CAAC,MACrC,CAAC,iBAA+B;AAC9B,SAAO;AAAA;AAAA;AAAA;AAAA,IAIL,cAAc;AAAA,MACZ;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,0BAA0B,OAAO;AAAA,UACrC,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,UAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,QACnC,CAAC;AAAA,QACD,gBAAgB;AAAA,MAClB;AAAA,MACA,OAAO,QAAyC;AAC9C,cAAM,UAAU,MAAM,kBAAkB,GAAG;AAE3C,YAAI;AAEJ,YAAI,IAAI,MAAM,MAAM;AAClB,gBAAM,mBACJ,OAAO,gBAAgB,aAAa,aAChC,MAAM,gBAAgB,SAAS,IAC/B,gBAAgB;AAEtB,gBAAM,YAAY,kBAAkB;AAAA,YAClC,CAAC,YAAY,QAAQ,SAAS,IAAI,KAAK;AAAA,UACzC,GAAG;AAEH,cAAI,CAAC,WAAW;AACd,kBAAM,IAAI,SAAS,eAAe;AAAA,cAChC,SAAS;AAAA,YACX,CAAC;AAAA,UACH;AAEA,kCAAwB;AAAA,QAC1B,OAAO;AACL,kCAAwB,IAAI,KAAK;AAAA,QACnC;AAEA,YAAI,gBAAgB,0BAA0B,CAAC,SAAS,KAAK,IAAI;AAC/D,gBAAM,IAAI,SAAS,gBAAgB;AAAA,YACjC,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAEA,YAAI;AACF,gBAA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BAChB,IAAI,SAAS;AAAA,cACf,EAAE,SAAS,IACX;AAAA,YACN;AAAA,YACA,aAAa,aAAa;AAAA,YAC1B,aAAa,aAAa,QAAQ,SAAS,MAAM,IAC7C,cACA;AAAA,YACJ,MAAM;AAAA,UACR,CAAC;AAED,gBAAM,cAAc,IAAI,IAAI,WAAW;AAEvC,iBAAO,IAAI,KAAK;AAAA,YACd,KAAK,YAAY,SAAS;AAAA,YAC1B,UAAU;AAAA,UACZ,CAAC;AAAA,QACH,SAAS,GAAY;AACnB,cAAI,aAAa,OAAO;AACtB,gBAAI,QAAQ,OAAO;AAAA,cACjB,iDAAiD,EAAE,OAAO;AAAA,YAC5D;AAAA,UACF;AAEA,gBAAM,IAAI,SAAS,yBAAyB;AAAA,YAC1C,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/usage.ts"],"sourcesContent":["import {\n APIError,\n createAuthEndpoint,\n sessionMiddleware,\n} from \"better-auth/api\";\nimport type { DodoPayments } from \"dodopayments\";\nimport { Event } from \"dodopayments/resources/usage-events.mjs\";\nimport { z } from \"zod/v3\";\nimport { getOrCreateCustomerId } from \"../utils\";\n\nconst EventInputSchema = z.object({\n event_id: z.string(),\n event_name: z.string(),\n metadata: z\n .record(z.union([z.string(), z.number(), z.boolean()]))\n .nullable()\n .optional(),\n timestamp: z\n // NOTE: coerce because the date object gets converted to a string over network requests\n // but we still want to enforce that it's a Date type\n .date({ coerce: true })\n .transform((d) => d.toISOString())\n .optional()\n .describe(\n \"Custom Timestamp. Defaults to current timestamp in UTC.\\\n Timestamps that are older that 1 hour or after 5 mins from\\\n current timestamp will be rejected.\",\n ),\n});\n\nexport const usage = () => (dodopayments: DodoPayments) => {\n return {\n // Ingest usage data\n dodoUsageIngest: createAuthEndpoint(\n \"/dodopayments/usage/ingest\",\n {\n method: \"POST\",\n body: EventInputSchema,\n use: [sessionMiddleware],\n },\n async (ctx): Promise<{ ingested_count: number }> => {\n if (!ctx.context.session?.user?.id) {\n throw new APIError(\"BAD_REQUEST\", {\n message: \"User not found\",\n });\n }\n\n if (!ctx.context.session?.user.emailVerified) {\n throw new APIError(\"UNAUTHORIZED\", {\n message: \"User email not verified\",\n });\n }\n\n try {\n const customerId = await getOrCreateCustomerId(\n dodopayments,\n ctx.context.session,\n ctx.context.internalAdapter,\n );\n\n const result = await dodopayments.usageEvents.ingest({\n events: [\n {\n event_id: ctx.body.event_id,\n customer_id: customerId,\n event_name: ctx.body.event_name,\n timestamp: ctx.body.timestamp,\n metadata: ctx.body.metadata,\n },\n ],\n });\n\n return ctx.json({ ingested_count: result.ingested_count });\n } catch (e: unknown) {\n if (e instanceof Error) {\n ctx.context.logger.error(\n `User usage ingestion error: ${e.message}`,\n );\n }\n\n throw new APIError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Failed to record the user usage\",\n });\n }\n },\n ),\n\n // List usage meters\n dodoUsageMetersList: createAuthEndpoint(\n \"/dodopayments/usage/meters/list\",\n {\n method: \"GET\",\n query: z\n .object({\n page_number: z.coerce.number().optional(),\n page_size: z.coerce.number().optional(),\n event_name: z.string().optional(),\n meter_id: z.string().optional(),\n start: z.string().optional(),\n end: z.string().optional(),\n })\n .optional(),\n use: [sessionMiddleware],\n },\n async (ctx): Promise<{ items: Event[] }> => {\n if (!ctx.context.session?.user?.id) {\n throw new APIError(\"BAD_REQUEST\", {\n message: \"User not found\",\n });\n }\n\n if (!ctx.context.session?.user.emailVerified) {\n throw new APIError(\"UNAUTHORIZED\", {\n message: \"User email not verified\",\n });\n }\n\n try {\n const customerId = await getOrCreateCustomerId(\n dodopayments,\n ctx.context.session,\n ctx.context.internalAdapter,\n );\n\n const meters = await dodopayments.usageEvents.list({\n customer_id: customerId,\n ...ctx.query,\n });\n\n return ctx.json({ items: meters.items });\n } catch (e: unknown) {\n if (e instanceof Error) {\n ctx.context.logger.error(\n `User usage meter list error: ${e.message}`,\n );\n }\n\n throw new APIError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Failed to fetch the user usage\",\n });\n }\n },\n ),\n };\n};\n\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,SAAS;AAGlB,IAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,UAAU,EAAE,OAAO;AAAA,EACnB,YAAY,EAAE,OAAO;AAAA,EACrB,UAAU,EACP,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrD,SAAS,EACT,SAAS;AAAA,EACZ,WAAW,EAGR,KAAK,EAAE,QAAQ,KAAK,CAAC,EACrB,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,EAChC,SAAS,EACT;AAAA,IACC;AAAA,EAGF;AACJ,CAAC;AAEM,IAAM,QAAQ,MAAM,CAAC,iBAA+B;AACzD,SAAO;AAAA;AAAA,IAEL,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,KAAK,CAAC,iBAAiB;AAAA,MACzB;AAAA,MACA,OAAO,QAA6C;AAClD,YAAI,CAAC,IAAI,QAAQ,SAAS,MAAM,IAAI;AAClC,gBAAM,IAAI,SAAS,eAAe;AAAA,YAChC,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAEA,YAAI,CAAC,IAAI,QAAQ,SAAS,KAAK,eAAe;AAC5C,gBAAM,IAAI,SAAS,gBAAgB;AAAA,YACjC,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAEA,YAAI;AACF,gBAAM,aAAa,MAAM;AAAA,YACvB;AAAA,YACA,IAAI,QAAQ;AAAA,YACZ,IAAI,QAAQ;AAAA,UACd;AAEA,gBAAM,SAAS,MAAM,aAAa,YAAY,OAAO;AAAA,YACnD,QAAQ;AAAA,cACN;AAAA,gBACE,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