-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
488e383
commit 462d946
Showing
31 changed files
with
144 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ MAIL_ENCRYPTION=null | |
MAIL_FROM_NAME="${APP_NAME}" | ||
MAIL_FROM_ADDRESS="[email protected]" | ||
|
||
STRIPE_SECRET_KEY= | ||
STRIPE_PUBLIC_KEY= | ||
|
||
SEARCH_ENGINE_DRIVER=meilisearch | ||
MEILISEARCH_HOST=http://127.0.0.1:7700 | ||
MEILISEARCH_KEY=masterKey | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,65 @@ | ||
export const publishableKey = import.meta.env.FRONTEND_STRIPE_PUBLIC_KEY | ||
import { loadStripe } from '@stripe/stripe-js' | ||
|
||
export const publishableKey = import.meta.env.FRONTEND_STRIPE_PUBLIC_KEY | ||
|
||
const stripe = ref(null as any) | ||
const elements = ref(null as any) | ||
|
||
export function useBillable() { | ||
async function fetchSetupIntent(): Promise<string> { | ||
const url = 'http://localhost:3008/stripe/create-setup-intent' | ||
|
||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json', | ||
}, | ||
}) | ||
async function fetchSetupIntent(): Promise<string> { | ||
const url = 'http://localhost:3008/stripe/create-setup-intent' | ||
|
||
const client: any = await response.json() | ||
const clientSecret = client.client_secret | ||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json', | ||
}, | ||
}) | ||
|
||
return clientSecret | ||
} | ||
const client: any = await response.json() | ||
const clientSecret = client.client_secret | ||
|
||
async function loadStripeElement(clientSecret: string): Promise<boolean> { | ||
stripe.value = await loadStripe(publishableKey) | ||
return clientSecret | ||
} | ||
|
||
if (stripe) { | ||
elements.value = stripe.value.elements({ clientSecret }) | ||
async function loadStripeElement(clientSecret: string): Promise<boolean> { | ||
stripe.value = await loadStripe(publishableKey) | ||
|
||
const paymentElement = elements.value.create('payment', { | ||
fields: { billingDetails: 'auto' }, | ||
}) | ||
if (stripe) { | ||
elements.value = stripe.value.elements({ clientSecret }) | ||
|
||
paymentElement.mount('#payment-element') | ||
const paymentElement = elements.value.create('payment', { | ||
fields: { billingDetails: 'auto' }, | ||
}) | ||
|
||
return true | ||
} | ||
paymentElement.mount('#payment-element') | ||
|
||
return false | ||
return true | ||
} | ||
|
||
async function handleAddPaymentMethod() { | ||
if (!stripe.value || !elements.value) return | ||
|
||
const { setupIntent, error } = await stripe.value.confirmSetup({ | ||
elements: elements.value, | ||
confirmParams: { | ||
return_url: 'http://localhost:5173/settings/billing' | ||
}, | ||
}) | ||
|
||
if (error) { | ||
console.error(error.message) // Display or handle error for the user | ||
} else { | ||
console.log('Setup Intent successful:', setupIntent) | ||
// You might save setupIntent.id to your database here | ||
} | ||
return false | ||
} | ||
|
||
async function handleAddPaymentMethod() { | ||
if (!stripe.value || !elements.value) | ||
return | ||
|
||
const { setupIntent, error } = await stripe.value.confirmSetup({ | ||
elements: elements.value, | ||
confirmParams: { | ||
return_url: 'http://localhost:5173/settings/billing', | ||
}, | ||
}) | ||
|
||
if (error) { | ||
console.error(error.message) // Display or handle error for the user | ||
} | ||
else { | ||
console.log('Setup Intent successful:', setupIntent) | ||
// You might save setupIntent.id to your database here | ||
} | ||
} | ||
|
||
return { fetchSetupIntent, loadStripeElement, handleAddPaymentMethod } | ||
} | ||
return { fetchSetupIntent, loadStripeElement, handleAddPaymentMethod } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
storage/framework/core/components/transition/src/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { TransitionRoot, TransitionChild } from '@headlessui/vue' | ||
import { TransitionChild, TransitionRoot } from '@headlessui/vue' | ||
|
||
export { | ||
TransitionChild, | ||
TransitionRoot | ||
TransitionRoot, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.