@stacksjs/browser 0.72.37 → 0.72.39

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 +1 @@
1
- const stacksConfig=globalThis.__STACKS_CONFIG__||{};export const publishableKey=stacksConfig.FRONTEND_STRIPE_PUBLIC_KEY||"";let client;async function loadStripe(key){let stripeJs;try{stripeJs=await import("@stripe/stripe-js")}catch{throw Error("Stripe is being used but the `@stripe/stripe-js` package is not installed. "+"It is an opt-in dependency \u2014 run `bun add @stripe/stripe-js` to enable Stripe payments in the browser.")}return stripeJs.loadStripe(key)}export async function loadCardElement(clientSecret){client=await loadStripe(publishableKey);const cardElement=client.elements({clientSecret}).create("card");cardElement.mount("#card-element");return cardElement}export async function loadPaymentElement(clientSecret){client=await loadStripe(publishableKey);const elements=client.elements({clientSecret});elements.create("payment",{fields:{billingDetails:"auto"}}).mount("#payment-element");return elements}export async function confirmCardSetup(clientSecret,elements){const data=await client.confirmCardSetup(clientSecret,{payment_method:{card:elements}}),{setupIntent,error}=data;return{setupIntent,error}}export async function confirmCardPayment(clientSecret,elements){try{const data=await client.confirmCardPayment(clientSecret,{payment_method:{card:elements,billing_details:{name:stacksConfig.USER_NAME||""}}}),{paymentIntent,error}=data;return{paymentIntent,error}}catch(err){console.error("Error confirming card payment:",err);return{paymentIntent:null,error:err}}}export async function createPaymentMethod(elements){try{const data=await client.createPaymentMethod({type:"card",card:elements}),{paymentIntent,error}=data;return{paymentIntent,error}}catch(err){console.error("Error confirming card payment:",err);return{paymentIntent:null,error:err}}}export async function confirmPayment(elements){try{const data=await client.confirmPayment({elements,confirmParams:{return_url:`${window.location.origin}/settings/billing`}}),{paymentIntent,error}=data;return{paymentIntent,error}}catch(err){console.error("Error confirming card payment:",err);return{paymentIntent:null,error:err}}}
1
+ const stacksConfig=globalThis.__STACKS_CONFIG__||{};export const publishableKey=stacksConfig.FRONTEND_STRIPE_PUBLIC_KEY||"";let client;async function loadStripe(key){let stripeJs;try{stripeJs=await import("@stripe/stripe-js")}catch{throw Error("Stripe is being used but the `@stripe/stripe-js` package is not installed. It is an opt-in dependency - run `bun add @stripe/stripe-js` to enable Stripe payments in the browser.")}return stripeJs.loadStripe(key)}export async function loadCardElement(clientSecret){client=await loadStripe(publishableKey);const cardElement=client.elements({clientSecret}).create("card");cardElement.mount("#card-element");return cardElement}export async function loadPaymentElement(clientSecret){client=await loadStripe(publishableKey);const elements=client.elements({clientSecret});elements.create("payment",{fields:{billingDetails:"auto"}}).mount("#payment-element");return elements}export async function confirmCardSetup(clientSecret,elements){const data=await client.confirmCardSetup(clientSecret,{payment_method:{card:elements}}),{setupIntent,error}=data;return{setupIntent,error}}export async function confirmCardPayment(clientSecret,elements){try{const data=await client.confirmCardPayment(clientSecret,{payment_method:{card:elements,billing_details:{name:stacksConfig.USER_NAME||""}}}),{paymentIntent,error}=data;return{paymentIntent,error}}catch(err){console.error("Error confirming card payment:",err);return{paymentIntent:null,error:err}}}export async function createPaymentMethod(elements){try{const data=await client.createPaymentMethod({type:"card",card:elements}),{paymentIntent,error}=data;return{paymentIntent,error}}catch(err){console.error("Error confirming card payment:",err);return{paymentIntent:null,error:err}}}export async function confirmPayment(elements){try{const data=await client.confirmPayment({elements,confirmParams:{return_url:`${window.location.origin}/settings/billing`}}),{paymentIntent,error}=data;return{paymentIntent,error}}catch(err){console.error("Error confirming card payment:",err);return{paymentIntent:null,error:err}}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/browser",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.72.37",
5
+ "version": "0.72.39",
6
6
  "description": "Stacks core frontend/browser functionalities.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -69,7 +69,7 @@
69
69
  "prepublishOnly": "bun run build"
70
70
  },
71
71
  "dependencies": {
72
- "@stacksjs/composables": "0.72.37",
72
+ "@stacksjs/composables": "0.72.39",
73
73
  "@stacksjs/stx": "^0.2.197",
74
74
  "bun-query-builder": "^0.2.53"
75
75
  },
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "devDependencies": {
85
85
  "better-dx": "^0.2.24",
86
- "@stacksjs/utils": "0.72.37",
86
+ "@stacksjs/utils": "0.72.39",
87
87
  "@stripe/stripe-js": "^9.10.0"
88
88
  }
89
89
  }