mpesa-sdk
Version:
Type safe SDK for M-Pesa API (Mozambique)
152 lines (148 loc) • 4.72 kB
text/typescript
type Configuration = {
mode: "sandbox" | "production";
apiKey: string;
publicKey: string;
origin: string;
serviceProviderCode: string;
};
type ErrorResponse = {
output_error: string;
};
type C2BRequest = {
input_TransactionReference: string;
input_CustomerMSISDN: string;
input_Amount: string;
input_ThirdPartyReference: string;
input_ServiceProviderCode: string;
};
type C2BResponse = {
output_ConversationID: string;
output_TransactionID: string;
output_ResponseDesc: string;
output_ResponseCode: string;
output_ThirdPartyReference: string;
};
type QueryTransactionStatusRequest = {
input_ThirdPartyReference: string;
input_QueryReference: string;
input_ServiceProviderCode: string;
};
type QueryTransactionStatusResponse = {
output_ConversationID: string;
output_ResponseDesc: string;
output_ResponseCode: string;
output_ThirdPartyReference: string;
output_ResponseTransactionStatus: string;
};
type B2CRequest = {
input_TransactionReference: string;
input_CustomerMSISDN: string;
input_Amount: string;
input_ThirdPartyReference: string;
input_ServiceProviderCode: string;
};
type B2CResponse = {
output_ConversationID: string;
output_TransactionID: string;
output_ResponseDesc: string;
output_ResponseCode: string;
output_ThirdPartyReference: string;
};
type ReversalRequest = {
input_TransactionID: string;
input_SecurityCredential: string;
input_InitiatorIdentifier: string;
input_ThirdPartyReference: string;
input_ServiceProviderCode: string;
input_ReversalAmount?: string;
};
type ReversalResponse = {
output_ConversationID: string;
output_TransactionID: string;
output_ResponseDesc: string;
output_ResponseCode: string;
output_ThirdPartyReference: string;
};
type B2BRequest = {
input_TransactionReference: string;
input_Amount: string;
input_ThirdPartyReference: string;
input_PrimaryPartyCode: string;
input_ReceiverPartyCode: string;
};
type B2BResponse = {
output_ConversationID: string;
output_TransactionID: string;
output_ResponseDesc: string;
output_ResponseCode: string;
output_ThirdPartyReference: string;
};
type QueryCustomerNameRequest = {
input_CustomerMSISDN: string;
input_ThirdPartyReference: string;
input_ServiceProviderCode: string;
};
type QueryCustomerNameResponse = {
output_ConversationID: string;
output_ResultDesc: string;
output_ResultCode: string;
output_ThirdPartyReference: string;
output_CustomerName: string;
};
declare class MPesa {
private configuration;
constructor(config: {
mode?: "sandbox" | "production";
apiKey: string;
publicKey: string;
origin: string;
serviceProviderCode: string;
});
getConfiguration(): Configuration;
updateConfiguration(config: {
mode?: "sandbox" | "production";
apiKey?: string;
publicKey?: string;
origin?: string;
serviceProviderCode?: string;
}): void;
c2bPayment(request: {
amount: number;
msisdn: string;
transactionReference: string;
thirdPartyReference: string;
}): Promise<C2BResponse>;
b2cPayment(request: {
amount: number;
msisdn: string;
transactionReference: string;
thirdPartyReference: string;
}): Promise<B2CResponse>;
b2bPayment(request: {
amount: number;
receiverPartyCode: string;
transactionReference: string;
thirdPartyReference: string;
}): Promise<B2BResponse>;
queryTransactionStatus(request: {
queryReference: string;
thirdPartyReference: string;
}): Promise<QueryTransactionStatusResponse>;
queryCustomerName(request: {
msisdn: string;
thirdPartyReference: string;
}): Promise<QueryCustomerNameResponse>;
reversal(request: {
transactionId: string;
securityCredential: string;
initiatorIdentifier: string;
thirdPartyReference: string;
reversalAmount?: number;
}): Promise<ReversalResponse>;
}
declare class MpesaResponseError extends Error {
statusCode: number;
data: ErrorResponse;
constructor(message: string, statusCode: number, data: ErrorResponse);
}
export { type B2BRequest, type B2BResponse, type B2CRequest, type B2CResponse, type C2BRequest, type C2BResponse, type Configuration, type ErrorResponse, MpesaResponseError, type QueryCustomerNameRequest, type QueryCustomerNameResponse, type QueryTransactionStatusRequest, type QueryTransactionStatusResponse, type ReversalRequest, type ReversalResponse, MPesa as default };