Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const logging = require('@tryghost/logging');

const CONFIGURATION_ID_SETTING = 'stripe_billing_portal_configuration_id';

const DEFAULT_FEATURES = {
Expand Down Expand Up @@ -91,7 +93,13 @@ class BillingPortalManager {
const configuration = await this.api.createBillingPortalConfiguration(this.getConfigurationOptions());
return configuration.id;
}
throw err;

logging.error('Failed to update the billing portal configuration', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: if we wanted to monitor those logs, it might be useful to have some further information in them, so we could action on it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error itself should help! That will have a message w plenty of context

err
});

// Couldn't modify configuration, means it's likely the default config
return id;
Comment thread
sam-lord marked this conversation as resolved.
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('BillingPortalManager', function () {
sinon.assert.calledOnce(mockApi.createBillingPortalConfiguration);
});

it('throws error when update fails with non-resource_missing error', async function () {
it('returns the passed id when failing with a non-resource based error', async function () {
mockSettingsCache.get.withArgs('title').returns('Test Site');
const genericError = new Error('Stripe API error');
mockApi.updateBillingPortalConfiguration.rejects(genericError);
Expand All @@ -185,10 +185,8 @@ describe('BillingPortalManager', function () {
});
manager.configure({siteUrl: 'https://example.com'});

await assert.rejects(
() => manager.createOrUpdateConfiguration('bpc_existing'),
{message: 'Stripe API error'}
);
const result = await manager.createOrUpdateConfiguration('bpc_existing');
assert.equal(result, 'bpc_existing');
});
});

Expand Down
Loading