One-Time Purchase Integration - Stellar Contract Settlement

Accept credit card payments and settle USDC directly to your Stellar smart contract

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

Complete these steps before starting the integration.

1

Create your sandbox account

Register or login to your sandbox merchant account

2

Generate API keys

Create a sandbox API key for authentication

3

Add chargeback protection

Add the protection script to every page of your app

4

Whitelist your Stellar contract

Whitelist your contract address for settlement

Quick Reference

HeaderDescription
AuthorizationYour API key from the merchant dashboard
x-coinflow-auth-walletUser’s Stellar wallet address (G-prefixed)
x-coinflow-auth-blockchainUse stellar for Stellar contract settlement
x-coinflow-auth-session-keyJWT token authorizing the payer

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 to generate TypeScript bindings for your contract:

$# 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

1import {YourContractClient} from './your-contract-client';
2
3// Initialize your contract client
4const client = new YourContractClient({
5 contractId: 'YOUR_CONTRACT_ID',
6 networkPassphrase: 'Test SDF Network ; September 2015', // Mainnet: 'Public Global Stellar Network ; September 2015'
7 rpcUrl: 'https://soroban-testnet.stellar.org', // Mainnet: use your Soroban RPC provider
8 publicKey: sourceAccountPublicKey,
9});
10
11// Build the contract invocation
12const tx = await client.your_purchase_function({
13 usdc: 'CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA',
14 payer: 'CA6F7DX4RBZLENHGLPPTGQA4CRNNH3U6QJ3KD7HQLN46YENHTWJRZUOH',
15 recipient: customerWalletAddress,
16});
17
18// Convert to base64 XDR string
19const stellarTransaction = tx.toXDR();

The payer should be the Coinflow checkout contract address:

EnvironmentCheckout Contract Address
SandboxCA6F7DX4RBZLENHGLPPTGQA4CRNNH3U6QJ3KD7HQLN46YENHTWJRZUOH
ProductionCDUVNW53LTEPPA6SWEGMAV2KJT4YCRECSLRB7XG3KEN3B62YK6HBKG7S

Choose Your Implementation


3DS Authentication

After implementing basic checkout, add 3DS for stronger authentication. Contact Coinflow to enable 3DS on your account.


Chargeback Protection

Improve approval rates and reduce fraud by sharing payer events with Coinflow.

Send user events

Track key user actions throughout their journey on your app.

$curl --request POST \
> --url https://api-sandbox.coinflow.cash/api/events \
> --header 'Authorization: YOUR_API_KEY' \
> --header 'content-type: application/json' \
> --data '{
> "eventType": "SignUp",
> "customerId": "user-123-abc",
> "country": "US",
> "username": "johndoe",
> "email": "john@example.com",
> "firstName": "John",
> "lastName": "Doe"
> }'

Required headers for checkout

When processing payments, include these headers for chargeback protection:

HeaderDescription
x-device-idDevice ID from the chargeback protection script
x-coinflow-client-ipCustomer’s IPv4 address
user-agentCustomer’s browser user agent

On sandbox, use partnerId = COINFTEST when configuring the protection script.


Next Steps