Skip to main content

Fiat Payment

Methods for payment using fiat, it uses the wert payment system and you can pay using master or visa card.

topUpWert method

  • method to top up your Wert account, it exports the handleWert method and takes the arguments currency and commodity, where currency is the fiat currency like USD and commodity is the cryptocurrency you want to buy, like ETH.

handleWert method

  • The method handleWert is exported from topUpWert and takes parameters like walletAddress and topUpAmount, where walletAddress is the user's wallet address and topUpAmount is the amount you want to charge to your account.

wertBuyNft

  • wertBuyNft is used to buy the Nft and returns handleBuyNftWert, wertLoaded, hideWert and wertPaymentStatus.

  • It takes parameters like totalAmountCrypto, accountAddress, collectionId, email, releaseData, numberOfNFTs, setPaymentType, setPaymentStepError, web3, collectionData.

  • where totalAmountCrypto is the amount in crypto required to buy nfts, accountAddress is user's wallet address to which nfts need to be transferred, collectionId is the id of the collection which we get from collection fetch api, email is the user email address, releaseData is data of the release which we get from fetch release api, numberOfNfts is the number of nfts user is buying, setPaymentType will be returning payment types which is one the given options CRYPTO or WERT, setPaymentStepError will return any error during the minting or payment proceeding process, where web3 is the provider returned by the signIn hook when user is logged in and collectionData is the data returned from fetch collection method.

handleBuyNftWert

  • wertBuyNft takes the above given parameters and returns handleBuyNftWert, wertLoaded, hideWert, and wertPaymentStatus

  • where handleBuyNftWert is the method to buy nft by clicking on the button, wertLoaded gives us the status of wert, whether it has already been initialized or not, hideWert returns the status of wert, whether it is hidden or not.

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

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

export const ShowFiatPaymentMethods = () => {
const { topUpWert, wertBuyNft } = MetastaqInstance;

const [paymentStepError, setPaymentStepError] = useState("");
const [paymentType, setPaymentType] = useState("");

const { handleWert } = topUpWert(currency, commodity);

const { handleBuyNftWert, wertLoaded, hideWert, wertPaymentStatus } =
wertBuyNft(
totalAmountCrypto,
accountAddress,
COLLECTION_ID,
email,
releaseData,
numberOfNfts,
setPaymentType,
setPaymentStepError,
web3,
collectionData
);

return (
<div>
<button onClick={() => connectCryptoWallet("testmetastaq@yopmail.com")}>
Connect an existing wallet{" "}
</button>

<button
onClick={() => {
handleBuyNftWert();
}}
>
Pay with Wert
</button>
<button
onClick={() => {
handleWert(walletAddress, topUpAmount);
}}
>
top up wert
</button>
<div id="buywidget" />
<div id="widget" />
</div>
);
};