> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.coinflow.cash/guides/checkout/implementation-overview/implementation-guides/advanced-use-cases/one-time-purchase-usdc-to-stellar-contract/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.coinflow.cash/_mcp/server. # One-Time Purchase Integration - Stellar Contract Settlement > **Warning** > > **This page is for advanced / cryptocurrency-native companies.** If that's not you, head back to the [Quickstart](/guides/getting-started/quickstart) for the standard flows. This guide walks you through integrating Coinflow checkout to accept one-time credit card purchases with USDC settlement to your whitelisted Stellar Soroban contract. ## Prerequisites > **Warning** > > Complete these steps before starting the integration. #### Create your sandbox account [Register](https://sandbox-merchant.coinflow.cash/register) or [login](https://sandbox-merchant.coinflow.cash/login) to your sandbox merchant account #### Generate API keys [Create a sandbox API key](https://sandbox-merchant.coinflow.cash/api-keys) for authentication #### Add chargeback protection [Add the protection script](/guides/checkout/payment-security-risk-management/fraud-protection/implement-chargeback-protection#how-to-add-chargeback-protection) to every page of your app #### Whitelist your Stellar contract [Whitelist your contract address](https://sandbox-merchant.coinflow.cash/whitelist-request) for settlement ## Quick Reference #### Authorization Headers | Header | Description | | ----------------------------- | ---------------------------------------------------------------------------------------------- | | `Authorization` | Your API key from [the merchant dashboard](https://sandbox-merchant.coinflow.cash/api-keys) | | `x-coinflow-auth-wallet` | User's Stellar wallet address (G-prefixed) | | `x-coinflow-auth-blockchain` | Use `stellar` for Stellar contract settlement | | `x-coinflow-auth-session-key` | [JWT token](/api-reference/api-reference/authentication/get-session-key) authorizing the payer | #### Helpful Resources * [How Stellar contract settlement works](/guides/checkout/settlement-locations/settlement-to-contracts/settle-to-stellar-contract/implement-settlement-to-stellar-contract) * [Test card numbers for sandbox](/guides/checkout/testing/testing-credit-cards) * [Checkout webhooks](/guides/developer-resources/webhooks/checkout-webhooks) * [Custom branding](/guides/developer-resources/custom-branding) > **Warning** > > Stellar checkout does not support Credits settlement or partial purchases where the customer contributes their own USDC alongside a credit card payment. --- ## Build Your Stellar Transaction Before integrating checkout, you need to build a `stellarTransaction` — a base64-encoded XDR string representing your Soroban contract invocation. ### Generate TypeScript Bindings Use the [Stellar CLI](https://developers.stellar.org/docs/tools/developer-tools/cli/stellar-cli) to generate TypeScript bindings for your contract: ```bash # Use --network mainnet for production stellar contract bindings typescript \ --network testnet \ --contract-id YOUR_CONTRACT_ID \ --output-dir ./your-contract-client ``` ### Build and Encode the Transaction ```typescript import {YourContractClient} from './your-contract-client'; // Initialize your contract client const client = new YourContractClient({ contractId: 'YOUR_CONTRACT_ID', networkPassphrase: 'Test SDF Network ; September 2015', // Mainnet: 'Public Global Stellar Network ; September 2015' rpcUrl: 'https://soroban-testnet.stellar.org', // Mainnet: use your Soroban RPC provider publicKey: sourceAccountPublicKey, }); // Build the contract invocation const tx = await client.your_purchase_function({ usdc: 'CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA', payer: 'CA6F7DX4RBZLENHGLPPTGQA4CRNNH3U6QJ3KD7HQLN46YENHTWJRZUOH', recipient: customerWalletAddress, }); // Convert to base64 XDR string const stellarTransaction = tx.toXDR(); ``` > **Info** > > The `payer` should be the Coinflow checkout contract address: > > | Environment | Checkout Contract Address | > | ----------- | ---------------------------------------------------------- | > | Sandbox | `CA6F7DX4RBZLENHGLPPTGQA4CRNNH3U6QJ3KD7HQLN46YENHTWJRZUOH` | > | Production | `CDUVNW53LTEPPA6SWEGMAV2KJT4YCRECSLRB7XG3KEN3B62YK6HBKG7S` | --- ## Choose Your Implementation #### Checkout Link Best for simple integrations. Generate a hosted checkout URL to redirect users or embed in an iframe. ### Step 1: Generate the checkout link **`Request`** ```bash title="Request" curl -X POST https://api-sandbox.coinflow.cash/api/checkout/link \ -H "Authorization: YOUR_API_KEY" \ -H "x-coinflow-auth-wallet: GBCG42WTVWPO4Q6OZCYI3D6ZSTFMO6S2WPUFM3MYO7LEDFCZU3IDALU" \ -H "x-coinflow-auth-blockchain: stellar" \ -H "Content-Type: application/json" \ -d '{ "email": "customer@example.com", "subtotal": { "cents": 500, "currency": "USD" }, "blockchain": "stellar", "stellarTransaction": "AAAAAgAAAABh...(base64 XDR)...", "chargebackProtectionData": [{ "productType": "inGameProduct", "productName": "NFT Item", "quantity": 1, "rawProductData": { "description": "A digital collectible on Stellar" } }], "deviceId": "123456789" }' ``` **`Response`** ```json title="Response" { "link": "https://sandbox.coinflow.cash/stellar/purchase-v2/YOUR_MERCHANT_ID?sessionKey=eyJhbGci..." } ``` ### Step 2: Use the checkout link **Embed in an iframe** ```html