File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 11import { createCryptAPIClient } from '../utils/cryptapi-wrapper.js' ;
22import { supabase } from '../utils/supabase.js' ;
33import { emailService } from './email-service.js' ;
4+ import { apiKeyService } from './api-key-service.js' ;
45import dotenv from 'dotenv-flow' ;
56
67// Load environment variables
@@ -89,6 +90,14 @@ export const paymentService = {
8990 */
9091 async createSubscription ( email , plan , coin ) {
9192 console . log ( `Payment service: Creating subscription for ${ email } , plan: ${ plan } , coin: ${ coin } ` ) ;
93+ // Ensure user exists in Supabase
94+ try {
95+ await apiKeyService . _createUserIfNotExists ( email ) ;
96+ console . log ( 'Payment service: Ensured user exists in Supabase' ) ;
97+ } catch ( userError ) {
98+ console . error ( 'Payment service: Error ensuring user exists in Supabase:' , userError ) ;
99+ throw userError ;
100+ }
92101
93102 // Validate plan
94103 if ( ! [ 'monthly' , 'yearly' ] . includes ( plan ) ) {
You can’t perform that action at this time.
0 commit comments