"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MpesaException = void 0;
const common_1 = require("@nestjs/common");
class MpesaException extends common_1.HttpException {
    constructor(message, code, httpStatus) {
        super({
            message,
            code,
            statusCode: httpStatus,
        }, httpStatus);
    }
    static configurationError(message = 'M-Pesa configuration error') {
        return new MpesaException(message, 'MPESA_CONFIGURATION_ERROR', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
    }
    static stkPushFailed(message = 'STK Push failed') {
        return new MpesaException(message, 'MPESA_STK_PUSH_FAILED', common_1.HttpStatus.BAD_GATEWAY);
    }
    static callbackProcessingFailed(message = 'Callback processing failed') {
        return new MpesaException(message, 'MPESA_CALLBACK_FAILED', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
    }
    static reconciliationFailed(message = 'Reconciliation failed') {
        return new MpesaException(message, 'MPESA_RECONCILIATION_FAILED', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
    }
    static duplicateCallback() {
        return new MpesaException('Duplicate callback received', 'MPESA_DUPLICATE_CALLBACK', common_1.HttpStatus.CONFLICT);
    }
    static invalidAmount(expected, received) {
        return new MpesaException(`Amount mismatch: expected ${expected}, received ${received}`, 'MPESA_INVALID_AMOUNT', common_1.HttpStatus.BAD_REQUEST);
    }
    static reversalFailed(message = 'Reversal failed') {
        return new MpesaException(message, 'MPESA_REVERSAL_FAILED', common_1.HttpStatus.BAD_GATEWAY);
    }
    static paymentNotFound(checkoutRequestId) {
        return new MpesaException(`Payment not found for CheckoutRequestID: ${checkoutRequestId}`, 'MPESA_PAYMENT_NOT_FOUND', common_1.HttpStatus.NOT_FOUND);
    }
    static accessTokenFailed(message = 'Failed to obtain access token') {
        return new MpesaException(message, 'MPESA_ACCESS_TOKEN_FAILED', common_1.HttpStatus.BAD_GATEWAY);
    }
}
exports.MpesaException = MpesaException;
