Skip to content

Commit c5a51d0

Browse files
committed
fixes
1 parent e03b91a commit c5a51d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/services/payment-service.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createCryptAPIClient } from '../utils/cryptapi-wrapper.js';
22
import { supabase } from '../utils/supabase.js';
33
import { emailService } from './email-service.js';
4+
import { apiKeyService } from './api-key-service.js';
45
import 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)) {

0 commit comments

Comments
 (0)