@@ -7,7 +7,6 @@ import React, { useEffect, useMemo, useRef } from 'react'
77import { formatUnits , zeroAddress , type Hex } from 'viem'
88
99import type { TransakConfig } from '../../contexts/CheckoutModal.js'
10- import { useEnvironmentContext } from '../../contexts/Environment.js'
1110import type { Collectible , CreditCardProviders } from '../../contexts/SelectPaymentModal.js'
1211import { TRANSAK_PROXY_ADDRESS , getCurrencyCode } from '../../utils/transak.js'
1312
@@ -77,13 +76,10 @@ export const useCreditCardPayment = ({
7776} : UseCreditCardPaymentArgs ) : UseCreditCardPaymentReturn => {
7877 const projectAccessKey = useProjectAccessKey ( )
7978 const { env } = useConfig ( )
80- const disableSardineClientTokenFetch =
81- isLoadingTokenMetadatas || isLoadingCurrencyInfo || isLoadingCollectionInfo || creditCardProvider !== 'sardine'
8279
8380 const disableTransakWidgetUrlFetch =
8481 isLoadingTokenMetadatas || isLoadingCurrencyInfo || isLoadingCollectionInfo || creditCardProvider !== 'transak'
8582
86- const { sardineCheckoutUrl : sardineProxyUrl } = useEnvironmentContext ( )
8783 const network = findSupportedNetwork ( chain )
8884 const error = errorCollectionInfo || errorTokenMetadata || errorCurrencyInfo
8985 const isLoading = isLoadingCollectionInfo || isLoadingTokenMetadatas || isLoadingCurrencyInfo
@@ -93,33 +89,6 @@ export const useCreditCardPayment = ({
9389 const iframeRef = useRef < HTMLIFrameElement | null > ( null )
9490 const tokenMetadata = tokenMetadatas ?. [ 0 ]
9591
96- const {
97- data : dataClientToken ,
98- isLoading : isLoadingClientToken ,
99- error : errorClientToken
100- } = useSardineClientToken (
101- {
102- order : {
103- chainId : network ?. chainId || 137 ,
104- contractAddress : targetContractAddress ,
105- recipientAddress,
106- currencyQuantity : totalPriceRaw ,
107- currencySymbol : currencyInfo ?. symbol || 'POL' ,
108- currencyDecimals : String ( currencyDecimals || 18 ) ,
109- currencyAddress,
110- nftId : collectible . tokenId ?? '' ,
111- nftAddress : collectionAddress ,
112- nftQuantity : collectible . quantity ,
113- nftDecimals : String ( dataCollectionInfo ?. decimals || 18 ) ,
114- calldata : txData
115- } ,
116- projectAccessKey : projectAccessKey ,
117- apiClientUrl : env . apiUrl ,
118- tokenMetadata : tokenMetadata
119- } ,
120- disableSardineClientTokenFetch
121- )
122-
12392 // Transak requires the recipient address to be the proxy address
12493 // so we need to replace the recipient address with the proxy address in the calldata
12594 // this is a weird hack so that credit card integrations are as simple as possible and should work 99% of the time
@@ -234,43 +203,14 @@ export const useCreditCardPayment = ({
234203 } ,
235204 isLoading : isLoadingTransakLink
236205 }
237- ] )
238-
239- const transakNftData = encodeURIComponent ( btoa ( transakNftDataJson ) )
240-
241- const estimatedGasLimit = '500000'
242-
243- const partnerOrderId = `${ recipientAddress } -${ new Date ( ) . getTime ( ) } `
244-
245- // Note: the network name might not always line up with Transak. A conversion function might be necessary
246- const networkName = network ?. name . toLowerCase ( )
247- const transakLink = `${ transakApiUrl } ?apiKey=${ transakApiKey } &isNFT=true&calldata=${ transakCallData } &contractId=${ transakConfig ?. contractId } &cryptoCurrencyCode=${ currencySymbol } &estimatedGasLimit=${ estimatedGasLimit } &nftData=${ transakNftData } &walletAddress=${ recipientAddress } &disableWalletAddressForm=true&partnerOrderId=${ partnerOrderId } &network=${ networkName } `
206+ }
248207
249208 return {
250209 error : null ,
251210 data : {
252- iframeId : TRANSAK_IFRAME_ID ,
253- paymentUrl : transakLink ,
254- CreditCardIframe : ( ) => (
255- < div className = "flex items-center justify-center" style = { { height : '770px' } } >
256- < iframe
257- id = "transakIframe"
258- ref = { iframeRef }
259- allow = "camera;microphone;payment"
260- src = { transakLink }
261- style = { {
262- maxHeight : '650px' ,
263- height : '100%' ,
264- maxWidth : '380px' ,
265- width : '100%'
266- } }
267- referrerPolicy = "strict-origin-when-cross-origin"
268- />
269- </ div >
270- ) ,
271- EventListener : ( ) => (
272- < TransakEventListener onSuccess = { onSuccess } onError = { onError } isLoading = { isLoading } iframeRef = { iframeRef } />
273- )
211+ iframeId : '' ,
212+ CreditCardIframe : ( ) => null ,
213+ EventListener : ( ) => null
274214 } ,
275215 isLoading : false
276216 }
0 commit comments