mpesa-mz-sdk
Version:
SDK para integração com a API M-Pesa de Moçambique
173 lines (172 loc) • 4.94 kB
TypeScript
export interface MpesaErrorDetail {
code: string;
description: string;
httpStatus: number;
transactionId?: string;
conversationId?: string;
thirdPartyReference?: string;
}
export interface MpesaAPIConfig {
apiKey: string;
publicKey: string;
serviceProviderCode: string;
origin: string;
apiHost?: string;
timeout?: number;
env?: 'sandbox' | 'live';
}
export interface MpesaBaseResponse {
output_ResponseCode: string;
output_ResponseDesc: string;
output_TransactionID?: string;
output_ConversationID?: string;
output_ThirdPartyReference?: string;
}
export interface MpesaAccessTokenResponse extends MpesaBaseResponse {
output_Token: string;
output_TokenExpiry: string;
}
export interface MpesaC2BResponse extends MpesaBaseResponse {
}
export interface MpesaB2CResponse extends MpesaBaseResponse {
output_Amount?: string;
output_PrimaryPartyCode?: string;
output_RecipientFirstName?: string;
output_RecipientLastName?: string;
output_SettlementAmount?: string;
}
export interface MpesaQueryResponse extends MpesaBaseResponse {
output_ResponseTransactionStatus?: string;
output_ResponsePaymentStatusCode?: string;
output_ResponsePaymentStatusDesc?: string;
}
export interface MpesaReversalResponse extends MpesaBaseResponse {
}
export interface MpesaB2BResponse extends MpesaBaseResponse {
output_Amount?: string;
output_PrimaryPartyCode?: string;
output_RecipientPartyCode?: string;
output_SettlementAmount?: string;
}
export interface C2BPaymentPayload {
input_Amount: string;
input_CustomerMSISDN: string;
input_ThirdPartyReference: string;
input_TransactionReference: string;
input_ServiceProviderCode: string;
}
export interface B2CPaymentPayload {
input_Amount: string;
input_CustomerMsisdn: string;
input_ThirdPartyReference: string;
input_TransactionReference: string;
input_ServiceProviderCode: string;
input_PaymentServices: string;
}
export interface QueryPaymentPayload {
input_QueryReference: string;
input_ServiceProviderCode: string;
input_ThirdPartyReference: string;
}
export interface ReversalPaymentPayload {
input_ReversalAmount: string;
input_TransactionID: string;
input_ThirdPartyReference: string;
input_ServiceProviderCode: string;
}
export interface B2BPaymentPayload {
input_Amount: string;
input_PrimaryPartyCode: string;
input_RecipientPartyCode: string;
input_ThirdPartyReference: string;
input_TransactionReference: string;
input_ServiceProviderCode: string;
input_PaymentServices: string;
}
export interface MpesaResponse<T = any> {
status: 'success' | 'error';
message: string;
data?: T;
code?: string;
httpStatus?: number;
transactionId?: string;
conversationId?: string;
thirdPartyReference?: string;
timestamp?: string;
}
export interface C2BResponseData {
transactionId: string;
conversationId: string;
thirdPartyReference: string;
amount: string;
customerMsisdn: string;
transactionReference: string;
}
export interface B2CResponseData {
transactionId: string;
conversationId: string;
thirdPartyReference: string;
amount: string;
customerMsisdn: string;
transactionReference: string;
recipientFirstName?: string;
recipientLastName?: string;
settlementAmount?: string;
}
export interface B2BResponseData {
transactionId: string;
conversationId: string;
thirdPartyReference: string;
amount: string;
primaryPartyCode: string;
recipientPartyCode: string;
transactionReference: string;
settlementAmount?: string;
}
export interface QueryResponseData {
transactionId: string;
conversationId: string;
thirdPartyReference: string;
queryReference: string;
transactionStatus?: string;
paymentStatusCode?: string;
paymentStatusDesc?: string;
}
export interface ReversalResponseData {
transactionId: string;
conversationId: string;
thirdPartyReference: string;
originalTransactionId: string;
reversalAmount: string;
}
export declare const MPESA_ERROR_MESSAGES: Record<string, string>;
export interface C2BArgs {
amount: number;
number: string;
transactionReference: string;
thirdPartyReference: string;
}
export interface B2CArgs {
amount: number;
number: string;
transactionReference: string;
thirdPartyReference: string;
paymentServices?: string;
}
export interface B2BArgs {
amount: number;
primaryPartyCode: string;
recipientPartyCode: string;
transactionReference: string;
thirdPartyReference: string;
paymentServices?: string;
}
export interface QueryArgs {
queryReference: string;
thirdPartyReference: string;
}
export interface ReversalArgs {
originalTransactionId: string;
reversalAmount: number;
thirdPartyReference: string;
}