'use strict';

require('./config-state-BIgGhhe9.js');
require('./dinero-BwNN_k7x.js');
var Plaid = require('./Plaid-CPESyiiV.js');
require('./Pagination-Dediz133.js');
require('./Business-oBifyXkW.js');
var utils = require('./utils-BsnepLy6.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 Plaid.Payment(response.data) });
        }
        else {
            const responseError = utils.getErrorMessage(response.error);
            const code = utils.getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
            onError({
                error: responseError,
                code,
                severity: Plaid.ComponentErrorSeverity.ERROR,
            });
        }
    }
    catch (error) {
        const code = utils.getErrorCode(error === null || error === void 0 ? void 0 : error.code);
        onError({
            error: utils.getErrorMessage(error),
            code,
            severity: Plaid.ComponentErrorSeverity.ERROR,
        });
    }
    finally {
        final();
    }
};

exports.makeGetPaymentDetails = makeGetPaymentDetails;
