@better-auth/stripe 1.2.2 → 1.2.3-beta.1
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 +3 -3
- package/dist/index.cjs +13 -6
- package/dist/index.mjs +13 -6
- package/package.json +2 -2
- package/src/hooks.ts +13 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.2.
|
|
2
|
+
> @better-auth/stripe@1.2.3-beta.1 build /home/runner/work/better-auth/better-auth/packages/stripe
|
|
3
3
|
> unbuild
|
|
4
4
|
|
|
5
5
|
[info] Automatically detected entries: src/index, src/client [esm] [cjs] [dts]
|
|
6
6
|
[info] Building stripe
|
|
7
7
|
[success] Build succeeded for stripe
|
|
8
|
-
[log] dist/index.cjs (total size: 30.
|
|
8
|
+
[log] dist/index.cjs (total size: 30.8 kB, chunk size: 30.8 kB, exports: stripe)
|
|
9
9
|
|
|
10
10
|
[log] dist/client.cjs (total size: 160 B, chunk size: 160 B, exports: stripeClient)
|
|
11
11
|
|
|
12
|
-
[log] dist/index.mjs (total size: 30.
|
|
12
|
+
[log] dist/index.mjs (total size: 30.5 kB, chunk size: 30.5 kB, exports: stripe)
|
|
13
13
|
|
|
14
14
|
[log] dist/client.mjs (total size: 133 B, chunk size: 133 B, exports: stripeClient)
|
|
15
15
|
|
package/dist/index.cjs
CHANGED
|
@@ -107,12 +107,19 @@ async function onSubscriptionUpdated(ctx, options, event) {
|
|
|
107
107
|
where: [{ field: "stripeCustomerId", value: customerId }]
|
|
108
108
|
});
|
|
109
109
|
if (subs.length > 1) {
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const activeSub = subs.find(
|
|
111
|
+
(sub) => sub.status === "active" || sub.status === "trialing"
|
|
112
112
|
);
|
|
113
|
-
|
|
113
|
+
if (!activeSub) {
|
|
114
|
+
betterAuth.logger.warn(
|
|
115
|
+
`Stripe webhook error: Multiple subscriptions found for customerId: ${customerId} and no active subscription is found`
|
|
116
|
+
);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
subscription = activeSub;
|
|
120
|
+
} else {
|
|
121
|
+
subscription = subs[0];
|
|
114
122
|
}
|
|
115
|
-
subscription = subs[0];
|
|
116
123
|
}
|
|
117
124
|
const seats = subscriptionUpdated.items.data[0].quantity;
|
|
118
125
|
await ctx.context.adapter.update({
|
|
@@ -132,8 +139,8 @@ async function onSubscriptionUpdated(ctx, options, event) {
|
|
|
132
139
|
},
|
|
133
140
|
where: [
|
|
134
141
|
{
|
|
135
|
-
field: "
|
|
136
|
-
value: subscription.
|
|
142
|
+
field: "id",
|
|
143
|
+
value: subscription.id
|
|
137
144
|
}
|
|
138
145
|
]
|
|
139
146
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -105,12 +105,19 @@ async function onSubscriptionUpdated(ctx, options, event) {
|
|
|
105
105
|
where: [{ field: "stripeCustomerId", value: customerId }]
|
|
106
106
|
});
|
|
107
107
|
if (subs.length > 1) {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const activeSub = subs.find(
|
|
109
|
+
(sub) => sub.status === "active" || sub.status === "trialing"
|
|
110
110
|
);
|
|
111
|
-
|
|
111
|
+
if (!activeSub) {
|
|
112
|
+
logger.warn(
|
|
113
|
+
`Stripe webhook error: Multiple subscriptions found for customerId: ${customerId} and no active subscription is found`
|
|
114
|
+
);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
subscription = activeSub;
|
|
118
|
+
} else {
|
|
119
|
+
subscription = subs[0];
|
|
112
120
|
}
|
|
113
|
-
subscription = subs[0];
|
|
114
121
|
}
|
|
115
122
|
const seats = subscriptionUpdated.items.data[0].quantity;
|
|
116
123
|
await ctx.context.adapter.update({
|
|
@@ -130,8 +137,8 @@ async function onSubscriptionUpdated(ctx, options, event) {
|
|
|
130
137
|
},
|
|
131
138
|
where: [
|
|
132
139
|
{
|
|
133
|
-
field: "
|
|
134
|
-
value: subscription.
|
|
140
|
+
field: "id",
|
|
141
|
+
value: subscription.id
|
|
135
142
|
}
|
|
136
143
|
]
|
|
137
144
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/stripe",
|
|
3
3
|
"author": "Bereket Engida",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3-beta.1",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"zod": "^3.24.1",
|
|
38
|
-
"better-auth": "^1.2.
|
|
38
|
+
"better-auth": "^1.2.3-beta.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/better-sqlite3": "^7.6.12",
|
package/src/hooks.ts
CHANGED
|
@@ -109,12 +109,19 @@ export async function onSubscriptionUpdated(
|
|
|
109
109
|
where: [{ field: "stripeCustomerId", value: customerId }],
|
|
110
110
|
});
|
|
111
111
|
if (subs.length > 1) {
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const activeSub = subs.find(
|
|
113
|
+
(sub) => sub.status === "active" || sub.status === "trialing",
|
|
114
114
|
);
|
|
115
|
-
|
|
115
|
+
if (!activeSub) {
|
|
116
|
+
logger.warn(
|
|
117
|
+
`Stripe webhook error: Multiple subscriptions found for customerId: ${customerId} and no active subscription is found`,
|
|
118
|
+
);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
subscription = activeSub;
|
|
122
|
+
} else {
|
|
123
|
+
subscription = subs[0];
|
|
116
124
|
}
|
|
117
|
-
subscription = subs[0];
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
const seats = subscriptionUpdated.items.data[0].quantity;
|
|
@@ -137,8 +144,8 @@ export async function onSubscriptionUpdated(
|
|
|
137
144
|
},
|
|
138
145
|
where: [
|
|
139
146
|
{
|
|
140
|
-
field: "
|
|
141
|
-
value: subscription.
|
|
147
|
+
field: "id",
|
|
148
|
+
value: subscription.id,
|
|
142
149
|
},
|
|
143
150
|
],
|
|
144
151
|
});
|