@stacksjs/payments 0.75.548 → 0.75.552

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.
@@ -3,8 +3,8 @@ import type Stripe from 'stripe';
3
3
  * Whether the two things Stripe needs are actually present.
4
4
  *
5
5
  * Reported separately because an app that is missing both should be told
6
- * both, and because the two are fixed in different places: one in the
7
- * environment, one in the app's package.json (stacksjs/stacks#2911).
6
+ * both: a missing key needs configuration, while a missing SDK means the
7
+ * dependency installation needs restoring (stacksjs/stacks#2911).
8
8
  */
9
9
  export declare function stripeAvailability(): StripeAvailability;
10
10
  /**
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{services}from"@stacksjs/config";const require=createRequire(import.meta.url);function StripeCtor(){try{return require("stripe")}catch{throw new Error(describeStripeAvailability({key:true,sdk:false}))}}let _stripe=null;export function stripeAvailability(){return{key:Boolean(String(services?.stripe?.secretKey||"").trim()),sdk:isStripeSdkInstalled()}}function isStripeSdkInstalled(){try{require.resolve("stripe");return true}catch{return false}}export function isStripeConfigured(){const{key,sdk}=stripeAvailability();return key&&sdk}export function describeStripeAvailability(available){if(available.key&&available.sdk)return null;const reasons=[];if(!available.sdk){reasons.push("the `stripe` package is not installed (it is an optional peer, which Bun does not install for you - "+"run `bun add stripe` in your app, pinned to an exact version)")}if(!available.key)reasons.push("no Stripe secret key is configured (set STRIPE_SECRET_KEY in your .env)");return`Stripe is being used but is not usable here: ${reasons.join("; and ")}.`}export function reportStripeAvailability(options={}){const available=options.available??stripeAvailability();if(!available.key||available.sdk)return null;const message=describeStripeAvailability(available);(options.warn??console.warn)(`[stacks] ${message}`);return message}export const stripe=new Proxy({},{get(_target,prop){if(!_stripe){const unusable=describeStripeAvailability(stripeAvailability());if(unusable)throw new Error(unusable);const apiKey=String(services?.stripe?.secretKey||"").trim();const Stripe=StripeCtor();const apiVersion=Stripe.API_VERSION;const configuredVersion=services?.stripe?.apiVersion;if(configuredVersion&&configuredVersion!==apiVersion)throw new Error(`Stripe API version ${configuredVersion} does not match the installed SDK version ${apiVersion}`);_stripe=new Stripe(apiKey,{apiVersion})}return _stripe[prop]}});
1
+ import{createRequire}from"node:module";import{services}from"@stacksjs/config";const require=createRequire(import.meta.url);function StripeCtor(){try{return require("stripe")}catch{throw new Error(describeStripeAvailability({key:true,sdk:false}))}}let _stripe=null;export function stripeAvailability(){return{key:Boolean(String(services?.stripe?.secretKey||"").trim()),sdk:isStripeSdkInstalled()}}function isStripeSdkInstalled(){try{require.resolve("stripe");return true}catch{return false}}export function isStripeConfigured(){const{key,sdk}=stripeAvailability();return key&&sdk}export function describeStripeAvailability(available){if(available.key&&available.sdk)return null;const reasons=[];if(!available.sdk){reasons.push("the required `stripe` package is missing (restore the app dependencies with `bun install --frozen-lockfile`)")}if(!available.key)reasons.push("no Stripe secret key is configured (set STRIPE_SECRET_KEY in your .env)");return`Stripe is being used but is not usable here: ${reasons.join("; and ")}.`}export function reportStripeAvailability(options={}){const available=options.available??stripeAvailability();if(!available.key||available.sdk)return null;const message=describeStripeAvailability(available);(options.warn??console.warn)(`[stacks] ${message}`);return message}export const stripe=new Proxy({},{get(_target,prop){if(!_stripe){const unusable=describeStripeAvailability(stripeAvailability());if(unusable)throw new Error(unusable);const apiKey=String(services?.stripe?.secretKey||"").trim();const Stripe=StripeCtor();const apiVersion=Stripe.API_VERSION;const configuredVersion=services?.stripe?.apiVersion;if(configuredVersion&&configuredVersion!==apiVersion)throw new Error(`Stripe API version ${configuredVersion} does not match the installed SDK version ${apiVersion}`);_stripe=new Stripe(apiKey,{apiVersion})}return _stripe[prop]}});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/payments",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.548",
5
+ "version": "0.75.552",
6
6
  "description": "The Stacks payments package. Currently supporting Stripe.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -60,29 +60,25 @@
60
60
  "prepublishOnly": "bun run build"
61
61
  },
62
62
  "dependencies": {
63
- "@stacksjs/config": "0.75.548",
64
- "@stacksjs/database": "0.75.548",
65
- "@stacksjs/error-handling": "0.75.548",
66
- "@stacksjs/logging": "0.75.548",
67
- "@stacksjs/orm": "0.75.548",
68
- "@stacksjs/types": "0.75.548"
63
+ "@stacksjs/config": "0.75.552",
64
+ "@stacksjs/database": "0.75.552",
65
+ "@stacksjs/error-handling": "0.75.552",
66
+ "@stacksjs/logging": "0.75.552",
67
+ "@stacksjs/orm": "0.75.552",
68
+ "@stacksjs/types": "0.75.552",
69
+ "stripe": "23.0.0"
69
70
  },
70
71
  "peerDependencies": {
71
- "@stripe/stripe-js": "^10.0.0",
72
- "stripe": "23.0.0"
72
+ "@stripe/stripe-js": "^10.0.0"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "@stripe/stripe-js": {
76
76
  "optional": true
77
- },
78
- "stripe": {
79
- "optional": true
80
77
  }
81
78
  },
82
79
  "devDependencies": {
83
- "@stacksjs/utils": "0.75.548",
80
+ "@stacksjs/utils": "0.75.552",
84
81
  "@stripe/stripe-js": "^10.0.0",
85
- "better-dx": "^0.2.24",
86
- "stripe": "23.0.0"
82
+ "better-dx": "^0.2.24"
87
83
  }
88
84
  }