@yengapay/nodejs-sdk
Version:
Official Node.js SDK for YengaPay - Accept mobile money payments and send payouts in West Africa
127 lines (126 loc) • 3.07 kB
TypeScript
/**
* YengaPay SDK Types
*/
export type Environment = 'production' | 'staging' | 'development';
export interface ClientConfig {
apiKey: string;
groupId: string;
projectId: string;
baseURL?: string;
environment?: Environment;
}
/**
* Direct Payment Types
*/
export interface Article {
title: string;
description?: string;
price: number;
pictures?: string[];
}
export interface InitDirectPaymentParams {
amount: number;
reference?: string;
articles?: Article[];
customerEmailToNotify?: string;
metadata?: Record<string, any>;
}
export interface AvailableOperator {
code: string;
name: string;
countryCode: string;
countryName: string;
flagUrl: string;
flow: 'ONE_STEP' | 'TWO_STEP';
amount: number;
fees: number;
totalAmount: number;
minAmount: number;
maxAmount: number;
}
export interface InitDirectPaymentResponse {
paymentIntentId: string;
expiresAt: Date;
availableOperators: AvailableOperator[];
}
export interface ProcessPaymentParams {
paymentIntentId: string;
operatorCode: string;
countryCode: string;
customerMSISDN: string;
otp?: string;
}
export interface ProcessPaymentResponse {
status: 'PENDING' | 'DONE' | 'FAILED';
paymentIntentId: string;
transactionId?: string;
amount?: number;
fees?: number;
totalAmount?: number;
operator?: string;
customerMSISDN?: string;
message?: string;
}
export interface SendOtpParams {
paymentIntentId: string;
operatorCode: string;
countryCode: string;
customerMSISDN: string;
}
export interface SendOtpResponse {
status: 'OTP_SENT';
message: string;
otpExpiresIn: number;
}
export interface PaymentStatusResponse {
paymentIntentId: string;
status: 'PENDING' | 'DONE' | 'FAILED';
transactionId?: string;
amount?: number;
fees?: number;
totalAmount?: number;
operator?: string;
customerMSISDN?: string;
createdAt?: Date;
completedAt?: Date;
message?: string;
}
/**
* Payout Types
*/
export type PaymentMethod = 'ORANGE_MONEY' | 'MOOV_MONEY' | 'TELECEL_MONEY' | 'CORIS_MONEY' | 'SANK_MONEY';
export interface CreatePayoutParams {
amount: number;
destNumber: string;
destName?: string;
destEmail?: string;
paymentMethod: PaymentMethod;
description?: string;
}
export interface CreatePayoutResponse {
id: string;
amount: number;
fees: number;
destNumber: string;
destName?: string;
destEmail?: string;
paymentMethod: string;
status: 'PENDING' | 'PROCESSING' | 'SUCCESS' | 'FAILED';
description?: string;
createdAt: Date;
}
export interface PayoutStatusResponse {
id: string;
amount: number;
fees: number;
destNumber: string;
destName?: string;
destEmail?: string;
paymentMethod: string;
status: 'PENDING' | 'PROCESSING' | 'SUCCESS' | 'FAILED' | 'CANCELLED';
description?: string;
errorMessage?: string;
operatorTransId?: string;
createdAt: Date;
processedAt?: Date;
}