Skip to content

Commit

Permalink
Do not use payments staging in dev1 (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
DJAndries authored Jul 22, 2024
1 parent 46ab40a commit ebda591
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ export const config = {
};

export const isProduction = env === "production";

export const shouldForcePaymentsStaging =
env.startsWith("development") && env !== "development";
5 changes: 3 additions & 2 deletions src/services.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export const env = process.env.ENVIRONMENT ?? "local";
import { shouldForcePaymentsStaging } from "./environment";

export function resolveService(
servicePrefix: string,
baseHost: string = window.location.host,
): string {
if (env.startsWith("development") && servicePrefix === "account") {
if (shouldForcePaymentsStaging && servicePrefix === "account") {
// Only use payments staging in dev2, dev3 and staging
return "https://account.bravesoftware.com";
}
return `https://${servicePrefix}.${secondLevelDomain(baseHost)}`;
Expand Down
6 changes: 3 additions & 3 deletions src/subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Rewards from "@brave-intl/skus-sdk";
import { isDevelopment, isProduction } from "./environment";
import { isProduction, shouldForcePaymentsStaging } from "./environment";

let sdkref: Rewards.JSSDK | undefined;

Expand All @@ -13,7 +13,7 @@ const loadRewardsSdk = async (): Promise<Rewards.JSSDK> => {

log(`calling initialize(${env}, false)...`);
const sdk = await Rewards.initialize(
isDevelopment ? "staging" : env,
shouldForcePaymentsStaging ? "staging" : env,
false,
isProduction ? "error" : "info",
);
Expand Down Expand Up @@ -69,7 +69,7 @@ export async function recoverCredsIfRequired(orderId: string): Promise<void> {
}

function getCredentialHostname(): string | undefined {
return isDevelopment ? "talk.bravesoftware.com" : undefined;
return shouldForcePaymentsStaging ? "talk.bravesoftware.com" : undefined;
}

export async function checkSubscribedUsingSDK(): Promise<boolean> {
Expand Down

0 comments on commit ebda591

Please sign in to comment.