MetaMask does not provide a way to get the private key through code by design. Any interaction with accounts in MetaMask has to be done through the Web3 API, to prevent a (malicious) website from stealing a user's private keys.
You are trying to send ether to a contract, rather that to an Externally Owner Address (EOA). This means that contract's code will executed and the contract will decide whether to accept your transfer and what to do with ether you've sent. As long as your transaction failed and didn't use all the gas you allowed it to use, one of the following probably took ...
You can look into https://app.gitbook.com/@arkane/s/widget/
Arkane allows you to easily integrate your app with several blockchains, whether you already have an app integrated with web3 or are building a new application from scratch.