Skip to content
Merged
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
4 changes: 2 additions & 2 deletions sdk/src/public-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import {
MOCK_NETWORK_DELAY_MS,
ParsedSdkKey,
parseSdkKey,
removeUnreleasedChannels,
removeBlockedChannels,
resolvePairedChannel,
satisfiesMinMax,
sleep,
Expand Down Expand Up @@ -395,7 +395,7 @@ export class XenditComponents extends EventTarget {
this[internal].sdkKey,
this[internal].sdkKey.sessionAuthKey,
);
bff.channels = removeUnreleasedChannels(bff.channels);
bff.channels = removeBlockedChannels(bff.channels);
} catch (error) {
this[internal].behaviorTree.bb.sdkStatus = "FATAL_ERROR";
this[internal].behaviorTree.bb.sdkFatalErrorMessage =
Expand Down
29 changes: 29 additions & 0 deletions sdk/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BffAction } from "./backend-types/payment-entity";
import { makeTestBffData } from "./data/test-data";
import {
assert,
BLOCKED_CHANNELS,
camelCaseToKebabCase,
cancellableSleep,
errorToString,
Expand All @@ -12,6 +13,7 @@ import {
randomBits,
randomHexString,
randomUUID,
removeBlockedChannels,
resolvePairedChannel,
satisfiesMinMax,
SLEEP_MULTIPLIER,
Expand Down Expand Up @@ -143,6 +145,33 @@ describe("utils - resolvePairedChannel", () => {
});
});

describe("utils - removeBlockedChannels", () => {
it("should pass through channels that are not in the blacklist", () => {
const channels = makeTestBffData().channels;
expect(removeBlockedChannels(channels)).toEqual(channels);
});

it("should filter out channels present in the blacklist", () => {
const channels = makeTestBffData().channels;
const blockedCode = channels[0].channel_code;
const previousValue = BLOCKED_CHANNELS[blockedCode];
BLOCKED_CHANNELS[blockedCode] = true;
try {
const result = removeBlockedChannels(channels);
expect(
result.find((ch) => ch.channel_code === blockedCode),
).toBeUndefined();
expect(result.length).toBe(channels.length - 1);
} finally {
if (previousValue === undefined) {
delete BLOCKED_CHANNELS[blockedCode];
} else {
BLOCKED_CHANNELS[blockedCode] = previousValue;
}
}
});
});

describe("utils - satisfiesMinMax", () => {
it("should validate min and max values", () => {
const channel = makeTestBffData().channels.find(
Expand Down
140 changes: 4 additions & 136 deletions sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,145 +514,13 @@ export function lockDownInteralProperty(obj: { [internal]: unknown }) {
});
}

const RELEASED_CHANNELS: Record<string, boolean> = {
AFFIN_FPX: true,
AFFIN_FPX_BUSINESS: true,
AGRO_FPX: true,
AGRO_FPX_BUSINESS: true,
ALIPAY: true,
ALLIANCE_FPX: true,
ALLIANCE_FPX_BUSINESS: true,
AMBANK_FPX: true,
AMBANK_FPX_BUSINESS: true,
APPOTA: true,
ASTRAPAY: true,
BAY_CARD_INSTALLMENT: true,
BAY_GBW_DIRECT_DEBIT: true,
BAY_GBW_MOBILE_BANKING: true,
BBL_CARD_INSTALLMENT: true,
BBL_DIRECT_DEBIT: true,
BBL_GBW_DIRECT_DEBIT: true,
BBL_GBW_MOBILE_BANKING: true,
BBL_MOBILE_BANKING: true,
BDO_DIRECT_DEBIT: true,
BDO_EPAY: true,
BDO_ONLINE_BANKING: true,
BNP_FPX_BUSINESS: true,
BOC_FPX: true,
BOC_ONLINE_BANKING: true,
BPI_DIRECT_DEBIT: true,
BPI_ONLINE_BANKING: true,
BPI_RECURRING: true,
BSN_FPX: true,
CARDS: true,
CHINABANK_DIRECT_DEBIT: true,
CHINABANK_ONLINE_BANKING: true,
CIMB_DIRECT_DEBIT: true,
CIMB_FPX: true,
CIMB_FPX_BUSINESS: true,
CITIBANK_FPX_BUSINESS: true,
DANA: true,
DEUTSCHE_FPX_BUSINESS: true,
DUITNOW_PAY: true,
GCASH: true,
GCASH_LINK_AND_PAY: true,
GOPAY: true,
GOPAY_RECURRING: true,
GRABPAY: true,
HLB_FPX: true,
HLB_FPX_BUSINESS: true,
HSBC_FPX: true,
HSBC_FPX_BUSINESS: true,
INSTAPAY_ONLINE_BANKING: true,
ISLAM_FPX: true,
ISLAM_FPX_BUSINESS: true,
JENIUSPAY: true,
KBANK_CARD_INSTALLMENT: true,
KBANK_GBW_MOBILE_BANKING: true,
KBANK_MOBILE_BANKING: true,
KFH_FPX: true,
KFH_FPX_BUSINESS: true,
KRUNGSRI_DIRECT_DEBIT: true,
KRUNGSRI_MOBILE_BANKING: true,
KTB_CARD_INSTALLMENT: true,
KTB_DIRECT_DEBIT: true,
KTB_GBW_DIRECT_DEBIT: true,
KTB_GBW_MOBILE_BANKING: true,
KTB_MOBILE_BANKING: true,
LANDBANK_ONLINE_BANKING: true,
LINEPAY: true,
LINKAJA: true,
MANDIRI_DIRECT_DEBIT: true,
MAYB2E_FPX: true,
MAYB2E_FPX_BUSINESS: true,
MAYB2U_FPX: true,
MAYBANK_ONLINE_BANKING: true,
METROBANK_ONLINE_BANKING: true,
MOMO: true,
MUAMALAT_FPX: true,
MUAMALAT_FPX_BUSINESS: true,
NEXCASH: true,
OCBC_FPX: true,
OCBC_FPX_BUSINESS: true,
OVO: true,
PAYMAYA: true,
PESONET_ONLINE_BANKING: true,
PNB_ONLINE_BANKING: true,
PROMPTPAY: true,
PSBANK_ONLINE_BANKING: true,
PUBLIC_FPX: true,
PUBLIC_FPX_BUSINESS: true,
QR_PH: true,
QRIS: true,
RAKYAT_FPX: true,
RAKYAT_FPX_BUSINESS: true,
RCBC_DIRECT_DEBIT: true,
RCBC_ONLINE_BANKING: true,
RHB_FPX: true,
RHB_FPX_BUSINESS: true,
ROBINSONS_BANK_ONLINE_BANKING: true,
SCB_CARD_INSTALLMENT: true,
SCB_DIRECT_DEBIT: true,
SCB_GBW_DIRECT_DEBIT: true,
SCB_GBW_MOBILE_BANKING: true,
SCB_MOBILE_BANKING: true,
SCH_FPX: true,
SCH_FPX_BUSINESS: true,
SECURITY_BANK_ONLINE_BANKING: true,
SGQR: true,
SHOPEEPAY: true,
TOUCHNGO: true,
TRUEMONEY: true,
TTB_CARD_INSTALLMENT: true,
UBP_DIRECT_DEBIT: true,
UBP_EADA: true,
UNIONBANK_ONLINE_BANKING: true,
UOB_FPX: true,
UOB_FPX_BUSINESS: true,
VIETTELPAY: true,
VNPTWALLET: true,
WECHATPAY: true,
ZALOPAY: true,
// OTC
"7ELEVEN": true,
"7ELEVEN_CLIQQ": true,
CEBUANA: true,
ECPAY: true,
PALAWAN: true,
MLHUILLIER: true,
ECPAY_DRAGONLOAN: true,
LBC: true,
ECPAY_SCHOOL: true,
USSC: true,
SM_BILLS_PAYMENT: true,
ROBINSONS_BILLS_PAYMENT: true,
ALFAMART: true,
INDOMARET: true,
export const BLOCKED_CHANNELS: Record<string, boolean> = {
BRI_DIRECT_DEBIT: true,
};

// filter out channels not supported by this SDK version
export function removeUnreleasedChannels(channels: BffChannel[]): BffChannel[] {
return channels.filter((channel) => RELEASED_CHANNELS[channel.channel_code]);
export function removeBlockedChannels(channels: BffChannel[]): BffChannel[] {
return channels.filter((channel) => !BLOCKED_CHANNELS[channel.channel_code]);
}

/**
Expand Down
Loading