import './config-state.js';
import './dinero.js';
import { e as Payment, C as ComponentErrorSeverity } from './Plaid.js';
import './Pagination.js';
import './Business.js';
import './ApplePay.js';
import { g as getErrorCode, a as getErrorMessage } from './utils3.js';

const makeGetPaymentDetails = ({ id, authToken, service }) => async ({ onSuccess, onError, final }) => {
    var _a;
    try {
        const response = await service.fetchPayment(id, authToken);
        if (!response.error) {
            onSuccess({ payment: new Payment(response.data) });
        }
        else {
            const responseError = getErrorMessage(response.error);
            const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
            onError({
                error: responseError,
                code,
                severity: ComponentErrorSeverity.ERROR,
            });
        }
    }
    catch (error) {
        const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
        onError({
            error: getErrorMessage(error),
            code,
            severity: ComponentErrorSeverity.ERROR,
        });
    }
    finally {
        final();
    }
};

export { makeGetPaymentDetails as m };
