feat: sweep up the Lemon Squeezy integration

This commit is contained in:
Ahmed Bouhuolia
2024-04-14 12:44:02 +02:00
parent a9748b23c0
commit e486333c96
17 changed files with 39 additions and 422 deletions

View File

@@ -1,30 +0,0 @@
import { Service } from "typedi";
@Service()
export default class SubscriptionMailMessages {
/**
*
* @param phoneNumber
* @param remainingDays
*/
public async sendRemainingSubscriptionPeriod(phoneNumber: string, remainingDays: number) {
const message: string = `
Your remaining subscription is ${remainingDays} days,
please renew your subscription before expire.
`;
this.smsClient.sendMessage(phoneNumber, message);
}
/**
*
* @param phoneNumber
* @param remainingDays
*/
public async sendRemainingTrialPeriod(phoneNumber: string, remainingDays: number) {
const message: string = `
Your remaining free trial is ${remainingDays} days,
please subscription before ends, if you have any quation to contact us.`;
this.smsClient.sendMessage(phoneNumber, message);
}
}

View File

@@ -1,40 +0,0 @@
import { Service, Inject } from 'typedi';
import SMSClient from '@/services/SMSClient';
@Service()
export default class SubscriptionSMSMessages {
@Inject('SMSClient')
smsClient: SMSClient;
/**
* Send remaining subscription period SMS message.
* @param {string} phoneNumber -
* @param {number} remainingDays -
*/
public async sendRemainingSubscriptionPeriod(
phoneNumber: string,
remainingDays: number
): Promise<void> {
const message: string = `
Your remaining subscription is ${remainingDays} days,
please renew your subscription before expire.
`;
this.smsClient.sendMessage(phoneNumber, message);
}
/**
* Send remaining trial period SMS message.
* @param {string} phoneNumber -
* @param {number} remainingDays -
*/
public async sendRemainingTrialPeriod(
phoneNumber: string,
remainingDays: number
): Promise<void> {
const message: string = `
Your remaining free trial is ${remainingDays} days,
please subscription before ends, if you have any quation to contact us.`;
this.smsClient.sendMessage(phoneNumber, message);
}
}

View File

@@ -23,11 +23,9 @@ export function configureLemonSqueezy() {
lemonSqueezySetup({
apiKey: process.env.LEMONSQUEEZY_API_KEY,
onError: (error) => {
console.log(error);
// console.log('LL', error.message);
// eslint-disable-next-line no-console -- allow logging
// console.error(error);
// throw new Error(`Lemon Squeezy API error: ${error.message}`);
console.error(error);
throw new Error(`Lemon Squeezy API error: ${error.message}`);
},
});
}