{"_id":"@bixypay/fintech-sdk","name":"@bixypay/fintech-sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bixypay/fintech-sdk","version":"1.0.0","description":"Official Node.js/TypeScript SDK for the BixyPay Fintech API Platform","main":"dist/client.js","types":"dist/client.d.ts","module":"dist/client.mjs","exports":{".":{"import":"./dist/client.mjs","require":"./dist/client.js","types":"./dist/client.d.ts"},"./types":{"types":"./types.ts"}},"scripts":{"build":"tsup client.ts --format cjs,esm --dts","prepublishOnly":"npm run build","test:smoke":"tsx tests/smoke-test.ts"},"keywords":["bixypay","fintech","payment","crypto","api","sdk","typescript"],"author":{"name":"BixyPay"},"license":"MIT","peerDependencies":{"openapi-fetch":"^0.12.0"},"devDependencies":{"@types/node":"^24.10.0","tsup":"^8.0.0","tsx":"^4.20.6","typescript":"^5.0.0"},"repository":{"type":"git","url":"git+https://github.com/bixypay/fintech-sdk.git"},"bugs":{"url":"https://github.com/bixypay/fintech-sdk/issues"},"homepage":"https://docs.bixypay.com","dependencies":{"dotenv":"^17.2.3"},"_id":"@bixypay/fintech-sdk@1.0.0","gitHead":"fa7357a80f0faa6c2aa77e9b1d676b36104cedc9","_nodeVersion":"20.19.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Iy8IhzqQWUKXRyNmrN6iYO2xZWqfZKBomJoVRHlgAUUv2Mpz91M2Ao3aW3zr3Pc9cVNUHjGp1efC02ky+zZSiw==","shasum":"4f8c5869ecf44b5424dadaf593362e1281878815","tarball":"https://registry.npmjs.org/@bixypay/fintech-sdk/-/fintech-sdk-1.0.0.tgz","fileCount":7,"unpackedSize":67181,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDTN+8mhfdD2uS8ZyhffTmDIe4rKkorFPfu4LSwSUhvxAiAK6zIPItAYkmvmof2rPGMxkvxw/RZsOAkNqojedwIIUg=="}]},"_npmUser":{"name":"bixypay","email":"rvr@rvrbet.com"},"directories":{},"maintainers":[{"name":"bixypay","email":"rvr@rvrbet.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fintech-sdk_1.0.0_1762182455045_0.8990062729509853"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-03T15:07:34.941Z","1.0.0":"2025-11-03T15:07:35.224Z","modified":"2025-11-03T15:07:35.478Z"},"maintainers":[{"name":"bixypay","email":"rvr@rvrbet.com"}],"description":"Official Node.js/TypeScript SDK for the BixyPay Fintech API Platform","homepage":"https://docs.bixypay.com","keywords":["bixypay","fintech","payment","crypto","api","sdk","typescript"],"repository":{"type":"git","url":"git+https://github.com/bixypay/fintech-sdk.git"},"author":{"name":"BixyPay"},"bugs":{"url":"https://github.com/bixypay/fintech-sdk/issues"},"license":"MIT","readme":"# BixyPay Fintech SDK - Node.js/TypeScript\n\nOfficial Node.js/TypeScript SDK for the BixyPay Fintech API Platform.\n\n## Installation\n\n```bash\nnpm install @bixypay/fintech-sdk\n# or\nyarn add @bixypay/fintech-sdk\n# or\npnpm add @bixypay/fintech-sdk\n```\n\n## Quick Start\n\n### 1. Initialize the Client\n\n```typescript\nimport { BixyPayClient } from '@bixypay/fintech-sdk';\n\nconst client = new BixyPayClient({\n  baseUrl: 'https://your-api-url.com',\n  apiKey: 'your-api-key-here', // Optional: for API key authentication\n  jwtToken: 'your-jwt-token',  // Optional: for JWT authentication\n});\n```\n\n### 2. Authentication\n\n#### Register a New Merchant\n\n```typescript\nconst { data, error } = await client.auth.register({\n  email: 'merchant@example.com',\n  password: 'SecurePassword123!',\n  businessName: 'Acme Corporation',\n  businessAddress: '123 Business St, City, Country'\n});\n\nif (error) {\n  console.error('Registration failed:', error);\n} else {\n  console.log('Merchant registered:', data);\n}\n```\n\n#### Login and Get JWT Token\n\n```typescript\nconst { data, error } = await client.auth.login({\n  email: 'merchant@example.com',\n  password: 'SecurePassword123!'\n});\n\nif (error) {\n  console.error('Login failed:', error);\n} else {\n  console.log('Login successful:', data);\n  // JWT token is automatically stored in the client\n}\n```\n\n#### Create API Key\n\n```typescript\nconst { data, error } = await client.auth.createApiKey({\n  name: 'Production API Key',\n  scopes: ['read', 'write']\n});\n\nif (error) {\n  console.error('Failed to create API key:', error);\n} else {\n  console.log('API Key created:', data);\n  // Use the returned API key for future requests\n  client.setApiKey(data.key);\n}\n```\n\n#### List All API Keys\n\n```typescript\nconst { data, error } = await client.auth.listApiKeys();\n\nif (error) {\n  console.error('Failed to list API keys:', error);\n} else {\n  console.log('API Keys:', data);\n}\n```\n\n#### Revoke an API Key\n\n```typescript\nconst { data, error } = await client.auth.revokeApiKey('key-id-here');\n\nif (error) {\n  console.error('Failed to revoke API key:', error);\n} else {\n  console.log('API key revoked successfully');\n}\n```\n\n### 3. Merchant Operations\n\n#### Get Merchant Profile\n\n```typescript\nconst { data, error } = await client.merchants.getProfile();\n\nif (error) {\n  console.error('Failed to get profile:', error);\n} else {\n  console.log('Merchant profile:', data);\n}\n```\n\n#### Get Account Balance\n\n```typescript\nconst { data, error } = await client.merchants.getBalance();\n\nif (error) {\n  console.error('Failed to get balance:', error);\n} else {\n  console.log('Balance:', data);\n}\n```\n\n#### Update KYC Status\n\n```typescript\nconst { data, error } = await client.merchants.updateKycStatus('approved');\n\nif (error) {\n  console.error('Failed to update KYC status:', error);\n} else {\n  console.log('KYC status updated:', data);\n}\n```\n\n### 4. Invoice Management\n\n#### Create an Invoice\n\n```typescript\nconst { data, error } = await client.invoices.create({\n  amount: 100.50,\n  currency: 'USD',\n  description: 'Payment for Product XYZ',\n  metadata: {\n    orderId: '12345',\n    customerId: 'cust_abc'\n  },\n  callbackUrl: 'https://yourapp.com/webhook'\n});\n\nif (error) {\n  console.error('Failed to create invoice:', error);\n} else {\n  console.log('Invoice created:', data);\n}\n```\n\n#### Get Invoice by ID\n\n```typescript\nconst { data, error } = await client.invoices.get('invoice-id-here');\n\nif (error) {\n  console.error('Failed to get invoice:', error);\n} else {\n  console.log('Invoice details:', data);\n}\n```\n\n#### List All Invoices (with Pagination)\n\n```typescript\nconst { data, error } = await client.invoices.list({\n  page: 1,\n  limit: 20\n});\n\nif (error) {\n  console.error('Failed to list invoices:', error);\n} else {\n  console.log('Invoices:', data);\n}\n```\n\n#### Update Invoice Status\n\n```typescript\nconst { data, error} = await client.invoices.updateStatus(\n  'invoice-id-here',\n  'completed',  // Status: 'pending', 'completed', 'failed'\n  '0x1234567890abcdef'  // Optional: transaction hash for completed payments\n);\n\nif (error) {\n  console.error('Failed to update invoice:', error);\n} else {\n  console.log('Invoice updated:', data);\n}\n```\n\n### 5. Webhook Management\n\n#### Create a Webhook\n\n```typescript\nconst { data, error } = await client.webhooks.create({\n  url: 'https://yourapp.com/webhooks/payment',\n  events: ['payment.completed', 'payment.failed', 'payout.processed']\n});\n\nif (error) {\n  console.error('Failed to create webhook:', error);\n} else {\n  console.log('Webhook created:', data);\n  console.log('Webhook secret:', data.secret); // Save this for verification\n}\n```\n\n#### List All Webhooks\n\n```typescript\nconst { data, error } = await client.webhooks.list();\n\nif (error) {\n  console.error('Failed to list webhooks:', error);\n} else {\n  console.log('Webhooks:', data);\n}\n```\n\n#### Delete a Webhook\n\n```typescript\nconst { data, error } = await client.webhooks.delete('webhook-id-here');\n\nif (error) {\n  console.error('Failed to delete webhook:', error);\n} else {\n  console.log('Webhook deleted successfully');\n}\n```\n\n## Complete Example: Payment Flow\n\n```typescript\nimport { BixyPayClient } from '@bixypay/fintech-sdk';\n\nasync function processPayment() {\n  // Initialize client\n  const client = new BixyPayClient({\n    baseUrl: 'https://your-api-url.com',\n    apiKey: 'your-api-key'\n  });\n\n  try {\n    // Create invoice\n    const invoice = await client.invoices.create({\n      amount: 250.00,\n      currency: 'USD',\n      description: 'Premium Subscription - Monthly',\n      metadata: {\n        planType: 'premium',\n        billingCycle: 'monthly',\n        userId: 'user_12345'\n      },\n      callbackUrl: 'https://yourapp.com/webhooks/payment'\n    });\n\n    if (invoice.error) {\n      throw new Error(`Invoice creation failed: ${invoice.error}`);\n    }\n\n    console.log('✓ Invoice created:', invoice.data);\n\n    // Get invoice status\n    const status = await client.invoices.get(invoice.data.id);\n    \n    if (status.error) {\n      throw new Error(`Failed to get invoice status: ${status.error}`);\n    }\n\n    console.log('✓ Invoice status:', status.data);\n\n    return invoice.data;\n\n  } catch (error) {\n    console.error('Payment processing error:', error);\n    throw error;\n  }\n}\n\nprocessPayment();\n```\n\n## Error Handling\n\nAll SDK methods return a response object with `data` and `error` properties:\n\n```typescript\nconst { data, error } = await client.invoices.create({...});\n\nif (error) {\n  // Handle error\n  console.error('Error:', error.message);\n  console.error('Status:', error.status);\n} else {\n  // Success - use data\n  console.log('Success:', data);\n}\n```\n\n## TypeScript Support\n\nThe SDK is fully typed with TypeScript. All request/response types are auto-generated from the OpenAPI specification:\n\n```typescript\nimport type { paths } from '@bixypay/fintech-sdk/types';\n\n// All endpoints are typed\nconst invoice: paths['/api/v1/transactions/invoices']['post']['responses']['201'] = ...;\n```\n\n## Authentication Methods\n\n### API Key Authentication (Recommended for Server-to-Server)\n\n```typescript\nconst client = new BixyPayClient({\n  baseUrl: 'https://your-api-url.com',\n  apiKey: 'sk_live_your-api-key'\n});\n```\n\n### JWT Authentication (For Dashboard/Admin Access)\n\n```typescript\nconst client = new BixyPayClient({\n  baseUrl: 'https://your-api-url.com'\n});\n\n// Login to get JWT token\nawait client.auth.login({\n  email: 'merchant@example.com',\n  password: 'password'\n});\n\n// JWT token is automatically stored and used for subsequent requests\n```\n\n### Switching Between Auth Methods\n\n```typescript\nconst client = new BixyPayClient({\n  baseUrl: 'https://your-api-url.com'\n});\n\n// Use JWT for admin operations\nclient.setJwtToken('your-jwt-token');\nawait client.merchants.getProfile();\n\n// Switch to API key for programmatic access\nclient.setApiKey('your-api-key');\nawait client.invoices.create({...});\n```\n\n## Rate Limiting\n\nThe API enforces rate limiting:\n- **100 requests per minute** per API key\n\nThe SDK automatically includes rate limit information in responses.\n\n## Support\n\n- **Documentation:** https://docs.bixypay.com\n- **API Reference:** https://your-api-url.com/api/docs\n- **Issues:** https://github.com/bixypay/fintech-sdk/issues\n\n## License\n\nMIT License - See LICENSE file for details\n","readmeFilename":"README.md","_rev":"1-3005d94ec17ae78e34954bbde2e17c97"}