diff --git a/src/views/creators/DonationButtonBanner.vue b/src/views/creators/DonationButtonBanner.vue
index ce73805..32921b0 100644
--- a/src/views/creators/DonationButtonBanner.vue
+++ b/src/views/creators/DonationButtonBanner.vue
@@ -1,16 +1,9 @@
-
- Je soutiens
+
+ Je supporte
+
@@ -34,7 +27,7 @@
-
Envoyez
@@ -73,9 +67,13 @@
+
+
-
- Annuler
+ Annuler
+
@@ -91,6 +89,14 @@ import {useBrandingStore} from "@/stores/brandingStore.js";
const brandingStore = useBrandingStore()
+const props = defineProps({
+ creatorId: {default: 'missing-creator-id', required: true},
+ creatorName: {default: 'missing-creator-name', required: true},
+ onSuccessUrl: {default: 'missing-on-success-u', required: true},
+ onCancelledUrl: {default: 'missing-on-cancelled-url', required: true},
+ iconColorClass: {default: 'text-black'}
+});
+
const donationModal = ref(false);
function openDonationDialog() {
@@ -101,9 +107,10 @@ function closeDonationDialog() {
donationModal.value = false
}
+
const isPaymentDialogActive = ref(false);
-const tipAmount = ref(0);
+const tipAmountInDollars = ref(0);
const tipMessage = ref("");
let stripe = null;
@@ -114,23 +121,21 @@ onMounted(async () => {
stripe = await loadStripe(import.meta.env.VITE_STRIPE_API_KEY);
});
-const fetchClientSecret = async () => {
- const clientSecret = await createCheckoutSession();
- return clientSecret;
-};
-
-
async function createCheckoutSession() {
const client = useClient()
- let clientSecret = await client.post('/api/Stripe', {
- amount: (tipAmount.value * 100),
- tipMessage: tipMessage.value,
- creatorId: props.creatorId
- });
+ let clientSecret = await client.post(
+ `/api/tips`,
+ {
+ amount: tipAmountInDollars.value * 100,
+ currency: 'CAD',
+ message: tipMessage.value,
+ creatorId: props.creatorId,
+ checkoutSuccessUrl: props.onSuccessUrl,
+ checkoutCancelledUrl: props.onCancelledUrl
+ });
- let secret = clientSecret["data"];
- return secret;
+ return clientSecret.data;
}
function closeDialog() {
@@ -143,11 +148,10 @@ function closeDialog() {
async function goPay() {
isPaymentDialogActive.value = true;
- checkout = await stripe.initEmbeddedCheckout({
- fetchClientSecret,
- });
+ const response = await createCheckoutSession()
- await checkout.mount('#checkout');
+ // Redirect to the Stripe Checkout page
+ window.location.href = response.stripeCheckoutUrl
}
function preventNonNumeric(event) {
@@ -159,3 +163,9 @@ function preventNonNumeric(event) {
}
}
+
+