Checkout Session is a standard object used to start accepting the crypto payments in USDC, USDT, DAI, ETH, BTC, MATIC, etc.
Let's create our first Checkout Session to accept 1 USDC from user.
Before we start, few things to keep in mind
We are using our dev environment which supports on Polygon Mumbai Testnet and Goerli Testnet.
We will be using a curl to request Copperx APIs.
Make sure you generate your API_KEY from our Dashboard. If you don't have one, then generate it from here.
You will need test ERC20 Faucets to make the payment, you can request them from https://dashboard.copperx.dev/faucet. If you need more faucet, then feel free to contact our team via Telegram.
As you are using test environment, there is no real money involved. So feel free to play around.
To create a checkout session, run below command in your terminal:
# Creating a Checkout Session for 1 USDC
curl --request POST \
--url 'https://api.copperx.dev/api/v1/checkout/sessions' \
--header 'Authorization: Bearer {YOUR_API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
"successUrl": "https://copperx.io/success?cid={CHECKOUT_SESSION_ID}",
"lineItems": {
"data": [
{
"priceData": {
"currency": "usdc",
"unitAmount": "100000000",
"productData": {
"name": "Basic",
"description": "For early stage projects who are getting started"
}
}
}
]
}
}'
You will receive a response similar to given below: