@dotted-labs/ngx-supabase-stripe 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/database.types.d.ts +129 -2
- package/fesm2022/dotted-labs-ngx-supabase-stripe.mjs +11 -15
- package/fesm2022/dotted-labs-ngx-supabase-stripe.mjs.map +1 -1
- package/lib/components/customer/subscriptions/subscriptions-list/subscription-item/subscription-item.component.d.ts +1 -1
- package/lib/components/embedded-subscription/embedded-subscription.component.d.ts +1 -1
- package/lib/components/embedded-subscription/return-page/subscription-return-page.component.d.ts +1 -1
- package/lib/config/supabase.config.d.ts +4 -0
- package/lib/services/supabase-client.service.d.ts +766 -14
- package/lib/store/subscriptions.store.d.ts +2 -1
- package/package.json +1 -1
package/database.types.d.ts
CHANGED
|
@@ -354,7 +354,134 @@ export type Database = {
|
|
|
354
354
|
[_ in never]: never;
|
|
355
355
|
};
|
|
356
356
|
Functions: {
|
|
357
|
-
|
|
357
|
+
get_stripe_checkout_session: {
|
|
358
|
+
Args: {
|
|
359
|
+
session_id: string;
|
|
360
|
+
};
|
|
361
|
+
Returns: {
|
|
362
|
+
id: string;
|
|
363
|
+
customer: string;
|
|
364
|
+
payment_intent: string;
|
|
365
|
+
subscription: string;
|
|
366
|
+
attrs: Json;
|
|
367
|
+
}[];
|
|
368
|
+
};
|
|
369
|
+
get_stripe_community_products: {
|
|
370
|
+
Args: {
|
|
371
|
+
p_community_id: string;
|
|
372
|
+
};
|
|
373
|
+
Returns: {
|
|
374
|
+
id: string;
|
|
375
|
+
name: string;
|
|
376
|
+
description: string;
|
|
377
|
+
price: number;
|
|
378
|
+
image_url: string;
|
|
379
|
+
video: string;
|
|
380
|
+
payment_provider_product_id: string;
|
|
381
|
+
created_at: string;
|
|
382
|
+
updated_at: string;
|
|
383
|
+
}[];
|
|
384
|
+
};
|
|
385
|
+
get_stripe_customer: {
|
|
386
|
+
Args: {
|
|
387
|
+
customer_email: string;
|
|
388
|
+
};
|
|
389
|
+
Returns: {
|
|
390
|
+
id: string;
|
|
391
|
+
email: string;
|
|
392
|
+
name: string;
|
|
393
|
+
description: string;
|
|
394
|
+
created: string;
|
|
395
|
+
attrs: Json;
|
|
396
|
+
}[];
|
|
397
|
+
};
|
|
398
|
+
get_stripe_customer_payment_intents: {
|
|
399
|
+
Args: {
|
|
400
|
+
customer_id: string;
|
|
401
|
+
};
|
|
402
|
+
Returns: {
|
|
403
|
+
id: string;
|
|
404
|
+
customer: string;
|
|
405
|
+
amount: number;
|
|
406
|
+
currency: string;
|
|
407
|
+
payment_method: string;
|
|
408
|
+
created: string;
|
|
409
|
+
attrs: Json;
|
|
410
|
+
}[];
|
|
411
|
+
};
|
|
412
|
+
get_stripe_customer_subscriptions: {
|
|
413
|
+
Args: {
|
|
414
|
+
customer_id: string;
|
|
415
|
+
};
|
|
416
|
+
Returns: {
|
|
417
|
+
id: string;
|
|
418
|
+
customer: string;
|
|
419
|
+
currency: string;
|
|
420
|
+
current_period_start: string;
|
|
421
|
+
current_period_end: string;
|
|
422
|
+
attrs: Json;
|
|
423
|
+
}[];
|
|
424
|
+
};
|
|
425
|
+
get_stripe_prices: {
|
|
426
|
+
Args: Record<PropertyKey, never>;
|
|
427
|
+
Returns: {
|
|
428
|
+
id: string;
|
|
429
|
+
active: boolean;
|
|
430
|
+
currency: string;
|
|
431
|
+
product: string;
|
|
432
|
+
unit_amount: number;
|
|
433
|
+
type: string;
|
|
434
|
+
attrs: Json;
|
|
435
|
+
}[];
|
|
436
|
+
};
|
|
437
|
+
get_stripe_product: {
|
|
438
|
+
Args: {
|
|
439
|
+
product_id: string;
|
|
440
|
+
};
|
|
441
|
+
Returns: {
|
|
442
|
+
id: string;
|
|
443
|
+
name: string;
|
|
444
|
+
active: boolean;
|
|
445
|
+
default_price: string;
|
|
446
|
+
description: string;
|
|
447
|
+
attrs: Json;
|
|
448
|
+
}[];
|
|
449
|
+
};
|
|
450
|
+
get_stripe_products: {
|
|
451
|
+
Args: Record<PropertyKey, never>;
|
|
452
|
+
Returns: {
|
|
453
|
+
id: string;
|
|
454
|
+
name: string;
|
|
455
|
+
active: boolean;
|
|
456
|
+
default_price: string;
|
|
457
|
+
description: string;
|
|
458
|
+
attrs: Json;
|
|
459
|
+
}[];
|
|
460
|
+
};
|
|
461
|
+
get_stripe_subscription: {
|
|
462
|
+
Args: {
|
|
463
|
+
subscription_id: string;
|
|
464
|
+
};
|
|
465
|
+
Returns: {
|
|
466
|
+
id: string;
|
|
467
|
+
customer: string;
|
|
468
|
+
currency: string;
|
|
469
|
+
current_period_start: string;
|
|
470
|
+
current_period_end: string;
|
|
471
|
+
attrs: Json;
|
|
472
|
+
}[];
|
|
473
|
+
};
|
|
474
|
+
get_stripe_subscriptions: {
|
|
475
|
+
Args: Record<PropertyKey, never>;
|
|
476
|
+
Returns: {
|
|
477
|
+
id: string;
|
|
478
|
+
customer: string;
|
|
479
|
+
currency: string;
|
|
480
|
+
current_period_start: string;
|
|
481
|
+
current_period_end: string;
|
|
482
|
+
attrs: Json;
|
|
483
|
+
}[];
|
|
484
|
+
};
|
|
358
485
|
};
|
|
359
486
|
Enums: {
|
|
360
487
|
[_ in never]: never;
|
|
@@ -364,7 +491,7 @@ export type Database = {
|
|
|
364
491
|
};
|
|
365
492
|
};
|
|
366
493
|
};
|
|
367
|
-
type DefaultSchema = Database[Extract<keyof Database, "public">];
|
|
494
|
+
type DefaultSchema = Database[Extract<keyof Database, "public" | "stripe">];
|
|
368
495
|
export type Tables<DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | {
|
|
369
496
|
schema: keyof Database;
|
|
370
497
|
}, TableName extends DefaultSchemaTableNameOrOptions extends {
|
|
@@ -85,7 +85,7 @@ class SupabaseClientService {
|
|
|
85
85
|
*/
|
|
86
86
|
async selectCheckoutSession(sessionId) {
|
|
87
87
|
return this.client
|
|
88
|
-
.schema(
|
|
88
|
+
.schema(this.config.supabaseSchema)
|
|
89
89
|
.rpc('get_stripe_checkout_session', { session_id: sessionId })
|
|
90
90
|
.select('*')
|
|
91
91
|
.single();
|
|
@@ -98,7 +98,7 @@ class SupabaseClientService {
|
|
|
98
98
|
*/
|
|
99
99
|
getStripeSubscriptions() {
|
|
100
100
|
return this.client
|
|
101
|
-
.schema(
|
|
101
|
+
.schema(this.config.supabaseSchema)
|
|
102
102
|
.rpc('get_stripe_subscriptions')
|
|
103
103
|
.select('*');
|
|
104
104
|
}
|
|
@@ -108,7 +108,7 @@ class SupabaseClientService {
|
|
|
108
108
|
*/
|
|
109
109
|
selectStripeSubscription(subscriptionId) {
|
|
110
110
|
return this.client
|
|
111
|
-
.schema(
|
|
111
|
+
.schema(this.config.supabaseSchema)
|
|
112
112
|
.rpc('get_stripe_subscription', { subscription_id: subscriptionId })
|
|
113
113
|
.select('*');
|
|
114
114
|
}
|
|
@@ -121,7 +121,7 @@ class SupabaseClientService {
|
|
|
121
121
|
*/
|
|
122
122
|
async selectStripePrices() {
|
|
123
123
|
return this.client
|
|
124
|
-
.schema(
|
|
124
|
+
.schema(this.config.supabaseSchema)
|
|
125
125
|
.rpc('get_stripe_prices')
|
|
126
126
|
.select('*');
|
|
127
127
|
}
|
|
@@ -134,7 +134,7 @@ class SupabaseClientService {
|
|
|
134
134
|
*/
|
|
135
135
|
async selectStripeProducts() {
|
|
136
136
|
return this.client
|
|
137
|
-
.schema(
|
|
137
|
+
.schema(this.config.supabaseSchema)
|
|
138
138
|
.rpc('get_stripe_products')
|
|
139
139
|
.select('*');
|
|
140
140
|
}
|
|
@@ -144,7 +144,7 @@ class SupabaseClientService {
|
|
|
144
144
|
*/
|
|
145
145
|
async selectStripeProduct(productId) {
|
|
146
146
|
return this.client
|
|
147
|
-
.schema(
|
|
147
|
+
.schema(this.config.supabaseSchema)
|
|
148
148
|
.rpc('get_stripe_product', { product_id: productId })
|
|
149
149
|
.select('*');
|
|
150
150
|
}
|
|
@@ -171,7 +171,7 @@ class SupabaseClientService {
|
|
|
171
171
|
* @param email The customer email
|
|
172
172
|
*/
|
|
173
173
|
async getCustomerByEmail(email) {
|
|
174
|
-
return this.client.schema(
|
|
174
|
+
return this.client.schema(this.config.supabaseSchema).rpc('get_stripe_customer', { customer_email: email });
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* Get customer payment intents
|
|
@@ -179,7 +179,7 @@ class SupabaseClientService {
|
|
|
179
179
|
*/
|
|
180
180
|
async getCustomerPaymentIntents(customerId) {
|
|
181
181
|
return this.client
|
|
182
|
-
.schema(
|
|
182
|
+
.schema(this.config.supabaseSchema)
|
|
183
183
|
.rpc('get_stripe_customer_payment_intents', { customer_id: customerId })
|
|
184
184
|
.select('*');
|
|
185
185
|
}
|
|
@@ -189,7 +189,7 @@ class SupabaseClientService {
|
|
|
189
189
|
*/
|
|
190
190
|
async getCustomerSubscriptions(customerId) {
|
|
191
191
|
return this.client
|
|
192
|
-
.schema(
|
|
192
|
+
.schema(this.config.supabaseSchema)
|
|
193
193
|
.rpc('get_stripe_customer_subscriptions', { customer_id: customerId })
|
|
194
194
|
.select('*');
|
|
195
195
|
}
|
|
@@ -717,13 +717,9 @@ const SubscriptionsStore = signalStore({ providedIn: 'root' }, withState(initial
|
|
|
717
717
|
* Create a subscription
|
|
718
718
|
* @param priceId The price ID for the subscription
|
|
719
719
|
*/
|
|
720
|
-
async createSubscription(priceId, returnPath,
|
|
720
|
+
async createSubscription(priceId, returnPath, customer) {
|
|
721
721
|
patchState(store, { status: 'loading', error: null });
|
|
722
722
|
try {
|
|
723
|
-
let customer = null;
|
|
724
|
-
if (customerEmail) {
|
|
725
|
-
customer = customerStore.customer().data;
|
|
726
|
-
}
|
|
727
723
|
const { clientSecret, error } = await stripeService.createSubscription(priceId, returnPath, customer);
|
|
728
724
|
console.log('🔍 [SubscriptionsStore] created subscription', clientSecret, error);
|
|
729
725
|
if (error) {
|
|
@@ -1316,7 +1312,7 @@ class EmbeddedSubscriptionComponent {
|
|
|
1316
1312
|
createSubscription() {
|
|
1317
1313
|
const baseUrl = window.location.origin;
|
|
1318
1314
|
const returnPath = `${baseUrl}${this.returnPagePath()}`;
|
|
1319
|
-
this.subscriptionsStore.createSubscription(this.priceId(), returnPath, this.customer()
|
|
1315
|
+
this.subscriptionsStore.createSubscription(this.priceId(), returnPath, this.customer());
|
|
1320
1316
|
}
|
|
1321
1317
|
ngOnDestroy() {
|
|
1322
1318
|
this.subscriptionsStore.destroyEmbeddedSubscription();
|