π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
Feat: insufficant funds
Nevo David72c8a4475c7a
diff --git a/libraries/nestjs-libraries/src/services/stripe.service.ts b/libraries/nestjs-libraries/src/services/stripe.service.tsindex 5d7a2e12c..8e6353d6f 100644--- a/libraries/nestjs-libraries/src/services/stripe.service.ts+++ b/libraries/nestjs-libraries/src/services/stripe.service.ts@@ -54,7 +54,10 @@ export class StripeService {return false;}- const getOrgFromCustomer = await this._organizationService.getOrgByCustomerId(event.data.object.customer as string);+ const getOrgFromCustomer =+ await this._organizationService.getOrgByCustomerId(+ event.data.object.customer as string+ );if (!getOrgFromCustomer?.allowTrial) {return true;@@ -74,28 +77,32 @@ export class StripeService {return prev;});- const paymentIntent = await stripe.paymentIntents.create({- amount: 100,- currency: 'usd',- payment_method: latestMethod.id,- customer: event.data.object.customer as string,- automatic_payment_methods: {- allow_redirects: 'never',- enabled: true,- },- capture_method: 'manual', // Authorize without capturing- confirm: true, // Confirm the PaymentIntent- });+ try {+ const paymentIntent = await stripe.paymentIntents.create({+ amount: 100,+ currency: 'usd',+ payment_method: latestMethod.id,+ customer: event.data.object.customer as string,+ automatic_payment_methods: {+ allow_redirects: 'never',+ enabled: true,+ },+ capture_method: 'manual', // Authorize without capturing+ confirm: true, // Confirm the PaymentIntent+ });++ if (paymentIntent.status !== 'requires_capture') {+ console.error('Cant charge');+ await stripe.paymentMethods.detach(paymentMethods.data[0].id);+ await stripe.subscriptions.cancel(event.data.object.id as string);+ return false;+ }- if (paymentIntent.status !== 'requires_capture') {- console.error('Cant charge');- await stripe.paymentMethods.detach(paymentMethods.data[0].id);- await stripe.subscriptions.cancel(event.data.object.id as string);+ await stripe.paymentIntents.cancel(paymentIntent.id as string);+ return true;+ } catch (err) {return false;}-- await stripe.paymentIntents.cancel(paymentIntent.id as string);- return true;}async createSubscription(event: Stripe.CustomerSubscriptionCreatedEvent) {