@better-auth/stripe 1.4.12-beta.2 → 1.4.13
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/.turbo/turbo-build.log +4 -4
- package/dist/client.d.mts +1 -1
- package/dist/{index-CkO4CTbB.d.mts → index-CLon-5Wv.d.mts} +85 -1
- package/dist/index.d.mts +1 -1
- package/package.json +5 -5
- package/src/routes.ts +3 -3
- package/src/schema.ts +10 -4
- package/test/stripe.test.ts +39 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.4.
|
|
2
|
+
> @better-auth/stripe@1.4.13 build /home/runner/work/better-auth/better-auth/packages/stripe
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.17.2[22m powered by rolldown [2mv1.0.0-beta.53[22m
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
[34mℹ[39m [2mdist/[22m[1mclient.mjs[22m [2m 0.26 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
12
12
|
[34mℹ[39m [2mdist/[22m[32m[1mclient.d.mts[22m[39m [2m 0.62 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
13
13
|
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
14
|
-
[34mℹ[39m [2mdist/[22m[32mindex-
|
|
15
|
-
[34mℹ[39m 5 files, total:
|
|
16
|
-
[32m✔[39m Build complete in [
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[32mindex-CLon-5Wv.d.mts[39m [2m30.22 kB[22m [2m│ gzip: 5.17 kB[22m
|
|
15
|
+
[34mℹ[39m 5 files, total: 89.02 kB
|
|
16
|
+
[32m✔[39m Build complete in [32m20381ms[39m
|
package/dist/client.d.mts
CHANGED
|
@@ -829,7 +829,91 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
829
829
|
};
|
|
830
830
|
};
|
|
831
831
|
} | undefined;
|
|
832
|
-
schema: {
|
|
832
|
+
schema: {
|
|
833
|
+
user: {
|
|
834
|
+
fields: {
|
|
835
|
+
stripeCustomerId: {
|
|
836
|
+
type: "string";
|
|
837
|
+
required: false;
|
|
838
|
+
};
|
|
839
|
+
};
|
|
840
|
+
};
|
|
841
|
+
} & (O["subscription"] extends {
|
|
842
|
+
enabled: true;
|
|
843
|
+
} ? {
|
|
844
|
+
subscription: {
|
|
845
|
+
fields: {
|
|
846
|
+
plan: {
|
|
847
|
+
type: "string";
|
|
848
|
+
required: true;
|
|
849
|
+
};
|
|
850
|
+
referenceId: {
|
|
851
|
+
type: "string";
|
|
852
|
+
required: true;
|
|
853
|
+
};
|
|
854
|
+
stripeCustomerId: {
|
|
855
|
+
type: "string";
|
|
856
|
+
required: false;
|
|
857
|
+
};
|
|
858
|
+
stripeSubscriptionId: {
|
|
859
|
+
type: "string";
|
|
860
|
+
required: false;
|
|
861
|
+
};
|
|
862
|
+
status: {
|
|
863
|
+
type: "string";
|
|
864
|
+
defaultValue: string;
|
|
865
|
+
};
|
|
866
|
+
periodStart: {
|
|
867
|
+
type: "date";
|
|
868
|
+
required: false;
|
|
869
|
+
};
|
|
870
|
+
periodEnd: {
|
|
871
|
+
type: "date";
|
|
872
|
+
required: false;
|
|
873
|
+
};
|
|
874
|
+
trialStart: {
|
|
875
|
+
type: "date";
|
|
876
|
+
required: false;
|
|
877
|
+
};
|
|
878
|
+
trialEnd: {
|
|
879
|
+
type: "date";
|
|
880
|
+
required: false;
|
|
881
|
+
};
|
|
882
|
+
cancelAtPeriodEnd: {
|
|
883
|
+
type: "boolean";
|
|
884
|
+
required: false;
|
|
885
|
+
defaultValue: false;
|
|
886
|
+
};
|
|
887
|
+
cancelAt: {
|
|
888
|
+
type: "date";
|
|
889
|
+
required: false;
|
|
890
|
+
};
|
|
891
|
+
canceledAt: {
|
|
892
|
+
type: "date";
|
|
893
|
+
required: false;
|
|
894
|
+
};
|
|
895
|
+
endedAt: {
|
|
896
|
+
type: "date";
|
|
897
|
+
required: false;
|
|
898
|
+
};
|
|
899
|
+
seats: {
|
|
900
|
+
type: "number";
|
|
901
|
+
required: false;
|
|
902
|
+
};
|
|
903
|
+
};
|
|
904
|
+
};
|
|
905
|
+
} : {}) & (O["organization"] extends {
|
|
906
|
+
enabled: true;
|
|
907
|
+
} ? {
|
|
908
|
+
organization: {
|
|
909
|
+
fields: {
|
|
910
|
+
stripeCustomerId: {
|
|
911
|
+
type: "string";
|
|
912
|
+
required: false;
|
|
913
|
+
};
|
|
914
|
+
};
|
|
915
|
+
};
|
|
916
|
+
} : {});
|
|
833
917
|
options: NoInfer<O>;
|
|
834
918
|
$ERROR_CODES: {
|
|
835
919
|
readonly UNAUTHORIZED: "Unauthorized access";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SubscriptionOptions, i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-
|
|
1
|
+
import { a as SubscriptionOptions, i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-CLon-5Wv.mjs";
|
|
2
2
|
export { StripePlan, StripePlugin, Subscription, SubscriptionOptions, stripe };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/stripe",
|
|
3
3
|
"author": "Bereket Engida",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.13",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.mts",
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"stripe": "^18 || ^19 || ^20",
|
|
53
|
-
"@better-auth/core": "1.4.
|
|
54
|
-
"better-auth": "1.4.
|
|
53
|
+
"@better-auth/core": "1.4.13",
|
|
54
|
+
"better-auth": "1.4.13"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"better-call": "1.1.7",
|
|
58
58
|
"stripe": "^20.0.0",
|
|
59
59
|
"tsdown": "^0.17.2",
|
|
60
|
-
"@better-auth/core": "1.4.
|
|
61
|
-
"better-auth": "1.4.
|
|
60
|
+
"@better-auth/core": "1.4.13",
|
|
61
|
+
"better-auth": "1.4.13"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"test": "vitest",
|
package/src/routes.ts
CHANGED
|
@@ -159,7 +159,7 @@ const upgradeSubscriptionBodySchema = z.object({
|
|
|
159
159
|
})
|
|
160
160
|
.optional(),
|
|
161
161
|
/**
|
|
162
|
-
*
|
|
162
|
+
* The URL to which Stripe should send customers when payment or setup is complete.
|
|
163
163
|
*/
|
|
164
164
|
successUrl: z
|
|
165
165
|
.string()
|
|
@@ -169,7 +169,7 @@ const upgradeSubscriptionBodySchema = z.object({
|
|
|
169
169
|
})
|
|
170
170
|
.default("/"),
|
|
171
171
|
/**
|
|
172
|
-
*
|
|
172
|
+
* If set, checkout shows a back button and customers will be directed here if they cancel payment.
|
|
173
173
|
*/
|
|
174
174
|
cancelUrl: z
|
|
175
175
|
.string()
|
|
@@ -179,7 +179,7 @@ const upgradeSubscriptionBodySchema = z.object({
|
|
|
179
179
|
})
|
|
180
180
|
.default("/"),
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
182
|
+
* The URL to return to from the Billing Portal (used when upgrading existing subscriptions)
|
|
183
183
|
*/
|
|
184
184
|
returnUrl: z
|
|
185
185
|
.string()
|
package/src/schema.ts
CHANGED
|
@@ -88,8 +88,14 @@ export const organization = {
|
|
|
88
88
|
},
|
|
89
89
|
} satisfies BetterAuthPluginDBSchema;
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
type GetSchemaResult<O extends StripeOptions> = typeof user &
|
|
92
|
+
(O["subscription"] extends { enabled: true } ? typeof subscriptions : {}) &
|
|
93
|
+
(O["organization"] extends { enabled: true } ? typeof organization : {});
|
|
94
|
+
|
|
95
|
+
export const getSchema = <O extends StripeOptions>(
|
|
96
|
+
options: O,
|
|
97
|
+
): GetSchemaResult<O> => {
|
|
98
|
+
let baseSchema: BetterAuthPluginDBSchema = {};
|
|
93
99
|
|
|
94
100
|
if (options.subscription?.enabled) {
|
|
95
101
|
baseSchema = {
|
|
@@ -115,8 +121,8 @@ export const getSchema = (options: StripeOptions) => {
|
|
|
115
121
|
"subscription" in options.schema
|
|
116
122
|
) {
|
|
117
123
|
const { subscription: _subscription, ...restSchema } = options.schema;
|
|
118
|
-
return mergeSchema(baseSchema, restSchema)
|
|
124
|
+
return mergeSchema(baseSchema, restSchema) as GetSchemaResult<O>;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
return mergeSchema(baseSchema, options.schema)
|
|
127
|
+
return mergeSchema(baseSchema, options.schema) as GetSchemaResult<O>;
|
|
122
128
|
};
|
package/test/stripe.test.ts
CHANGED
|
@@ -58,6 +58,45 @@ describe("stripe type", () => {
|
|
|
58
58
|
expectTypeOf<MyAuth["api"]["upgradeSubscription"]>().toBeFunction();
|
|
59
59
|
expectTypeOf<MyAuth["api"]["createBillingPortal"]>().toBeFunction();
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
it("should infer plugin schema fields on user type", async () => {
|
|
63
|
+
const { auth } = await getTestInstance({
|
|
64
|
+
plugins: [
|
|
65
|
+
stripe({
|
|
66
|
+
stripeClient: {} as Stripe,
|
|
67
|
+
stripeWebhookSecret: "test",
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
expectTypeOf<
|
|
72
|
+
(typeof auth)["$Infer"]["Session"]["user"]["stripeCustomerId"]
|
|
73
|
+
>().toEqualTypeOf<string | null | undefined>();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should infer plugin schema fields alongside additional user fields", async () => {
|
|
77
|
+
const { auth } = await getTestInstance({
|
|
78
|
+
plugins: [
|
|
79
|
+
stripe({
|
|
80
|
+
stripeClient: {} as Stripe,
|
|
81
|
+
stripeWebhookSecret: "test",
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
user: {
|
|
85
|
+
additionalFields: {
|
|
86
|
+
customField: {
|
|
87
|
+
type: "string",
|
|
88
|
+
required: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
expectTypeOf<
|
|
94
|
+
(typeof auth)["$Infer"]["Session"]["user"]["stripeCustomerId"]
|
|
95
|
+
>().toEqualTypeOf<string | null | undefined>();
|
|
96
|
+
expectTypeOf<
|
|
97
|
+
(typeof auth)["$Infer"]["Session"]["user"]["customField"]
|
|
98
|
+
>().toEqualTypeOf<string | null | undefined>();
|
|
99
|
+
});
|
|
61
100
|
});
|
|
62
101
|
|
|
63
102
|
describe("stripe", () => {
|