Post-purchase

Know when your customer finishes checking out with Winter.

The Winter widget emits events that tell you when your customer finishes purchasing an NFT. You can listen for these events and use the information as needed in your application - for instance, to redirect the user to a post-purchase page.

Message events we emit:

  • "successfulWinterCheckout" - emitted when a successful purchase has been completed and the user is on the order confirmation screen

    • With a successful checkout, we also emit details of the purchase, such as transaction hash and email (see example below)

  • "closeWinterCheckoutModal" - emitted when a user closes the Winter checkout

successfulWinterCheckout

This event emits information from the checkout including:

  • transactionHash - the transaction hash on the blockchain. You can use this to query etherscan, polygonscan or solscan for the mint transaction.

  • transferHash - the transfer hash on the blockchain if there is one. You can use this to query etherscan, polygonscan, solscan, and tzkt for the transfer transaction.

  • email - in case you need it.

  • nftQuantity - the number of NFTs purchased

  • amountUSD - the price of the purchase in cents

  • nftTokenIds - the token ids of each nft purchased

  • nftUrls - the url for the image of each NFT

  • openseaUrls - the opensea url for each NFT purchased

    function handleWindowEvent(event) {
        if (event.data.name === "closeWinterCheckoutModal") {
          // properly close the winter modal so it can be opened again
          setShowWinter(false)
        } else if (event.data.name === 'successfulWinterCheckout') {
          // Successfully checked out. This event contains information 
          // You can see the full message body below
          // you can use to continue the flow: 
          console.log(event.data.transactionHash) // do what you need with the txhash here! 
          console.log(event.data.email) // email that the user bought an NFT with
          console.log(event.data.nftQuantity) // the number of NFTs bought
          console.log(event.data.amountUSD) // the price of the purchase in cents
          console.log(event.data.nftTokenIds) // the token ids of each nft purchased
          console.log(event.data.nftUrls) // the url for the image of each NFT
          console.log(event.data.openseaUrls) // the opensea url for each NFT purchased
        }
    }

    useEffect(() => {
        window.addEventListener("message", handleWindowEvent)
        return () => window.removeEventListener("message", handleWindowEvent)
    }, [])
// This is what the successful checkout message looks like
{
    "name": "successfulWinterCheckout",
    "email": "evan@usewinter.com",
    "amountUSD": 2100,
    "nftQuantity": 1,
    "nftUrls": [
        "https://winternft.mypinata.cloud/ipfs/QmbQ3bPVoFBAM6pAcVXb2xRU3bmDsUZ3qcTJJv43cA53tL/1.png"
    ],
    "nftTokenIds": [
        1211
    ],
    "openseaUrls": [
        "https://testnets.opensea.io/assets/matic/0x39c05f113835883a9a53a928a5b8763d1f32df71/1211"
    ],
    "transactionHash": "0x7783f21ac0aab93a9a24b3df77b33dba674457bc83a0bdf73f27adb97868f068"
}

Last updated