1- import { createCheckoutLink , createCustomer , getProducts , searchCustomer } from "@lowcoder-ee/api/subscriptionApi" ;
1+ import { createCheckoutLink , cleanupCustomer } from "@lowcoder-ee/api/subscriptionApi" ;
22import { StripeCustomer , SubscriptionProduct , InitSubscriptionProducts , LowcoderSearchCustomer , LowcoderNewCustomer , Subscription } from "@lowcoder-ee/constants/subscriptionConstants" ;
33import { getDeploymentId } from "@lowcoder-ee/redux/selectors/configSelectors" ;
44import { getFetchSubscriptionsFinished , getSubscriptions , getSubscriptionsError } from "@lowcoder-ee/redux/selectors/subscriptionSelectors" ;
@@ -78,17 +78,6 @@ export const SubscriptionContextProvider = (props: {
7878 userId : user . id ,
7979 } ;
8080
81- const subscriptionNewCustomer : LowcoderNewCustomer = {
82- hostname : domain ,
83- hostId : deploymentId ,
84- email : currentUser . email ,
85- orgId : orgID ,
86- userId : user . id ,
87- userName : user . username ,
88- type : admin ,
89- companyName : currentOrg ?. name || "Unknown" ,
90- } ;
91-
9281 useEffect ( ( ) => {
9382 // If products are already loaded in the outer context, reuse them
9483 if ( productsLoaded ) {
@@ -104,28 +93,11 @@ export const SubscriptionContextProvider = (props: {
10493 const initializeCustomer = async ( ) => {
10594 if ( existingCustomer ) {
10695 setCustomer ( existingCustomer ) ;
96+
97+ cleanupCustomer ( subscriptionSearchCustomer ) ;
98+
10799 return ;
108100 }
109-
110- /* try {
111- setIsCreatingCustomer(true);
112- const subscriptionSearchCustomer: LowcoderSearchCustomer = {
113- hostId: deploymentId,
114- orgId: orgID,
115- userId: user.id,
116- };
117- const existingCustomer = await searchCustomer(subscriptionSearchCustomer);
118- if (existingCustomer) {
119- setCustomer(existingCustomer);
120- } else {
121- const newCustomer = await createCustomer(subscriptionNewCustomer);
122- setCustomer(newCustomer);
123- }
124- } catch (error) {
125- setCustomerDataError(true);
126- } finally {
127- setIsCreatingCustomer(false);
128- } */
129101 } ;
130102
131103 if ( ! customer && isCustomerInitializationComplete ) {
0 commit comments