Skip to main content

Suggested Prompt

Read this documentation then integrate business payouts from the v3 SDK: https://docs.handcash.io/v3/business-wallet/payouts

Business Wallet Authentication

Business payouts require a business wallet authentication token. You need to obtain this token through the Handcash Developer Dashboard for your business wallet.
import { getInstance, Connect } from '@handcash/sdk';

const sdk = getInstance({
  appId: 'your-app-id',
  appSecret: 'your-app-secret'
});

// Get business wallet client using business auth token
const businessClient = sdk.getAccountClient('<BUSINESS_WALLET_AUTH_TOKEN>');

Send Business Payouts

Basic Payout

// Send payout from business wallet
const payout = await Connect.pay({
  client: businessClient,
  body: {
    instrumentCurrencyCode: 'BSV',
    denominationCurrencyCode: 'USD',
    receivers: [
      {
        destination: 'recipient@handcash.io',
        sendAmount: 0.01
      }
    ]
  }
});

Bulk Payouts

// Send multiple payouts
const bulkPayout = await Connect.pay({
  client: businessClient,
  body: {
    instrumentCurrencyCode: 'BSV',
    denominationCurrencyCode: 'USD',
    receivers: [
      {
        destination: 'user1@handcash.io',
        sendAmount: 0.01
      },
      {
        destination: 'user2@handcash.io',
        sendAmount: 0.02
      }
    ]
  }
});

Business Wallet Management

Check Balance

// Get business wallet balance
const balance = await Connect.getSpendableBalances({
  client: businessClient
});

console.log('Business wallet balance:', balance);

Exchange Rates

// Get current exchange rates
const rates = await Connect.getExchangeRate({
  client: businessClient,
  path: { currencyCode: 'USD' }
});

console.log('USD to BSV rate:', rates.data?.rate);

Error Handling

try {
  const payout = await Connect.pay({
    client: businessClient,
    body: {
      instrumentCurrencyCode: 'BSV',
      denominationCurrencyCode: 'USD',
      receivers: [
        {
          destination: 'recipient@handcash.io',
          sendAmount: 0.01
        }
      ]
    }
  });
  
  if (payout.data) {
    console.log('Payout successful:', payout.data);
  }
} catch (error) {
  console.error('Payout failed:', error.message);
}
I