Skip to content
Merged
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
28 changes: 27 additions & 1 deletion sdk/src/components/payment-channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,35 @@ export const PaymentChannel: FunctionComponent<Props> = (props) => {
const instructions = instructionsAsTuple(resolvedChannel.instructions);

const onChannelPropertiesChanged = (channelProperties: ChannelProperties) => {
let cleanedProperties = channelProperties;
if (
firstMemberChannel.channel_code === "CARDS" &&
channelProperties.installment_configuration
) {
// for cards installment configuration, we need to remove any properties that have empty string values,
// because the presence of those properties causes validation errors, even if the value is an empty string
const cleanedInstallmentConfiguration = Object.fromEntries(
Object.entries(channelProperties.installment_configuration).filter(
([_, value]) => value !== "",
),
);
if (Object.keys(cleanedInstallmentConfiguration).length === 0) {
// if there are no valid properties left, set installment_configuration to undefined to avoid validation errors
cleanedProperties = {
...channelProperties,
installment_configuration: undefined,
};
} else {
cleanedProperties = {
...channelProperties,
installment_configuration: cleanedInstallmentConfiguration,
};
}
}

const event = new XenditChannelPropertiesChangedEvent(
firstMemberChannel.channel_code,
channelProperties,
cleanedProperties,
);
divRef.current?.dispatchEvent(event);
};
Expand Down