@acountpay/ais-sdk
v1.0.2
Published
AcountPay SDK
Readme
AcountPay SDK
A TypeScript SDK for AcountPay payment processing and account linking services.
Features
- Payment Processing: Initiate payments with Token.io integration
- Account Linking: Link customer bank accounts for accessing account details, balances, and transactions
- TypeScript Support: Full type safety and IntelliSense
- Multiple Build Formats: CommonJS, ES Modules, and UMD
Installation
npm install @acountpay/ais-sdkQuick Start
Initialize the SDK
import Account from '@acountpay/sdk';
const account = new Account({
clientId: 'your-client-id'
});Process Payments
// Initiate a payment
await account.initiatePayment({
amount: 100.00,
referenceNumber: 'REF-12345'
});
// User gets redirected to Token.io payment pageLink Customer Accounts
import { ACCOUNT_PERMISSIONS } from '@acountpay/sdk';
// Link a customer's bank account
const result = await account.linkAccount({
merchantId: 'merchant_abc123',
userId: 'user_2def456ghi789',
permissions: [
ACCOUNT_PERMISSIONS.READ_ACCOUNTS_DETAIL,
ACCOUNT_PERMISSIONS.READ_BALANCES,
ACCOUNT_PERMISSIONS.READ_TRANSACTIONS_DETAIL
],
});
if (result.success) {
console.log('Account linking successful:', result.message);
if (result.linkUrl) {
// Redirect user to account linking URL
window.location.href = result.linkUrl;
}
}API Reference
Account Class
Constructor
new Account({ clientId: string })Methods
initiatePayment(options)
Initiates a payment and redirects user to Token.io hosted payment page.
Parameters:
amount: number- Payment amountreferenceNumber: string- Unique reference number
Returns: Promise<void>
linkAccount(options)
Links a customer's bank account for accessing financial data.
Parameters:
merchantId: string- Your merchant IDuserId: string- Customer's user IDpermissions: string[]- Array of permission stringsauthorizationToken: string- Your API authorization token
Returns: Promise<AccountLinkingResponse>
Types
AccountLinkingResponse
interface AccountLinkingResponse {
success: boolean;
linkUrl?: string;
message?: string;
}AccountLinkingOptions
interface AccountLinkingOptions {
merchantId: string;
userId: string;
permissions: string[];
authorizationToken: string;
}Constants
ACCOUNT_PERMISSIONS
Predefined permission constants:
ACCOUNT_PERMISSIONS.READ_ACCOUNTS_DETAIL- "ReadAccountsDetail"ACCOUNT_PERMISSIONS.READ_BALANCES- "ReadBalances"ACCOUNT_PERMISSIONS.READ_TRANSACTIONS_DETAIL- "ReadTransactionsDetail"
Environment Configuration
The SDK uses environment variables for configuration:
API_BASE_URL- Your backend API base URLTOKEN_ENVIRONMENT- "sandbox" or "production"
Create a .env file in your project root:
API_BASE_URL=https://api.acount.com
TOKEN_ENVIRONMENT=sandboxBackend Integration
Your backend needs to provide these endpoints:
Payment Creation
POST {API_URL}/sdk/payment/{clientId}?amount={amount}&referenceNumber={referenceNumber}
Response: { paymentId: string }Link Token Generation
POST {API_URL}/sdk/link-token/{clientId}?paymentId={paymentId}
Response: { tokenRequestUrl: string }License
MIT
