billing platform - minor property renaming
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -1720,7 +1720,8 @@ export default class StripeBillingIntegration extends BillingIntegration {
}
return {
- accountID: subAccount.id,
+ accountExternalID: subAccount.id,
+ liveMode: subAccount.liveMode,
activationLink: activationLink.url,
status: BillingAccountStatus.IDLE
};

MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -495,7 +495,7 @@ export default class BillingService {
MODULE_NAME, 'handleCreateSubAccount', req.user);
// Create the sub account
const subAccount = await billingImpl.createSubAccount();
- subAccount.userID = user.id;
+ subAccount.businessOwnerID = user.id;
// Save the sub account
subAccount.id = await BillingStorage.saveSubAccount(req.tenant, subAccount);
res.status(StatusCodes.CREATED).json(subAccount);
@@ -520,8 +520,8 @@ export default class BillingService {
});
}
// Get the sub account owner
- const user = await UserStorage.getUser(tenant, subAccount.userID);
- UtilsService.assertObjectExists(action, user, `User ID '${subAccount.userID}' does not exist`, MODULE_NAME, 'handleActivateSubAccount', req.user);
+ const user = await UserStorage.getUser(tenant, subAccount.businessOwnerID);
+ UtilsService.assertObjectExists(action, user, `User ID '${subAccount.businessOwnerID}' does not exist`, MODULE_NAME, 'handleActivateSubAccount', req.user);
// Activate and save the sub account
subAccount.status = BillingAccountStatus.ACTIVE;
await BillingStorage.saveSubAccount(tenant, subAccount);
@@ -594,8 +594,8 @@ export default class BillingService {
});
}
// Get the sub account owner
- const user = await UserStorage.getUser(req.tenant, subAccount.userID);
- UtilsService.assertObjectExists(action, user, `User ID '${subAccount.userID}' does not exist`, MODULE_NAME, 'handleOnboardAccount', req.user);
+ const user = await UserStorage.getUser(req.tenant, subAccount.businessOwnerID);
+ UtilsService.assertObjectExists(action, user, `User ID '${subAccount.businessOwnerID}' does not exist`, MODULE_NAME, 'handleOnboardAccount', req.user);
// Activate and save the sub account
subAccount.status = BillingAccountStatus.PENDING;
await BillingStorage.saveSubAccount(req.tenant, subAccount);

MODIFY
src/storage/mongodb/BillingStorage.ts
src/storage/mongodb/BillingStorage.ts
@@ -223,9 +223,9 @@ export default class BillingStorage {
// Properties to save
const subAccountMDB: any = {
_id: subAccount.id ? DatabaseUtils.convertToObjectID(subAccount.id) : new ObjectId(),
- accountID: subAccount.accountID,
+ accountID: subAccount.accountExternalID,
status: subAccount.status,
- userID: DatabaseUtils.convertToObjectID(subAccount.userID)
+ userID: DatabaseUtils.convertToObjectID(subAccount.businessOwnerID)
};
// Modify and return the modified document
await global.database.getCollection<any>(tenant.id, 'billingsubaccounts').findOneAndUpdate(

MODIFY
src/types/Billing.ts
src/types/Billing.ts
@@ -169,10 +169,11 @@ export interface BillingPlatformFee {
export interface BillingAccount extends AuthorizationActions {
id?: string;
- accountID: string;
- activationLink?: string;
- userID?: string;
+ businessOwnerID?: string;
status: BillingAccountStatus;
+ activationLink?: string;
+ accountExternalID: string;
+ liveMode: boolean;
}
export interface BillingAccountData {
@@ -197,12 +198,12 @@ export interface BillingPlatformFeeData {
export interface BillingTransfer {
id?: string;
status: BillingTransferStatus;
- liveMode: boolean;
sessions: BillingTransferSession[];
amount: number;
accountID: string;
platformFeeData: BillingPlatformFeeData;
transferExternalID?: string; // Transfer sent to the CPO
+ liveMode: boolean;
}
export interface BillingTransferSession {

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -90,7 +90,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
describe('Sub-accounts', () => {
it('Should create a sub-account with its associated activation link', async () => {
const subAccount = await stripeTestHelper.createSubAccount();
- expect(subAccount.accountID).to.exist;
+ expect(subAccount.accountExternalID).to.exist;
expect(subAccount.activationLink).to.include('https://connect.stripe.com/setup/s/');
expect(subAccount.status).to.be.eq(BillingAccountStatus.IDLE);
});

billing platform - minor property renaming