diff --git a/src/component/subscribe/StripeSubscriptionButton.jsx b/src/component/subscribe/StripeSubscriptionButton.jsx
new file mode 100644
index 0000000..1bf50b6
--- /dev/null
+++ b/src/component/subscribe/StripeSubscriptionButton.jsx
@@ -0,0 +1,56 @@
+import React from 'react';
+import { loadStripe } from '@stripe/stripe-js';
+import { Elements, useStripe, useElements, CardElement } from '@stripe/react-stripe-js';
+import {MyProductData, StripeSubscriptionCreate} from '../../services/services';
+import {useQuery} from "@tanstack/react-query";
+import queryKeys from "../../services/queryKeys";
+import { useNavigate } from 'react-router-dom';
+//const stripePromise = loadStripe('your_stripe_publishable_key');
+const stripePromise = loadStripe('pk_test_51RqL5WLjZLojw6IZmEpwFidNZSl9lLlVUHNvuFZNEz1eTR9XXepnyyVhfvXe9cp4eMnqkDPpoe9wxLLRSV0dxRee00UfhayUOT');
+
+const CheckoutForm = ({ priceId, customerId }) => {
+ const stripe = useStripe();
+ const elements = useElements();
+ const navigate = useNavigate();
+ const handleSubmit = async (event) => {
+ event.preventDefault();
+
+ if (!stripe || !elements) {
+ return;
+ }
+
+ let reqData = {
+ priceId : priceId,
+ customerId: customerId,
+ token: localStorage.getItem('token'), // USER TOKEN
+ uid: localStorage.getItem('uid') // USER UID
+ }
+
+ StripeSubscriptionCreate(reqData).then( (res)=>{
+ console.log(res);
+ console.log(res.data.stripe_session);
+ //navigate(res.data.stripe_session)
+ window.location.replace(res.data.stripe_session);
+ });
+
+ };
+
+ return (
+
+ );
+};
+
+const StripeSubscriptionButton = ({ priceId, customerId }) => {
+ return (
+
+
+
+ );
+};
+
+export default StripeSubscriptionButton;
\ No newline at end of file
diff --git a/src/component/subscribe/Subscribe.jsx b/src/component/subscribe/Subscribe.jsx
index 679c57b..8b74d8c 100644
--- a/src/component/subscribe/Subscribe.jsx
+++ b/src/component/subscribe/Subscribe.jsx
@@ -1,25 +1,25 @@
-import React, { useState } from 'react'
+import React, {useState} from 'react'
import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS";
-import getImage from "../../utils/getImage";
-import { getSubscriptions } from '../../services/services';
-import { useQuery } from '@tanstack/react-query';
-import queryKeys from '../../services/queryKeys';
-import siteLinks from "../../links/siteLinks";
-import { Link, useLocation } from 'react-router-dom'
+import {Link, useLocation} from 'react-router-dom'
import SubscribeNewCard from "./SubscribeNewCard";
import SubscribePreviousCard from "./SubscribePreviousCard";
import SubcribePaymentOptions from "./SubcribePaymentOptions";
+import StripeSubscriptionButton from "./StripeSubscriptionButton";
+
+
+
export default function Subscribe() {
+ const {state: {selectedSubscription,customerId}} = useLocation()
- const {state:{selectedSubscription}} = useLocation()
+ console.log('selectedSubscription', selectedSubscription)
+ console.log('customerId', customerId)
- // console.log('selectedSubscription', selectedSubscription)
let [activePaymentType, setActivePaymentType] = useState('previous')
return (
<>
-
+
@@ -28,38 +28,42 @@ export default function Subscribe() {
Current Subscription(s)
{/*{currentSubscription?.display_name}
*/}
-
- {activePaymentType == 'new' ?
-
+
+ {activePaymentType == 'new' ?
+
:
-
- }
-
+
+ }
+ <>
+
+ >
<>
-
-
-
-
-
{selectedSubscription.display_name}
-
${selectedSubscription.monthly}
-
/ Monthly
-
- {selectedSubscription?.items?.map(item =>(
- - {item.description}
- ))}
-
- {/*
*/}
- {/* */}
- {/*
*/}
+
+
+
+
+
{selectedSubscription.display_name}
+
${selectedSubscription.monthly}
+
/ Monthly
+
+ {selectedSubscription?.items?.map(item => (
+ - {item.description}
+ ))}
+
+ {/*
*/}
+ {/* */}
+ {/*
*/}
+
-
>
>
diff --git a/src/component/subscription/Subscription.jsx b/src/component/subscription/Subscription.jsx
index 78faab5..1532fcf 100644
--- a/src/component/subscription/Subscription.jsx
+++ b/src/component/subscription/Subscription.jsx
@@ -28,6 +28,8 @@ export default function Subscription() {
const currentSubscription = data?.data?.current_product
const otherSubscriptions = data?.data?.options
+ const stripe_customer_id = data?.data.stripe_customer_id
+
// console.log('urlData', data?.data)
return (
@@ -83,7 +85,7 @@ export default function Subscription() {
diff --git a/src/services/services.js b/src/services/services.js
index e63e7b2..9de35af 100644
--- a/src/services/services.js
+++ b/src/services/services.js
@@ -83,6 +83,13 @@ export const MyProductData = (reqData) => {
return postAuxEnd(`/panel/myproduct/dash`, postData, false)
}
+export const StripeSubscriptionCreate = (reqData) => {
+ let postData = {
+ ...reqData,
+ }
+ return postAuxEnd(`/panel/subscription/start`, postData, false)
+}
+
// FUNCTION TO GET CALENDAR EVENTS
export const getCalendarEvents = (reqData) => {
let postData = {