1
- import { createCheckoutLink , createCustomer , getProducts , searchCustomer } from "@lowcoder-ee/api/subscriptionApi" ;
1
+ import { createCheckoutLink , cleanupCustomer } from "@lowcoder-ee/api/subscriptionApi" ;
2
2
import { StripeCustomer , SubscriptionProduct , InitSubscriptionProducts , LowcoderSearchCustomer , LowcoderNewCustomer , Subscription } from "@lowcoder-ee/constants/subscriptionConstants" ;
3
3
import { getDeploymentId } from "@lowcoder-ee/redux/selectors/configSelectors" ;
4
4
import { getFetchSubscriptionsFinished , getSubscriptions , getSubscriptionsError } from "@lowcoder-ee/redux/selectors/subscriptionSelectors" ;
@@ -78,17 +78,6 @@ export const SubscriptionContextProvider = (props: {
78
78
userId : user . id ,
79
79
} ;
80
80
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
-
92
81
useEffect ( ( ) => {
93
82
// If products are already loaded in the outer context, reuse them
94
83
if ( productsLoaded ) {
@@ -104,28 +93,11 @@ export const SubscriptionContextProvider = (props: {
104
93
const initializeCustomer = async ( ) => {
105
94
if ( existingCustomer ) {
106
95
setCustomer ( existingCustomer ) ;
96
+
97
+ cleanupCustomer ( subscriptionSearchCustomer ) ;
98
+
107
99
return ;
108
100
}
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
- } */
129
101
} ;
130
102
131
103
if ( ! customer && isCustomerInitializationComplete ) {
0 commit comments