Swap BNB for token(with transfer fees) not working

Hello developers

I am working on a contract on BSC, and have to Swap BNB for my token from it, using the PanCake Swap. The swap will either Burn the token or send it to a specified address.
The other day it was working just fine with uniswapV2Router.swapExactETHForTokens{value: amount} when the contract was Burning the token, but when I added the functionality to send it to some address, it gives following error:

{ "code": 3, "message": "execution reverted: PancakeLibrary: INSUFFICIENT_INPUT_AMOUNT", "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002950616e63616b654c6962726172793a20494e53554646494349454e545f494e5055545f414d4f554e540000000000000000000000000000000000000000000000" }

Also one thing to note is my token charges some fees on transfer, and contract is not whitelisted yet.

Here is the piece of code which does the swap:

function _swapExactETHForTokens(uint256 amount, address transferToAddress)
    private
{
    // generate the uniswap pair path of token -> weth
    address[] memory path = new address[](2);
    path[0] = uniswapV2Router.WETH();
    path[1] = address(myToken);

    // make the swap
    uniswapV2Router.swapExactETHForTokens{value: amount}(
        0, // accept any amount of Tokens
        path,
        transferToAddress,
        block.timestamp
    );
}
  • I can use swapExactETHForTokensSupportingFeeOnTransferTokens rather than the previous method, but since I already broke the contract on BSC Mainnet, I don't want to experiment with it.

I would love to understand what I am doing wrong here. Any help is welcome.

Thanks