Metamask receipt confirmation

Hi all, I am trying to create a dapp that requests payment when a button is clicked. Is there a way for me to confirm that the person has actually paid or not before proceeding to the next page? I am selling a paid service that needs this confirmation before proceeding.

I’m not sure what method you’re using exactly but this is an example. This will wait until the transaction is confirmed on-chain and then you can redirect the user after this.

what can I do with that information and where does it sit? I need that information in order to create the logic.

You can handle that with a smart contract then.

I’m not sure what you mean. For example with that wait, it will return a successful response if the transaction is confirmed. That’s where your dapp logic can sit.

What are you doing now in code to request payment?

So, right now it is only returning a ‘promise’ that says pending. It does not look like the transaction.wait function is working Here is my code:

   async function donate() {
        await Moralis.enableWeb3();

        let options = {
           contractAddress: "0x14EF837d6d6D5e2BDC9f26BF3BD79FF020D2DD42",
           functionName: "newDonation",
           abi: [
           {"inputs":[{"internalType":"string","name":"note","type":"string"}],
           "name":"newDonation","outputs":[],"stateMutability":"payable","type":"function"}],
           params: {
             note: "Thanks for booking an audit with us!",
           },
           msgValue: Moralis.Units.ETH(0.001),
         }

         transaction = await Moralis.executeFunction(options);
         
                  
         result = transaction.wait(1);
          console.log(result);

        }

Hi you need to also await the transaction.wait(1).

result = await transaction.wait(1);