@moneygraph/sdk
Version:
AI-native SDK for global payouts powered by StratosPay
319 lines (318 loc) • 8.25 kB
TypeScript
/**
* MoneyGraph SDK - Core Type Definitions
* Based on StratosPay API Postman Collection
*/
import type { PayInCurrency, PayoutCurrency } from './currencies';
export interface ApiResponse<T> {
message: string;
status: 'success' | 'failed';
data: T | null;
}
export interface PaginatedResponse<T> {
data: T[];
links: {
first: string;
last: string;
prev: string | null;
next: string | null;
};
meta: {
current_page: number;
from: number;
last_page: number;
path: string;
per_page: number;
to: number;
total: number;
links: Array<{
url: string | null;
label: string;
active: boolean;
}>;
};
}
export interface Address {
country: string;
state: string | null;
city: string | null;
street: string | null;
postal_code: string | null;
}
export type AccountType = 'personal' | 'business';
export type KycStatus = 'PENDING' | 'APPROVED' | 'REJECTED';
export type Gender = 'male' | 'female';
export type IdType = 'PASSPORT' | 'DRIVERS' | 'NATIONAL_ID';
export interface CustomerDocument {
document: string | null;
selfie: string | null;
}
export interface BusinessDetails {
business_name: string;
website: string | null;
staff_size: string | null;
registration_number: string | null;
tax_number: string | null;
registration_date: string | null;
registration_location: string | null;
registration_type: string | null;
mcc: string | null;
complete_ownership: boolean;
address: Address;
}
export interface Customer {
id: string;
mode: 'test' | 'live';
first_name: string;
last_name: string;
email: string;
phone: string;
account_type: AccountType;
birthday: string | null;
gender: Gender | null;
id_type: IdType | null;
id_number: string | null;
source_of_funds: string | null;
kyc_status: KycStatus;
document: CustomerDocument;
address: Address;
business_details?: BusinessDetails;
}
export interface CreatePersonalCustomerParams {
account_type: 'personal';
first_name: string;
middle_name?: string;
last_name: string;
email: string;
phone: string;
phone_iso2: string;
country: string;
}
export interface CreateBusinessCustomerParams {
account_type: 'business';
first_name: string;
middle_name?: string;
last_name: string;
email: string;
phone: string;
phone_iso2: string;
country: string;
business_details: {
business_name: string;
address?: Address;
};
}
export type CreateCustomerParams = CreatePersonalCustomerParams | CreateBusinessCustomerParams;
export interface UpdateCustomerParams {
account_type?: AccountType;
gender?: Gender;
first_name?: string;
middle_name?: string;
last_name?: string;
email?: string;
phone?: string;
phone_iso2?: string;
country?: string;
state?: string;
city?: string;
street?: string;
postal_code?: string;
birthday?: string;
source_of_fund_id?: string;
ip_address?: string;
id_type?: IdType;
id_number?: string;
business_details?: {
business_name?: string;
staff_size?: string;
mcc_id?: string;
reg_type_id?: string;
registration_date?: string;
registration_number?: string;
tax_number?: string;
registration_location?: string;
complete_ownership?: boolean;
address?: Address;
};
}
export interface Director {
id: string;
first_name: string;
last_name: string;
email: string;
phone: string;
country: string;
state: string;
city: string;
street: string;
postal_code: string;
birthday: string;
ownership: number;
position: string;
mode: 'test' | 'live';
}
export interface CreateDirectorParams {
first_name: string;
middle_name?: string;
last_name: string;
email: string;
phone: string;
phone_iso2: string;
country: string;
state: string;
city: string;
street: string;
postal_code: string;
ownership: number;
position: string;
birthday: string;
}
export type UpdateDirectorParams = Partial<CreateDirectorParams>;
export interface Wallet {
id: string;
currency_id: string;
amount: number;
human_readable_amount: number;
currency: string;
mode: 'test' | 'live';
}
export type TransactionStatus = 'pending' | 'processing' | 'success' | 'failed' | 'cancelled';
export type TransactionType = 'credit' | 'debit';
export interface Transaction {
id: string;
amount: string;
human_readable_amount: number;
charge: string;
human_readable_charge: number;
status: TransactionStatus;
decline_reason: string | null;
mode: 'test' | 'live';
type: TransactionType;
description: string;
external_id: string | null;
created_at: string;
}
export interface QuoteParams {
from: PayInCurrency;
to: PayoutCurrency;
amount: number;
}
export interface Quote {
id: string;
from_currency: PayInCurrency;
to_currency: PayoutCurrency;
from_amount: number;
to_amount: number;
rate: number;
fee: number;
expires_at: string;
created_at: string;
}
export interface QuoteConfirmation {
id: string;
quote_id: string;
locked_rate: number;
transaction_id: string;
status: 'confirmed';
confirmed_at: string;
}
export type PayoutStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
export interface PayoutRecipient {
name: string;
email?: string;
phone?: string;
bank_code?: string;
account_number?: string;
account_name?: string;
mobile_network?: string;
mobile_number?: string;
wallet_address?: string;
network?: string;
}
export interface PayoutParams {
quote_id: string;
customer_id: string;
recipient: PayoutRecipient;
reference?: string;
narration?: string;
}
export interface Payout {
id: string;
quote_id: string;
customer_id: string;
amount: number;
currency: PayoutCurrency;
recipient: PayoutRecipient;
status: PayoutStatus;
reference: string;
narration?: string;
created_at: string;
updated_at: string;
}
export interface SourceOfFunds {
id: string;
name: string;
}
export interface MerchantCategoryCode {
id: string;
name: string;
}
export interface BusinessRegistrationType {
id: string;
name: string;
director_required: boolean;
}
export interface Country {
name: string;
iso2: string;
}
export interface CurrencyRate {
currency: string;
rate: number;
}
export interface LocalTransferRate {
iso2: string;
currency: string;
rate: number;
free_transfer: boolean;
}
export interface CurrencySettings {
topup: 'active' | 'inactive';
payout: 'active' | 'inactive';
delivery_window_required: boolean;
local_swap?: {
active: boolean;
limit: {
min: number;
max: number;
};
fee: {
type: string;
fiat: number;
percent: number;
};
rates: CurrencyRate[];
};
local_transfer?: {
active: boolean;
limit: {
min: number;
max: number;
};
fee: {
type: string;
fiat: number;
percent: number;
};
rates: LocalTransferRate[];
};
}
export interface Currency {
id: string;
name: string;
currency: string;
symbol: string;
settings: CurrencySettings;
}
export type ErrorCode = 'INVALID_API_KEY' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'VALIDATION_ERROR' | 'KYC_NOT_APPROVED' | 'KYC_PENDING' | 'KYC_REJECTED' | 'KYC_ALREADY_APPROVED' | 'QUOTE_EXPIRED' | 'QUOTE_NOT_FOUND' | 'CUSTOMER_NOT_FOUND' | 'DIRECTOR_NOT_FOUND' | 'INSUFFICIENT_BALANCE' | 'INVALID_CURRENCY' | 'INVALID_AMOUNT' | 'PAYOUT_FAILED' | 'RATE_LIMITED' | 'INTERNAL_ERROR' | 'NETWORK_ERROR' | 'SANDBOX_ONLY';
export type MockPersonaType = 'business_verified' | 'individual_verified' | 'pending_kyc' | 'rejected_kyc';
export * from './currencies';