billing - STRIPE  - liveMode property on users/invoices
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -314,7 +314,8 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
});
}
// Destructuring the STRIPE invoice to extract the required information
- const { id: invoiceID, customer, number, amount_due: amount, amount_paid: amountPaid, status, currency, invoice_pdf: downloadUrl, metadata } = stripeInvoice;
+ // eslint-disable-next-line id-blacklist, max-len
+ const { id: invoiceID, customer, number, livemode: liveMode, amount_due: amount, amount_paid: amountPaid, status, currency, invoice_pdf: downloadUrl, metadata } = stripeInvoice;
const customerID = customer as string;
const createdOn = moment.unix(stripeInvoice.created).toDate(); // epoch to Date!
// Check metadata consistency - userID is mandatory!
@@ -340,7 +341,8 @@ export default class StripeBillingIntegration extends BillingIntegration<StripeB
const billingInvoice: BillingInvoice = await BillingStorage.getInvoiceByInvoiceID(this.tenantID, stripeInvoice.id);
const invoiceToSave: BillingInvoice = {
id: billingInvoice?.id, // ACHTUNG: billingInvoice is null when creating the Billing Invoice
- userID, invoiceID, customerID, number, amount, amountPaid, currency, createdOn, downloadUrl, downloadable: !!downloadUrl,
+ // eslint-disable-next-line id-blacklist
+ userID, invoiceID, customerID, liveMode, number, amount, amountPaid, currency, createdOn, downloadUrl, downloadable: !!downloadUrl,
status: status as BillingInvoiceStatus,
};
// Let's persist the up-to-date data

MODIFY
src/storage/mongodb/BillingStorage.ts
src/storage/mongodb/BillingStorage.ts
@@ -165,7 +165,9 @@ export default class BillingStorage {
const invoiceMDB: any = {
_id: invoiceToSave.id ? Utils.convertToObjectID(invoiceToSave.id) : new ObjectID(),
invoiceID: invoiceToSave.invoiceID,
+ // eslint-disable-next-line id-blacklist
number: invoiceToSave.number,
+ liveMode: Utils.convertToBoolean(invoiceToSave.liveMode),
userID: invoiceToSave.userID ? Utils.convertToObjectID(invoiceToSave.userID) : null,
customerID: invoiceToSave.customerID,
amount: Utils.convertToFloat(invoiceToSave.amount),

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -70,8 +70,10 @@ export interface BillingTax {
export interface BillingInvoice {
id: string;
invoiceID: string;
+ liveMode: boolean;
userID?: string;
user?: User;
+ // eslint-disable-next-line id-blacklist
number?: string;
status?: BillingInvoiceStatus;
amount?: number;

billing - STRIPE  - liveMode property on users/invoices