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 likeUSD
and commodity is the cryptocurrency you want to buy, likeETH
.
handleWert method
- The method
handleWert
is exported fromtopUpWert
and takes parameters likewalletAddress
andtopUpAmount
, wherewalletAddress
is the user's wallet address andtopUpAmount
is the amount you want to charge to your account.
wertBuyNft
wertBuyNft
is used to buy the Nft and returnshandleBuyNftWert
,wertLoaded
,hideWert
andwertPaymentStatus
.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 optionsCRYPTO
orWERT
,setPaymentStepError
will return any error during the minting or payment proceeding process, whereweb3
is the provider returned by the signIn hook when user is logged in andcollectionData
is the data returned from fetch collection method.
handleBuyNftWert
wertBuyNft
takes the above given parameters and returnshandleBuyNftWert
,wertLoaded
,hideWert
, andwertPaymentStatus
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 theloading
,success
orfailed
so that you can update your system's state accordingly.
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>
);
};