npm package: @santi-dev/blindpay-sdk
Description: A TypeScript SDK for integrating with the BlindPay payment processing API. This SDK provides a comprehensive interface for managing payments, quotes, receivers, and blockchain transactions across multiple networks.
Author: Santi
Latest version: 0.1.3

# BlindPay SDK

A TypeScript SDK for integrating with the BlindPay payment processing API. This SDK provides a comprehensive interface for managing payments, quotes, receivers, and blockchain transactions across multiple networks.

## Features

- **Multi-Blockchain Support**: EVM chains and Stellar network integration
- **Payment Processing**: Create quotes, process payouts, and manage transactions
- **Receiver Management**: Handle payment recipients with bank accounts and blockchain wallets
- **FX Rate Management**: Check and manage foreign exchange rates
- **Webhook Integration**: Set up webhook endpoints for real-time notifications
- **API Key Management**: Secure API key creation and management
- **Instance Management**: Multi-tenant instance support with member management

## Installation

```bash
npm install @santi-dev/blindpay-sdk
```

## Quick Start

```typescript
import { Client } from '@santi-dev/blindpay-sdk';

// Initialize the client
const client = new Client('https://api.blindpay.com');

// Create a quote
const quote = await client.quotes('instance_id', {
  // quote parameters
});

// Process a payout on EVM chain
const payout = await client.evm('instance_id', {
  // payout parameters
});
```

## Core Functionality

### Quotes
Create payment quotes for transactions:
```typescript
const quote = await client.quotes(instanceId, {
  // Quote parameters
});
```

### FX Rates
Check foreign exchange rates:
```typescript
const fxRate = await client.fx(instanceId, {
  // FX rate parameters
});
```

### Payouts
Process payouts across different networks:

#### EVM Chains
```typescript
const evmPayout = await client.evm(instanceId, {
  receiver_id: 'receiver_id',
  amount: '100',
  currency: 'USD',
  // other parameters
});
```

#### Stellar Network
```typescript
const stellarPayout = await client.stellar(instanceId, {
  receiver_id: 'receiver_id',
  amount: '100',
  currency: 'XLM',
  // other parameters
});
```

### Receiver Management
Manage payment recipients:

```typescript
// Create a receiver
const receiver = await client.receiversPOST(instanceId, {
  name: 'John Doe',
  email: 'john@example.com',
  // other receiver details
});

// Get all receivers
const receivers = await client.receiversAll(instanceId);

// Update receiver
await client.receiversPUT(instanceId, receiverId, {
  name: 'John Smith'
});

// Delete receiver
await client.receiversDELETE(instanceId, receiverId);
```

### Bank Account Management
Handle traditional banking:

```typescript
// Add bank account to receiver
const bankAccount = await client.bankAccountsPOST(receiverId, instanceId, {
  account_number: '1234567890',
  routing_number: '123456789',
  bank_name: 'Example Bank',
  // other bank details
});

// Get all bank accounts
const bankAccounts = await client.bankAccountsAll(receiverId, instanceId);
```

### Blockchain Wallet Management
Manage blockchain wallets:

```typescript
// Add blockchain wallet
const wallet = await client.blockchainWalletsPOST(receiverId, instanceId, {
  address: '0x...',
  network: 'ethereum',
  // other wallet details
});

// Get sign message for wallet verification
const signMessage = await client.signMessage(receiverId, instanceId);
```

### Webhook Management
Set up webhook endpoints:

```typescript
// Create webhook endpoint
const webhook = await client.webhookEndpointsPOST(instanceId, {
  url: 'https://your-app.com/webhook',
  events: ['payout.completed', 'payout.failed']
});

// Get webhook secret
const secret = await client.secret(instanceId, webhookId);
```

### API Key Management
Manage API keys securely:

```typescript
// Create API key
const apiKey = await client.apiKeysPOST(instanceId, {
  name: 'Production API Key',
  permissions: ['read', 'write']
});

// List all API keys
const apiKeys = await client.apiKeysAll(instanceId);
```

## Configuration

The SDK client can be configured with custom settings:

```typescript
import axios from 'axios';
import { Client } from '@santi-dev/blindpay-sdk';

// Custom axios instance
const axiosInstance = axios.create({
  timeout: 30000,
  headers: {
    'User-Agent': 'MyApp/1.0'
  }
});

// Initialize client with custom configuration
const client = new Client('https://api.blindpay.com', axiosInstance);
```

## Error Handling

The SDK provides comprehensive error handling:

```typescript
try {
  const result = await client.quotes(instanceId, quoteData);
} catch (error) {
  if (error.response) {
    // API error response
    console.error('API Error:', error.response.status, error.response.data);
  } else {
    // Network or other error
    console.error('Error:', error.message);
  }
}
```

## Pagination

Many endpoints support pagination:

```typescript
// Get payouts with pagination
const payouts = await client.payouts3(
  instanceId,
  10, // limit
  0,  // offset
  undefined, // starting_after
  undefined, // ending_before
  undefined  // receiver_id
);
```

## Export Functionality

Export data in various formats:

```typescript
// Export all payouts as CSV
const payouts = await client.payoutsAll(instanceId, '1000', '0');
```

## Available Rails

Get information about available payment rails:

```typescript
// Get all available rails
const rails = await client.rails();

// Get bank details for specific rail
const bankDetails = await client.bankDetails('rail_name');
```

## Instance Management

Manage multi-tenant instances:

```typescript
// Update instance
await client.instancesPUT(instanceId, {
  name: 'Updated Instance Name'
});

// Delete instance
await client.instancesDELETE(instanceId);

// Get instance members
const members = await client.membersAll(instanceId);
```

## TypeScript Support

This SDK is built with TypeScript and provides full type definitions for all API responses and request parameters.

## Dependencies

- **axios**: HTTP client for API requests
- **typescript**: Type definitions and compilation

## Development

### Building

```bash
npm run build
```

### Project Structure

```
src/
├── index.ts              # Main export file
├── blindpay-sdk.ts      # Core SDK implementation
└── types/               # TypeScript type definitions
```

## License

MIT License - see LICENSE file for details.

## Support

For support and questions about the BlindPay API, please refer to the official BlindPay documentation or contact their support team.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

---

**Note**: This SDK is designed to work with the BlindPay API. Make sure you have valid API credentials and instance IDs before using the SDK.