@better-auth/stripe 1.2.8-beta.4 → 1.2.8-beta.6

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.
@@ -1,17 +1,17 @@
1
1
 
2
- > @better-auth/stripe@1.2.8-beta.4 build /home/runner/work/better-auth/better-auth/packages/stripe
2
+ > @better-auth/stripe@1.2.8-beta.6 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: 37.2 kB, chunk size: 37.2 kB, exports: stripe)
8
+ [log] dist/index.cjs (total size: 37.3 kB, chunk size: 37.3 kB, exports: stripe)
9
9
 
10
10
  [log] dist/client.cjs (total size: 224 B, chunk size: 224 B, exports: stripeClient)
11
11
 
12
- [log] dist/index.mjs (total size: 36.9 kB, chunk size: 36.9 kB, exports: stripe)
12
+ [log] dist/index.mjs (total size: 37.1 kB, chunk size: 37.1 kB, exports: stripe)
13
13
 
14
14
  [log] dist/client.mjs (total size: 197 B, chunk size: 197 B, exports: stripeClient)
15
15
 
16
- Σ Total dist size (byte size): 201 kB
16
+ Σ Total dist size (byte size): 202 kB
17
17
  [log]
package/dist/index.cjs CHANGED
@@ -800,7 +800,7 @@ const stripe = (options) => {
800
800
  value: ctx.body.subscriptionId
801
801
  }
802
802
  ]
803
- }) : await ctx.context.adapter.findOne({
803
+ }) : await ctx.context.adapter.findMany({
804
804
  model: "subscription",
805
805
  where: [
806
806
  {
@@ -808,7 +808,11 @@ const stripe = (options) => {
808
808
  value: referenceId
809
809
  }
810
810
  ]
811
- });
811
+ }).then(
812
+ (subs) => subs.find(
813
+ (sub) => sub.status === "active" || sub.status === "trialing"
814
+ )
815
+ );
812
816
  if (!subscription || !subscription.stripeCustomerId) {
813
817
  throw ctx.error("BAD_REQUEST", {
814
818
  message: STRIPE_ERROR_CODES.SUBSCRIPTION_NOT_FOUND
package/dist/index.mjs CHANGED
@@ -798,7 +798,7 @@ const stripe = (options) => {
798
798
  value: ctx.body.subscriptionId
799
799
  }
800
800
  ]
801
- }) : await ctx.context.adapter.findOne({
801
+ }) : await ctx.context.adapter.findMany({
802
802
  model: "subscription",
803
803
  where: [
804
804
  {
@@ -806,7 +806,11 @@ const stripe = (options) => {
806
806
  value: referenceId
807
807
  }
808
808
  ]
809
- });
809
+ }).then(
810
+ (subs) => subs.find(
811
+ (sub) => sub.status === "active" || sub.status === "trialing"
812
+ )
813
+ );
810
814
  if (!subscription || !subscription.stripeCustomerId) {
811
815
  throw ctx.error("BAD_REQUEST", {
812
816
  message: STRIPE_ERROR_CODES.SUBSCRIPTION_NOT_FOUND
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.8-beta.4",
4
+ "version": "1.2.8-beta.6",
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.8-beta.4"
38
+ "better-auth": "^1.2.8-beta.6"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/better-sqlite3": "^7.6.12",
package/src/index.ts CHANGED
@@ -650,15 +650,21 @@ export const stripe = <O extends StripeOptions>(options: O) => {
650
650
  },
651
651
  ],
652
652
  })
653
- : await ctx.context.adapter.findOne<Subscription>({
654
- model: "subscription",
655
- where: [
656
- {
657
- field: "referenceId",
658
- value: referenceId,
659
- },
660
- ],
661
- });
653
+ : await ctx.context.adapter
654
+ .findMany<Subscription>({
655
+ model: "subscription",
656
+ where: [
657
+ {
658
+ field: "referenceId",
659
+ value: referenceId,
660
+ },
661
+ ],
662
+ })
663
+ .then((subs) =>
664
+ subs.find(
665
+ (sub) => sub.status === "active" || sub.status === "trialing",
666
+ ),
667
+ );
662
668
  if (!subscription || !subscription.stripeCustomerId) {
663
669
  throw ctx.error("BAD_REQUEST", {
664
670
  message: STRIPE_ERROR_CODES.SUBSCRIPTION_NOT_FOUND,