Pay with Card - Memecoins
Create a fully customized memecoin checkout experience that accepts credit cards
Introduction
This guide will show you how to accept credit card payments using Crossmint’s Embedded Checkout or Headless Checkout API for memecoin sales with Checkout.com as the payment provider. You’ll learn how to:
- Set up credit card payments for Solana memecoin purchases in JavaScript
- Implement a checkout UI using Checkout.com’s Flow component
- Track order status and delivery
You can jump to the sections on the right toolbar to get integrate with either:
- Option 1, using Embedded Checkout, or
- Option 2, using Headless Checkout.
Important Notes
Compliance Checks
Crossmint runs compliance checks on all tokens to ensure they do not qualify as securities or currencies under applicable regulations. Transactions for tokens that are determined to be too similar to securities or currencies will fail.
Supported Tokens
Currently, memecoin checkout only supports Solana network. If you’re an enterprise customer, you can check which tokens are supported by using the fungibleCheckoutAvailable endpoint, or reach out to support for an updated list of supported tokens.
Delivery to External Wallets Only
Memecoin checkout only delivers memecoins to EOAs (Externally Owned Accounts), not Crossmint supported delivery solutions, such as on-the-fly wallet creation (both Crossmint custodial wallets and smart wallet), delivery Twitter handle, etc.
Merchant of Record
Crossmint remains the merchant of record for all transactions. Your buyers will still receive delivery receipts and transaction confirmations from Crossmint.
Prerequisites
Solana Wallet
Have a Solana wallet address ready to receive purchased memecoins
Get API Keys
Get your API keys from the Crossmint Console
Navigate to the "Integrate" section on the left navigation bar, and ensure you're on the "API Keys" tab.
Within the Server-side keys section, click the "Create new key" button in the top right.
Next, check the scopes labeled orders.create
, orders.read
, orders.update
.
Finally, create your key and save it for subsequent steps.
Fungible Token Specification
To define which fungible token you’d like to purchase, you’ll need to specify the tokenLocator in the tokenLocator format: solana:${tokenMintHash}
(tokenMintHash is commonly known as contract address, CA, or mint hash).
Option 1 - Embedded Memecoin Checkout
The fastest way to start selling memecoins is to adapt our embedded checkout solution to use fungibles.
Important Parameters
Before implementing the checkout, note these key parameters:
maxSlippageBps
: Optional slippage tolerance (default provided if not specified)receiptEmail
: Required for delivering payment receiptsexecutionParameters.mode
: Set to “exact-in” for memecoin purchases (specifies exact USD amount to spend). Exact-out is for NFT’s, exact-in is for fungibles.Integration Steps
This guide will start from scratch with an empty Next.js application. You'll install the required@crossmint/client-sdk-react-ui
dependency and add the embedded checkout component. To get started:Set up the Project
1Create a new Next.js application
If you see this message, type
y
and pressEnter
to proceed:2Name your app `crossmint-embedded-checkout-demo` and accept the default options
3Change into the directory created in previous steps
4Install @crossmint/client-sdk-react-ui
5Open the project in your preferred code editor
Memecoin Embedded Integration
Next, we will set up a project file with Crossmint’s embedded checkout to accept memecoin purchases.
Add environment variables
Create .env.local
in your project root:
Create the checkout page
Create /src/app/page.tsx
with:
Run your app
Visit http://localhost:3000
to see your checkout!
Test your app
Memecoin purchases are only supported in production, so pay with credit card in a small amount to test the flow.
Here’s how your embedded checkout will look after implementation: 🎉 Congratulations! You’ve successfully set up your embedded memecoin checkout. Check out the Next Steps section below to learn how to customize your integration.
Option 2 - Headless Memecoin Checkout
Headless Memecoin Checkout
The headless checkout API allows complete control over your checkout experience, including:
- Custom UI components and styling
- Custom payment flow sequences
- Integrated analytics and tracking
- Custom error handling and retry logic
- Branded confirmation pages
Create an Order
The first step in the headless checkout process is to create an order. An order is an object datastructure, that represents an intent to purchase in Crossmint's systems. This guide will create a basic order, and then update it with required info step-by-step.
You can also create the entire order in one API call if the necessary information is available at the time of order creation. This can be used for custom "one-click-checkout" experiences, should you wish to make them.
POST
https://staging.crossmint.com/api/2022-06-09/orders
Refer to the complete create order API reference here.
Use the javascript code snippet below to create a starting point for your order. Alternatively, use the API playground to explore and create your own order.
Note the following parameters in the request body:
maxSlippageBps
: Optional, or else default autogenerated slippage will be applied.receiptEmail
: Required for credit card payments to deliver receiptexecutionParameters.mode
: The execution method for the order. Exact-out is for NFT’s, exact-in is for fungibles.
Render the Checkout.com Flow Component
After creating an order, you’ll need to render the Checkout.com Flow component to collect payment information. The Flow component is a pre-built UI that handles the payment collection process.
Checkout.com docs for desktop
Checkout.com docs for mobile
Submit Payment
The Checkout.com Flow component handles the payment submission process automatically. When a user completes the payment form and clicks the payment button, the onPaymentCompleted
callback will be triggered with the payment response.
Unlike with Stripe, you don’t need to manually submit the payment form. The Checkout.com Flow component takes care of the entire payment process, including validation, submission, and handling the response.
Here’s how the payment flow works with Checkout.com:
- The user fills out the payment form rendered by the Flow component
- The user clicks the payment button in the Flow component
- The Flow component validates the payment information
- If valid, the Flow component submits the payment to Checkout.com
- The
onPaymentCompleted
callback is triggered with the payment response - You can use the payment response to update your UI and proceed to the next step
If there’s an error during the payment process, the onError
callback will be triggered:
Poll for Status Updates
After making the payment via whichever payment method, you'll need to poll the Get Order API to check on the delivery status and present this info to your user.
Refer to the complete get order API reference here.
GET
https://staging.crossmint.com/api/2022-06-09/orders/<orderId>
Example response from the Get Order API:
Handling Refunded Payments
When polling for order status, you may encounter a situation where payment.status
is completed
but the order also contains a payment.refunded
property. This indicates that the payment was initially successful but has since been refunded.
The payment.refunded
object includes the following fields:
amount
: The amount that was refundedcurrency
: The currency of the refundtxId
: The on-chain transaction ID the refund was sent inchain
: The blockchain where the refund transaction occurred
When you encounter this state, your application should:
- Display an appropriate message to the user indicating that their payment was refunded
- Provide the transaction ID (
txId
) so users can verify the refund on-chain - Prevent any further actions related to the order (such as delivery expectations)
- Provide options for the user to place a new order if desired
This state typically occurs when there was an issue with processing the order after payment was received, such as insufficient liquidity for memecoin purchases or compliance issues.
🎉 Congratulations! You’ve successfully set up your headless memecoin checkout. Check out the Next Steps section below to learn how to customize your integration.
Understanding the Code
Quote Expiration
Price quotes are valid for 30 seconds. After expiration, you’ll need to request a new quote from the headless checkout API
Slippage
Crossmint applies the slippage specified in your API request via executionParameters.slippageBps. If not provided, Crossmint will use the default slippage configuration from Crossmint’s provider
Next Steps
Customize UI
Learn how to customize the checkout experience
Handle Webhooks
Implement webhook handling for order updates
Order Lifecycle
The order goes through several phases: Learn more about order phases in the headless checkout guide
A summary of the phases is below:
-
Quote Phase (30-second validity)
- Initial price quote generated
- Requires recipient information to proceed
-
Payment Phase
- Process credit card payment via Checkout.com
- Collect payment information using the Checkout.com Flow component
- Handle payment completion and errors
-
Delivery Phase
- Purchase memecoin with USDC
- Apply specified slippage tolerance
- Send transfer transaction to recipient wallet
-
Completion
- Order marked as completed
- Receipt email sent to recipient
- Memecoins have been delivered to the recipient wallet
If the quote expires (after 30 seconds), you’ll need to create a new order to get updated pricing. You can choose the UX flow to handle this.
Refreshing Orders with Checkout.com
If an order expires before payment is completed (e.g., the 30-second quote validity period ends), you can either create a new order or use the refresh quote API: