Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion packages/backend/src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const Config = {
'SEND_TENANT_WEBHOOKS_TO_OPERATOR',
false
),
cardServiceUrl: envString('CARD_SERVICE_URL')
cardServiceUrl: process.env.CARD_SERVICE_URL
}

function parseRedisTlsConfig(
Expand Down
15 changes: 9 additions & 6 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,16 @@ export function initIocContainer(
})
})

container.singleton('cardService', async (deps) => {
return createCardService({
axios: await deps.use('axios'),
logger: await deps.use('logger'),
cardServiceUrl: config.cardServiceUrl
if (config.cardServiceUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this if and keep the cardService service defined, otherwise we might get unexpected behaviour if a singleton resolves to undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do a NoopCardService (similar to the NoopTelemetryService)

const cardServiceUrl = config.cardServiceUrl
container.singleton('cardService', async (deps) => {
return createCardService({
axios: await deps.use('axios'),
logger: await deps.use('logger'),
cardServiceUrl
})
})
})
}

return container
}
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/open_payments/wallet_address/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class WalletAddress
}: {
authServer: string
resourceServer: string
cardService: string
cardService?: string
}): OpenPaymentsWalletAddress {
const returnVal: OpenPaymentsWalletAddress = {
id: this.address,
Expand All @@ -132,7 +132,7 @@ export class WalletAddress
assetScale: this.asset.scale,
authServer,
resourceServer,
cardService
...(cardService && { cardService })
}
if (this.additionalProperties && this.additionalProperties.length) {
returnVal.additionalProperties = this.additionalProperties
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/open_payments/wallet_address/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export async function getWalletAddress(
ctx.body = walletAddress.toOpenPaymentsType({
authServer: `${ensureTrailingSlash(deps.config.authServerGrantUrl)}${walletAddress.tenantId}`,
resourceServer: `${ensureTrailingSlash(deps.config.openPaymentsUrl)}${walletAddress.tenantId}`,
cardService: `${ensureTrailingSlash(deps.config.cardServiceUrl)}${walletAddress.tenantId}`
...(deps.config.cardServiceUrl && {
cardService: `${ensureTrailingSlash(deps.config.cardServiceUrl)}${walletAddress.tenantId}`
})
})
}

Expand Down
Loading