Skip to main content

Crypto Payment

Methods for different Payment Methods Integrations provided by metastaq.

payment method

Payment method to create crypto orders and handle payment status.

  • Import payment using const { payment } = MetastaqInstance and import handlePayWithCrypto and cryptoPaymentStatus for payment status.

  • Its required params includes web3, setPaymentType, setMintedToken, setPaymentStepError, setInsufficientBalance and email. where web3 is the provider returned by the signIn hook when user is logged in and setPaymentType, setMintedToken, setPaymentStepError, setInsufficientBalance are callback methods which will be returning required data.

  • Here setPaymentType will be returning payment types which is one the given options CRYPTO or WERT. setMintedToken will return details of the nft token that is minted if your payment proceeds.

  • setPaymentStepError will return any error during the minting or payment proceeding process, setInsufficientBalance is the error specifically related to less balance in your wallet then required to proceed the payment and email is the user email address.

handlePayWithCrypto method

  • handlePayWithCrypto is returned by the payment method, you can use it to process your crypto payment, its required params are releaseData, collectionData, walletAddress, numberOfNfts and totalAmountCrypto.
  • Where releaseData is the release data returned from Fetch Release Method, collectionData is data related to collection that was created in our creator panel it can be fetched from Fetch collection Method, walletAddress is the user's wallet address, numberOfNfts are total number of nfts user is buying in current transection and totalAmountCrypto should be the amount user will be paying to buy these nfts.

cryptoPaymentStatus

cryptoPaymentStatus will return the current status of your payment, it will be one of the loading, success or failed so that you can update your system's state accordingly.

crypto payment
import React from "react";
import { MetastaqInstance } from "./MetastaqInstance";

export const ShowCryptoPaymentMethods = () => {
const { payment } = MetastaqInstance;

const [paymentStepError, setPaymentStepError] = useState("");
const [mintedToken, setMintedToken] = useState([]);
const [paymentType, setPaymentType] = useState("");
const [insufficientBalance, setInsufficientBalance] = useState(false);

const { handlePayWithCrypto, cryptoPaymentStatus } = payment(
web3,
setPaymentType,
setMintedToken,
setPaymentStepError,
setInsufficientBalance,
email
);

return (
<button
onClick={() => {
handlePayWithCrypto(
releaseData,
collectionData,
walletAddress,
numberOfNfts,
totalAmountCrypto
);
}}
>
Create Crypto order
</button>
);
};