Skip to content

Commit 3c6dd72

Browse files
committed
params passed to checkout UI
1 parent 1152b3f commit 3c6dd72

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

examples/react/src/components/CustomCheckout.tsx

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,71 @@
11
import { Text, Button, Spinner } from '@0xsequence/design-system'
22
import { useCheckoutUI } from '@0xsequence/checkout'
3+
import { encodeFunctionData, toHex } from 'viem'
4+
import { useAccount } from 'wagmi'
5+
import { ERC_1155_SALE_CONTRACT } from '../constants/erc1155-sale-contract'
36

47
export const CustomCheckout = () => {
5-
const { orderSummary, creditCardPayment, cryptoPayment } = useCheckoutUI()
8+
const { address } = useAccount()
9+
10+
// NATIVE token sale
11+
// const currencyAddress = zeroAddress
12+
// const salesContractAddress = '0xf0056139095224f4eec53c578ab4de1e227b9597'
13+
// const collectionAddress = '0x92473261f2c26f2264429c451f70b0192f858795'
14+
// const price = '200000000000000'
15+
// const contractId = '674eb55a3d739107bbd18ecb'
16+
17+
// // ERC-20 contract
18+
const currencyAddress = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359'
19+
const salesContractAddress = '0xe65b75eb7c58ffc0bf0e671d64d0e1c6cd0d3e5b'
20+
const collectionAddress = '0xdeb398f41ccd290ee5114df7e498cf04fac916cb'
21+
const price = '20000'
22+
const contractId = '674eb5613d739107bbd18ed2'
23+
24+
const chainId = 137
25+
26+
const collectible = {
27+
tokenId: '1',
28+
quantity: '1'
29+
}
30+
31+
const purchaseTransactionData = encodeFunctionData({
32+
abi: ERC_1155_SALE_CONTRACT,
33+
functionName: 'mint',
34+
// [to, tokenIds, amounts, data, expectedPaymentToken, maxTotal, proof]
35+
args: [
36+
address,
37+
[BigInt(collectible.tokenId)],
38+
[BigInt(collectible.quantity)],
39+
toHex(0),
40+
currencyAddress,
41+
price,
42+
[toHex(0, { size: 32 })]
43+
]
44+
})
45+
46+
const checkoutUIParams = {}
47+
48+
const { orderSummary, creditCardPayment, cryptoPayment } = useCheckoutUI({
49+
collectible,
50+
chain: chainId,
51+
totalPriceRaw: price,
52+
targetContractAddress: salesContractAddress,
53+
recipientAddress: address || '',
54+
currencyAddress,
55+
collectionAddress,
56+
creditCardProvider: 'sardine',
57+
transakConfig: {
58+
contractId,
59+
apiKey: '5911d9ec-46b5-48fa-a755-d59a715ff0cf'
60+
},
61+
onSuccess: (txnHash: string) => {
62+
console.log('success!', txnHash)
63+
},
64+
onError: (error: Error) => {
65+
console.error(error)
66+
},
67+
txData: purchaseTransactionData
68+
})
669

770
console.log('orderSummary', orderSummary)
871
console.log('creditCardPayment', creditCardPayment)

0 commit comments

Comments
 (0)