Buy tokens from a contract that receives BNB from another contract

I'm developing a contract that receives BNB directly from a token contract and would like this contract to buy tokens from the BNB received, but everything I try seems to cause issues and I'm not quite sure why, or where the issue lies?

The token contract uses the following function to send BNB

function transferToAddress(address payable recipient, uint256 amount) private {

This function works and I receive the BNB in both the new contract and personal wallets, but when I add the following code to a new contract and have the token contract send the BNB to this instead it fails.

If I send the new contract BNB directly it does work, but when the token contract calls the transferToAddress function and sends BNB to the new contract it fails.

receive() external payable {

function buyTokens(uint256 _amount) private {
        address[] memory path;
        path = new address[](2);
        path[0] = WBNB;
        path[1] = TOKEN;

        // call the router swap
        router.swapExactETHForTokens{ value: _amount }(

This fails with the below error when trying to sell the token through a router.

The transaction cannot succeed due to error: undefined. This is probably an issue with one of the tokens you are swapping.

I have added a bool to enable/disable the buying and when this is disabled, everything works fine - but as soon as its enabled it shows the same error?

hey @TheDev

can you try to replace that line with this:

(bool success, ) ={value: amount}("");
require(success, "unable to send value, recipient may have reverted");